var testuj = function () { this.cache = []; this.xmlHttp = vytvorXmlHttpRequestObjekt (); this.odesli = function (obsluha, id) { //pridej do cache if (obsluha) { var query = "obsluha=" + encodeURIComponent (obsluha); query += "&id=" + encodeURIComponent (id); query += "&jazyk=" + encodeURIComponent (jazyk); for (var i = 2; i < arguments.length; i++) query += "&hodnota" + (i - 1) + "=" + encodeURIComponent (arguments[i]); this.cache.push (query); } if ((this.xmlHttp.readyState == 4 || this.xmlHttp.readyState == 0) && this.cache.length > 0) { var cachePolozka = this.cache.shift (); this.xmlHttp.open ("POST", ajaxCesta, true); this.xmlHttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded"); this.xmlHttp.setRequestHeader ("Content-length", cachePolozka.length); this.xmlHttp.setRequestHeader ("Connection", "close"); var objekt = this; this.xmlHttp.onreadystatechange = function () {objekt.zpracuj()}; this.xmlHttp.send (cachePolozka); } } this.zpracuj = function () { if (this.xmlHttp.readyState == 4) { if (this.xmlHttp.status == 200) { this.vypis (); } else { //dokonceno s chybou prenosu, napr. server neodpovedel, server je spadly apod... moznost zkusit znovu //this.xmlHttp.statusText } //zpracuj dalsi polozky v cache this.odesli (); } } this.vycisti = function (id) { document.getElementById (id + "Chyba").innerHTML = ""; } this.pocetZnaku = function (id, hodnota, maximum) { var retezec = new String (hodnota); var objekt = document.getElementById (id + "PocetZnaku"); objekt.innerHTML = retezec.length + '/' + maximum; if (retezec.length > maximum) objekt.style.color = "#ff0000"; else objekt.style.color = "#000000"; } this.vypis = function () { var xmlDokument = this.xmlHttp.responseXML.documentElement; var id = xmlDokument.getElementsByTagName ("id")[0].childNodes[0].nodeValue; var vysledek = xmlDokument.getElementsByTagName ("vysledek")[0].childNodes[0].nodeValue; document.getElementById (id + "Chyba").innerHTML = vysledek; } };