mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-07-26 09:18:39 +00:00
clean up save-slot click handling
This commit is contained in:
+14
-13
@@ -76,20 +76,21 @@ window.init = function init() {
|
||||
}
|
||||
};
|
||||
|
||||
document.getElementById('save-slot-1').onclick = function slot1click(e) {
|
||||
e.stopPropagation();
|
||||
SAVESLOTS.loadSlot(1);
|
||||
};
|
||||
const saveSlots = document.getElementsByClassName('save-slot');
|
||||
|
||||
document.getElementById('save-slot-2').onclick = function slot2click(e) {
|
||||
e.stopPropagation();
|
||||
SAVESLOTS.loadSlot(2);
|
||||
};
|
||||
|
||||
document.getElementById('save-slot-3').onclick = function slot3click(e) {
|
||||
e.stopPropagation();
|
||||
SAVESLOTS.loadSlot(3);
|
||||
};
|
||||
for (let i = 0; i < saveSlots.length; i++) {
|
||||
const saveSlot = saveSlots[i];
|
||||
saveSlot.addEventListener('click', (event) => {
|
||||
// get save slot from button id save-slot-1 = 1
|
||||
const saveSlotIndex = parseInt(
|
||||
event.target.id.replace('save-slot-', ''),
|
||||
10
|
||||
);
|
||||
if (saveSlotIndex) {
|
||||
SAVESLOTS.loadSlot(saveSlotIndex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('refresh-device-button').onclick =
|
||||
function refreshClick(e) {
|
||||
|
||||
+7
-12
@@ -298,19 +298,14 @@ module.exports.getPinnedDevices = function getPinnedDevices() {
|
||||
};
|
||||
|
||||
module.exports.toggleSlotButtons = function toggleSlotButtons(slotIndex) {
|
||||
if (slotIndex === 1) {
|
||||
document.getElementById('save-slot-1').classList.add('active');
|
||||
document.getElementById('save-slot-2').classList.remove('active');
|
||||
document.getElementById('save-slot-3').classList.remove('active');
|
||||
} else if (slotIndex === 2) {
|
||||
document.getElementById('save-slot-1').classList.remove('active');
|
||||
document.getElementById('save-slot-2').classList.add('active');
|
||||
document.getElementById('save-slot-3').classList.remove('active');
|
||||
} else if (slotIndex === 3) {
|
||||
document.getElementById('save-slot-1').classList.remove('active');
|
||||
document.getElementById('save-slot-2').classList.remove('active');
|
||||
document.getElementById('save-slot-3').classList.add('active');
|
||||
// remove all currently active classes
|
||||
const currentActiveSlots = document.getElementsByClassName('active');
|
||||
for (let i = 0; i < currentActiveSlots.length; i++) {
|
||||
const slotButton = currentActiveSlots[i];
|
||||
slotButton.classList.remove('active');
|
||||
}
|
||||
// add the active class to the newly selected slot
|
||||
document.getElementById(`save-slot-${slotIndex}`).classList.add('active');
|
||||
};
|
||||
|
||||
module.exports.selectPreviousDevice = function selectPreviousDevice() {
|
||||
|
||||
Reference in New Issue
Block a user