@justgage/reason-cookie
Version:
a simple way to use cross-browser cookies that contain JSON.
31 lines (29 loc) • 956 B
JavaScript
var checkHash = () => {
if (!window.shouldCheckHashes) {
return
}
var id = window.location.hash.slice(1)
if (id && !document.getElementById(id)) {
document.getElementById("error-message").style.display = 'block'
var parts = id.split('-')
document.querySelector('#error-message span').textContent = parts[0]
document.querySelector('#error-message code').textContent = parts[1]
} else {
document.getElementById("error-message").style.display = 'none'
}
}
window.onload = () => {
checkHash()
var expander = document.querySelector('.sidebar-expander')
expander.onclick = () => {
var sidebar = document.querySelector('.sidebar');
if (sidebar.classList.contains('expanded')) {
sidebar.classList.remove('expanded')
expander.textContent = 'Show navigation'
} else {
sidebar.classList.add('expanded')
expander.textContent = 'Hide navigation'
}
}
}
window.onhashchange = checkHash