4 function LoginDialog(logged_in_callback) {
5 this.callback = logged_in_callback;
6 this.rand = PopupBoxId++;
11 /* node is the element the dialog should popup under */
12 LoginDialog.prototype.display = function(node) {
14 if(UserSession.instance().verifySession()) {
15 if(this.callback) this.callback(UserSession.instance());
19 this.box = new PopupBox(node);
23 var ut = elem("input", {id:"login_uname_" + this.rand,type:"text",size:"16"});
24 var pw = elem("input",{id:"login_passwd_" + this.rand,type:"password",size:"16"});
28 var but = elem("input",
29 {style:"margin-right: 10px", type:"submit",value:"Login"});
30 var cancel = elem("input",
31 {style:"margin-left: 10px;",type:"submit",value:"Cancel"});
35 var submitFunc = function() {
36 var uname = getById("login_uname_" + obj.rand).value;
37 var passwd = getById("login_passwd_" + obj.rand).value;
39 if(uname == null || uname == "") {
40 alert("Please enter username");
44 if(passwd == null || passwd == "") {
45 alert("Please enter password");
49 var ses = UserSession.instance();
50 if( ses.login(uname, passwd)) {
51 /* now grab the org_unit associated with this user */
53 ses.fleshMe(true); /* flesh the user */
55 if(obj.callback) obj.callback(ses);
57 alert("Password is incorrect");
58 try{pw.focus();}catch(e){}
62 but.onclick = submitFunc;
63 ut.onkeyup = function(evt) { if(userPressedEnter(evt)) submitFunc(); }
64 pw.onkeyup = function(evt) { if(userPressedEnter(evt)) submitFunc(); }
65 cancel.onclick = function() { obj.hideMe(); }
67 box.addText("Username ");
70 box.addText("Passwod ");
73 box.makeGroup([but, cancel]);
76 try{ut.focus();}catch(E){}
80 function runLoginOnEnter(evt) {
81 var code = grabCharCode(evt);
82 if(code==13||code==3) { }
86 LoginDialog.prototype.hideMe = function() {