50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
let prev = null
|
|
const wordBank = document.getElementById('wordBank')
|
|
const input = document.getElementById('input')
|
|
|
|
;[].forEach.call(
|
|
document.querySelectorAll('[data-open]'),
|
|
function (el) {
|
|
el.addEventListener('click', function (e) {
|
|
const iam = Array.from(document.body.children).filter(el => !el.hidden)[0];
|
|
iam.hidden = true;
|
|
if (this.dataset.open === 'prev') {
|
|
prev.hidden = false;
|
|
} else {
|
|
document.getElementById(this.dataset.open).hidden = false
|
|
}
|
|
prev = iam
|
|
});
|
|
}
|
|
)
|
|
|
|
;[].forEach.call(
|
|
document.querySelectorAll('[data-fire]'),
|
|
function (el) {
|
|
el.addEventListener('click', function (e) {
|
|
document.dispatchEvent(new Event(this.dataset.fire))
|
|
});
|
|
}
|
|
)
|
|
|
|
document.addEventListener('word', (e) => {
|
|
// wordBank.innerHTML = ''
|
|
wordBank.innerHTML = Math.random()
|
|
});
|
|
|
|
document.addEventListener('fs', (e) => {
|
|
if (!screen.orientation.lock) return
|
|
document
|
|
.documentElement
|
|
.requestFullscreen()
|
|
.then(function () {
|
|
screen.orientation.lock('landscape').catch(function () {
|
|
document.exitFullscreen()
|
|
})
|
|
})
|
|
});
|
|
|
|
|
|
}()); |