/* ** Global Variables */ var baseURL = 'https://admin.covid-19.infotalk.eu/'; var mediaURL = 'https://dwmbpc85i11i.cloudfront.net/'; /* ** http Helper Functions */ function httpGet(theUrl) { var xmlHttp = null; try { // Mozilla, Opera, Safari sowie Internet Explorer (ab v7) xmlHttp = new XMLHttpRequest(); } catch(e) { try { // MS Internet Explorer (ab v6) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { try { // MS Internet Explorer (ab v5) xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xmlHttp = null; } } } var noCacheUrl = theUrl + ((/\?/).test(theUrl) ? "&" : "?") + (new Date()).getTime(); //xmlHttp.open("GET", theUrl, false); // ohne den cache zu umgehen xmlHttp.open("GET", noCacheUrl, false); xmlHttp.send(null); return xmlHttp.responseText; } function httpPost(theUrl,theData) { var xmlHttp = null; try { // Mozilla, Opera, Safari sowie Internet Explorer (ab v7) xmlHttp = new XMLHttpRequest(); } catch(e) { try { // MS Internet Explorer (ab v6) xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { try { // MS Internet Explorer (ab v5) xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { xmlHttp = null; } } } var parameterString = ''; for (var i = 0; i < theData.length; i++) { parameterString += (i == 0 ? "" : "&") + theData[i][0] + "=" + encodeURI(theData[i][1]); } xmlHttp.open("POST", theUrl, false); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); //xmlHttp.setRequestHeader("Content-length", parameterString.length); //xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(parameterString); return xmlHttp.responseText; } /* ** Data Helper Functions */ /* function encryptTextFieldModal() { password = $('#encrypt-data-modal-password').val(); password2 = $('#encrypt-data-modal-password2').val(); content_field = $('#encrypt-data-modal-field').val(); if(password!=password2) { $('#encrypt-data-modal-password').focus(); $('#encrypt-data-modal-error').text('Passwords do not match!'); return false; } content = ''; nodename = $(content_field).prop('nodeName'); if(nodename=='P') { content = $(content_field).text(); } else { content = $(content_field).val(); } try { encrypted = sjcl.encrypt(password, content); } catch(error) { $('#encrypt-data-modal-password').val(''); $('#encrypt-data-modal-password').focus(); $('#encrypt-data-modal-password2').val(''); $('#encrypt-data-modal-error').text('Encryption Error!'); return false; } $('#encrypt-data-modal-password').val(''); $('#encrypt-data-modal-password2').val(''); $('#encrypt-data-modal-field').val(''); $('#encrypt-data-modal-error').text(''); if(nodename=='P') { $(content_field).text(encrypted); } else { $(content_field).val(encrypted); } return true; } function decryptTextFieldModal() { password = $('#decrypt-data-modal-password').val(); content_field = $('#decrypt-data-modal-field').val(); if(content_field.charAt(0)=='#') { content = ''; nodename = $(content_field).prop('nodeName'); if(nodename=='P' || nodename=='TD') { content = $(content_field).attr('value'); } else { content = $(content_field).val(); } content = content.replace('"','"'); try { decrypted = sjcl.decrypt(password, content); } catch(error) { $('#decrypt-data-modal-password').val(''); $('#decrypt-data-modal-password').focus(); $('#decrypt-data-modal-error').text('Decryption Error! Wrong Password?'); return false; } if(nodename=='P' || nodename=='TD') { decrypted = returnPreformattedTextForHTML(decrypted); $(content_field).html(decrypted); } else { $(content_field).val(decrypted); } } if(content_field.charAt(0)=='.') { $(content_field).each( function() { content = $(this).attr('value'); decrypted = ''; try { decrypted = sjcl.decrypt(password, content); } catch(error) { decrypted = 'Uh-oh, the content is still encrypted! Password mismatch?'; } decrypted = returnPreformattedTextForHTML(decrypted); $(this).html(decrypted); } ); } $('#decrypt-data-modal-password').val(''); $('#decrypt-data-modal-field').val(''); $('#decrypt-data-modal-error').text(''); return true; } */ /* VINTAGE FUNCTIONS! function encryptTextField(textfieldid) { password = prompt('Enter password!', ''); content = $(textfieldid).val(); encrypted = sjcl.encrypt(password, content); $(textfieldid).val(encrypted); } function decryptTextField(textfieldid) { password = prompt('Enter password!', ''); content = $(textfieldid).val(); decrypted = sjcl.decrypt(password, content); $(textfieldid).val(decrypted); } function encryptTextFieldUsingTextContents(textfieldid) { password = prompt('Enter password!', ''); content = $(textfieldid).text(); encrypted = sjcl.encrypt(password, content); $(textfieldid).text(encrypted); } function decryptTextFieldUsingTextContents(textfieldid) { password = prompt('Enter password!', ''); content = $(textfieldid).text(); decrypted = sjcl.decrypt(password, content); decrypted = returnPreformattedTextForHTML(decrypted); $(textfieldid).html(decrypted); } */ function returnPreformattedTextForHTML(text) { if(text.indexOf('{"iv":"')!=-1) { text = 'Uh-oh, the content is encrypted! Hit button to decrypt.'; return text; } // htmlentities //text = text.replace(/&/gi,'&'); //text = text.replace(//gi,'>'); text = text.replace(/[\u00A0-\u9999<>\&]/gim, function(i) { return '&#'+i.charCodeAt(0)+';'; }); // tab stops text = text.replace(/ /gi,''); // nl2br text = text.replace(/\n/gi,'
'); // links text = Autolinker.link(text, { newWindow: true, stripPrefix: false }); //text = text.replace(/(((f|ht){1}tp://)[-a-zA-^Z0-9@:\%_\+.~#?&//=]+)/gi,'\\1'); //$return = preg_replace('%(((f|ht){1}tp://)[-a-zA-^Z0-9@:\%_\+.~#?&//=]+)%i', '\\1', $return ); //$return = preg_replace('%(((f|ht){1}tps://)[-a-zA-^Z0-9@:\%_\+.~#?&//=]+)%i', '\\1', $return ); return text; } /* ** Cookie Helper Functions */ if (typeof String.prototype.trimLeft !== "function") { String.prototype.trimLeft = function() { return this.replace(/^\s+/, ""); }; } if (typeof String.prototype.trimRight !== "function") { String.prototype.trimRight = function() { return this.replace(/\s+$/, ""); }; } if (typeof Array.prototype.map !== "function") { Array.prototype.map = function(callback, thisArg) { for (var i=0, n=this.length, a=[]; i 1 ? decodeURIComponent(parts[1].trimRight()) : null; cookies[name] = value; }); } else { c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) { var name = $0, value = $1.charAt(0) === '"' ? $1.substr(1, -1).replace(/\\(.)/g, "$1") : $1; cookies[name] = value; }); } return cookies; } function getCookie(name) { return getCookies()[name]; } /* ** Random Number Helper Functions */ function randomIntFromInterval(min,max) { return Math.floor(Math.random()*(max-min+1)+min); }function goFullscreen() { var elem = document.getElementById("wrapper"); if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(); } } function ajaxNextPrevious(presentation_id,nextprevious) { var geturl = baseURL + 'presenter/ajaxnextprevious/id/'+presentation_id + '/nextprevious/'+nextprevious; $.ajax({ url: geturl, method: 'GET', timeout: 5000, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { $('#wrapper-error').show(); return; } if(result.status=='ok') { if(content_presentation!=result.slide_raw) { $("#image").css("background-image",'url('+result.slide_raw+')'); content_presentation = result.slide_raw; presentation_image_preloader_current_slide = result.slide_raw; slide_current = parseInt(result.slide_current); slides_total = parseInt(result.slides_total); } $('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { $('#wrapper-error').show(); console.log(textStatus); } }); return; } function ajaxPresentationGo(presentation_id,slide) { var geturl = baseURL + 'presenter/ajaxpresentationgo/id/'+presentation_id + '/slide/'+slide; $.ajax({ url: geturl, method: 'GET', timeout: 5000, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { $('#wrapper-error').show(); return; } if(result.status=='ok') { if(content_presentation!=result.slide_raw) { $("#image").css("background-image",'url('+result.slide_raw+')'); content_presentation = result.slide_raw; presentation_image_preloader_current_slide = result.slide_raw; slide_current = parseInt(result.slide_current); slides_total = parseInt(result.slides_total); } $('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { $('#wrapper-error').show(); console.log(textStatus); } }); return; } function ajaxGetPresentation(presentation_id) { var geturl = baseURL + 'presenter/ajaxgetjson/id/'+presentation_id; $.ajax({ url: geturl, method: 'GET', timeout: 2800, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { $('#wrapper-error').show(); return; } if(result.status=='ok') { if(content_presentation!=result.slide_raw) { $("#image").css("background-image",'url('+result.slide_raw+')'); content_presentation = result.slide_raw; } // FOR PRELOADING IMAGES... presentation_image_preloader_array = result.slides_all; presentation_image_preloader_current_slide = result.slide_raw; slide_current = parseInt(result.slide_current); slides_total = parseInt(result.slides_total); $('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { // $('#wrapper-error').show(); console.log(textStatus); } }); return; } function presenterPreloadSlides() { presentation_image_preloader_id = 0; presentation_image_preloader_errors = 0; var img = new Image(); img.onload = function() { console.log("... "+this.src+" loaded."); $("#image").css("background-image",'url('+this.src+')'); presentation_image_preloader_id++; if(presentation_image_preloader_id < presentation_image_preloader_array.length) { this.src = presentation_image_preloader_array[presentation_image_preloader_id]; $('#wrapper-preload').show(); $('#wrapper-preload').html("Preloading: "+presentation_image_preloader_array[presentation_image_preloader_id]); console.log("Preloading: " + presentation_image_preloader_array[presentation_image_preloader_id] + " ..."); } else { $('#wrapper-preload').show(); $('#wrapper-preload').html("Preloading finished. Errors: "+presentation_image_preloader_errors+"."); console.log("Preloading finished. Errors: "+presentation_image_preloader_errors+""); setTimeout(function(){ $("#image").css("background-image",'url('+presentation_image_preloader_current_slide+')'); $('#wrapper-preload').hide(); },2000); } } img.onerror = img.onabort = function() { console.log("... "+this.src+" preload error."); presentation_image_preloader_errors++; presentation_image_preloader_id++; if(presentation_image_preloader_id < presentation_image_preloader_array.length) { this.src = presentation_image_preloader_array[presentation_image_preloader_id]; $('#wrapper-preload').show(); $('#wrapper-preload').html("Preloading: "+presentation_image_preloader_array[presentation_image_preloader_id]); console.log("Preloading: " + presentation_image_preloader_array[presentation_image_preloader_id] + " ..."); } else { $('#wrapper-preload').show(); $('#wrapper-preload').html("Preloading finished. Errors: "+presentation_image_preloader_errors+"."); console.log("Preloading finished. Errors: "+presentation_image_preloader_errors+""); setTimeout(function(){ $("#image").css("background-image",'url('+presentation_image_preloader_current_slide+')'); $('#wrapper-preload').hide(); },2000); } } img.src = presentation_image_preloader_array[presentation_image_preloader_id]; $('#wrapper-preload').show(); $('#wrapper-preload').html("Preloading: "+presentation_image_preloader_array[presentation_image_preloader_id]); console.log("Preloading: " + presentation_image_preloader_array[presentation_image_preloader_id] + " ..."); } function ajaxPingPresentation(presentation_id) { var geturl = baseURL + 'presenter/ajaxping/id/'+presentation_id; $.ajax({ url: geturl, method: 'GET', timeout: 2000, success: function(result) { $('#wrapper-error').hide(); }, error: function(jqXHR, textStatus, errorThrown) { $('#wrapper-error').show(); console.log(textStatus); } }); return; } function ajaxGetHost(infotalk_id) { var geturl = baseURL + 'host/ajaxgetjson/id/'+infotalk_id; $.ajax({ url: geturl, method: 'GET', timeout: 2800, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { $('#wrapper-error').show(); return; } if(result.status=='ok') { if(content_host!=result.host) { if(result.host_flash=='true') { var timeout = 0; var timeout_add = 50; setTimeout(function(){$('#wrapper').css({'background-color': 'white'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'black'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'white'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'black'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'white'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'black'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'white'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'black'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'white'});}, timeout); timeout+=timeout_add; setTimeout(function(){$('#wrapper').css({'background-color': 'black'});}, timeout); timeout+=timeout_add; } $("#text").html( ''+result.host+'' ); $('#text').textfill({ maxFontPixels:-1 }); content_host = result.host; } $('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { $('#wrapper-error').show(); console.log(textStatus); } }); return; } function ajaxPingHost(infotalk_id) { var geturl = baseURL + 'host/ajaxping/id/'+infotalk_id; $.ajax({ url: geturl, method: 'GET', timeout: 2000, success: function(result) { $('#wrapper-error').hide(); }, error: function(jqXHR, textStatus, errorThrown) { $('#wrapper-error').show(); console.log(textStatus); } }); return; } function ajaxGetStatusOverview(infotalk_id) { var geturl = baseURL + 'infotalks/statusoverviewajax/id/'+infotalk_id; $.ajax({ url: geturl, method: 'GET', timeout: 4000, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { $('#wrapper-error').show(); return; } if(result.status=='ok') { $("#text").html( ''+result.content+'' ); //!! NOT USED ANYMORE IN STATUS DISPLAY!!! $('#text').textfill({ // maxFontPixels:-1 //}); $('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { statusoverview_last_error_time = Date.now(); $('#wrapper-error').show(); console.log(textStatus); } }); return; } /* ** BEGIN CLOCK DECLARATIONS AND FUNCTIONS */ var myClockData = [ {mode:"rtcutc",label:"_UTC",lastvalue:""}, //{mode:"rtc",label:"UHR:",lastvalue:""} //{mode:"datetime",label:"CLK1",lastvalue:"",targettime:"2020-12-10 12:59:00"}, //{mode:"countdowncountup",label:"CLK2",lastvalue:"",time:"00:01:00",started:"2020-11-23 18:19:17"} ] var myInfoString = ""; var myInfoStringHasChanged = false; var serverTimeTimeDiff = 0; var serverTimeTimeDiffLast = 0; var serverTimeTimeDiffOverride = 0; var lastMeasuredRTT = 0; function initServerTime() { var webServer = "https://admin.covid-19.infotalk.eu/time.php"; var blob = new Blob([ document.querySelector('#servertimeworker').textContent ], { type: "text/javascript" }) // Note: window.webkitURL.createObjectURL() in Chrome 10+. var worker = new Worker(window.URL.createObjectURL(blob)); worker.onmessage = function(e) { console.log("[INFOTALK] SRV:"+e.data.serverTimeMS+"ms LOC:"+e.data.localTimeMS+"ms RTT:"+e.data.roundtripToServer+"ms"); lastMeasuredRTT = 0; if(true) lastMeasuredRTT = e.data.roundtripToServer; // use RTT/2 serverTimeTimeDiffLast = e.data.serverTimeMS - e.data.localTimeMS + (lastMeasuredRTT/2); console.log("[INFOTALK] DIFF:"+serverTimeTimeDiffLast+"ms"); var maxTimeDiff = 2 * 1000 * 60; // zwei Minuten if(serverTimeTimeDiffLast < -maxTimeDiff || serverTimeTimeDiffLast > maxTimeDiff) { serverTimeTimeDiffLast = 0; console.log("[INFOTALK] Calculated time difference > "+maxTimeDiffMinutes+"m: falling back to local time."); } if(serverTimeTimeDiffLast!=0) { if(serverTimeTimeDiff==0) { serverTimeTimeDiff = serverTimeTimeDiffLast; } else { serverTimeTimeDiff += serverTimeTimeDiffLast; serverTimeTimeDiff /= 2; serverTimeTimeDiff = Math.round(serverTimeTimeDiff); } } worker.terminate(); } worker.postMessage(webServer); } function getCalculatedServerTimeMS() { //if(serverTimeTimeDiff==0) console.log("[INFOTALK] Server time unkown, falling back to local time!"); var currentDate = new moment.utc(); if(serverTimeTimeDiffOverride==0) { currentDate += serverTimeTimeDiff; } else { currentDate += serverTimeTimeDiffOverride; } return currentDate; } function setServerTimeTimeDiffOverrideNew(serverTimeTimeDiffOverrideNew) { if(serverTimeTimeDiffOverrideNew!=null) { serverTimeTimeDiffOverride = parseInt(serverTimeTimeDiffOverrideNew); } } function updateClockPacer() { var somethingHasChanged = false; var serverTime = getCalculatedServerTimeMS(); for(i=0; iset) | PTB"; if(myInfoString!=myInfoStringNew) { myInfoString = myInfoStringNew; myInfoStringHasChanged = true; somethingHasChanged = true; } return somethingHasChanged; } function returnTimeStringForCountdown(milliseconds) { if(milliseconds<0) { var appendForDays = " "; milliseconds *= -1; if(milliseconds > 24*60*60*1000) appendForDays = "d"; return appendForDays + "+" + moment.utc(milliseconds).format("HH:mm:ss"); } if(milliseconds==0) { return "  00:00:00" } if(milliseconds>0) { var appendForDays = " "; milliseconds+=1000; if(milliseconds > 24*60*60*1000) appendForDays = "d"; return appendForDays + "-" + moment.utc(milliseconds).format("HH:mm:ss"); } } function updateClockRender() { var displayString = ""; for(i=0; i'+displayString+'' ); $('#text').textfill({ maxFontPixels:-1 }); if(myInfoStringHasChanged) { $("#info").html( myInfoString ); myInfoStringHasChanged = false; } } function ajaxGetClock(infotalk_id) { var geturl = baseURL + 'host/ajaxgetjson/id/'+infotalk_id; $.ajax({ url: geturl, method: 'GET', timeout: 2800, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { //$('#wrapper-error').show(); return; } if(result.status=='ok') { // neue werte hier setzen console.log(myClockData); myClockData = result.clockdata; myClockData = JSON.parse(myClockData); console.log(myClockData); //$('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { //$('#wrapper-error').show(); console.log(textStatus); } }); return; } /* ** END CLOCK DECLARATIONS AND FUNCTIONS */ /* ** BEGIN CLIENTSPLIT DECLARATIONS AND FUNCTIONS */ function ajaxGetClientSplit(url_string) { var geturl = baseURL + 'infotalksclientsplits/getreloaddatetime/s/'+url_string; $.ajax({ url: geturl, method: 'GET', timeout: 2800, success: function(result) { result = base64_decode(result); result = JSON.parse(result); if(result.error!='') { //$('#wrapper-error').show(); return; } if(result.status=='ok') { if(result.reload_datetime!=reloaddatetime) { console.log("NEW reloaddatetime: "+result.reload_datetime); reloaddatetime = result.reload_datetime; window.location.reload(true); } //$('#wrapper-error').hide(); } }, error: function(jqXHR, textStatus, errorThrown) { //$('#wrapper-error').show(); console.log(textStatus); } }); return; } /* ** END CLIENTSPLIT DECLARATIONS AND FUNCTIONS */ function checkKey(e) { e = e || window.event; switch(e.keyCode) { case 37: // left arrow case 38: // up arrow case 33: // Page Up { ajaxNextPrevious(presentation_id,0); break; } case 39: // right arrow case 40: // down arrow case 13: // enter key case 32: // space key case 34: // Page Down { ajaxNextPrevious(presentation_id,1); break; } case 49: // 1 { ajaxPresentationGo(presentation_id,1); break; } case 171: // + { slide_go = slide_current + 5; if(slide_go > slides_total) slide_go = slides_total; ajaxPresentationGo(presentation_id,slide_go); break; } case 173: // - { slide_go = slide_current - 5; if(slide_go < 1) slide_go = 1; ajaxPresentationGo(presentation_id,slide_go); break; } case 80: // p { presenterPreloadSlides(); break; } default: { console.log(e.keyCode); break; } } } function checkKeyPresenterMonitor(e) { e = e || window.event; switch(e.keyCode) { case 80: // p { presenterPreloadSlides(); break; } default: { console.log(e.keyCode); break; } } } var content_presentation = ''; var content_host = ''; var presentation_image_preloader_id = 0; var presentation_image_preloader_array = []; var presentation_image_preloader_current_slide = ""; var presentation_image_preloader_errors = 0; var slide_current = 0; var slides_total = 0; /* ** On Load */ $(document).ready(function() { if(typeof is_presenter_mode != 'undefined') { if(presenter_monitor=='false') { document.onkeydown = checkKey; setInterval(function(){ ajaxPingPresentation(presentation_id); }, 2500); // war 1500 vor corona } else { document.onkeydown = checkKeyPresenterMonitor; setInterval(function(){ ajaxGetPresentation(presentation_id); }, 2000); // war 1500 vor corona } ajaxGetPresentation(presentation_id); } if(typeof is_host_mode != 'undefined') { setInterval(function(){ ajaxGetHost(infotalk_id); }, 2000); // war 1500 vor corona if(host_monitor=='false') { setInterval(function(){ ajaxPingHost(infotalk_id); }, 2000); // war 1500 vor corona } } if(typeof is_statusoverview_mode != 'undefined') { setInterval(function(){ ajaxGetStatusOverview(infotalk_id); }, 2000); // war 1500 vor corona } if(typeof is_clock_mode != 'undefined') { initServerTime(); setInterval(function(){ initServerTime(); }, 10000); ajaxGetClock(infotalk_id); setInterval(function(){ ajaxGetClock(infotalk_id); }, 10000); setInterval(function(){ if(updateClockPacer()) updateClockRender(); }, 20); } if(typeof is_clientsplit_mode != 'undefined') { setInterval(function(){ ajaxGetClientSplit(clientspliturlstring); }, 10000); } });