This commit is contained in:
2020-07-08 23:19:53 +06:00
parent dfd5a1ba05
commit 0781e51bc2
10 changed files with 276 additions and 108 deletions

View File

@ -1,22 +1,15 @@
function TUser()
{
//Функция запрашивает информацию о текущем пользователе с сервера
this.LoadData = function()
{
var r = new TRequest(this);
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[0]]></cmd></metadata>';
if(r.callServer(ScriptName,xs))
{
this.showShadow(true);
}
};
this.applyReq=function(req,fn,node)
{
//alert(getXMLNodeSerialisation(node));
this.showShadow(false);
if (fn==-1)
{
alert(findFirstNode(node,'#cdata-section').nodeValue);
}else
if(fn==7)
{
var nCmd=findFirstNode(node, "cmd");
@ -43,16 +36,29 @@ function TUser()
//configGUIbyAccessLevel();
//var shadow=document.getElementById("shadow");
//if(shadow.parentNode!=null) shadow.parentNode.removeChild(shadow);
//Информируем слушатеелй о логине
for(i=0;i<this.m_ls.length;i++){
if(this.m_ls[i]!==null){
this.m_ls[i].OnLogin(true); //0 - authorized, 1 - an incorrect username or password, 2 - left.
}
}
}
}else if(findFirstNode(nCmd,'#cdata-section').nodeValue=="3") //Login
{
//if(findNode(node,'#cdata-section').nodeValue=="0") //if not logged
//{
// alert(_('Invalid_username_and_or_password'));
//}else
//{
// location.reload();
//}
{
if(findNode(node,'#cdata-section').nodeValue=="0") //if not logged
{
alert(_('Invalid_username_and_or_password'));
}else
{
//location.reload();
//Информируем слушатеелй о логине
for(i=0;i<this.m_ls.length;i++){
if(this.m_ls[i]!==null){
this.m_ls[i].OnLogin(true); //0 - authorized, 1 - an incorrect username or password, 2 - left.
}
}
}
}else if(findFirstNode(nCmd,'#cdata-section').nodeValue=="4") //Register
{
//if(findNode(node,'#cdata-section').nodeValue=="1") //if register
@ -164,6 +170,17 @@ function TUser()
deleteHTML(this.divsh);
}
};
//Функция запрашивает информацию о текущем пользователе с сервера
this.LoadData = function()
{
var r = new TRequest(this);
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[2]]></cmd></metadata>';
if(r.callServer(ScriptName,xs))
{
this.showShadow(true);
}
};
//Check whether the already authorized (+ attempt to log in through "hash").
this.isLogined=function()
{
@ -179,6 +196,18 @@ function TUser()
}
};
this.addListener=function(l)
{ if(l.OnLogin==null) alert('Object does not have the function "OnLogin()"!');
this.m_ls[this.m_ls.length]=l;
};
this.remListener=function(l)
{ for(i=0;i<this.m_ls.length;i++)
{ if(this.m_ls[i]==l)
this.m_ls[i]=null;
}
};
this.divsh=null;
this.id=null;
this.name='';
@ -186,6 +215,7 @@ function TUser()
this.patronymic='';
this.temp=false;
this.role='';
this.m_ls=new Array(); //Listeners called OnLogin function.
//Запрашиваю данные о текущем пользователе с сервера
//this.LoadData();
@ -196,7 +226,7 @@ function TUser()
* Login form (not cross-source).
* [^\x00-\x7F]+
*/
function TLogin()
/*function TLogin()
{
this.showLoginForm = function()
{
@ -311,11 +341,11 @@ function TLogin()
this.m_ls[i].OnLogin(true); //0 - authorized, 1 - an incorrect username or password, 2 - left.
}
}
/*
this.m_lo=getCdataValue(findFirstNode(node,"login")) == '0' ? true : false;
if(this.m_lo && this.win.div!==null) this.win.hide(true);
this.m_UserName=getCdataValue(findFirstNode(node,"name"));
*/
//this.m_lo=getCdataValue(findFirstNode(node,"login")) == '0' ? true : false;
//if(this.m_lo && this.win.div!==null) this.win.hide(true);
//this.m_UserName=getCdataValue(findFirstNode(node,"name"));
}else
alert("Not known function! fn=\""+fn+"\"" );
@ -347,16 +377,6 @@ function TLogin()
}
};
//Check whether the already authorized (+ attempt to log in through "hash").
this.Logined=function()
{
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[0]]></cmd></metadata>';
//alert('xs='+xs);
this.request.callServer(ScriptName,xs);
};
//logout current user
this.Exit=function()
{
@ -378,6 +398,16 @@ function TLogin()
this.m_ls[i]=null;
}
};
//Check whether the already authorized (+ attempt to log in through "hash").
this.LoadData=function()
{
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[2]]></cmd></metadata>';
//alert('xs='+xs);
this.request.callServer(ScriptName,xs);
};
TLogin.LoginIsOk=0; //login in
TLogin.LoginIsError=1; //Invalid password and / or login.
@ -396,7 +426,7 @@ function TLogin()
this.m_html=false;
this.request = new TRequest(this);
}
}*/
//Display password recovery form
function showRestoreForm()