add eslint, fix bugs found

This commit is contained in:
Wingy 2020-11-08 16:54:08 -05:00
parent fc2c3a7114
commit 12558d3384
28 changed files with 1774 additions and 745 deletions

View file

@ -1,8 +1,8 @@
window.onload = () => {
const burger = document.getElementById('navBarBurger');
const navBarMenu = document.getElementById('navBarMenu');
const burger = document.getElementById('navBarBurger')
const navBarMenu = document.getElementById('navBarMenu')
burger.addEventListener('click', () => {
burger.classList.toggle('is-active');
navBarMenu.classList.toggle('is-active');
});
};
burger.classList.toggle('is-active')
navBarMenu.classList.toggle('is-active')
})
}

View file

@ -1,37 +1,36 @@
function animateCSS(node, animationName) {
/* eslint-env browser */
function animateCSS (node, animationName) {
return new Promise(resolve => {
node.classList.add('animated', animationName)
function handleAnimationEnd() {
node.classList.remove('animated', animationName)
node.removeEventListener('animationend', handleAnimationEnd)
resolve()
function handleAnimationEnd () {
node.classList.remove('animated', animationName)
node.removeEventListener('animationend', handleAnimationEnd)
resolve()
}
node.addEventListener('animationend', handleAnimationEnd)
})
}
// These move function are stolen from
// https://stackoverflow.com/a/34914096
function moveUp(element) {
if(element.previousElementSibling)
element.parentNode.insertBefore(element, element.previousElementSibling);
function moveUp (element) {
if (element.previousElementSibling) { element.parentNode.insertBefore(element, element.previousElementSibling) }
}
function moveDown(element) {
if(element.nextElementSibling)
element.parentNode.insertBefore(element.nextElementSibling, element);
function moveDown (element) {
if (element.nextElementSibling) { element.parentNode.insertBefore(element.nextElementSibling, element) }
}
function listen(element, upOrDown) {
function listen (element, upOrDown) {
element.addEventListener('submit', async event => {
try {
event.preventDefault()
const tr = event.currentTarget.parentElement.parentElement
const otherTr = upOrDown === 'up' ? tr.previousSibling : tr.nextSibling
await Promise.all([
animateCSS(tr, 'zoomOut'),
animateCSS(otherTr, 'zoomOut')
@ -66,8 +65,8 @@ function listen(element, upOrDown) {
return false
} catch (error) {
alert(error.message)
throw error
location.reload()
throw error // probably useless but just in case reload doesn't do anything
}
})
}
@ -75,4 +74,4 @@ function listen(element, upOrDown) {
setTimeout(() => {
document.querySelectorAll('.upForm').forEach(element => listen(element, 'up'))
document.querySelectorAll('.downForm').forEach(element => listen(element, 'down'))
}, 0)
}, 0)