alert ok funktion
This commit is contained in:
@ -111,7 +111,7 @@ class DBMSUser
|
||||
<td style="padding: 2px;"><input type="password" maxlength="33" style="width: 100%; padding: 2px; display: inline;" id="tcPassword'+this.uid+'" name="password"><br></td>\n\
|
||||
</tr>\n\
|
||||
<tr>\n\
|
||||
<td style="padding: 2px;" colspan="2"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"><tr><td><label for="save0" style="white-space: nowrap;"><input id="save_'+this.uid+'" type="checkbox" style="display: inline;" checked/> Remember (<a href="#" onclick="showRestoreForm();">Forgot your password?</a>)</label></td></tr></table></td>\n\
|
||||
<td style="padding: 2px;" colspan="2"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"><tr><td><label for="save0" style="white-space: nowrap;"><input id="save_'+this.uid+'" type="checkbox" style="display: inline;" checked/> Remember (<a href="#" onclick="g_user.showRestoreForm();">Forgot your password?</a>)</label></td></tr></table></td>\n\
|
||||
</tr>\n\
|
||||
<tr><td colspan="2" style="text-align: right;"><input class="button-secondary" id="TLogin_E'+this.uid+'" type="button" style="display: inline;" value="'+trt('Log_in')+'"></td></tr>\n\
|
||||
</table>\n\
|
||||
@ -222,223 +222,15 @@ class DBMSUser
|
||||
this.m_ls[i]=null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Login form (not cross-source).
|
||||
* [^\x00-\x7F]+
|
||||
*/
|
||||
/*function TLogin()
|
||||
{
|
||||
this.showLoginForm = function()
|
||||
{
|
||||
this.win.BuildGUI(10,10);
|
||||
this.win.shadow=true;
|
||||
this.win.setCaption(document.createTextNode("Enter"));
|
||||
|
||||
var str='<div style="width: 100%; height: 100%; padding: 3px; text-align: left;">\n\
|
||||
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%;">\n\
|
||||
<tbody>\n\
|
||||
<tr><td>\n\
|
||||
<table border="0" style="width: 100%; height: 100%;">\n\
|
||||
<tr>\n\
|
||||
<td style="padding: 2px; width: 30%; white-space: nowrap"><b>'+trt('Login')+' (E-mail):</b></td>\n\
|
||||
<td style="padding: 2px;"><input type="text" maxlength="50" style="width: 100%; padding: 2px; display: inline;" id="tcLogin'+this.uid+'" name="login"><br></td>\n\
|
||||
</tr>\n\
|
||||
<tr>\n\
|
||||
<td style="padding: 2px;"><b>Password:</b></td>\n\
|
||||
<td style="padding: 2px;"><input type="password" maxlength="33" style="width: 100%; padding: 2px; display: inline;" id="tcPassword'+this.uid+'" name="password"><br></td>\n\
|
||||
</tr>\n\
|
||||
<tr>\n\
|
||||
<td style="padding: 2px;" colspan="2"><table cellspacing="0" cellpadding="0" border="0" style="width: 100%;"><tr><td><label for="save0" style="white-space: nowrap;"><input id="save_'+this.uid+'" type="checkbox" style="display: inline;" checked/> Remember (<a href="#" onclick="showRestoreForm();">Forgot your password?</a>)</label></td></tr></table></td>\n\
|
||||
</tr>\n\
|
||||
<tr><td colspan="2" style="text-align: right;"><input class="button-secondary" id="TLogin_E'+this.uid+'" type="button" style="display: inline;" value="'+trt('Log_in')+'"></td></tr>\n\
|
||||
</table>\n\
|
||||
</td></tr>\n\
|
||||
</tbody>\n\
|
||||
</table>\n\
|
||||
</div>';
|
||||
|
||||
this.win.setContent(str);
|
||||
|
||||
var e=document.getElementById('TLogin_E'+this.uid);
|
||||
e.onclick=function(obj){ return function(){obj.onEnter(); };}(this);
|
||||
e=document.getElementById('tcLogin'+this.uid);
|
||||
e.onkeydown=function(obj){ return function(e){ if(e.which==13) obj.onEnter(); return true; };}(this);
|
||||
e=document.getElementById('tcPassword'+this.uid);
|
||||
e.onkeydown=function(obj){ return function(e){ if(e.which==13) obj.onEnter(); return true; };}(this);
|
||||
|
||||
this.win.setSize("300px","155px");
|
||||
this.win.setCenter();
|
||||
this.win.obj=this;
|
||||
|
||||
this.win.hide(false);
|
||||
};
|
||||
|
||||
|
||||
this.onEnter=function()
|
||||
{
|
||||
var login=document.getElementById('tcLogin'+this.uid).value;
|
||||
var password=document.getElementById('tcPassword'+this.uid).value;
|
||||
if(login=='' || password=='')
|
||||
{ str="Not filled in the required fields: ";
|
||||
if(login=='') str+='"'+trt('Login')+' (E-mail)"';
|
||||
if(login=='' && password=='') str+=', ';
|
||||
if(password=='') str+='"Password"';
|
||||
str+='!';
|
||||
alert(str);
|
||||
}else
|
||||
this.Login(login,password,document.getElementById('save_'+this.uid).checked);
|
||||
};
|
||||
|
||||
this.applyReq=function(req,fn,node)
|
||||
{
|
||||
// alert(getXMLNodeSerialisation(node));
|
||||
|
||||
if (fn==-1)
|
||||
{
|
||||
alert(findFirstNode(node,'#cdata-section').nodeValue);
|
||||
}else if (fn==4)
|
||||
{
|
||||
//nodeToTable(node);
|
||||
}else if (fn==7)
|
||||
{
|
||||
var cmd=getCdataValue(findFirstNode(node,"cmd"));
|
||||
//alert('cmd='+cmd);
|
||||
if(cmd==='0')
|
||||
{
|
||||
this.m_lo=getCdataValue(findFirstNode(node,"login")) == '0' ? false : true;
|
||||
if(!this.m_lo)
|
||||
{ this.showLoginForm();
|
||||
}else
|
||||
{
|
||||
var name=getCdataValue(findFirstNode(node,"name"));
|
||||
var user_name=document.getElementById('user_name');
|
||||
if(user_name!=null) user_name.innerHTML=name;
|
||||
|
||||
//Информируем слушатеелй о логине
|
||||
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(cmd==='1')
|
||||
{
|
||||
location.reload();
|
||||
}else if(cmd==='2')
|
||||
{
|
||||
var login=getCdataValue(findFirstNode(node,"login")) == '0' ? false : true;
|
||||
if(!login)
|
||||
{ alert('Не удалось авторизоваться.\nНеверный логин и/или пароль.');
|
||||
}else
|
||||
{
|
||||
this.m_lo=true;
|
||||
this.win.Close();
|
||||
|
||||
var name=getCdataValue(findFirstNode(node,"name"));
|
||||
var user_name=document.getElementById('user_name');
|
||||
if(user_name!=null) user_name.innerHTML=name;
|
||||
//Информируем слушатеелй о логине
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
||||
//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+"\"" );
|
||||
|
||||
this.win.hideProgressBar();
|
||||
};
|
||||
|
||||
//l - login, p - password, s - allow or disallow auto-login!
|
||||
this.Login=function(login,password,save)
|
||||
{
|
||||
if(save)
|
||||
{ setCookie('GUID', guid(), 60, '/','','');
|
||||
}else
|
||||
{ setCookie('GUID', '', 60, '/','','');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var xs='<?xml version="1.0" encoding="utf-8"?><metadata fn="7">\n\
|
||||
<cmd><![CDATA[2]]></cmd>\n\
|
||||
<login><![CDATA['+login+']]></login>\n\
|
||||
<password><![CDATA['+password+']]></password>\n\
|
||||
</metadata>';
|
||||
|
||||
//alert(xs);
|
||||
|
||||
if(this.request.callServer(ScriptName,xs))
|
||||
{
|
||||
this.win.showProgressBar();
|
||||
}
|
||||
};
|
||||
|
||||
//logout current user
|
||||
this.Exit=function()
|
||||
{
|
||||
if(this.request.callServer(ScriptName,'<?xml version="1.0" encoding="utf-8"?><metadata fn="7"><cmd><![CDATA[1]]></cmd></metadata>'))
|
||||
{
|
||||
setCookie('GUID', '', 60, '/','','');
|
||||
showProgressBar(document.body);
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
//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.
|
||||
TLogin.LoginIsExit=2; //Exit
|
||||
|
||||
this.m_lo=false; //login in?
|
||||
this.name='Login';
|
||||
this.uid=getUID();
|
||||
this.win=new TWin();
|
||||
this.win.shadow=true;
|
||||
|
||||
this.m_ls=new Array(); //Listeners called OnLogin function.
|
||||
this.guid='';
|
||||
this.m_UserName=''; //Member Name
|
||||
|
||||
this.m_html=false;
|
||||
|
||||
this.request = new TRequest(this);
|
||||
}*/
|
||||
|
||||
//Display password recovery form
|
||||
function showRestoreForm()
|
||||
{
|
||||
var win=new TWin(true);
|
||||
win.BuildGUI(10,10);
|
||||
win.setCaption(trt("Password_recovery"));
|
||||
|
||||
str='<div id="TWin_DT_'+win.tWinId+'" style="width: 100%; height: 100%; padding: 4px; text-align: left;">\n\
|
||||
showRestoreForm()
|
||||
{
|
||||
var win=new TWin(true);
|
||||
win.BuildGUI(10,10);
|
||||
win.setCaption(trt("Password_recovery"));
|
||||
|
||||
str='<div id="TWin_DT_'+win.tWinId+'" style="width: 100%; height: 100%; padding: 4px; text-align: left;">\n\
|
||||
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%; padding: 0px;">\n\
|
||||
<tr>\n\
|
||||
<td style="padding: 2px; white-space: nowrap"><b>'+trt('Login')+' (E-mail)</b></td>\n\
|
||||
@ -449,30 +241,30 @@ function showRestoreForm()
|
||||
</table>\n\
|
||||
</td></tr>\n\
|
||||
</div>';
|
||||
document.getElementById('TWin_Co_'+win.tWinId).innerHTML=str;
|
||||
document.getElementById('TWin_Co_'+win.tWinId).innerHTML=str;
|
||||
|
||||
win.setSize("300px","100px");
|
||||
win.setSize("300px","100px");
|
||||
|
||||
//Центрируем окно и отображаем тень
|
||||
if(win.tbl.offsetHeight>win.div.offsetHeight) win.div.style.height=win.tbl.offsetHeight+"px";
|
||||
if(win.tbl.offsetWidth>win.div.offsetWidth) win.div.style.width=win.tbl.offsetWidth+"px";
|
||||
win.setCenter();
|
||||
win.shadow=true;
|
||||
win.hide(false);
|
||||
//Центрируем окно и отображаем тень
|
||||
if(win.tbl.offsetHeight>win.div.offsetHeight) win.div.style.height=win.tbl.offsetHeight+"px";
|
||||
if(win.tbl.offsetWidth>win.div.offsetWidth) win.div.style.width=win.tbl.offsetWidth+"px";
|
||||
win.setCenter();
|
||||
win.shadow=true;
|
||||
win.hide(false);
|
||||
|
||||
//Click on restore button
|
||||
var obj=null;
|
||||
obj=document.getElementById(win.uid+'_restore');
|
||||
if(obj!=null)
|
||||
{
|
||||
obj.onclick=function(win)
|
||||
{ return function()
|
||||
//Click on restore button
|
||||
var obj=null;
|
||||
obj=document.getElementById(win.uid+'_restore');
|
||||
if(obj!=null)
|
||||
{
|
||||
obj.onclick=function(win)
|
||||
{ return function()
|
||||
{
|
||||
win.showProgressBar();
|
||||
//showProgressBar(document.getElementById('TWin_DT_'+win.tWinId),win.uid);
|
||||
|
||||
|
||||
var em=document.getElementById(win.uid+'_email').value;
|
||||
|
||||
|
||||
if(em==''){ document.getElementById(win.uid+'_email').select(); alert(trt('Not_filled_Email_address')); win.hideProgressBar(); return; }
|
||||
if(! isEmail(em)){ document.getElementById(win.uid+'_email').select(); alert(trt('Please_enter_a_valid_email_address')); win.hideProgressBar(); return; }
|
||||
|
||||
@ -514,7 +306,7 @@ function showRestoreForm()
|
||||
}else
|
||||
if(fn==7)
|
||||
{
|
||||
alert(findFirstNode(node,'#cdata-section').nodeValue);
|
||||
alert(findFirstNode(node,'#cdata-section').nodeValue);
|
||||
this.win.Close();
|
||||
}
|
||||
}
|
||||
@ -534,8 +326,11 @@ function showRestoreForm()
|
||||
|
||||
var call=new myXMLHttpRequest(obj);
|
||||
call.callServer(ScriptName,xml);
|
||||
|
||||
|
||||
};
|
||||
}(win);
|
||||
}(win);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user