/* ** Global Variables */ var baseURL = 'https://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 initServerTime() { var webServer = "https://covid-19.infotalk.eu/time.html"; //webServer = "https://www.googleapis.com/"; // NOTFALLS-FALLBACK console.log("[INFOTALK] Fetching server time from '"+webServer+"'..."); xmlhttp = new XMLHttpRequest(); xmlhttp.onload=function() { if(this.readyState==this.DONE) { if(this.responseText!="") { var serverDate = moment.utc(xmlhttp.getResponseHeader("Date")); var localDate = moment.utc(); console.log("[INFOTALK] Server time: " + serverDate.toISOString()); console.log("[INFOTALK] Local time: " + localDate.toISOString()); serverTimeTimeDiff = serverDate - localDate; console.log("[INFOTALK] Time difference (server-local): " + serverTimeTimeDiff + "ms"); var maxTimeDiffMinutes = 2; var maxTimeDiff = 1000 * 60 * maxTimeDiffMinutes; if(serverTimeTimeDiff < -maxTimeDiff || serverTimeTimeDiff > maxTimeDiff) { serverTimeTimeDiff = 0; console.log("[INFOTALK] Calculated time difference > "+maxTimeDiffMinutes+"m: falling back to local time."); } var serverTimeMS = getCalculatedServerTimeMS(); var serverTime = new Date(serverTimeMS); console.log("[INFOTALK] Calculated Server time: " + serverTime.toISOString()); } } }; xmlhttp.open("HEAD", webServer); xmlhttp.send(); } function getCalculatedServerTimeMS() { if(serverTimeTimeDiff==0) { console.log("[INFOTALK] Server time unkown, falling back to local time!"); } var currentDate = new moment.utc(); currentDate += serverTimeTimeDiff; return currentDate; } function regexText(content) { var returnvalue = content; returnvalue = returnvalue.replace( /\*\*\*(.*?)\*\*\*/g , "

$1

"); returnvalue = returnvalue.replace( /\*\*(.*?)\*\*/g , "

$1

"); returnvalue = returnvalue.replace( /\_\_(.*?)\_\_/g , "$1"); returnvalue = returnvalue.replace( /\+\+\+(.*?)\+\+\+/g , "

$1

"); returnvalue = returnvalue.replace( /\+\+(.*?)\+\+/g , "

$1

"); returnvalue = returnvalue.replace( /--(.*?)--/g , "$1"); returnvalue = returnvalue.replace( /\n\*(.*)/g , "" ); returnvalue = returnvalue.replace( /\n/g , "
" ); return returnvalue; } function processSectionChange(section) { var returnvalue = ""; switch(section.mode) { case "Video": { returnvalue = "PGRpdiBjbGFzcz0iZW1iZWQtcmVzcG9uc2l2ZSBlbWJlZC1yZXNwb25zaXZlLTE2Ynk5Ij48aWZyYW1lIGlkPSJ2aWRlb2lmcmFtZV8lJVNFQ1RJT04lJSIgY2xhc3M9ImVtYmVkLXJlc3BvbnNpdmUtaXRlbSIgZnJhbWVib3JkZXI9IjAiIGFsbG93ZnVsbHNjcmVlbj48L2lmcmFtZT48L2Rpdj4="; returnvalue = base64_decode(returnvalue); returnvalue = returnvalue.replace( /\%\%SECTION\%\%/g, section.section); break; } case "FreeText": { returnvalue = regexText(section.content); break; } case "Presentation": { returnvalue = "PGltZyBpZD0iaW1nX3ByZXNlbnRhdGlvbl8lJUVMRU1FTlRJRCUlIiBjbGFzcz0iaW1nLXJlc3BvbnNpdmUgY2VudGVyLWJsb2NrIiBzcmM9IiUlU0xJREUlJSIgLz4="; returnvalue = base64_decode(returnvalue); returnvalue = returnvalue.replace( /\%\%ELEMENTID\%\%/g, section.element_id); returnvalue = returnvalue.replace( /\%\%SLIDE\%\%/g, section.content); break; } case "Poll": { returnvalue = "CQkJCQkJPHNwYW4gaWQ9InBvbGxfdmlzaWJsZV8lJUlEJSUiIHN0eWxlPSJkaXNwbGF5OiBub25lOyI+CgkJCQkJCQk8Zm9ybSBpZD0icG9sbF9mb3JtXyUlSUQlJSI+CgkJCQkJCQk8aDIgY2xhc3M9InJlZHRleHQiPiUlSDElJTwvaDI+CgkJCQkJCQk8aDI+JSVIMyUlPC9oMj4KCQkJCQkJCSUlT1BUSU9OUyUlCgkJCQkJCQk8YnV0dG9uIHR5cGU9ImJ1dHRvbiIgY2xhc3M9ImJ0biBidG4tcHJpbWFyeSIgb25DbGljaz0ic2VuZFZvdGUoJyUlSUQlJScpOyI+JSVCVVRUT05URVhUJSU8L2J1dHRvbj4KCQkJCQkJCTwvZm9ybT4KCQkJCQkJPC9zcGFuPgoJCQkJCQk8c3BhbiBpZD0icG9sbF9maW5pc2hlZF8lJUlEJSUiIHN0eWxlPSJkaXNwbGF5OiBub25lOyI+CgkJCQkJCQk8aDI+JSVGSU5JU0hFRFRFWFQlJTwvaDI+CgkJCQkJCTwvc3Bhbj4K"; returnvalue = base64_decode(returnvalue); returnvalue = returnvalue.replace( /\%\%ID\%\%/g, section.id); returnvalue = returnvalue.replace( /\%\%H1\%\%/g, section.h1); returnvalue = returnvalue.replace( /\%\%H3\%\%/g, section.h3); returnvalue = returnvalue.replace( /\%\%BUTTONTEXT\%\%/g, section.buttontext); returnvalue = returnvalue.replace( /\%\%FINISHEDTEXT\%\%/g, section.finishedtext); var polloption = "CQkJCQkJCQk8ZGl2IGNsYXNzPSJyYWRpbyI+CgkJCQkJCQkJCTxsYWJlbD48aW5wdXQgdHlwZT0icmFkaW8iIG5hbWU9InBvbGxfb3B0aW9uIiB2YWx1ZT0iJSVLRVklJSI+JSVWQUxVRSUlPC9sYWJlbD4KCQkJCQkJCQk8L2Rpdj4K"; polloption = base64_decode(polloption); var options = section.options.split("\n"); var optionsstring = ""; for(i=0; i