feat: web interface: mode icon instead of 'Mode'

This commit is contained in:
Terry Geng
2020-04-29 10:24:57 +08:00
parent 5617268270
commit 984309409a
2 changed files with 15 additions and 5 deletions

View File

@ -52,6 +52,12 @@ var playModeBtns = {
repeat: $('#repeat-mode-btn'),
autoplay: $('#autoplay-mode-btn')
};
var playModeIcon = {
'one-shot': 'fa-tasks',
random: 'fa-random',
repeat: 'fa-redo',
autoplay: 'fa-robot'
};
function request(_url, _data, refresh = false) {
console.log(_data);
@ -263,13 +269,17 @@ function updateControls(empty, play, mode, volume) {
}
}
let otherModes = Object.assign({}, playModeBtns);
delete otherModes[mode];
for (_mode in otherModes) {
otherModes[_mode].removeClass('active');
for (const otherModes of Object.values(playModeBtns)) {
otherModes.removeClass('active');
}
playModeBtns[mode].addClass('active');
let playModeIndicator = $('#modeIndicator');
for (const icon_class of Object.values(playModeIcon)) {
playModeIndicator.removeClass(icon_class);
}
playModeIndicator.addClass(playModeIcon[mode]);
if (volume != last_volume) {
last_volume = volume;
if (volume > 1) {