var actId; var liveStreamAvailable = false; var stories = []; var storiesWorkaround = []; var storiesBarSize = 0; var storiesTimeout = 10000; var storiesBarStepsPercent = 0; var loadStoriesBarInterval; var loadStoriesTimeout; var loadStoryInterval; var previousStory; var actualStory; function makeRequest(parameters) { httpRequest = new XMLHttpRequest(); if (!httpRequest) { alert('Problem creating connection.'); return false; } httpRequest.onreadystatechange = makeContents; httpRequest.open('GET','/handler.php?unique=1738727929' + parameters); httpRequest.send(); } function makeContents(htmlId) { if (httpRequest.readyState === XMLHttpRequest.DONE) { if (httpRequest.status === 200) { if(httpRequest.responseText.length == 0){ liveStreamAvailable = false; if(document.getElementById(actId)){ document.getElementById(actId).innerHTML = " "; } if(document.getElementById("nxtLive")){ document.getElementById("nxtLive").style.display = "block"; } }else{ liveStreamAvailable = true; if(document.getElementById(actId)){ document.getElementById(actId).innerHTML = httpRequest.responseText; } if(document.getElementById("nxtLive")){ document.getElementById("nxtLive").style.display = "none"; } } } } } function getCWD(){ actId = "cwd"; var parameters = "&a=checkLiveAvailable"; makeRequest(parameters); } function checkLiveAvailable(){ if(liveStreamAvailable == true){ document.getElementById('headLiveEye').style.display = "block"; }else{ document.getElementById('headLiveEye').style.display = "none"; } } function initScan(){ getCWD(); setInterval(getCWD, 5000); setInterval(checkLiveAvailable, 1000); } function hideStories(){ storiesBarSize = 0; document.getElementById('story').style.display='none'; clearInterval(loadStoryInterval); clearInterval(loadStoriesBarInterval); clearTimeout(loadStoriesTimeout); previousStory = null; storiesWorkaround = []; for (let i = 0; i < stories.length; i++) { document.getElementById('story-'+stories[i]).style.display='none'; } } function loadStoriesBar(){ storiesBarSize = storiesBarSize + storiesBarStepsPercent; document.getElementById("storiesbar").style.width=storiesBarSize + "%"; } function showStory(){ if(storiesWorkaround[0] > 0){ actualStory = storiesWorkaround[0]; if(previousStory > 0){ document.getElementById('story-' + previousStory).style.display='none'; } localStorage.setItem("story", storiesWorkaround[0]); document.getElementById('story-' + storiesWorkaround[0]).style.display='block'; previousStory = storiesWorkaround[0]; storiesWorkaround.shift(); }else{ clearInterval(loadStoryInterval); } } function skipStory(){ var indexOfActualStory = storiesWorkaround.indexOf(actualStory); var storiesFullTime = stories.length * storiesTimeout; var storiesFullSkipTime = storiesWorkaround.length * storiesTimeout; clearInterval(loadStoryInterval); clearTimeout(loadStoriesTimeout); clearInterval(loadStoriesBarInterval); loadStoriesTimeout = setTimeout(hideStories, storiesFullSkipTime); storiesBarSize = ( ( 100 / ( stories.length ) ) * (stories.length - storiesWorkaround.length) ); document.getElementById("storiesbar").style.width = storiesBarSize + "%"; storiesBarStepsPercent = 1; FortschrittNachÜbersprungenenTeilen = (stories.length - (stories.length - storiesWorkaround.length)) / stories.length; GesamtzeitVerbleibendeTeile = storiesTimeout * (stories.length - (stories.length - storiesWorkaround.length)); VerbleibendeZeitProProzentNachÜbersprungenenTeilen = GesamtzeitVerbleibendeTeile / FortschrittNachÜbersprungenenTeilen / 100; FortschrittAufDemLadebalken = FortschrittNachÜbersprungenenTeilen * 100; timeValue = VerbleibendeZeitProProzentNachÜbersprungenenTeilen; loadStoriesBarInterval = setInterval(loadStoriesBar, timeValue); showStory(); loadStoryInterval = setInterval(showStory, storiesTimeout); } function showStories(){ hideStories(); storiesWorkaround = stories.slice(); document.getElementById('story').style.display='flex'; var storiesFullTime = stories.length * storiesTimeout; loadStoriesTimeout = setTimeout(hideStories, storiesFullTime); showStory(); loadStoryInterval = setInterval(showStory, storiesTimeout); storiesBarSize = 0; storiesBarStepsPercent = 1; timeValue = storiesFullTime / 100; loadStoriesBarInterval = setInterval(loadStoriesBar, timeValue); document.getElementById('stories').style.opacity='0.35'; } window.addEventListener("load", (event) => { initScan(); if(stories[ stories.length - 1 ] > localStorage.getItem("story")){ }else{ if(document.getElementById('stories')){ document.getElementById('stories').style.opacity='0.35'; } } }); if(typeof AndroidInterface !== 'undefined'){ document.addEventListener('touchstart', handleTouchStart, false); document.addEventListener('touchmove', handleTouchMove, false); var xDown = null; var yDown = null; var sensitivityThreshold = 10; function getTouches(evt) { return evt.touches || evt.originalEvent.touches; } function handleTouchStart(evt) { const firstTouch = getTouches(evt)[0]; xDown = firstTouch.clientX; yDown = firstTouch.clientY; }; function handleTouchMove(evt) { if ( ! xDown || ! yDown ) { return; } var xUp = evt.touches[0].clientX; var yUp = evt.touches[0].clientY; var xDiff = xDown - xUp; var yDiff = yDown - yUp; if (Math.abs(xDiff) > Math.abs(yDiff) && Math.abs(xDiff) > sensitivityThreshold) { if (xDiff > 0) { // Handle swipe to the left } else if (xDiff < -sensitivityThreshold) { history.back(); } } xDown = null; yDown = null; }; } function adjustScrollForStickyHead(elName) { const top = document.getElementById('top'); const header = document.getElementById('header'); if (top.classList.contains('shrink')) { const elementHeight = header.offsetHeight; window.scrollBy({ top: -elementHeight, behavior: 'smooth' }); }else{ var c = document.getElementById(elName); c.scrollIntoView({behavior:'smooth',block:'start'}); } } function initialScrollTo(elName) { var c = document.getElementById(elName); c.scrollIntoView({behavior:'smooth',block:'start'}); setTimeout(function(){adjustScrollForStickyHead(elName);}, 500); } function customConfirm(message) { return new Promise((resolve) => { const overlay = document.createElement("div"); overlay.style.position = "fixed"; overlay.style.top = 0; overlay.style.left = 0; overlay.style.width = "100%"; overlay.style.height = "100%"; overlay.style.backgroundColor = "rgba(0, 0, 0, 0.5)"; overlay.style.display = "flex"; overlay.style.alignItems = "center"; overlay.style.justifyContent = "center"; document.body.appendChild(overlay); const dialog = document.createElement("div"); dialog.style.width = "300px"; dialog.style.padding = "20px"; dialog.style.backgroundColor = "white"; dialog.style.borderRadius = "8px"; dialog.style.boxShadow = "0 4px 8px rgba(0, 0, 0, 0.2)"; overlay.appendChild(dialog); const messageText = document.createElement("p"); messageText.innerText = message; messageText.style.marginBottom = "20px"; dialog.appendChild(messageText); const okButton = document.createElement("button"); okButton.innerText = "OK"; okButton.style.marginRight = "10px"; dialog.appendChild(okButton); const cancelButton = document.createElement("button"); cancelButton.innerText = "Abbrechen"; dialog.appendChild(cancelButton); okButton.addEventListener("click", () => { document.body.removeChild(overlay); resolve(true); }); cancelButton.addEventListener("click", () => { document.body.removeChild(overlay); resolve(false); }); }); } /* Verwenden der Funktion customConfirm("Möchten Sie fortfahren?").then((result) => { if (result) { console.log("Bestätigt"); } else { console.log("Abgelehnt"); } });*/