19 if (typeof Debug ==
'undefined')
20 console.log(
'ERROR: Debug is undefined! Must include Debug.js before Desktop.js');
22 if (typeof Desktop ==
'undefined')
23 console.log(
'ERROR: Desktop is undefined! Must include Desktop.js before DesktopLogin.js');
31 Desktop.login =
function() {
32 if(
false === (
this instanceof Desktop.login)) {
35 return new Desktop.login();
42 var _DEFAULT_SESSION_STRING_LEN = 512;
43 var _DEFAULT_COOKIE_STRING_LEN = 512;
44 var _DEFAULT_COOKIE_DURATION_DAYS = 1;
45 var _DEFAULT_REMEMBER_ME_DURATION_DAYS = 30;
46 var _DEFAULT_PASSWORD_MIN_LEN = 4;
47 var _DEFAULT_PASSWORD_MAX_LEN = 50;
48 var _DEFAULT_USER_MIN_LEN = 4;
49 var _DEFAULT_USER_MAX_LEN = 50;
51 var _cookieCodeStr =
"otsCookieCode";
52 var _cookieUserStr =
"otsCookieUser";
53 var _cookieRememberMeStr =
"otsRememberMeUser";
54 var _BLACKOUT_COOKIE_STR =
"TEMPORARY_SYSTEM_BLACKOUT";
55 var _system_blackout =
false;
57 var _displayName =
"No-Login";
64 var _badSessionIdCount = 0;
66 var _areLoginInputsValid =
false;
67 var _killLogoutInfiniteLoop =
false;
68 var _keepFeedbackText =
false;
69 var _keptFeedbackText =
"";
74 var _userPref_bgColor, _userPref_dbColor, _userPref_winColor, _userPref_layout, _sysPref_layout;
75 var _applyUserPreferences;
76 var _updateCurrentLayoutTimeout = 0;
77 var _UPDATE_LAYOUT_TIMEOUT_PERIOD = 2000;
92 var _closeLoginPrompt =
function(isLoginSuccess) {
95 var ldiv = document.getElementById(
"Desktop-loginDiv");
98 Debug.log(
"found login div and deleted",Debug.LOW_PRIORITY);
99 ldiv.parentNode.removeChild(ldiv);
106 ldiv = document.getElementById(
"DesktopDashboard-user-displayName");
107 var tmpStr =
"Welcome to " + _otsOwner +
"ots, " + _displayName;
109 if(ldiv.innerHTML !=
"" &&
110 ldiv.innerHTML != tmpStr)
113 Debug.log(
"Desktop.desktop.closeAllWindows() for new user",Debug.LOW_PRIORITY);
114 Desktop.desktop.closeAllWindows();
116 ldiv.innerHTML = tmpStr;
119 Desktop.desktop.resetDesktop(_permissions);
127 var _loginPrompt =
function() {
129 Debug.log(
"loginPrompt " + _keepFeedbackText,Debug.LOW_PRIORITY);
131 if(_attemptedCookieCheck)
135 if(document.getElementById(
"Desktop-loginDiv"))
137 Debug.log(
"Login screen already up.");
138 if(_keepFeedbackText)
140 document.getElementById(
"loginFeedbackDiv").innerHTML = _keptFeedbackText;
141 _keepFeedbackText =
false;
151 ldiv = document.createElement(
"div");
152 ldiv.setAttribute(
"id",
"Desktop-loginDiv");
153 ldiv.style.width = Desktop.desktop.getDesktopWidth() +
"px";
154 ldiv.style.height = Desktop.desktop.getDesktopHeight() +
"px";
158 str =
"<table width='100%' height='100%'><td valign='middle' align='center'>";
159 str +=
"<b><u>Welcome to " + _otsOwner +
"ots!</u></b><br /><br />";
160 str +=
"<table><td align='right'><div id='Desktop-loginContent'></div></td></table></td></table>";
161 ldiv.innerHTML = str;
164 Desktop.desktop.login.loginDiv = _loginDiv = document.getElementById(
"DesktopLoginDiv");
171 _loginDiv.appendChild(ldiv);
174 ldiv = document.getElementById(
"Desktop-loginContent");
177 Debug.log(
"ldiv has no parent!");
182 var rememberMeName = _getCookie(_cookieRememberMeStr);
183 str +=
"Username: <input id='loginInput0' type='email' spellcheck='false' value='" +
184 (rememberMeName?rememberMeName:
"") +
"'/>";
186 str +=
"<div id='loginInputRememberMeDiv'>" +
187 "<div style='float:left; margin: -5px 0 0 89px;'><input type='checkbox' id='loginInputRememberMe' " +
188 (rememberMeName?
"checked":
"") +
" /></div>" +
189 "<div style='float: left; margin: -7px -50px 0px 6px;'><a href='#' onclick='var el=document.getElementById(\"loginInputRememberMe\"); el.checked = !el.checked;'>Remember me</a></div></div>";
190 str +=
"Password: <input id='loginInput1' type='password' /><br />";
191 str +=
"<div id='loginRetypeDiv' style='display:none' >Re-type Password: <input id='loginInput2' type='password' /><br /></div>";
192 str +=
"<div id='newAccountCodeDiv' style='display:none' >New Account Code: <input id='loginInput3' type='text' /><br /></div>";
193 str +=
"<a target='_blank' href='" +
194 "https://docs.google.com/document/d/1Mw4HByYfLo1bO5Hy9npDWkD4CFxa9xNsYZ5pJ7qwaTM/edit?usp=sharing" +
195 "' title='Click to open Help documentation' ><img src='/WebPath/images/dashboardImages/icon-Help.png'></a>";
196 str +=
"<a href='#' onmouseup='Desktop.desktop.login.promptNewUser(this); return false;' style='margin:0 100px 0 50px'>New User?</a>";
197 str +=
"<input type='submit' class='DesktopDashboard-button' value=' Login ' onmouseup='Desktop.desktop.login.attemptLogin();' /><br />"
199 str +=
"<div id='loginFeedbackDiv'>" + (_keepFeedbackText?_keptFeedbackText:
"") +
"</div>";
200 _keepFeedbackText =
false;
203 str +=
"<a href='http://www.google.com/chrome'>Note: ots works best in the Chrome web browser.</a>";
204 ldiv.innerHTML = str;
210 document.getElementById(
'loginInput1').focus();
212 document.getElementById(
'loginInput0').focus();
214 for(var i=0;i<4;++i) {
215 document.getElementById(
'loginInput'+i).onkeydown =
function(e) {
216 if(e.keyCode == 13) Desktop.desktop.login.attemptLogin();
217 else if(e.keyCode == 9) {
218 var newFocusIndex = parseInt(this.
id[this.
id.length-1])+(e.shiftKey?-1:1);
219 if(newFocusIndex != 0 && newFocusIndex != 1 &&
220 document.getElementById(
'loginRetypeDiv').style.display ==
"none")
221 newFocusIndex += e.shiftKey?2:-2;
222 newFocusIndex = (newFocusIndex + 4)%4;
223 document.getElementById(
'loginInput'+newFocusIndex).focus();
225 else if((e.keyCode >= 48 && e.keyCode <= 57) ||
226 (e.keyCode >= 96 && e.keyCode <= 105) ||
227 (e.keyCode >= 65 && e.keyCode <= 90) ||
228 e.keyCode == 46 || e.keyCode == 8 ||
229 e.keyCode == 35 || e.keyCode == 36 ||
230 (e.keyCode >= 37 && e.keyCode <= 40)) {
236 document.getElementById(
'loginInput'+i).onkeyup = _checkLoginInputs;
243 var _checkLoginInputs =
function() {
246 for(var i=0;i<3;++i) x[i] = document.getElementById(
'loginInput'+i).value;
248 document.getElementById(
'loginFeedbackDiv').style.color =
"";
249 if(document.getElementById(
'loginRetypeDiv').style.display !=
"none") {
251 _areLoginInputsValid =
false;
254 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords do not match";
return;
256 if(x[1].length < _DEFAULT_PASSWORD_MIN_LEN) {
257 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords must be at least " + _DEFAULT_PASSWORD_MIN_LEN +
" characters";
return;
259 if(x[1].length > _DEFAULT_PASSWORD_MAX_LEN) {
260 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords must be at most " + _DEFAULT_PASSWORD_MAX_LEN +
" characters";
return;
262 if(x[0].length < _DEFAULT_USER_MIN_LEN) {
263 document.getElementById(
'loginFeedbackDiv').innerHTML =
"User name must be at least " + _DEFAULT_USER_MIN_LEN +
" characters";
return;
265 if(x[0].length > _DEFAULT_USER_MAX_LEN) {
266 document.getElementById(
'loginFeedbackDiv').innerHTML =
"User name must be at most " + _DEFAULT_USER_MAX_LEN +
" characters";
return;
269 _areLoginInputsValid =
true;
270 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords are valid!";
271 document.getElementById(
'loginFeedbackDiv').style.color =
"RGB(100,255,150)";
279 var _setCookie =
function(code) {
281 if(code == _BLACKOUT_COOKIE_STR)
283 Debug.log(
"maintaining cookie code = " + _cookieCode);
285 var exdate =
new Date();
286 exdate.setDate(exdate.getDate() + _DEFAULT_COOKIE_DURATION_DAYS);
288 c_value = escape(code) + ((_DEFAULT_COOKIE_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
289 document.cookie= _cookieCodeStr +
"=" + c_value;
294 if(_user ==
"" || !code.length || code.length < 2)
return;
295 if(!_system_blackout && _cookieCode == code)
return;
298 var exdate =
new Date();
299 exdate.setDate(exdate.getDate() + _DEFAULT_COOKIE_DURATION_DAYS);
301 c_value = escape(code) + ((_DEFAULT_COOKIE_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
302 document.cookie= _cookieCodeStr +
"=" + c_value;
303 c_value = escape(_user) + ((_DEFAULT_COOKIE_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
304 document.cookie= _cookieUserStr +
"=" + c_value;
307 var ccdiv = document.getElementById(
"DesktopContent-cookieCodeMailbox");
308 ccdiv.innerHTML = _cookieCode;
309 ccdiv = document.getElementById(
"DesktopContent-updateTimeMailbox");
310 ccdiv.innerHTML = (
new Date()).getTime();
311 _cookieTime = parseInt(ccdiv.innerHTML);
316 var _getCookie =
function(c_name) {
317 var i,x,y,ARRcookies=document.cookie.split(
";");
318 for (i=0;i<ARRcookies.length;i++)
320 x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(
"="));
321 y=ARRcookies[i].substr(ARRcookies[i].indexOf(
"=")+1);
322 x=x.replace(/^\s+|\s+$/g,
"");
332 var _deleteCookies =
function() {
334 Debug.log(
"Delete cookies",Debug.LOW_PRIORITY);
336 c_value =
"; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
337 document.cookie= _cookieCodeStr +
"=" + c_value;
338 c_value =
"; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
339 document.cookie= _cookieUserStr +
"=" + c_value;
344 var _getUniqueUserId =
function() {
345 return '4xxx'.replace(/[x]/g,
function(c) {
346 var r = Math.random()*16|0, v = r;
347 return v.toString(16);
355 var _checkCookieLogin =
function() {
356 if(_sessionId.length != _DEFAULT_SESSION_STRING_LEN)
return;
358 var code = _getCookie(_cookieCodeStr);
359 _user = _getCookie(_cookieUserStr);
361 if ((code != null && code !=
"") &&
362 (_user != null && _user !=
""))
364 Debug.log(
"Attempting browser cookie login.");
367 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=checkCookie",
368 "uuid="+_uid+
"&ju="+_jumble(_user,_sessionId)+
"&cc="+code,
373 Debug.log(
"No cookie found (" + code +
")",Debug.LOW_PRIORITY);
376 if(!_attemptedLoginWithCert)
378 Debug.log(
"Attempting CERT login.");
379 _attemptLoginWithCert();
390 var _handleLoginAttempt =
function(req) {
391 Debug.log(
"Received login attempt back",Debug.LOW_PRIORITY);
393 var cookieCode = Desktop.getXMLValue(req,
"CookieCode");
394 _displayName = Desktop.getXMLValue(req,
"DisplayName");
396 _otsOwner = Desktop.getXMLValue(req,
"ots_owner");
397 if(!_otsOwner || _otsOwner.length < 2)
399 else if(_otsOwner[_otsOwner.length-1] !=
' ')
401 Debug.log(
"_otsOwner = " + _otsOwner);
403 if(Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE)
404 _user = Desktop.getXMLValue(req,
"pref_username");
405 _permissions = Desktop.getXMLValue(req,
"desktop_user_permissions");
406 if(cookieCode && _displayName && cookieCode.length == _DEFAULT_COOKIE_STRING_LEN)
409 Debug.log(
"Login Successful!",Debug.LOW_PRIORITY);
410 _setCookie(cookieCode);
411 _applyUserPreferences(req);
414 if (Desktop.getXMLValue(req,
"pref_username"))
415 _user = Desktop.getXMLValue(req,
"pref_username");
417 var activeSessionCount = parseInt(Desktop.getXMLValue(req,
"user_active_session_count"));
418 if(activeSessionCount && _loginDiv)
420 Debug.log(
"Found other active sessions: " + activeSessionCount,Debug.LOW_PRIORITY);
421 _offerActiveSessionOptions(activeSessionCount);
424 _closeLoginPrompt(1);
429 Desktop.desktopTooltip();
430 _attemptedCookieCheck =
false;
437 Debug.log(
"Login failed.");
443 if(cookieCode ==
"1")
444 _keptFeedbackText =
"Sorry, your login session was invalid.<br>" +
445 "A new session has been started - please try again.";
446 else if(req && document.getElementById(
'loginInput3') &&
447 document.getElementById(
'loginInput3').value !=
"")
448 _keptFeedbackText =
"New Account Code (or Username/Password) not valid.";
450 _keptFeedbackText =
"Username/Password not correct.";
452 _keptFeedbackText =
"ots Server failed.";
453 _keepFeedbackText =
true;
455 if(_attemptedLoginWithCert)
457 Debug.log(
"Hiding feedback after CERT attempt.");
458 _keepFeedbackText =
false;
461 for(var i=1;i<3;++i)
if(document.getElementById(
'loginInput'+i)) document.getElementById(
'loginInput'+i).value =
"";
464 _uid = _getUniqueUserId();
465 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
"uuid="+_uid,_handleGetSessionId);
473 var _attemptedCookieCheck =
false;
474 var _handleCookieCheck =
function(req) {
476 var cookieCode = Desktop.getXMLValue(req,
"CookieCode");
477 _displayName = Desktop.getXMLValue(req,
"DisplayName");
478 _permissions = Desktop.getXMLValue(req,
"desktop_user_permissions");
481 if(cookieCode && _displayName && cookieCode.length == _DEFAULT_COOKIE_STRING_LEN)
485 Debug.log(
"Cookie is good!",Debug.LOW_PRIORITY);
486 _setCookie(cookieCode);
487 _applyUserPreferences(req);
488 _closeLoginPrompt(1);
491 Desktop.desktopTooltip();
492 _attemptedCookieCheck =
false;
497 Debug.log(
"Cookie is bad " + cookieCode.length + _displayName,Debug.LOW_PRIORITY);
500 Debug.log(
"Attempting CERT login.");
501 _attemptLoginWithCert();
510 var _handleGetSessionId =
function(req) {
512 if(!req || req.responseText.length != _DEFAULT_SESSION_STRING_LEN) {
513 Debug.log(
"Invalid session ID",Debug.HIGH_PRIORITY);
518 _killLogoutInfiniteLoop =
true;
522 _uid = _getUniqueUserId();
524 Debug.log(
"UUID: " + _uid);
525 ++_badSessionIdCount;
526 if (_badSessionIdCount < 10)
527 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
"uuid="+_uid,_handleGetSessionId);
529 Desktop.log(
"Cannot establish session ID - failed 10 times",Desktop.HIGH_PRIORITY);
533 _badSessionIdCount = 0;
536 _sessionId = req.responseText;
541 if(!_attemptedCookieCheck &&
542 _getCookie(_cookieCodeStr) == _BLACKOUT_COOKIE_STR)
545 Debug.log(
"There is a system wide blackout! (Attempts to login right now may fail - likely someone is rebooting the system)", Debug.WARN_PRIORITY);
552 if(_attemptedCookieCheck)
554 Debug.log(
"Already tried browser cookie login. Giving up.");
558 _attemptedCookieCheck =
true;
560 Debug.log(
"Attempting browser cookie login with new session ID.");
562 _killLogoutInfiniteLoop =
false;
567 var _offerActiveSessionOptions =
function(cnt) {
569 ldiv = document.getElementById(
"Desktop-loginContent");
572 Debug.log(
"No login prompt, so not offering active session options.");
573 _closeLoginPrompt(1);
578 str +=
"<center>Warning! You currently have " + cnt +
" other active session" + (cnt > 1?
"s":
"") +
".<br />";
579 str +=
"<div id='loginFeedbackDiv'>You can opt to force logout the other session" + (cnt > 1?
"s":
"") +
", " +
580 "or alternatively leave your other session" + (cnt > 1?
"s":
"") +
" active and continue.</div><br />";
581 str +=
"<input type='submit' class='DesktopDashboard-button' value=' Logout Other Sessions ' " +
582 "onmouseup='Desktop.desktop.login.activeSessionLogoutOption();' />";
583 str +=
" ";
584 str +=
"<input type='submit' class='DesktopDashboard-button' value=' Ignore and Continue ' " +
585 "onmouseup='Desktop.desktop.login.activeSessionIgnoreOption();' /></center>";
586 ldiv.innerHTML = str;
589 var _jumble =
function (u,s) {
590 if(s.length%2)
return "";
595 var c = parseInt(s[p*2]+s[p*2+1],16);
596 for(var i=0;i<l;++i) x[i] = 0;
598 var s0 = s[p*2],s1 = s[p*2+1];
600 p = (p + parseInt(s0+s1,16)) % ss;
601 while(x[p]) p = (p+1) % ss;
602 x[p] = 1; s0 = s[p*2]; s1 = s[p*2+1];
603 c = (c + parseInt(s[p*2]+s[p*2+1],16) + parseInt((i==0)?u.length:u.charCodeAt(i-1))) % ss;
604 h = c.toString(16);
if(h.length == 1) h =
"0" + h;
605 s = s.substr(0,p*2) + h + s.substr(p*2+2,s.length-p*2-2);
606 --l;
if(i==u.length) i = 1;
else ++i;
611 var _saveUsernameCookie =
function () {
612 Debug.log(
"Desktop _saveUsernameCookie _user " + _user);
613 var exdate =
new Date();
614 exdate.setDate(exdate.getDate() + _DEFAULT_REMEMBER_ME_DURATION_DAYS);
616 c_value = escape(_user) + ((_DEFAULT_REMEMBER_ME_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
617 document.cookie= _cookieRememberMeStr +
"=" + c_value;
620 var _deleteUsernameCookie =
function () {
621 Debug.log(
"Desktop _deleteUsernameCookie _user " + _user);
623 c_value =
"; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
624 document.cookie= _cookieRememberMeStr +
"=" + c_value;
633 var _updateLayoutTimeoutHandler =
function() {
634 Debug.log(
"Desktop login _updateLayoutTimeoutHandler");
640 var colorFields = [
"bgcolor",
"dbcolor",
"wincolor"];
641 var colorPrefVals = [_userPref_bgColor,_userPref_dbColor,_userPref_winColor];
643 data += colorFields[j] +
"=" + colorPrefVals[j] +
"&";
647 var layoutArray = _userPref_layout.split(
";");
648 layoutArray[layoutArray.length-1] = Desktop.desktop.getWindowLayoutStr();
651 for(var j=0;j<layoutArray.length;++j)
652 layoutStr += layoutArray[j] + (j==layoutArray.length-1?
"":
";");
653 data +=
"layout=" + layoutStr +
"&";
657 layoutArray = _sysPref_layout.split(
";");
660 for(var j=0;j<layoutArray.length;++j)
661 layoutStr += layoutArray[j] + (j==layoutArray.length-1?
"":
";");
662 data +=
"syslayout=" + layoutStr +
"&";
667 Debug.log(
"Desktop Login Settings Save Preferences -- " + data);
668 Desktop.XMLHttpRequest(
"Request?RequestType=setSettings", data);
677 this.logout =
function() {
678 Debug.log(
"Desktop Logout occured " + _killLogoutInfiniteLoop,Debug.MED_PRIORITY);
680 if(_cookieCode && !_killLogoutInfiniteLoop)
681 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=logout");
685 if(!_killLogoutInfiniteLoop)
687 _uid = _getUniqueUserId();
688 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
"uuid="+_uid,_handleGetSessionId);
689 Debug.log(
"UUID: " + _uid)
692 _killLogoutInfiniteLoop =
false;
701 this.blackout =
function(setVal) {
702 setVal = setVal?
true:
false;
703 if(setVal == _system_blackout)
708 _setCookie(_BLACKOUT_COOKIE_STR);
712 _setCookie(_cookieCode);
715 _system_blackout = setVal;
716 Debug.log(
"Login blackout " + _system_blackout);
721 this.isBlackout =
function() {
722 var cc = _getCookie(_cookieCodeStr);
723 if(!cc)
return false;
725 return (cc == _BLACKOUT_COOKIE_STR);
733 this.getCookieCode =
function(doNotRefresh) {
736 if(this.isBlackout())
738 Debug.log(
"Found an external blackout signal.");
742 _setCookie(_cookieCode);
747 this.updateCookieFromContent =
function(newTime) {
748 _cookieTime = newTime;
749 var ccdiv = document.getElementById(
"DesktopContent-cookieCodeMailbox");
750 _setCookie(ccdiv.innerHTML);
753 this.getCookieTime =
function() {
return _cookieTime;}
754 this.getUserDisplayName =
function() {
return _displayName;}
755 this.getUsername =
function() {
return _user;}
757 this.redrawLogin =
function() {
758 var ldiv = document.getElementById(
"Desktop-loginDiv");
761 ldiv.style.width = Desktop.desktop.getDesktopWidth() +
"px";
762 ldiv.style.height = Desktop.desktop.getDesktopHeight() +
"px";
766 this.promptNewUser =
function(linkObj) {
767 document.getElementById(
'loginFeedbackDiv').innerHTML =
"";
768 Debug.log(
"Desktop Login Prompt New User",Debug.LOW_PRIORITY);
769 document.getElementById(
'loginRetypeDiv').style.display =
770 document.getElementById(
'loginRetypeDiv').style.display ==
"none"?
"inline":
"none";
771 document.getElementById(
'newAccountCodeDiv').style.display =
772 document.getElementById(
'newAccountCodeDiv').style.display ==
"none"?
"inline":
"none";
774 for(var i=1;i<4;++i) document.getElementById(
'loginInput'+i).value =
"";
776 linkObj.innerHTML = document.getElementById(
'loginRetypeDiv').style.display ==
"none"?
"New User?":
"Have an Account?";
779 this.attemptLogin =
function() {
780 Debug.log(
"Desktop Login Prompt Attempt Login ",Debug.LOW_PRIORITY);
781 _attemptedLoginWithCert =
false;
784 for(var i=0;i<3;++i) x[i] = document.getElementById(
'loginInput'+i).value;
786 if(document.getElementById(
'loginRetypeDiv').style.display !=
"none" && !_areLoginInputsValid) {
787 Debug.log(
"Invalid Inputs on new login attempt",Debug.LOW_PRIORITY);
return;
790 document.getElementById(
'loginFeedbackDiv').innerHTML =
"";
791 document.getElementById(
'loginFeedbackDiv').style.color =
"";
793 if(x[0] ==
"" || x[1] ==
"") {
794 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Some fields were left empty.";
return;
799 if(document.getElementById(
'loginInputRememberMe').checked) _saveUsernameCookie();
800 else _deleteUsernameCookie();
802 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=login",
"uuid="+_uid+
"&nac="+document.getElementById(
'loginInput3').value
803 +
"&ju="+_jumble(x[0],_sessionId)+
"&jp="+_jumble(x[1],_sessionId),_handleLoginAttempt);
806 function getParameterByName(name, url) {
807 if (!url) url = window.location.href;
808 name = name.replace(/[\[\]]/g,
"\\$&");
809 var regex =
new RegExp(
"[?&]" + name +
"(=([^&#]*)|&|#|$)"),
810 results = regex.exec(url);
811 if (!results)
return null;
812 if (!results[2])
return '';
813 return decodeURIComponent(results[2].replace(/\+/g,
" "));
816 var _attemptedLoginWithCert =
false;
817 var _attemptLoginWithCert =
function () {
818 Debug.log(
"Desktop Login Certificate Attempt Login ", Debug.LOW_PRIORITY);
820 _attemptedLoginWithCert =
true;
821 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=cert",
"uuid=" + _uid, _handleLoginAttempt);
827 _applyUserPreferences = this.applyUserPreferences =
function(req) {
829 if (typeof req !=
'undefined') {
831 _userPref_bgColor = Desktop.getXMLValue(req,
"pref_bgcolor");
832 _userPref_dbColor = Desktop.getXMLValue(req,
"pref_dbcolor");
833 _userPref_winColor = Desktop.getXMLValue(req,
"pref_wincolor");
834 _userPref_layout = Desktop.getXMLValue(req,
"pref_layout");
835 _sysPref_layout = Desktop.getXMLValue(req,
"pref_syslayout");
838 Desktop.desktop.dashboard.setDefaultDashboardColor(_userPref_dbColor);
839 Desktop.desktop.setDefaultWindowColor(_userPref_winColor);
840 document.body.style.backgroundColor = _userPref_bgColor;
849 this.resetCurrentLayoutUpdateTimer =
function() {
853 if(_updateCurrentLayoutTimeout)
854 clearTimeout(_updateCurrentLayoutTimeout);
855 _updateCurrentLayoutTimeout = setTimeout(_updateLayoutTimeoutHandler,_UPDATE_LAYOUT_TIMEOUT_PERIOD);
858 this.getUserDefaultLayout =
function(i) {
return _userPref_layout.split(
";")[i]; }
859 this.getSystemDefaultLayout =
function(i) {
return _sysPref_layout.split(
";")[i]; }
861 this.activeSessionLogoutOption =
function() {
862 Debug.log(
"Desktop login activeSessionLogoutOption");
863 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=logout",
"LogoutOthers=1");
864 _closeLoginPrompt(1);
867 this.activeSessionIgnoreOption =
function() {
868 Debug.log(
"Desktop activeSessionIgnoreOption");
869 _closeLoginPrompt(1);
887 this.setupLogin =
function()
889 _uid = _getUniqueUserId();
890 if(Desktop.desktop.security == Desktop.SECURITY_TYPE_DIGEST_ACCESS)
892 this.loginDiv = _loginDiv = document.createElement(
"div");
893 _loginDiv.setAttribute(
"id",
"DesktopLoginDiv");
894 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
895 "uuid="+_uid,_handleGetSessionId);
897 else if(Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE)
898 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=login",
"uuid="+_uid,_handleLoginAttempt);
901 Debug.log(
"UUID: " + _uid);
905 Debug.log(
"Desktop Login created",Debug.LOW_PRIORITY);