1
0
mirror of https://github.com/SuperBFG7/ympd synced 2025-02-04 21:29:20 +00:00

Feat: add more shortcuts #58

This commit is contained in:
jcorporation 2018-11-06 23:59:44 +00:00
parent c5628a0989
commit db8b0a1d24
3 changed files with 43 additions and 12 deletions

View File

@ -18,8 +18,8 @@
<body>
<header>
<nav class="navbar navbar-expand navbar-dark fixed-top bg-dark">
<div class="dropdown col-auto mr-auto pl-0" id="mainMenu">
<a class="dropdown-toggle navbar-brand" data-toggle="dropdown" href="#">
<div class="dropdown col-auto mr-auto pl-0">
<a class="dropdown-toggle navbar-brand" data-toggle="dropdown" href="#" id="mainMenu">
<span class="material-icons header-logo">play_circle_outline</span>myMPD
</a>
<div class="dropdown-menu bg-dark">
@ -52,8 +52,8 @@
skip_next
</button>
</div>
<div class="btn-group">
<button id="volumeIcon" class="btn btn-secondary dropdown-toggle pl-2 pr-2 material-icons" type="button" data-toggle="dropdown">
<div class="btn-group dropdown">
<button id="volumeMenu" class="btn btn-secondary dropdown-toggle pl-2 pr-2 material-icons" type="button" data-toggle="dropdown">
volume_up
</button>
<div class="dropdown-menu dropdown-menu-right bg-dark">

View File

@ -13,13 +13,18 @@ var keymap = {
"67": {"cmd": "MPD_API_QUEUE_CLEAR", "options": []}, // c
"85": {"cmd": "updateDB", "options": []}, // u
"82": {"cmd": "rescanDB", "options": []}, // r
"76": {"cmd": "openLocalPlayer", "options": []}, // l
"80": {"cmd": "updateSmartPlaylists", "options": []}, // p
"65": {"cmd": "showAddToPlaylist", "options": ["stream"]}, // a
"84": {"cmd": "openModal", "options": ["modalSettings"]}, // t
"89": {"cmd": "openModal", "options": ["modalAbout"]}, // y
"49": {"cmd": "appGoto", "options": ["Playback"]}, // 1
"50": {"cmd": "appGoto", "options": ["Queue"]}, // 2
"51": {"cmd": "appGoto", "options": ["Browse"]}, // 3
"52": {"cmd": "appGoto", "options": ["Search"]} // 4
"51": {"cmd": "appGoto", "options": ["Browse","Database"]}, // 3
"52": {"cmd": "appGoto", "options": ["Browse","Playlists"]}, // 4
"53": {"cmd": "appGoto", "options": ["Browse","Filesystem"]}, // 5
"54": {"cmd": "appGoto", "options": ["Search"]}, // 6
"77": {"cmd": "openDropdown", "options": ["dropdownMainMenu"]}, // m
"86": {"cmd": "openDropdown", "options": ["dropdownVolumeMenu"]}, // v
}
}

View File

@ -69,7 +69,7 @@ domCache.panelHeadingBrowseLen = domCache.panelHeadingBrowse.length;
domCache.counter = document.getElementById('counter');
domCache.volumePrct = document.getElementById('volumePrct');
domCache.volumeControl = document.getElementById('volumeControl');
domCache.volumeIcon = document.getElementById('volumeIcon');
domCache.volumeMenu = document.getElementById('volumeMenu');
domCache.btnsPlay = document.getElementsByClassName('btnPlay');
domCache.btnsPlayLen = domCache.btnsPlay.length;
domCache.btnPrev = document.getElementById('btnPrev');
@ -94,6 +94,11 @@ var modalUpdateDB = new Modal(document.getElementById('modalUpdateDB'));
var modalSaveSmartPlaylist = new Modal(document.getElementById('modalSaveSmartPlaylist'));
var modalDeletePlaylist = new Modal(document.getElementById('modalDeletePlaylist'));
var dropdownMainMenu = new Dropdown(document.getElementById('mainMenu'));
var dropdownVolumeMenu = new Dropdown(document.getElementById('volumeMenu'));
var collapseDBupdate = new Collapse(document.getElementById('navDBupdate'));
function appPrepare(scrollPos) {
if (app.current.app != app.last.app || app.current.tab != app.last.tab || app.current.view != app.last.view) {
//Hide all cards + nav
@ -323,14 +328,31 @@ function appInit() {
else
icon.innerText = 'keyboard_arrow_right';
}, false);
document.getElementById('volumeIcon').parentNode.addEventListener('show.bs.dropdown', function () {
document.addEventListener('keyup', function(event) {
if (event.which != 13)
return;
if (event.target.nodeName == 'A') {
event.stopPropagation();
event.preventDefault();
event.target.click();
}
}, false);
document.getElementById('volumeMenu').parentNode.addEventListener('show.bs.dropdown', function () {
sendAPI({"cmd": "MPD_API_PLAYER_OUTPUT_LIST"}, parseOutputs);
});
document.getElementById('modalAbout').addEventListener('shown.bs.modal', function () {
sendAPI({"cmd": "MPD_API_DATABASE_STATS"}, parseStats);
});
document.getElementById('modalAddToPlaylist').addEventListener('shown.bs.modal', function () {
if (!document.getElementById('addStreamFrm').classList.contains('hide'))
document.getElementById('streamUrl').focus();
else
document.getElementById('addToPlaylistPlaylist').focus();
});
document.getElementById('modalUpdateDB').addEventListener('hidden.bs.modal', function () {
document.getElementById('updateDBprogress').classList.remove('updateDBprogressAnimate');
@ -1396,11 +1418,11 @@ function parseVolume(obj) {
domCache.volumeControl.classList.remove('hide');
domCache.volumePrct.innerText = obj.data.volume + ' %';
if (obj.data.volume == 0)
domCache.volumeIcon.innerText = 'volume_off';
domCache.volumeMenu.innerText = 'volume_off';
else if (obj.data.volume < 50)
domCache.volumeIcon.innerText = 'volume_down';
domCache.volumeMenu.innerText = 'volume_down';
else
domCache.volumeIcon.innerText = 'volume_up';
domCache.volumeMenu.innerText = 'volume_up';
}
domCache.volumeBar.value = obj.data.volume;
}
@ -2821,6 +2843,10 @@ function openModal(modal) {
window[modal].show();
}
function openDropdown(dropdown) {
window[dropdown].toggle();
}
function chVolume(increment) {
var newValue = parseInt(domCache.volumeBar.value) + increment;
if (newValue < 0)