socialbox.js: improvements to refresh at interval

This commit is contained in:
Silvan Calarco 2016-08-20 16:22:06 +02:00
parent 12b9f32dd4
commit 47e5bacd9c

View File

@ -45,6 +45,7 @@ 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";
@ -67,9 +68,19 @@ function ajax_getvalues_refresh(request,user,user_email,secret) {
request="REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid;
if (window.XMLHttpRequest)
var xmlhttp1 = new 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)
var xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
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;
@ -77,6 +88,8 @@ function ajax_getvalues_refresh(request,user,user_email,secret) {
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;
@ -92,10 +105,15 @@ function ajax_getvalues_refresh(request,user,user_email,secret) {
}
$(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);
socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime);
}