var webbuildhost = "" var socialbox_fullrefresh_count = 0; function socialbox_refresh_times() { "use strict"; var times = document.getElementsByName("socialtime"); var datenow = new Date(); var utcnow = parseInt(Date.UTC(datenow.getUTCFullYear(), datenow.getUTCMonth(), datenow.getUTCDate(), datenow.getUTCHours(), datenow.getUTCMinutes(), datenow.getUTCSeconds()) / 1000); for (var i = 0; i < times.length; i++) { if (times[i].attributes[0].name == "time") { var socialtime = times[i].attributes[0].value; } else { var socialtime = times[i].attributes[1].value; } var timeago = utcnow - socialtime; if ((times[i].innerHTML == "") || (timeago <= 120) || // update every 15 secs if < 2 min (timeago <= 7200 && (socialbox_fullrefresh_count % 4 == 0)) || // update every minute if < 120 min (timeago <= 86400 && (socialbox_fullrefresh_count % 120 == 0)) || // update every thirty minutes if < 1 day (socialbox_fullrefresh_count >= 240)) // else update all every hour { var daysago = parseInt(timeago / 86400); var hoursago = parseInt(timeago / 3600 % 24); var minutesago = parseInt(timeago / 60 % 60); var secondsago = parseInt(timeago % 60); times[i].innerHTML = "("; if (daysago > 1) times[i].innerHTML += daysago + " days"; else if (daysago == 1) times[i].innerHTML += "1 day, " + hoursago + " hours"; else if (hoursago > 1) times[i].innerHTML += hoursago + " hours"; else if (hoursago == 1) times[i].innerHTML += "1 hour, " + minutesago + " minutes"; else if (minutesago > 1) times[i].innerHTML += minutesago + " minutes"; else if (minutesago == 1) times[i].innerHTML += "1 minute, " + secondsago + " seconds"; else times[i].innerHTML += secondsago + " seconds"; times[i].innerHTML += " ago) "; } } if (socialbox_fullrefresh_count++ >= 240) socialbox_fullrefresh_count = 0; } var socialbox_interval = null; var socialbox_reloadtime = 5000; function ajax_getvalues_refresh(request,user,user_email,secret) { "use strict"; var webbuildurl = "/cgi-bin/webbuild.cgi" var xmlhttp1; if (typeof webbuildhost != 'undefined' && webbuildhost != "") { webbuildurl = "/cgi-bin/webbuild-" + webbuildhost + ".cgi"; } var fromid = 0; if (socialbox_interval != null) { clearInterval(socialbox_interval); } if (document.getElementsByName("social").length > 0) { if (document.getElementsByName("social")[0].attributes[0].name == "sid") { fromid = parseInt(document.getElementsByName("social")[0].attributes[0].value) + 1; } else { fromid = parseInt(document.getElementsByName("social")[0].attributes[1].value) + 1; } } if (request != "") request=request+"&REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid; else request="REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid; if (window.XMLHttpRequest) try { xmlhttp1 = new XMLHttpRequest(); } catch(e) { console.log('XMLHttpRequest Error'); socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime); } else if (window.ActiveXObject) try { xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { console.log('XMLHttpRequest Error'); socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime); } else return; xmlhttp1.onreadystatechange = function() { if (xmlhttp1.readyState != 4) return; if (xmlhttp1.responseXML == undefined) { console.log('XMLHttpRequest Undefined response'); socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime); return; } var xmldoc = xmlhttp1.responseXML.documentElement; var nodes = xmldoc.getElementsByTagName("socialbox")[0].childNodes; for (var i = 0; i < nodes.length; i++) { var id = nodes[i].attributes[0].value; $("" + nodes[i].childNodes[0].nodeValue + "") .clone().hide().prependTo("#socialbox").slideDown(); } if (xmldoc.getElementsByTagName("processes")[0] != undefined) { document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue; $(function() { $('.scroll-pane3').jScrollPane({scrollbarWidth:10}); }); } $(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); }); socialbox_refresh_times(); socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime); } xmlhttp1.timeout = function() { console.log('XMLHttpRequest Timeout'); socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime); } xmlhttp1.open("POST", webbuildurl, true); xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp1.send(request); }