prevent the browsing from overwriting the requestobject, before the answer is received

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1764 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent e089f15135
commit 88c0e1da1e

@ -1,47 +1,46 @@
function AllSnippets() {
function AllSnippets() { var query = document.getElementsByName("former")[0].value;
var query = document.getElementsByName("former")[0].value;
var span = document.getElementsByTagName("span");
var span = document.getElementsByTagName("span"); for(var x=0;x<span.length;x++) {
for(var x=0;x<span.length;x++) { if (span[x].className == 'snippetLoading') {
if (span[x].className == 'snippetLoading') { var url = document.getElementById("url" + span[x].id);
var url = document.getElementById("url" + span[x].id); requestSnippet(url,query);
requestSnippet(url,query); }
} }
} }
}
function requestSnippet(url, query){
function requestSnippet(url, query){ var req=createRequestObject();
var req=createRequestObject(); req.open('get', '/xml/snippet.xml?url=' + escape(url) + '&search=' + escape(query),false);
req.open('get', '/xml/snippet.xml?url=' + escape(url) + '&search=' + escape(query),true); req.onreadystatechange = function () {handleState(req)};
req.onreadystatechange = function () {handleState(req)}; req.send(null);
req.send(null); }
}
function handleState(req) {
function handleState(req) { if(req.readyState != 4){
if(req.readyState != 4){ return;
return; }
}
var response = req.responseXML;
var response = req.responseXML;
var snippetText = response.getElementsByTagName("text")[0].firstChild.data;
var snippetText = response.getElementsByTagName("text")[0].firstChild.data; var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data;
var urlHash = response.getElementsByTagName("urlHash")[0].firstChild.data; var status = response.getElementsByTagName("status")[0].firstChild.data;
var status = response.getElementsByTagName("status")[0].firstChild.data;
var span = document.getElementById(urlHash) var span = document.getElementById(urlHash)
removeAllChildren(span); removeAllChildren(span);
//span.removeChild(span.firstChild); //span.removeChild(span.firstChild);
if (status < 11) { if (status < 11) {
span.className = "snippetLoaded"; span.className = "snippetLoaded";
//span.setAttribute("class", "snippetLoaded"); //span.setAttribute("class", "snippetLoaded");
} else { } else {
span.className = "snippetError"; span.className = "snippetError";
//span.setAttribute("class", "snippetError"); //span.setAttribute("class", "snippetError");
} }
var snippetNode = document.createTextNode(snippetText); var snippetNode = document.createTextNode(snippetText);
span.appendChild(snippetNode); span.appendChild(snippetNode);
} }

Loading…
Cancel
Save