|
|
|
function executeXhr(callback, url) {
|
|
|
|
req = false;
|
|
|
|
req = createHttpRequest();
|
|
|
|
if (req) {
|
|
|
|
req.onreadystatechange = callback;
|
|
|
|
req.open("GET", url, true);
|
|
|
|
req.send(null);
|
|
|
|
} else {
|
|
|
|
alert("Error initializing XMLHttpRequest!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createHttpRequest() {
|
|
|
|
var httpRequest = false;
|
|
|
|
if (window.XMLHttpRequest) { // branch for native XMLHttpRequest object
|
|
|
|
httpRequest = new XMLHttpRequest();
|
|
|
|
} else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version
|
|
|
|
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
|
|
|
|
if (!httpRequest) {
|
|
|
|
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return httpRequest;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function buildOptions(xmlDoc,id) {
|
|
|
|
var selectObj = document.getElementById(id);
|
|
|
|
if (!selectObj || selectObj.tagName!="TR") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var selectObjNew = selectObj.childNodes[3].childNodes[1]
|
|
|
|
var options = xmlDoc.getElementsByTagName("option");
|
|
|
|
//clear select object
|
|
|
|
// for (var i = selectObj.length-1 ; i >= 0 ; i--){
|
|
|
|
// selectObj.options[i] = null;
|
|
|
|
// }
|
|
|
|
selectObj.length = 0;
|
|
|
|
for (var i=0; i<options.length; i++) {
|
|
|
|
var len = selectObj.length;
|
|
|
|
selectObj.length = len + 1;
|
|
|
|
if(id == 'func'){
|
|
|
|
let optionsArray = Array.from(options);
|
|
|
|
let filteredOptions = optionsArray.filter(option => {
|
|
|
|
return option.attributes[0].nodeValue.indexOf('SP') === -1;
|
|
|
|
});
|
|
|
|
selectObjNew.options[len] = new Option(filteredOptions[i].attributes[1].nodeValue, filteredOptions[i].attributes[0].nodeValue);
|
|
|
|
if (filteredOptions[i].attributes[2].nodeValue =="selected") {
|
|
|
|
selectObjNew.options[len].selected = true;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
selectObjNew.options[len] = new Option(options[i].attributes[1].nodeValue, options[i].attributes[0].nodeValue);
|
|
|
|
if (options[i].attributes[2].nodeValue =="selected") {
|
|
|
|
selectObjNew.options[len].selected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|