wordpress-theme-openmamba/scripts/distroquery.js

43 lines
1.6 KiB
JavaScript
Raw Permalink Normal View History

//var lastupdate = 0;
function distroquery_request(request) {
var url = "/cgi-bin/distroquery";
var statusupdated = false;
var xmlhttp;
document.getElementById("querystatus").innerHTML = "Ricerca in corso...";
if (window.XMLHttpRequest)
xmlhttp = new XMLHttpRequest();
else if (window.ActiveXObject)
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
else
return;
document.getElementById("noajax_msg").innerHTML = "";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState != 4) {
return;
}
var xmldoc = xmlhttp.responseXML.documentElement;
var xmlelement = xmldoc.getElementsByTagName("*");
for (var i=0, max=xmlelement.length; i < max; i++) {
if (xmlelement[i].nodeName == "title")
document.title = xmldoc.getElementsByTagName("title")[0].childNodes[0].nodeValue;
else if (document.getElementById(xmlelement[i].nodeName).innerHTML != null) {
document.getElementById(xmlelement[i].nodeName).innerHTML = xmlelement[i].childNodes[0].nodeValue;
if (xmlelement[i].nodeName == "querystatus") statusupdated = true;
}
}
//lastupdate = (+new Date());
if (xmlhttp.readyState==4 && xmlhttp.status==200 && !statusupdated)
document.getElementById("querystatus").innerHTML = "";
}
if (request)
xmlhttp.open("GET", url + "?lang=it_IT.UTF-8&" + request, true);
else
xmlhttp.open("GET", url + "?lang=it_IT.UTF-8", true);
xmlhttp.send();
// xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
// xmlhttp.send(request);
}