Optimizations of webbuild.js and socialbox.js

This commit is contained in:
Silvan Calarco 2016-07-22 15:21:34 +02:00
parent 61960704b0
commit 12b9f32dd4
4 changed files with 43 additions and 47 deletions

View File

@ -1,14 +1,8 @@
var webbuildhost = "" var webbuildhost = ""
//var url = "http://buildvm01.openmamba.org/cgi-bin/webbuild"
var url = "/cgi-bin/webbuild.cgi"
/*function socialbox_refresh_times() {
socialbox_refresh_times(false);
}*/
var socialbox_fullrefresh_count = 0; var socialbox_fullrefresh_count = 0;
function socialbox_refresh_times() { function socialbox_refresh_times() {
"use strict";
var times = document.getElementsByName("socialtime"); var times = document.getElementsByName("socialtime");
var datenow = new Date(); var datenow = new Date();
var utcnow = parseInt(Date.UTC(datenow.getUTCFullYear(), datenow.getUTCMonth(), datenow.getUTCDate(), var utcnow = parseInt(Date.UTC(datenow.getUTCFullYear(), datenow.getUTCMonth(), datenow.getUTCDate(),
@ -45,13 +39,15 @@ function socialbox_refresh_times() {
} }
var socialbox_interval = null; var socialbox_interval = null;
var socialbox_reloadtime = 15000; var socialbox_reloadtime = 5000;
function ajax_getvalues_refresh(request,user,user_email,secret) { function ajax_getvalues_refresh(request,user,user_email,secret) {
var url = "/cgi-bin/webbuild.cgi" "use strict";
// var url = "http://buildvm01.openmamba.org/cgi-bin/webbuild"
var webbuildurl = "/cgi-bin/webbuild.cgi"
if (typeof webbuildhost != 'undefined' && webbuildhost != "") { if (typeof webbuildhost != 'undefined' && webbuildhost != "") {
url = "/cgi-bin/webbuild-" + webbuildhost + ".cgi"; webbuildurl = "/cgi-bin/webbuild-" + webbuildhost + ".cgi";
} }
var fromid = 0; var fromid = 0;
@ -71,9 +67,9 @@ function ajax_getvalues_refresh(request,user,user_email,secret) {
request="REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid; request="REQUEST=refresh&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+secret+"&FROMID="+fromid;
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
xmlhttp1 = new XMLHttpRequest(); var xmlhttp1 = new XMLHttpRequest();
else if (window.ActiveXObject) else if (window.ActiveXObject)
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP"); var xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
else else
return; return;
@ -86,23 +82,19 @@ function ajax_getvalues_refresh(request,user,user_email,secret) {
var xmldoc = xmlhttp1.responseXML.documentElement; var xmldoc = xmlhttp1.responseXML.documentElement;
var nodes = xmldoc.getElementsByTagName("socialbox")[0].childNodes; var nodes = xmldoc.getElementsByTagName("socialbox")[0].childNodes;
for (var i = 0; i < nodes.length; i++) { for (var i = 0; i < nodes.length; i++) {
id = nodes[i].attributes[0].value; var id = nodes[i].attributes[0].value;
document.getElementById("socialbox").innerHTML = $("<span name=social sid=\""+ id + "\">" + nodes[i].childNodes[0].nodeValue + "</span>")
"<span name=social sid=\""+ id + "\">" + nodes[i].childNodes[0].nodeValue + "</span>" + .clone().hide().prependTo("#socialbox").slideDown();
document.getElementById("socialbox").innerHTML;
// alert(document.getElementById("socialbox").innerHTML);
} }
if (xmldoc.getElementsByTagName("processes")[0] != undefined) { if (xmldoc.getElementsByTagName("processes")[0] != undefined) {
document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue; document.getElementById("processes").innerHTML = xmldoc.getElementsByTagName("processes")[0].childNodes[0].nodeValue;
$(function() { $('.scroll-pane3').jScrollPane({scrollbarWidth:10}); }); $(function() { $('.scroll-pane3').jScrollPane({scrollbarWidth:10}); });
} }
$(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); }); $(function() { $('.scroll-pane').jScrollPane({scrollbarWidth:10}); });
// lastupdate = (+new Date());
socialbox_refresh_times(); socialbox_refresh_times();
//alert("refreshed_times");
} }
xmlhttp1.open("POST", url, true); xmlhttp1.open("POST", webbuildurl, true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp1.send(request); xmlhttp1.send(request);
socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime); socialbox_interval = setInterval("ajax_getvalues_refresh(\"\",\""+user+"\",\""+user_email+"\",\""+secret+"\",\""+webbuildhost+"\")",socialbox_reloadtime);

View File

@ -32,7 +32,7 @@ function getSelectedValueById(selectname,idx) {
function checkEnter(event) { function checkEnter(event) {
event=event || window.event; event=event || window.event;
getEvent=event.keyCode; var getEvent=event.keyCode;
if (getEvent == "13") { if (getEvent == "13") {
return true; return true;
} }
@ -51,7 +51,7 @@ function suggestSpecName(url) {
var url=document.getElementById("speccreateurl").value; var url=document.getElementById("speccreateurl").value;
if (url.indexOf('?') > 0) url=url.substring(0,url.indexOf('?')); if (url.indexOf('?') > 0) url=url.substring(0,url.indexOf('?'));
var specname=url.substring(url.lastIndexOf('/')+1); var specname=url.substring(url.lastIndexOf('/')+1);
var extension; var extension,i,e;
while (i=specname.lastIndexOf('.')) { while (i=specname.lastIndexOf('.')) {
e=specname.substring(i); e=specname.substring(i);
if (e != ".tar" && e != ".gz" && e != ".zip" && e != ".bz2" && if (e != ".tar" && e != ".gz" && e != ".zip" && e != ".bz2" &&
@ -163,7 +163,7 @@ function getDownload(request) {
alert("ERROR: webbuildhost is undefined!"); alert("ERROR: webbuildhost is undefined!");
return; return;
} }
url = "/cgi-bin/webbuild-" + webbuildhost + ".cgi"; var url = "/cgi-bin/webbuild-" + webbuildhost + ".cgi";
if (request != "") if (request != "")
request=request+"&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+encodeURIComponent(secret); request=request+"&USER="+user+"&USER_EMAIL="+user_email+"&SECRET="+encodeURIComponent(secret);
@ -174,7 +174,7 @@ function getDownload(request) {
// var hiddenIFrameID = 'hiddenDownloader', iframe = document.getElementById(hiddenIFrameID); // var hiddenIFrameID = 'hiddenDownloader', iframe = document.getElementById(hiddenIFrameID);
// if (iframe == null) { // if (iframe == null) {
iframe = document.createElement('iframe'); var iframe = document.createElement('iframe');
// iframe.id = hiddenIFrameID; // iframe.id = hiddenIFrameID;
iframe.style.display = 'none'; iframe.style.display = 'none';
// } // }

View File

@ -8,6 +8,8 @@ pre {
box-shadow:none; box-shadow:none;
font-family: monospace; font-family: monospace;
word-break: break-all; word-break: break-all;
white-space: pre-wrap;
word-wrap: break-word;
} }
code { code {

View File

@ -3,7 +3,7 @@
var lastupdate = 0; var lastupdate = 0;
var reloadtime = 15000; var reloadtime = 15000;
var editor; var editor;
var xmlhttp; var lastxmlhttp;
function getUrlVars() { function getUrlVars() {
var vars = {}; var vars = {};
@ -13,9 +13,9 @@ function getUrlVars() {
return vars; return vars;
} }
function clearid(id) { function clearid(id,xmlhttp) {
document.getElementById(id).innerHTML = ''; document.getElementById(id).innerHTML = '';
if (xmlhttp != undefined) xmlhttp.abort(); if (lastxmlhttp != undefined) lastxmlhttp.abort();
} }
function editorChanged() { function editorChanged() {
@ -28,7 +28,7 @@ function editorChanged() {
function ajax_getvalues(request,confirm) { function ajax_getvalues(request,confirm) {
var url; var url;
// limit to this function the scope of xmlhttp to avoid sockets left pending // limit to this function the scope of xmlhttp to avoid sockets left pending
var xmlhttp; var o = {};
if (host != undefined) { if (host != undefined) {
webbuildhost=host; webbuildhost=host;
@ -54,11 +54,12 @@ function ajax_getvalues(request,confirm) {
/* if (window.location.href.indexOf('?') > 0) /* if (window.location.href.indexOf('?') > 0)
url = url + "?" + window.location.href.replace(/.*\?/,"");*/ url = url + "?" + window.location.href.replace(/.*\?/,"");*/
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest(); o.xmlhttp = new XMLHttpRequest();
else if (window.ActiveXObject) else if (window.ActiveXObject)
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); o.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
else else
return; return;
lastxmlhttp = o.xmlhttp;
document.getElementById("noajax_msg").innerHTML = ""; document.getElementById("noajax_msg").innerHTML = "";
document.getElementById("status").innerHTML = document.getElementById("status").innerHTML =
@ -68,17 +69,18 @@ function ajax_getvalues(request,confirm) {
'<div style="position:fixed;left:95%;top:95%;color:red;"><a href="javascript:clearid(\'status\');">[x] Close</a></div>'+ '<div style="position:fixed;left:95%;top:95%;color:red;"><a href="javascript:clearid(\'status\');">[x] Close</a></div>'+
'</div>'; '</div>';
xmlhttp.onreadystatechange = function() { o.xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState < 4) if (o.xmlhttp.readyState < 4) {
return; return;
if (xmlhttp.responseXML == undefined) { }
if (o.xmlhttp.responseXML == undefined) {
// && xmlhttp.responseText == undefined) { // && xmlhttp.responseText == undefined) {
document.getElementById("status").innerHTML = ""; document.getElementById("status").innerHTML = "";
document.getElementById("output").innerHTML = "<br>ERROR: there was a network connection problem."; document.getElementById("output").innerHTML = "<br>ERROR: there was a network connection problem.";
xmlhttp.abort(); o.xmlhttp.abort();
return; return;
} }
var xmldoc = xmlhttp.responseXML.documentElement; var xmldoc = o.xmlhttp.responseXML.documentElement;
if (xmldoc == undefined) { if (xmldoc == undefined) {
return; return;
} }
@ -88,10 +90,10 @@ function ajax_getvalues(request,confirm) {
document.title = nodes[i].childNodes[0].nodeValue; document.title = nodes[i].childNodes[0].nodeValue;
} else if (document.getElementById(nodes[i].nodeName) != undefined) { } else if (document.getElementById(nodes[i].nodeName) != undefined) {
// var node = document.getElementById(nodes[i].nodeName) // var node = document.getElementById(nodes[i].nodeName)
//alert("replace " + node.nodeValue + "with " + nodes[i].childNodes[0].nodeValue); replaceHTML(document.getElementById(nodes[i].nodeName), nodes[i].childNodes[0].nodeValue);
// node = replaceHTML(node, nodes[i].childNodes[0].nodeValue); // document.getElementById(nodes[i].nodeName).innerHTML = nodes[i].childNodes[0].nodeValue;
$("#"+nodes[i].nodeName).html(nodes[i].childNodes[0].nodeValue); // $("#"+nodes[i].nodeName).html(nodes[i].childNodes[0].nodeValue);
spectext = document.getElementById("spectext"); var spectext = document.getElementById("spectext");
if ((nodes[i].nodeName == "editor") && (spectext != undefined) && (spectext.parentNode != undefined)) if ((nodes[i].nodeName == "editor") && (spectext != undefined) && (spectext.parentNode != undefined))
{ {
editor = CodeMirror.fromTextArea(spectext, editor = CodeMirror.fromTextArea(spectext,
@ -112,7 +114,7 @@ function ajax_getvalues(request,confirm) {
document.getElementById("status").innerHTML = ""; document.getElementById("status").innerHTML = "";
} }
xmlhttp.onprogress = function() { o.xmlhttp.onprogress = function() {
var end = 0,to; var end = 0,to;
// save responseText length when entering the function // save responseText length when entering the function
to = this.responseText.length - 1; to = this.responseText.length - 1;
@ -135,10 +137,10 @@ function ajax_getvalues(request,confirm) {
} }
} }
xmlhttp.open("POST", url, true); o.xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); o.xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send(request); o.xmlhttp.send(request);
// setTimeout(function() { alert ("Timeout expired"); xmlhttp.abort(); }, 600000); // setTimeout(function() { alert ("Timeout expired"); o.xmlhttp.abort(); }, 600000);
var currpos = 0, start = -1; var currpos = 0, start = -1;
@ -193,7 +195,7 @@ function ajaxFileUpload(request)
} }
var webbuild_status_lastupdate = 0; var webbuild_status_lastupdate = 0;
var webbuild_status_reloadtime = 60000; var webbuild_status_reloadtime = 300000;
function webbuild_status_getvalues() { function webbuild_status_getvalues() {
var url = "/cgi-bin/autodist"; var url = "/cgi-bin/autodist";