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;
93 var _closeLoginPrompt =
function(isLoginSuccess)
97 var ldiv = document.getElementById(
"Desktop-loginDiv");
101 Debug.log(
"found login div and deleted",Debug.LOW_PRIORITY);
102 ldiv.parentNode.removeChild(ldiv);
109 ldiv = document.getElementById(
"DesktopDashboard-user-displayName");
110 var tmpStr =
"Welcome to " + _otsOwner +
"ots, " + _displayName;
112 if(ldiv.innerHTML !=
"" &&
113 ldiv.innerHTML != tmpStr)
116 Debug.log(
"Desktop.desktop.closeAllWindows() for new user",Debug.LOW_PRIORITY);
117 Desktop.desktop.closeAllWindows();
119 ldiv.innerHTML = tmpStr;
122 Desktop.desktop.resetDesktop(_permissions);
131 var _loginPrompt =
function()
133 Debug.log(
"loginPrompt " + _keepFeedbackText,Debug.LOW_PRIORITY);
135 if(_attemptedCookieCheck)
139 if(document.getElementById(
"Desktop-loginDiv"))
141 Debug.log(
"Login screen already up.");
142 if(_keepFeedbackText)
144 document.getElementById(
"loginFeedbackDiv").innerHTML = _keptFeedbackText;
145 _keepFeedbackText =
false;
155 ldiv = document.createElement(
"div");
156 ldiv.setAttribute(
"id",
"Desktop-loginDiv");
157 ldiv.style.width = Desktop.desktop.getDesktopWidth() +
"px";
158 ldiv.style.height = Desktop.desktop.getDesktopHeight() +
"px";
162 str =
"<table width='100%' height='100%'><td valign='middle' align='center'>";
163 str +=
"<b><u>Welcome to " + _otsOwner +
"ots!</u></b><br /><br />";
164 str +=
"<table><td align='right'><div id='Desktop-loginContent'></div></td></table></td></table>";
165 ldiv.innerHTML = str;
168 Desktop.desktop.login.loginDiv = _loginDiv = document.getElementById(
"DesktopLoginDiv");
175 _loginDiv.appendChild(ldiv);
178 ldiv = document.getElementById(
"Desktop-loginContent");
181 Debug.log(
"ldiv has no parent!");
186 var rememberMeName = _getCookie(_cookieRememberMeStr);
187 str +=
"Username: <input id='loginInput0' type='email' spellcheck='false' value='" +
188 (rememberMeName?rememberMeName:
"") +
"'/>";
190 str +=
"<div id='loginInputRememberMeDiv'>" +
191 "<div style='float:left; margin: -5px 0 0 89px;'><input type='checkbox' id='loginInputRememberMe' " +
192 (rememberMeName?
"checked":
"") +
" /></div>" +
193 "<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>";
194 str +=
"Password: <input id='loginInput1' type='password' /><br />";
195 str +=
"<div id='loginRetypeDiv' style='display:none' >Re-type Password: <input id='loginInput2' type='password' /><br /></div>";
196 str +=
"<div id='newAccountCodeDiv' style='display:none' >New Account Code: <input id='loginInput3' type='text' /><br /></div>";
197 str +=
"<a target='_blank' href='" +
198 "https://docs.google.com/document/d/1Mw4HByYfLo1bO5Hy9npDWkD4CFxa9xNsYZ5pJ7qwaTM/edit?usp=sharing" +
199 "' title='Click to open Help documentation' ><img src='/WebPath/images/dashboardImages/icon-Help.png' onerror='this.style.display=\"none\";'></a>";
200 str +=
"<a href='#' onmouseup='Desktop.desktop.login.promptNewUser(this); return false;' style='margin:0 100px 0 50px'>New User?</a>";
201 str +=
"<input type='submit' class='DesktopDashboard-button' value=' Login ' onmouseup='Desktop.desktop.login.attemptLogin();' /><br />"
203 str +=
"<div id='loginFeedbackDiv'>" + (_keepFeedbackText?_keptFeedbackText:
"") +
"</div>";
204 _keepFeedbackText =
false;
207 str +=
"<a href='http://www.google.com/chrome'>Note: ots works best in the Chrome web browser.</a>";
208 ldiv.innerHTML = str;
214 document.getElementById(
'loginInput1').focus();
216 document.getElementById(
'loginInput0').focus();
220 document.getElementById(
'loginInput'+i).onkeydown =
223 if(e.keyCode == 13) Desktop.desktop.login.attemptLogin();
224 else if(e.keyCode == 9)
226 var newFocusIndex = parseInt(this.
id[this.
id.length-1])+(e.shiftKey?-1:1);
227 if(newFocusIndex != 0 && newFocusIndex != 1 &&
228 document.getElementById(
'loginRetypeDiv').style.display ==
"none")
229 newFocusIndex += e.shiftKey?2:-2;
230 newFocusIndex = (newFocusIndex + 4)%4;
231 document.getElementById(
'loginInput'+newFocusIndex).focus();
233 else if((e.keyCode >= 48 && e.keyCode <= 57) ||
234 (e.keyCode >= 96 && e.keyCode <= 105) ||
235 (e.keyCode >= 65 && e.keyCode <= 90) ||
236 e.keyCode == 46 || e.keyCode == 8 ||
237 e.keyCode == 35 || e.keyCode == 36 ||
238 (e.keyCode >= 37 && e.keyCode <= 40)) {
244 document.getElementById(
'loginInput'+i).onkeyup = _checkLoginInputs;
252 var _checkLoginInputs =
function()
256 for(var i=0;i<3;++i) x[i] = document.getElementById(
'loginInput'+i).value;
258 document.getElementById(
'loginFeedbackDiv').style.color =
"";
259 if(document.getElementById(
'loginRetypeDiv').style.display !=
"none")
262 _areLoginInputsValid =
false;
266 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords do not match";
269 else if(x[1].length < _DEFAULT_PASSWORD_MIN_LEN)
271 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords must be at least " + _DEFAULT_PASSWORD_MIN_LEN +
" characters";
274 else if(x[1].length > _DEFAULT_PASSWORD_MAX_LEN)
276 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords must be at most " + _DEFAULT_PASSWORD_MAX_LEN +
" characters";
279 else if(x[0].length < _DEFAULT_USER_MIN_LEN)
281 document.getElementById(
'loginFeedbackDiv').innerHTML =
"User name must be at least " + _DEFAULT_USER_MIN_LEN +
" characters";
284 else if(x[0].length > _DEFAULT_USER_MAX_LEN)
286 document.getElementById(
'loginFeedbackDiv').innerHTML =
"User name must be at most " + _DEFAULT_USER_MAX_LEN +
" characters";
291 _areLoginInputsValid =
true;
292 document.getElementById(
'loginFeedbackDiv').innerHTML =
"Passwords are valid!";
293 document.getElementById(
'loginFeedbackDiv').style.color =
"RGB(100,255,150)";
302 var _setCookie =
function(code)
305 if(code == _BLACKOUT_COOKIE_STR)
307 Debug.log(
"maintaining cookie code = " + _cookieCode);
309 var exdate =
new Date();
310 exdate.setDate(exdate.getDate() + _DEFAULT_COOKIE_DURATION_DAYS);
312 c_value = escape(code) + ((_DEFAULT_COOKIE_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
313 document.cookie= _cookieCodeStr +
"=" + c_value;
318 if(_user ==
"" || !code.length || code.length < 2)
return;
319 if(!_system_blackout && _cookieCode == code)
return;
322 var exdate =
new Date();
323 exdate.setDate(exdate.getDate() + _DEFAULT_COOKIE_DURATION_DAYS);
325 c_value = escape(code) + ((_DEFAULT_COOKIE_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
326 document.cookie= _cookieCodeStr +
"=" + c_value;
327 c_value = escape(_user) + ((_DEFAULT_COOKIE_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
328 document.cookie= _cookieUserStr +
"=" + c_value;
335 _cookieTime = (
new Date()).getTime();
341 var _getCookie =
function(c_name)
343 var i,x,y,ARRcookies=document.cookie.split(
";");
344 for (i=0;i<ARRcookies.length;i++)
346 x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(
"="));
347 y=ARRcookies[i].substr(ARRcookies[i].indexOf(
"=")+1);
348 x=x.replace(/^\s+|\s+$/g,
"");
359 var _deleteCookies =
function()
362 Debug.log(
"Delete cookies",Debug.LOW_PRIORITY);
364 c_value =
"; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
365 document.cookie= _cookieCodeStr +
"=" + c_value;
366 c_value =
"; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
367 document.cookie= _cookieUserStr +
"=" + c_value;
373 var _getUniqueUserId =
function()
375 return '4xxx'.replace(/[x]/g,
function(c)
377 var r = Math.random()*16|0, v = r;
378 return v.toString(16);
387 var _checkCookieLogin =
function()
389 if(_sessionId.length != _DEFAULT_SESSION_STRING_LEN)
return;
391 var code = _getCookie(_cookieCodeStr);
392 _user = _getCookie(_cookieUserStr);
394 if ((code != null && code !=
"") &&
395 (_user != null && _user !=
""))
397 Debug.log(
"Attempting browser cookie login.");
400 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=checkCookie",
401 "uuid="+_uid+
"&ju="+_jumble(_user,_sessionId)+
"&cc="+code,
406 Debug.log(
"No cookie found (" + code +
")",Debug.LOW_PRIORITY);
409 if(!_attemptedLoginWithCert)
411 Debug.log(
"Attempting CERT login.");
412 _attemptLoginWithCert();
424 var _handleLoginAttempt =
function(req)
426 Debug.log(
"Received login attempt back",Debug.LOW_PRIORITY);
428 var cookieCode = Desktop.getXMLValue(req,
"CookieCode");
429 _displayName = Desktop.getXMLValue(req,
"DisplayName");
431 _otsOwner = Desktop.getXMLValue(req,
"ots_owner");
432 if(!_otsOwner || _otsOwner.length < 2)
434 else if(_otsOwner[_otsOwner.length-1] !=
' ')
436 Debug.log(
"_otsOwner = " + _otsOwner);
438 if(Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE)
439 _user = Desktop.getXMLValue(req,
"pref_username");
440 _permissions = Desktop.getXMLValue(req,
"desktop_user_permissions");
441 if(cookieCode && _displayName && cookieCode.length == _DEFAULT_COOKIE_STRING_LEN)
444 Debug.log(
"Login Successful!",Debug.LOW_PRIORITY);
445 _setCookie(cookieCode);
446 _applyUserPreferences(req);
449 if (Desktop.getXMLValue(req,
"pref_username"))
450 _user = Desktop.getXMLValue(req,
"pref_username");
452 var activeSessionCount = parseInt(Desktop.getXMLValue(req,
"user_active_session_count"));
453 if(activeSessionCount && _loginDiv)
455 Debug.log(
"Found other active sessions: " + activeSessionCount,Debug.LOW_PRIORITY);
456 _offerActiveSessionOptions(activeSessionCount);
459 _closeLoginPrompt(1);
465 Desktop.desktopTooltip();
466 _attemptedCookieCheck =
false;
467 _killLogoutInfiniteLoop =
false;
474 Debug.log(
"Login failed.");
480 if(cookieCode ==
"1")
487 Debug.log(
"Attempting auto session renewal");
490 _uid = _getUniqueUserId();
491 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
498 if(!req || req.responseText.length != _DEFAULT_SESSION_STRING_LEN)
500 Debug.log(
"Invalid auto session ID",Debug.HIGH_PRIORITY);
501 _keptFeedbackText =
"Sorry, your login session was invalid.<br>" +
502 "A new session is being started - please try again.";
504 _killLogoutInfiniteLoop =
true;
509 Debug.log(
"Attempting auto re-login");
511 _attemptedLoginWithCert =
true;
512 _badSessionIdCount = 0;
515 _sessionId = req.responseText;
517 Desktop.desktop.login.attemptLogin();
523 else if(req && document.getElementById(
'loginInput3') &&
524 document.getElementById(
'loginInput3').value !=
"")
525 _keptFeedbackText =
"New Account Code (or Username/Password) not valid.";
528 var err = Desktop.getXMLValue(req,
"Error");
529 _keptFeedbackText =
"Username/Password not correct." + (err?(
"<br>" + err):
"");
532 _keptFeedbackText =
"ots Server failed.";
534 _keepFeedbackText =
true;
536 if(_attemptedLoginWithCert)
538 Debug.log(
"Hiding feedback after CERT attempt.");
539 _keepFeedbackText =
false;
543 if(document.getElementById(
'loginInput'+i))
544 document.getElementById(
'loginInput'+i).value =
"";
547 _uid = _getUniqueUserId();
548 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
550 _handleGetSessionId);
561 var _attemptedCookieCheck =
false;
562 var _handleCookieCheck =
function(req)
565 var cookieCode = Desktop.getXMLValue(req,
"CookieCode");
566 _displayName = Desktop.getXMLValue(req,
"DisplayName");
567 _permissions = Desktop.getXMLValue(req,
"desktop_user_permissions");
570 if(cookieCode && _displayName && cookieCode.length == _DEFAULT_COOKIE_STRING_LEN)
574 Debug.log(
"Cookie is good!",Debug.LOW_PRIORITY);
575 _setCookie(cookieCode);
576 _applyUserPreferences(req);
577 _closeLoginPrompt(1);
581 DesktopContent._cookieCodeMailbox = cookieCode;
582 DesktopContent._serverUrnLid = urnLid_;
583 DesktopContent._serverOrigin = serverOrigin_;
584 Desktop.desktopTooltip();
586 _attemptedCookieCheck =
false;
587 _killLogoutInfiniteLoop =
false;
592 Debug.log(
"Cookie is bad " + cookieCode.length + _displayName,Debug.LOW_PRIORITY);
595 Debug.log(
"Attempting CERT login.");
596 _attemptLoginWithCert();
606 var _handleGetSessionId =
function(req)
610 if(!req || req.responseText.length != _DEFAULT_SESSION_STRING_LEN)
612 Debug.log(
"Invalid session ID",Debug.HIGH_PRIORITY);
617 _killLogoutInfiniteLoop =
true;
621 _uid = _getUniqueUserId();
623 Debug.log(
"UUID: " + _uid);
624 ++_badSessionIdCount;
625 if (_badSessionIdCount < 10)
626 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
628 _handleGetSessionId);
630 Desktop.log(
"Cannot establish session ID - failed 10 times",Desktop.HIGH_PRIORITY);
634 _badSessionIdCount = 0;
637 _sessionId = req.responseText;
640 if(!_attemptedCookieCheck &&
641 _getCookie(_cookieCodeStr) == _BLACKOUT_COOKIE_STR)
644 Debug.log(
"There is a system wide blackout! (Attempts to login right now may fail - likely someone is rebooting the system)", Debug.WARN_PRIORITY);
648 if(_attemptedCookieCheck)
650 Debug.log(
"Already tried browser cookie login. Giving up.");
654 _attemptedCookieCheck =
true;
656 Debug.log(
"Attempting browser cookie login with new session ID.");
658 _killLogoutInfiniteLoop =
false;
664 var _offerActiveSessionOptions =
function(cnt) {
666 ldiv = document.getElementById(
"Desktop-loginContent");
669 Debug.log(
"No login prompt, so not offering active session options.");
670 _closeLoginPrompt(1);
675 str +=
"<center>Warning! You currently have " + cnt +
" other active session" + (cnt > 1?
"s":
"") +
".<br />";
676 str +=
"<div id='loginFeedbackDiv'>You can opt to force logout the other session" + (cnt > 1?
"s":
"") +
", " +
677 "or alternatively leave your other session" + (cnt > 1?
"s":
"") +
" active and continue.</div><br />";
678 str +=
"<input type='submit' class='DesktopDashboard-button' value=' Logout Other Sessions ' " +
679 "onmouseup='Desktop.desktop.login.activeSessionLogoutOption();' />";
680 str +=
" ";
681 str +=
"<input type='submit' class='DesktopDashboard-button' value=' Ignore and Continue ' " +
682 "onmouseup='Desktop.desktop.login.activeSessionIgnoreOption();' /></center>";
683 ldiv.innerHTML = str;
687 var _jumble =
function (u,s) {
688 if(s.length%2)
return "";
693 var c = parseInt(s[p*2]+s[p*2+1],16);
694 for(var i=0;i<l;++i) x[i] = 0;
696 var s0 = s[p*2],s1 = s[p*2+1];
698 p = (p + parseInt(s0+s1,16)) % ss;
699 while(x[p]) p = (p+1) % ss;
700 x[p] = 1; s0 = s[p*2]; s1 = s[p*2+1];
701 c = (c + parseInt(s[p*2]+s[p*2+1],16) + parseInt((i==0)?u.length:u.charCodeAt(i-1))) % ss;
702 h = c.toString(16);
if(h.length == 1) h =
"0" + h;
703 s = s.substr(0,p*2) + h + s.substr(p*2+2,s.length-p*2-2);
704 --l;
if(i==u.length) i = 1;
else ++i;
710 var _saveUsernameCookie =
function () {
711 Debug.log(
"Desktop _saveUsernameCookie _user " + _user);
712 var exdate =
new Date();
713 exdate.setDate(exdate.getDate() + _DEFAULT_REMEMBER_ME_DURATION_DAYS);
715 c_value = escape(_user) + ((_DEFAULT_REMEMBER_ME_DURATION_DAYS==null) ?
"" :
"; expires="+exdate.toUTCString());
716 document.cookie= _cookieRememberMeStr +
"=" + c_value;
720 var _deleteUsernameCookie =
function () {
721 Debug.log(
"Desktop _deleteUsernameCookie _user " + _user);
723 c_value =
"; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
724 document.cookie= _cookieRememberMeStr +
"=" + c_value;
734 var _updateLayoutTimeoutHandler =
function() {
735 Debug.log(
"Desktop login _updateLayoutTimeoutHandler");
741 var colorFields = [
"bgcolor",
"dbcolor",
"wincolor"];
742 var colorPrefVals = [_userPref_bgColor,_userPref_dbColor,_userPref_winColor];
744 data += colorFields[j] +
"=" + colorPrefVals[j] +
"&";
748 var layoutArray = _userPref_layout.split(
";");
749 layoutArray[layoutArray.length-1] = Desktop.desktop.getWindowLayoutStr();
752 for(var j=0;j<layoutArray.length;++j)
753 layoutStr += layoutArray[j] + (j==layoutArray.length-1?
"":
";");
754 data +=
"layout=" + layoutStr +
"&";
758 layoutArray = _sysPref_layout.split(
";");
761 for(var j=0;j<layoutArray.length;++j)
762 layoutStr += layoutArray[j] + (j==layoutArray.length-1?
"":
";");
763 data +=
"syslayout=" + layoutStr +
"&";
768 Debug.log(
"Desktop Login Settings Save Preferences -- " + data);
769 Desktop.XMLHttpRequest(
"Request?RequestType=setSettings", data);
779 this.logout =
function()
781 Debug.log(
"Desktop Logout occured " + _killLogoutInfiniteLoop,Debug.MED_PRIORITY);
783 if(_cookieCode && !_killLogoutInfiniteLoop)
784 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=logout");
788 if(!_killLogoutInfiniteLoop)
790 _uid = _getUniqueUserId();
791 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
"uuid="+_uid,_handleGetSessionId);
792 Debug.log(
"UUID: " + _uid)
795 _killLogoutInfiniteLoop =
false;
805 this.blackout =
function(setVal)
807 setVal = setVal?
true:
false;
808 if(setVal == _system_blackout)
813 _setCookie(_BLACKOUT_COOKIE_STR);
817 _setCookie(_cookieCode);
820 _system_blackout = setVal;
821 Debug.log(
"Login blackout " + _system_blackout);
827 this.isBlackout =
function()
829 var cc = _getCookie(_cookieCodeStr);
830 if(!cc)
return false;
832 return (cc == _BLACKOUT_COOKIE_STR);
841 this.getCookieCode =
function(doNotRefresh)
845 if(this.isBlackout())
847 Debug.log(
"Found an external blackout signal.");
851 _setCookie(_cookieCode);
857 this.updateCookieFromContent =
function(newCC, newTime)
859 _cookieTime = newTime;
865 this.getCookieTime =
function() {
return _cookieTime;}
866 this.getUserDisplayName =
function() {
return _displayName;}
867 this.getUsername =
function() {
return _user;}
870 this.redrawLogin =
function()
872 var ldiv = document.getElementById(
"Desktop-loginDiv");
875 ldiv.style.width = Desktop.desktop.getDesktopWidth() +
"px";
876 ldiv.style.height = Desktop.desktop.getDesktopHeight() +
"px";
881 this.promptNewUser =
function(linkObj)
883 document.getElementById(
'loginFeedbackDiv').innerHTML =
"";
884 Debug.log(
"Desktop Login Prompt New User", Debug.LOW_PRIORITY);
885 document.getElementById(
'loginRetypeDiv').style.display =
886 document.getElementById(
'loginRetypeDiv').style.display ==
"none"?
"inline":
"none";
887 document.getElementById(
'newAccountCodeDiv').style.display =
888 document.getElementById(
'newAccountCodeDiv').style.display ==
"none"?
"inline":
"none";
890 for(var i=1;i<4;++i) document.getElementById(
'loginInput'+i).value =
"";
892 linkObj.innerHTML = document.getElementById(
'loginRetypeDiv').style.display ==
"none"?
"New User?":
"Have an Account?";
896 this.attemptLogin =
function()
898 Debug.log(
"Desktop Login Prompt Attempt Login", Debug.LOW_PRIORITY);
899 _attemptedLoginWithCert =
false;
903 x[i] = document.getElementById(
'loginInput'+i).value;
905 if(document.getElementById(
'loginRetypeDiv').style.display !=
"none" && !_areLoginInputsValid)
907 Debug.log(
"Invalid Inputs on new login attempt", Debug.LOW_PRIORITY);
911 document.getElementById(
'loginFeedbackDiv').innerHTML =
"";
912 document.getElementById(
'loginFeedbackDiv').style.color =
"";
914 if(x[0] ==
"" || x[1] ==
"")
916 _keptFeedbackText =
"Some login fields were left empty.";
922 if(document.getElementById(
'loginInputRememberMe').checked)
923 _saveUsernameCookie();
925 _deleteUsernameCookie();
927 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=login",
928 "uuid="+_uid+
"&nac="+document.getElementById(
'loginInput3').value
929 +
"&ju="+_jumble(x[0],_sessionId)+
"&jp="+_jumble(x[1],_sessionId),
930 _handleLoginAttempt);
934 function getParameterByName(name, url)
936 if (!url) url = window.location.href;
937 name = name.replace(/[\[\]]/g,
"\\$&");
938 var regex =
new RegExp(
"[?&]" + name +
"(=([^&#]*)|&|#|$)"),
939 results = regex.exec(url);
940 if (!results)
return null;
941 if (!results[2])
return '';
942 return decodeURIComponent(results[2].replace(/\+/g,
" "));
946 var _attemptedLoginWithCert =
false;
947 var _attemptLoginWithCert =
function () {
948 Debug.log(
"Desktop Login Certificate Attempt Login ", Debug.LOW_PRIORITY);
950 _attemptedLoginWithCert =
true;
951 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=cert",
"uuid=" + _uid, _handleLoginAttempt);
958 _applyUserPreferences = this.applyUserPreferences =
function(req) {
960 if (typeof req !=
'undefined') {
962 _userPref_bgColor = Desktop.getXMLValue(req,
"pref_bgcolor");
963 _userPref_dbColor = Desktop.getXMLValue(req,
"pref_dbcolor");
964 _userPref_winColor = Desktop.getXMLValue(req,
"pref_wincolor");
965 _userPref_layout = Desktop.getXMLValue(req,
"pref_layout");
966 _sysPref_layout = Desktop.getXMLValue(req,
"pref_syslayout");
969 Desktop.desktop.dashboard.setDefaultDashboardColor(_userPref_dbColor);
970 Desktop.desktop.setDefaultWindowColor(_userPref_winColor);
971 document.body.style.backgroundColor = _userPref_bgColor;
981 this.resetCurrentLayoutUpdateTimer =
function() {
985 if(_updateCurrentLayoutTimeout)
986 clearTimeout(_updateCurrentLayoutTimeout);
987 _updateCurrentLayoutTimeout = setTimeout(_updateLayoutTimeoutHandler,_UPDATE_LAYOUT_TIMEOUT_PERIOD);
991 this.getUserDefaultLayout =
function(i) {
return _userPref_layout.split(
";")[i]; }
992 this.getSystemDefaultLayout =
function(i) {
return _sysPref_layout.split(
";")[i]; }
995 this.activeSessionLogoutOption =
function()
997 Debug.log(
"Desktop login activeSessionLogoutOption");
998 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=logout",
"LogoutOthers=1");
999 _closeLoginPrompt(1);
1004 this.activeSessionIgnoreOption =
function()
1006 Debug.log(
"Desktop activeSessionIgnoreOption");
1007 _closeLoginPrompt(1);
1026 this.setupLogin =
function()
1028 _uid = _getUniqueUserId();
1030 Debug.log(
"UUID: " + _uid +
", " + Desktop.desktop.security);
1032 if(Desktop.desktop.security == Desktop.SECURITY_TYPE_DIGEST_ACCESS)
1034 this.loginDiv = _loginDiv = document.createElement(
"div");
1035 _loginDiv.setAttribute(
"id",
"DesktopLoginDiv");
1036 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=sessionId",
1038 _handleGetSessionId);
1040 else if(Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE)
1041 Desktop.XMLHttpRequest(
"LoginRequest?RequestType=login",
1043 _handleLoginAttempt);
1046 Debug.log(
"UUID: " + _uid);
1050 Debug.log(
"Desktop Login created",Debug.LOW_PRIORITY);