I don't understand why I didn't send these changes earlier.

This commit is contained in:
Igor I
2025-07-30 08:40:45 +05:00
parent 65fe6498cd
commit cb2146cb7a
11 changed files with 113 additions and 2908 deletions

View File

@ -265,7 +265,7 @@ function postJsonData(url,data,fun){
{
return function(){
if(req.readyState == 4 || typeof(req.readyState)=='undefined'){
if(req.status == 200) {
//if(req.status == 200) {
if(req.responseXML!=null) {
let node = req.responseXML.documentElement;
node.error_code='0';
@ -281,9 +281,9 @@ function postJsonData(url,data,fun){
else
fun(false, req.responseText);
}
}else{
fun(false,trt('Failed_to_receive_data'));
}
//}else{
// fun(false,trt('Failed_to_receive_data'));
//}
}
};
}(req);
@ -327,8 +327,30 @@ function postXMLData(url,data,fun){
req.open( "POST", url, true );
req.setRequestHeader("Content-type", "application/xml");
req.send(data);
}
function errorDialog(data,okFunc){
if(data!=null && data !== undefined && data.error_message !== undefined && data.error_message!=null){
if(typeof data.error_message === "string"){
alert2(trt('Alert'), trt(data.error_message), '', okFunc);
}else if(Array.isArray(data.error_message)){
let text = '';
for(let i=0;i<data.error_message.length;i++){
let word = data.error_message[i];
if(Array.isArray(data.error_setting)){
let keys = data.error_setting[i];
if (keys != null || keys != undefined) {
keys = keys.split(";")
word = vsprintf(trt(word), keys);
}
}
text += trt(word) + "<br>\n";
}
alert2(trt('Alert'), text, '', okFunc);
}
}else{
alert2(trt('Alert'), trt('Error_while_receiving_data'), data, okFunc);
}
}
//Вывести текст поверх окон с кнопочкой OK
@ -407,7 +429,7 @@ function confirm2(title,smallText,fullText,okFunc,cancelFunc)
<td colspan="3" style="text-align: center; vertical-align: middle; width: 100%;">`+fullText+`</td>
</tr>
<tr style="height: 10px;">
<td style="width: 100%;">`+(fullText === undefined || fullText == '' ? '' : '<label><input type="checkbox" id="show_'+win.uid+'" name="scales"> '+trt('Full_text')+'</label>')+`&nbsp;</td>
<td style="width: 100%;">`+(fullText === undefined || fullText == null || fullText == '' ? '' : '<label><input type="checkbox" id="show_'+win.uid+'" name="scales"> '+trt('Full_text')+'</label>')+`&nbsp;</td>
<td><button class="button-secondary" id="`+win.uid+`_ok" style="width: 80px;margin:1px;">`+trt('Ok')+`</button></td>
<td><button class="button-secondary" id="`+win.uid+`_cancel" style="width: 80px;margin:1px;">`+trt('Cancel')+`</button></td>
</tr>
@ -1312,64 +1334,6 @@ class TRequest
return null;
}
/*processReqChange(xmlHttpRequest,url,xmlString)
{
//if (typeof(xmlHttpRequest.readyState)=='undefined' || xmlHttpRequest.readyState == 4)
//{
if(typeof(xmlHttpRequest.status)=='undefined' || xmlHttpRequest.status == 200)
{
alert(JSON.stringify(xmlHttpRequest));
if(typeof(xmlHttpRequest.responseXML)=='undefined') {
if(xmlHttpRequest.contentType.match(/\/xml/)) {
xmlHttpRequest.responseXML = CreateXMLDOC(xmlHttpRequest.responseText);
if(xmlHttpRequest.responseXML==null) {
alert2(trt('Alert'), trt('Wrong_XML_document') + "!\nXML=(" + xmlHttpRequest.responseText + ')\nURL=(' + url + ')\nxmlString=(' + xmlString + ')');
return;
}
//загрузился xml документ начинаем его разбирать (по id функции в документе)
let node = xmlHttpRequest.responseXML.documentElement;
if((node==null)||(node.getAttribute("fn")==null)) alert(trt('Error')+"\n"+trt('No_data')+"!\n"+xmlHttpRequest.responseText);
else
{
let fn = node.getAttribute("fn");
if(this.winObj!=null)
{
this.winObj.applyReq(this,fn,node,xmldoc,this.winObj);
return null;
}else if(fn==0) alert(findFirstNode(node,'#cdata-section').nodeValue);
}
}else if(xmlHttpRequest.contentType.match(/\/json/)){
xmlHttpRequest.responseXML = JSON.parse(xmlHttpRequest.responseText);
if(xmlHttpRequest.responseXML==null) {
alert2(trt('Alert'), trt('Wrong_JSON_document') + "!\nJSON=(" + xmlHttpRequest.responseText + ')\nURL=(' + url + ')\njsonString=(' + xmlString + ')');
return;
}
//загрузился xml документ начинаем его разбирать (по id функции в документе)
let node=xmlHttpRequest.responseXML;
if((node==null)||(node.fn==null)) alert(trt('Error')+"\n"+trt('No_data')+"!\n"+xmlHttpRequest.responseText);
else
{
if(this.winObj!=null)
{
this.winObj.applyReq(this,node.fn,node,null,this.winObj);
return null;
}else if(fn==0) alert(findFirstNode(node,'#cdata-section').nodeValue);
}
}
}
}else
{
if(confirm(trt('Failed_to_get_data')+"\n URL: "+url+"\n"+xmlHttpRequest.statusText+"\nПовторить запрос?"))
{
this.callServer(url,xmlString);
};
}
//}
return null;
}*/
};
/** Класс асинхронных запросов к серверу (TODO удалить его и не использовать)