var sFolder = "https://dzieci.eu/xml/"; var sURLGetList = sFolder + "get_list.php?"; var requestsQueue = new Array(); var arrInitialValuesOfAsyncFields = new Array(); var updatedFields = new Array(); var sPostName; var sPostValue; var bPostAction; /* * updateList - function updates options list in drop-down box */ function UpdateListCommon(dataType, targetField, filterFlag, iID, sCustomTargetField1, sCustomTargetField2, sUnit) { if (document.getElementById(targetField)) {//if targer exists switch (dataType) { case "ReloadClassifieds": ClearSelection(targetField); selection = document.getElementById(targetField); optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField); break; case "ReloadSubTree": selection = document.getElementById(targetField); if (selection.innerHTML == '') { oPicSelection = document.getElementById("tree_action_img_" + iID); oPicSelection.src = "images/minus.gif"; var bReloadTree = true; var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField, '', '', '', bReloadTree); } else { oPicSelection = document.getElementById("tree_action_img_" + iID); oPicSelection.src = "images/plus.gif"; selection.innerHTML = ''; } break; case "ReloadClassifiedsAndCustomsFields": ClearSelection(targetField); selection = document.getElementById(targetField); if (selection) { optionObject = new Option('Loading...', 'null', false, false); selection.options[selection.length] = optionObject; } var bAdminMan = document.getElementById('admin_managing'); if (bAdminMan) { //document.getElementById('customRow1').style.display = 'none'; //document.getElementById('customRow2').style.display = 'none'; document.getElementById('CustomName1').value=""; document.getElementById('CustomName2').value=""; document.getElementById('CustomAction1').value="-1"; document.getElementById('CustomAction2').value="-1"; } if (oElement = document.getElementById(targetField)) { oElement.style.display = 'none'; } if (oElement = getCustomActionField(sCustomTargetField1)) { oElement.style.display = 'none'; } if (oElement = getCustomActionField(sCustomTargetField2)) { oElement.style.display = 'none'; } var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, targetField, sCustomTargetField1, sCustomTargetField2, sUnit); break; case "ReloadOnlyCustomsFields": if (oElement = getCustomActionField(sCustomTargetField1)) { oElement.style.display = 'none'; } if (oElement = getCustomActionField(sCustomTargetField2)) { oElement.style.display = 'none'; } var sURLRequest = "dataType="+dataType+"&"+filterFlag+"="+iID; addRequestToQueue(sURLRequest, dataType, '', sCustomTargetField1, sCustomTargetField2); break; } } } function addRequestToQueue(sURLRequest, sXmlNodeName, toField, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree) { requestsQueue[requestsQueue.length] = new QueueItem(sURLGetList+sURLRequest, sXmlNodeName, toField, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree); if (requestsQueue.length == 1) doSendRequest(); } function QueueItem(url, sXmlNodeName, toField, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree) { this.url=url; this.sXmlNodeName=sXmlNodeName; this.toField=toField; this.bReloadTree=bReloadTree; this.sCustomTargetField1 = sCustomTargetField1; this.sCustomTargetField2 = sCustomTargetField2; this.sUnit = sUnit; } function doSendRequest() { globalObjXmlHttpRequest = createXmlHttpObject(); if ( globalObjXmlHttpRequest ) { globalObjXmlHttpRequest.onreadystatechange = RecieveData; globalObjXmlHttpRequest.open("GET", requestsQueue[0].url); globalObjXmlHttpRequest.send(null); } } function createXmlHttpObject() { var objXmlHttp = false; if ( window.XMLHttpRequest ) objXmlHttp = new XMLHttpRequest(); else if ( window.ActiveXObject ) objXmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); return objXmlHttp; } function RecieveData() { if(globalObjXmlHttpRequest.readyState == 4) { // if( requestsQueue[0] ) // { // alert( requestsQueue[0].url ); //window.open( requestsQueue[0].url ); // } // Dequeue request and run the handler if ((requestData = requestsQueue.shift()) == null) throw new Error('Internal error: queue is empty'); if (globalObjXmlHttpRequest.status == 200) { if (requestData.toField) { ClearSelection(requestData.toField, requestData.bReloadTree); } fillSelectionWithXmlData(requestData.sXmlNodeName, requestData.toField, globalObjXmlHttpRequest.responseXML, requestData.sCustomTargetField1, requestData.sCustomTargetField2, requestData.sUnit, requestData.bReloadTree); } if (requestsQueue.length > 0) doSendRequest(); selection = document.getElementById(requestData.toField); if (arrInitialValuesOfAsyncFields[requestData.toField] != undefined && arrInitialValuesOfAsyncFields[requestData.toField] != '') selection.value = arrInitialValuesOfAsyncFields[requestData.toField]; arrInitialValuesOfAsyncFields[requestData.toField]=null; selection = document.getElementById(requestData.toField); if (selection) { if (typeof(selection.onchange) == 'function') selection.onchange(); // Perform chain action } } } function ClearSelection(selectionID, bReloadTree) { var selection = document.getElementById(selectionID); if (bReloadTree) { selection.innerHTML = ''; } else { for (var i = selection.options.length - 1; i >= 0; i--) { selection.options[i] = null; } } } function fillSelectionWithXmlData(targetXmlTagName, selectionID, xmlNode, sCustomTargetField1, sCustomTargetField2, sUnit, bReloadTree) { var selection = document.getElementById(selectionID); var options = xmlNode.getElementsByTagName(targetXmlTagName); var custSel1; var custSel1; var strt=''; var bAdminMan = document.getElementById('admin_managing'); if (bAdminMan==null) bAdminMan = false; if (sCustomTargetField1 && sCustomTargetField2 && bAdminMan==false) { custSel1 = document.getElementById(sCustomTargetField1); custSel2 = document.getElementById(sCustomTargetField2); custSel1.innerHTML = ''; custSel2.innerHTML = ''; } for (var optionIndex = 0; optionIndex <= options.length - 1; optionIndex++) { var optionData = options[optionIndex].childNodes; var optionID = ''; var optionValue = ''; var optionCnt = ''; var custFieldName1 = ''; var custFieldName2 = ''; var customAction1 = ''; var customAction2 = ''; var sUnitValue = ''; for (var propertyIndex = 0; propertyIndex <= optionData.length - 1; propertyIndex++) { if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'ID') optionID = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'Name') optionValue = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'Count') optionCnt = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomFieldName1') custFieldName1 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomFieldName2') custFieldName2 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomAction1') customAction1 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'CustomAction2') customAction2 = getNodeText(optionData[propertyIndex]); if (optionData[propertyIndex].nodeType == 1 && optionData[propertyIndex].nodeName == 'Unit') sUnitValue = getNodeText(optionData[propertyIndex]); } if (bReloadTree) { //var re = /(\d+$)/; //re.exec(selectionID); //var ahrefs = "\n"; var ahrefs = "\n"; var ahrefe = ""; strt += '