This commit is contained in:
2024-01-03 01:24:28 +06:00
3 changed files with 37 additions and 274 deletions

View File

@ -25,6 +25,35 @@ function trt(key)
else return val;
}
function trts(text)
{
let result='';
let pLen=4; //Длина преамбулы trt(
let cut=0;
let from = 0; // Позиция поиска для итерации
while (true)
{
let pos1 = text.indexOf('trt(', from);
if(pos1 >= 0)
{
from = pos1+pLen+1;
let pos2 = -1;
if(text[pos1+pLen] == '"') pos2 = text.indexOf('")', from);
if(text[pos1+pLen] == "'") pos2 = text.indexOf("')", from);
if(pos2 > 0)
{
result+=text.substring(cut, pos1);
let toTranslate=text.substring(pos1+pLen+1, pos2 );
result+=trt(toTranslate);
cut=pos2+2;
from = pos2;
}
}else break;
}
result+=text.substring(cut); //Копируем остатки
return result;
}
function deleteOption(sel,id){
if(typeof sel == 'string') sel=document.getElementById(sel);
let i=0;
@ -1691,7 +1720,7 @@ class TWin
//Подгрузить содержимое окна из указаного места
//json - объект который передастца в виде JSON строки по URL
//func - функция которая выполниться после загрузки данных в форму
load(url,json,func)
load(url,json,func,tr)
{
this.showProgressBar();
var r=createRequestObject();
@ -1699,7 +1728,8 @@ class TWin
{
return function(){
if(r.readyState == 4){
w.innerHTML=r.responseText;
if(tr) w.innerHTML=trts(r.responseText);
else w.innerHTML=r.responseText;
thiz.hideProgressBar();
if(func !== undefined && func!=null) func();
@ -1710,7 +1740,7 @@ class TWin
thiz.setCenter();
}
}
}(r,this.co,this,func)
}(r,this.co,this,func,tr)
r.open( "POST", url, true );
if(json!=null)
r.send(JSON.stringify(json));