refactor
This commit is contained in:
parent
a307c5f743
commit
2602f82d26
17
index.html
17
index.html
@ -134,34 +134,37 @@
|
|||||||
'link': 'https://dreamsinco.de'
|
'link': 'https://dreamsinco.de'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const cursor = document.getElementById('cursor');
|
||||||
|
const live = document.getElementById('live');
|
||||||
|
|
||||||
// bonzi cursor
|
// bonzi cursor
|
||||||
['mousemove', 'touchstart', 'touchmove'].forEach(type => {
|
['mousemove', 'touchstart', 'touchmove'].forEach(type => {
|
||||||
window.addEventListener(type, event => {
|
window.addEventListener(type, event => {
|
||||||
document.getElementById('cursor').style.top = (event.clientY || event.touches[0].clientY) + 'px';
|
cursor.style.top = (event.clientY || event.touches[0].clientY) + 'px';
|
||||||
document.getElementById('cursor').style.left = (event.clientX || event.touches[0].clientX) + 'px';
|
cursor.style.left = (event.clientX || event.touches[0].clientX) + 'px';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove stream if embedded
|
// remove stream if embedded
|
||||||
if (window.self !== window.top) {
|
if (window.self !== window.top) {
|
||||||
document.getElementById('live').remove();
|
live.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
const vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
|
||||||
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
const vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
|
||||||
|
|
||||||
// resize iframe if view width is smaller than frame
|
// resize iframe if view width is smaller than frame
|
||||||
if (document.getElementById('live').width > vw) {
|
if (parseInt(live.width, 10) > vw) {
|
||||||
document.getElementById('live').setAttribute('width', vw + 'px');
|
live.width = vw + 'px';
|
||||||
document.getElementById('live').setAttribute('height', vw * (9 / 16) + 'px');
|
live.height = vw * (9 / 16) + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if stream active every 5 seconds
|
// check if stream active every 5 seconds
|
||||||
setInterval(function checkLive() {
|
setInterval(function checkLive() {
|
||||||
fetch(new URL('index.m3u8', socials.live.link))
|
fetch(new URL('index.m3u8', socials.live.link))
|
||||||
.then(response => {
|
.then(response => {
|
||||||
document.getElementById('live').style.display = response.ok ? 'inline' : 'none';
|
live.style.display = response.ok ? 'inline' : 'none';
|
||||||
});
|
});
|
||||||
return checkLive;
|
return checkLive;
|
||||||
}(), 5000);
|
}(), 5000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user