var req;
var which;
var xmlTags;
var htmlTag;
function startCall(){
var abi = document.forms[0].testAjax.value;
var url = "ajaxcall.do?abi=" + abi;
xmlTags = new Array("abi", "flag","tabi");
htmlTag = "rssData";
retrieveURLSingle(url);
}
function retrieveURL(url,callback) {
if (url != "") {
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
return;
}
callback(req);
}
try {
req.open("POST", url, true);
} catch (e) {
alert(e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function () {
if (req.readyState != 4) return;
if (req.status != 200 && req.status != 304) {
return;
}
callback(req);
}
req.open("POST", url, true);
req.send();
}
}
}
}
function retrieveURLSingle(url) {
if (url != "") {
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = processStateChange;
try {
req.open("POST", url, true);
} catch (e) {
alert(e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processStateChange;
req.open("POST", url, true);
req.send();
}
}
}
}
function creaTabellaErrori(t,s,errors){
//var tabella = '';
return tabella;
}
function validationErrors(xml){
t = xml.getElementsByTagName("errorTitle")[0];
if (t != null){
t = t.firstChild.data;
}else{
t = "";
}
s = xml.getElementsByTagName("errorSubitle")[0];
if (s != null){
s = s.firstChild.data;
}else{
s = "";
}
j = 0;
var errors = "";
while (j >= 0) {
e = xml.getElementsByTagName("error")[j];
if (e != null) {
e = e.firstChild.data;
errors += e;
j++;
} else {
j = -1;
}
}
if(errors == ""){
document.getElementById("rssErrors").innerHTML="";
} else {
document.getElementById("rssErrors").innerHTML = creaTabellaErrori(t,s,errors);
}
}
function processStateChange() {
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
xml = req.responseXML;
validationErrors(xml);
var html = "";
i = 0;
while (i >= 0) {
var singleLine = tagProcess(xml, i);
if(singleLine != ""){
html += singleLine;
i++;
} else {
i = -1;
}
}
document.getElementById(htmlTag).innerHTML = html;
} else {
alert("Problem: " + req.statusText);
}
}
}
function tagProcess(xml, line){
var lineString = "";
for (var k = 0; k < xmlTags.length; k++){
var tagSingolo = xml.getElementsByTagName(xmlTags[k])[line];
if(tagSingolo != null){
lineString += tagSingolo.firstChild.data;
}
}
return lineString;
}
//*********************************************************************
// goPrevious: submit verso WizardActioncon richiesta pagina precedente
//*********************************************************************
function goPrevious() {
document.forms[0].method.value="goBack";
document.forms[0].submit();
}
//*********************************************************************
// goAhead: submit verso WizardActioncon richiesta prossima pagina
//*********************************************************************
function goAhead() {
//document.forms[0].method.value="goAhead";
document.forms[0].submit();
}
//*********************************************************************
// uscita applicazione
//*********************************************************************
function goOut() {
window.close();
}