Files
ReZygisk/webroot/js/navbar.js
ThePedroo dde0436fd9 fix: JS code indentation/syntax
This commit fixes the syntax and indentation of the JavaScript code to meet the organization standard.
2024-11-12 00:09:12 -03:00

41 lines
1.5 KiB
JavaScript

setData('home')
document.getElementById('ni_home').style.display = 'flex'
document.getElementById('nid_home').style.display = 'none'
document.getElementById('panel_home').style.display = 'block'
document.querySelectorAll('[name=navbutton]').forEach((element) => {
element.addEventListener('click', (event) => {
const value = event.target.value
const previous = !localStorage.getItem('/cache/navbar/previous') ? setData('home') : localStorage.getItem('/cache/navbar/previous')
if (previous === value) return;
/* INFO: Disable icon on old state */
const pre_input = document.getElementById(`n_${previous}`)
const pre_icon = document.getElementById(`ni_${previous}`)
const pre_icon_disabled = document.getElementById(`nid_${previous}`)
document.getElementById(`panel_${previous}`).style.display = 'none'
pre_input.removeAttribute('checked')
pre_icon.style.display = 'none'
pre_icon_disabled.style.display = 'flex'
/* INFO: Enable icon on new state */
const curr_input = document.getElementById(`n_${value}`)
const icon = document.getElementById(`ni_${value}`)
const icon_disabled = document.getElementById(`nid_${value}`)
document.getElementById(`panel_${value}`).style.display = 'block'
curr_input.setAttribute('checked', '')
icon.style.display = 'flex'
icon_disabled.style.display = 'none'
setData(value)
})
})
function setData(data) {
localStorage.setItem('/cache/navbar/previous', data)
return data
}