40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
(function() {
|
|
'use strict';
|
|
var btns = document.querySelectorAll('[data-open]')
|
|
let prev = null
|
|
|
|
|
|
|
|
for (var i = 0; i < btns.length; i++) {
|
|
;btns[i].addEventListener('click', function (e) {
|
|
|
|
const iam = Array.from(document.body.children).filter(el => !el.hidden)[0];
|
|
console.log({iam, prev})
|
|
|
|
|
|
iam.hidden = true;
|
|
if (this.dataset.open === 'prev') {
|
|
prev.hidden = false;
|
|
} else {
|
|
document.getElementById(this.dataset.open).hidden = false
|
|
}
|
|
prev = iam
|
|
})
|
|
}
|
|
|
|
const fs = document.getElementById('fs')
|
|
|
|
fs.addEventListener('click', e => {
|
|
if (!screen.orientation.lock) return
|
|
document
|
|
.documentElement
|
|
.requestFullscreen()
|
|
.then(function () {
|
|
screen.orientation.lock('landscape').catch(function () {
|
|
document.exitFullscreen()
|
|
})
|
|
})
|
|
});
|
|
|
|
|
|
}()); |