//alert(tmp); function addnew(id){ //Если окно уже открыто - возвращает false if(document.getElementById(id).style.display != 'none'){ return false; } //чистим все существующие инпуты и селекты for(i=0;iVALUE //функция вызывается ВСЕГДА когда работает ajax //По факту выполнения основного кода (тот, который без action в XML) пишет статус в див id=ajaxresult и запускает функцию ajaxDone(), которую можно переопределить function updateModalWindowContents(txtdata){ // alert(txtdata); setTimeout("hideBlocker()", 500); var docobj = false; var browser = 1; if (window.XMLHttpRequest) { // Safari, Firefox... docobj = new XMLHttpRequest(); if (docobj.overrideMimeType) { docobj.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE browser = 2; try { docobj = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { docobj = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!docobj) { alert('Невозможно создать экземпляр класса XMLHTTP '); return false; } if(window.ActiveXObject){ docobj = new ActiveXObject("Microsoft.XMLDOM"); docobj.async = "false"; docobj.loadXML(txtdata); } else{ var domParser = new DOMParser(); docobj = domParser.parseFromString(txtdata, 'application/xml'); } if(docobj.documentElement.firstChild.nodeName == 'action' && docobj.documentElement.firstChild.childNodes.item(0).nodeValue == 'alertError'){ if(docobj.documentElement.childNodes.item(1).childNodes.item(0).childNodes.item(0)){ alert(docobj.documentElement.childNodes.item(1).childNodes.item(0).childNodes.item(0).nodeValue); } else{ alert('Произошла непредвиденная ошибка!'); } return false; } if(docobj.documentElement.firstChild.nodeName == 'action' && docobj.documentElement.firstChild.childNodes.item(0).nodeValue == 'insertItemData'){ var nid = docobj.documentElement.childNodes.item(1).childNodes; document.getElementById('typeName').value = nid.item(0).childNodes.item(0).nodeValue; try{ //document.getElementById('typeStructure').innerHTML = nid.item(1).childNodes.item(0).xml; var xti = nid.item(1).childNodes.item(0).xml; document.getElementById('typeStructure').innerText = xti; } catch(e){ var errormsg = e.number & 0xFFFF; errormsg = 'Error: '+errormsg+' '+e.description; alert(errormsg); } document.getElementById('typeComment').innerHTML = nid.item(2).childNodes.item(0).nodeValue; return true; } if(docobj.documentElement.firstChild.nodeName == 'action' && docobj.documentElement.firstChild.childNodes.item(0).nodeValue == 'insertXMLById'){ var nid = docobj.documentElement.childNodes.item(1).childNodes.item(0).xml; var non = docobj.documentElement.childNodes.item(1).childNodes.item(0).nodeName; document.getElementById(non).innerHTML = nid; // alert(document.getElementById(non).innerHTML); return true; } if(docobj.documentElement.firstChild.nodeName == 'action' && docobj.documentElement.firstChild.childNodes.item(0).nodeValue == 'prelimListItems'){ var nid = docobj.documentElement.childNodes.item(1).xml; document.getElementById('existingTypes').innerHTML = nid; return true; } if(docobj.documentElement.firstChild.nodeName == 'action' && docobj.documentElement.firstChild.childNodes.item(0).nodeValue == 'openSearchWindow'){ var srchhtml = ''; for(i=1;i 0){ var name = curNode.childNodes.item(1).childNodes.item(0).nodeValue; var id = curNode.childNodes.item(0).childNodes.item(0).nodeValue; var opf = curNode.childNodes.item(2).childNodes.item(0).nodeValue; var inn = ''; if(curNode.childNodes.item(3).childNodes.item(0)){ inn = curNode.childNodes.item(3).childNodes.item(0).nodeValue; } srchhtml += "
"+name+"
"; } else srchhtml = 'Поиск не дал результатов.'; } document.getElementById('kares').innerHTML = srchhtml; return false; } if(docobj.documentElement.firstChild.nodeName == 'action' && docobj.documentElement.firstChild.childNodes.item(0).nodeValue == 'void'){ return null; } for(i=0;i 0){ if(document.getElementById(curNode.nodeName).tagName == "INPUT" || document.getElementById(curNode.nodeName).tagName == "SELECT"){ document.getElementById(curNode.nodeName).value = curNode.childNodes.item(0).nodeValue; } else{ document.getElementById(curNode.nodeName).innerHTML = curNode.childNodes.item(0).xml; } } } if(document.getElementById('ajaxresult')){ document.getElementById('ajaxresult').innerHTML = '200'; ajaxDone(); } return true; } function ajaxDone(){ return true; } function reportParseError(error){ error_str = "Ошибка при загрузке документа '" + error.url + "'"+error.reason; if (error.line > 0) error_str += "Строка " + error.line + ", символ " + error.linepos + "
" + error.srcText; return error_str; } function ajaxopen(id, parameters) { //ajaxopen('', string parameters). parameters - строка фрмата uri без лидирующего ? для передачи на сервер методом POST if (window.XMLHttpRequest) { // Mozilla, Safari, ... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Невозможно создать экземпляр класса XMLHTTP '); return false; } if(document.getElementById('clickBlocker')){ document.getElementById('clickBlocker').style.display = ''; document.getElementById('clickBlocker').style.top = document.body.scrollTop+'px'; } http_request.onreadystatechange = function() { contOut(http_request, id); }; http_request.open('POST', '/staff/mco/ajax_mod.php', true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); } function contOut(http_request, id) { var res = ''; if (http_request.readyState == 4) { if (http_request.status == 200) { if(http_request.responseText == 'appare'){ window.location.href = window.location.href; return false; } // document.getElementById('ajaxResultContainer').style.display = ''; // document.getElementById('tmpz').style.display = ''; if(document.getElementById('ajaxResultContainer')){ document.getElementById('ajaxResultContainer').innerHTML = http_request.responseText; } res = updateModalWindowContents(http_request.responseText); //Эта функция вызывается всегда, определяется в файлах разделов. Она обновляет данные в окошках. } else{ res = updateModalWindowContents(http_request.responseText); } } else { // document.getElementById('tmp').innerHTML = ''; } } //================Функции модуля================== function buildPrelimObjects(sid){ var params = 'action=buildPrelimObjects&sid='+sid; ajaxopen('',params); } function setNewType(tpid){ document.getElementById('ajaxtpid').value = tpid; var params = 'action=getItemInfo&id='+tpid; ajaxopen('',params); return true; } function buildFrontendData(cont, sid, tid){ var params = 'action=getItemByClassname&container='+cont+'&tid='+tid+'&sid='+sid; //alert(params); ajaxopen('',params); return true; } function saveMCType(newt){ var tnm = document.getElementById('typeName').value; var stru = document.getElementById('typeStructure').value; var comment = document.getElementById('typeComment').value; var sid = document.getElementById('ajaxsid').value; if(tnm == '' || tnm == ' '){ alert('Не введено имя!'); return false; } var params = 'action=insertNewItem&sid='+sid+'&name='+tnm+'&structure='+stru+'&comment='+comment; if(newt == 'update' && document.getElementById('ajaxtpid').value != ''){ params += '&typeid='+document.getElementById('ajaxtpid').value; } // alert(params); ajaxopen('',params); return true; }