15 var Desktop = Desktop || {};
17 if (typeof Debug ==
'undefined')
18 console.log(
'ERROR: Debug is undefined! Must include Debug.js before Desktop.js');
19 else if (typeof Globals ==
'undefined')
20 console.log(
'ERROR: Globals is undefined! Must include Globals.js before Desktop.js');
24 Desktop.init =
function(security) {
26 Desktop.desktop = Desktop.createDesktop(security);
28 Debug.log(
"Desktop.desktop Initalized Successfully",Debug.LOW_PRIORITY);
31 Desktop.SECURITY_TYPE_NONE =
"NoSecurity";
32 Desktop.SECURITY_TYPE_DIGEST_ACCESS =
"DigestAccessAuthentication";
39 Desktop.createDesktop =
function(security) {
41 if (typeof Debug ==
'undefined')
return 0;
43 if(
false === (
this instanceof Desktop.createDesktop)) {
46 return new Desktop.createDesktop(security);
131 var _defaultWindowMinZindex = 10;
132 var _defaultWindowMaxZindex = 10000;
133 var _defaultDashboardZindex = 11000;
134 var _defaultWidth = 620;
135 var _defaultHeight = 580;
136 var _defaultLeft = 200;
137 var _defaultTop = 70;
138 var _defaultLeftOffset = 50;
139 var _defaultTopOffset = 25;
140 var _defaultOffsetTimes = 5;
141 var _currentLeft = _defaultLeft;
142 var _currentTop = _defaultTop;
144 var _windows =
new Array();
146 var _dashboard, _icons, _windowZmailbox, _mouseOverXmailbox, _mouseOverYmailbox;
147 var _needToLoginMailbox, _updateTimeMailbox, _updateSettingsMailbox, _settingsLayoutMailbox, _openWindowMailbox, _blockSystemCheckMailbox;
148 var _windowColorPostbox;
149 var _MAILBOX_TIMER_PERIOD = 500;
151 var _SYS_MSG_SOUND_PATH =
"/WebPath/sounds/fx-System-Message.wav";
152 var _sysMsgSound =
new Audio(_SYS_MSG_SOUND_PATH);
159 var _sysMsgCounter = 0;
160 var _SYS_MSG_MAX_COUNT = 10;
162 var _firstCheckOfMailboxes =
true;
170 this.checkMailboxTimer;
171 this.serverConnected =
true;
172 this.security = security;
174 this.defaultWindowFrameColor =
"rgba(196,229,255,.9)";
180 var _handleDesktopResize =
function(event) {
181 _desktopElement.style.height = (window.innerHeight-_desktopElement.offsetTop) +
"px";
182 _desktopElement.style.width = (window.innerWidth-_desktopElement.offsetLeft) +
"px";
183 if(!_dashboard)
return;
184 _dashboard.redrawDashboard();
185 if(_login) _login.redrawLogin();
186 if(_icons) _icons.redrawIcons();
189 if(_windows.length && _windows[_windows.length-1].isMaximized()) {
190 var w = _windows[_windows.length-1];
191 w.setWindowSizeAndPosition(w.getWindowX(),w.getWindowY(),w.getWindowWidth(),w.getWindowHeight());
201 var _getWindowLayoutStr =
function() {
202 var dw = Desktop.desktop.getDesktopContentWidth()/10000.0;
203 var dh = Desktop.desktop.getDesktopContentHeight()/10000.0;
204 var dx = Desktop.desktop.getDesktopContentX();
205 var dy = Desktop.desktop.getDesktopContentY();
208 for(var i=0;i<_windows.length;++i)
210 if(_windows[i].getWindowName() ==
"Settings")
continue;
212 layout += (i?
",":
"") +
213 encodeURIComponent(_windows[i].getWindowName())
214 +
"," + encodeURIComponent(_windows[i].getWindowSubName())
215 +
"," + encodeURIComponent(_windows[i].getWindowUrl())
216 +
"," + (((_windows[i].getWindowX()-dx)/dw)|0)
217 +
"," + (((_windows[i].getWindowY()-dy)/dh)|0)
218 +
"," + ((_windows[i].getWindowWidth()/dw)|0)
219 +
"," + ((_windows[i].getWindowHeight()/dh)|0)
220 +
"," + (_windows[i].isMinimized()?
"0":(_windows[i].isMaximized()?
"2":
"1"));
228 var _scrambleEggs =
function(u) {
return u; }
230 var _getForeWindow =
function() {
return _windows.length?_windows[_windows.length-1]:0; }
232 var _closeWindow =
function(win) {
233 Desktop.desktop.setForeWindow(win);
234 win.windiv.parentNode.removeChild(win.windiv);
238 _windows.splice(_windows.length-1,1);
241 _dashboard.updateWindows();
249 var _checkMailboxes =
function(win)
253 if(_firstCheckOfMailboxes)
255 Debug.log(
"First check of mailboxes!");
257 Debug.log(
"Checking for any shortcut work from get parameters...",Debug.LOW_PRIORITY);
258 _firstCheckOfMailboxes =
false;
259 Desktop.desktop.actOnParameterAction();
264 if(_blockSystemCheckMailbox.innerHTML ==
"1")
266 Desktop.desktop.login.blackout(
true);
270 Desktop.desktop.login.blackout(
false);
280 if(_openWindowMailbox.innerHTML !=
"")
282 Debug.log(
"_openWindowMailbox.textContent=" + _openWindowMailbox.textContent);
285 var paramsStr = _openWindowMailbox.textContent;
288 var spliti, splitiOld = 0;
289 for(var i=0;i<paramCnt;++i)
293 params.push(paramsStr.substr(splitiOld));
297 spliti = paramsStr.indexOf(
'&', splitiOld);
298 params.push(paramsStr.substr(splitiOld,spliti-splitiOld))
299 splitiOld = spliti+1;
303 var requestingWindowId =
"", windowPath =
"";
304 var windowName, windowSubname, windowUnique;
305 for(var i=0;i<params.length;++i)
307 spliti = params[i].indexOf(
'=');
308 varPair = [params[i].substr(0,spliti),params[i].substr(spliti+1)];
309 if(varPair[0] ==
"requestingWindowId")
310 requestingWindowId = varPair[1];
311 else if(varPair[0] ==
"windowPath")
312 windowPath = varPair[1];
313 else if(varPair[0] ==
"windowName")
314 windowName = varPair[1];
315 else if(varPair[0] ==
"windowSubname")
316 windowSubname = varPair[1];
317 else if(varPair[0] ==
"windowUnique")
318 windowUnique = varPair[1];
320 if(requestingWindowId !=
"" && windowPath !=
"")
324 Debug.log(
"_openWindowMailbox.innerHTML=" + _openWindowMailbox.innerHTML);
325 Debug.log(
"requestingWindowId=" + requestingWindowId);
326 Debug.log(
"windowPath=" + windowPath);
327 while(windowPath.length && windowPath[0] ==
'?') windowPath = windowPath.substr(1);
328 Debug.log(
"modified windowPath=" + windowPath);
329 Debug.log(
"windowName=" + windowName);
330 Debug.log(
"windowSubname=" + windowSubname);
331 Debug.log(
"windowUnique=" + windowUnique);
337 if(windowSubname ==
"undefined" &&
338 windowUnique ==
"undefined")
340 Debug.log(
"Opening desktop window... " + windowName);
342 var pathUniquePair = Desktop.desktop.icons.iconNameToPathMap[windowName];
343 console.log(
"Desktop.desktop.icons.iconNameToPathMap",
344 Desktop.desktop.icons.iconNameToPathMap);
346 if(pathUniquePair ===
349 Debug.log(
"An error occurred opening the window named '" +
350 windowName +
"' - it was not found in the Desktop icons. " +
351 "Do you have permissions to access this window? Notify admins if the problem persists.",
352 Debug.HIGH_PRIORITY);
355 var str =
"requestingWindowId=" + requestingWindowId;
357 _openWindowMailbox.innerHTML = str;
362 var pathStr = pathUniquePair[0];
364 if(windowPath !=
"undefined")
366 Debug.log(
"Adding parameter path " + windowPath);
367 if(pathStr.indexOf(
'?') >= 0)
369 else if(pathStr.length)
371 windowPath = pathStr + windowPath;
374 windowPath = pathStr;
376 newWin = Desktop.desktop.addWindow(
380 eval(pathUniquePair[1]));
384 newWin = Desktop.desktop.addWindow(
392 setTimeout(
function(){ Desktop.desktop.setForeWindow(newWin); }, 200);
394 var str =
"requestingWindowId=" + requestingWindowId;
396 _openWindowMailbox.innerHTML = str;
404 if(!Desktop.desktop.login || !Desktop.desktop.login.getCookieCode(
true))
406 if(_needToLoginMailbox.innerHTML ==
"1")
407 _needToLoginMailbox.innerHTML =
"";
413 if(_windowZmailbox.innerHTML > _defaultWindowMaxZindex)
415 Desktop.desktop.setForeWindow(Desktop.desktop.getForeWindow());
420 if(_needToLoginMailbox.innerHTML ==
"1")
422 _needToLoginMailbox.innerHTML =
"";
423 if(!document.getElementById(
"Desktop-loginDiv") &&
424 !Desktop.desktop.login.isBlackout())
427 Debug.log(
"DesktopContent signaled new login needed!",Debug.HIGH_PRIORITY);
431 Debug.log(
"Ignoring desktop content need for login signal due to blackout.");
435 if(parseInt(_updateTimeMailbox.innerHTML) > parseInt(Desktop.desktop.login.getCookieTime()))
436 Desktop.desktop.login.updateCookieFromContent(parseInt(_updateTimeMailbox.innerHTML));
439 if(_updateSettingsMailbox.innerHTML !=
"")
445 if(_updateSettingsMailbox.innerHTML ==
"LAYOUT")
448 var layout = _getWindowLayoutStr();
449 _settingsLayoutMailbox.innerHTML = layout;
450 Debug.log(
"Desktop _updateSettingsMailbox " + layout,Debug.LOW_PRIORITY);
455 var xml = _updateSettingsMailbox.innerHTML;
457 req.responseXML = (
new window.DOMParser() ).parseFromString(xml,
"text/xml");
458 _login.applyUserPreferences(req);
461 _updateSettingsMailbox.innerHTML =
"";
466 if(_sysMsgCounter == _SYS_MSG_MAX_COUNT)
469 if(_blockSystemCheckMailbox.innerHTML ==
"1" ||
470 Desktop.desktop.login.isBlackout())
472 Debug.log(
"System blackout (likely rebooting)...");
476 Desktop.XMLHttpRequest(
"Request?RequestType=getSystemMessages",
"",_handleSystemMessages);
481 var _lastSystemMessage =
"";
484 var _handleSystemMessages =
function(req) {
492 userLock = Desktop.getXMLValue(req,
"username_with_lock");
493 Desktop.desktop.dashboard.displayUserLock(userLock);
495 var tmp = Desktop.getXMLValue(req,
"systemMessages");
502 if((tmpi = tmp.indexOf(_lastSystemMessage)) >= 0)
504 Debug.log(
"Desktop pretmp " + tmp);
505 Debug.log(
"Desktop _lastSystemMessage " + _lastSystemMessage);
506 Debug.log(
"Desktop tmp " + tmp.substr(tmpi+_lastSystemMessage.length+1));
507 tmp = tmp.substr(tmpi+_lastSystemMessage.length+1);
513 var msgArr = tmp.split(
"|");
514 Debug.log(
"Desktop msgArr.length " + msgArr.length);
516 if(msgArr.length < 2)
return;
518 Debug.log(
"Desktop _handleSystemMessages ========================== " + Desktop.formatTime(msgArr[0]) +
520 ,Debug.LOW_PRIORITY);
523 var sysMsgEl = document.createElement(
"div");
524 sysMsgEl.setAttribute(
"class",
"Desktop-systemMessageBox");
525 sysMsgEl.setAttribute(
"id",
"Desktop-systemMessageBox-" + _sysMsgId);
526 sysMsgEl.style.left = (50 + _sysMsgId % 5 * 10) +
"px";
527 sysMsgEl.style.top = (50 + _sysMsgId % 5 * 10) +
"px";
528 _desktopElement.appendChild(sysMsgEl);
532 for(var i=0;i<msgArr.length;i+=2)
534 str +=
"<div style='font-size:12px'>System Message Received at " + Desktop.formatTime(msgArr[i]) +
"</div>";
535 str +=
"<div>" + msgArr[i+1] +
"</div><br>";
536 _lastSystemMessage = msgArr[i] +
"|" + msgArr[i+1];
540 str +=
"<div style='float:right; margin-left:30px'>";
541 str +=
"<a href='Javascript:Desktop.closeSystemMessage(" + _sysMsgId +
");' " +
542 "title='Click here to dismiss system message'>Dismiss</a></div>";
544 sysMsgEl.innerHTML = str;
546 if(sysMsgEl.clientHeight > 300)
547 sysMsgEl.style.height = 300 +
"px";
557 this.getDesktopWidth =
function() {
return _desktopElement.clientWidth;}
558 this.getDesktopHeight =
function() {
return _desktopElement.clientHeight;}
559 this.getDesktopX =
function() {
return _desktopElement.offsetLeft;}
560 this.getDesktopY =
function() {
return _desktopElement.offsetTop;}
561 this.getDesktopContentX =
function() {
return _desktopElement.offsetLeft+_dashboard.getDashboardWidth();}
562 this.getDesktopContentY =
function() {
return _desktopElement.offsetTop+_dashboard.getDashboardHeight();}
563 this.getDesktopContentWidth =
function() {
return _desktopElement.clientWidth-_dashboard.getDashboardWidth();}
564 this.getDesktopContentHeight =
function() {
return _desktopElement.clientHeight-_dashboard.getDashboardHeight();}
565 this.getNumberOfWindows =
function() {
return _windows.length;}
566 this.getWindowNameByIndex =
function(i) {
return _windows[i].getWindowName();}
567 this.getWindowSubNameByIndex =
function(i) {
return _windows[i].getWindowSubName();}
568 this.getWindowByIndex =
function(i) {
return _windows[i];}
569 this.getForeWindow = _getForeWindow;
570 this.redrawDesktop = _handleDesktopResize;
571 this.getLastFrameMouseX =
function() {
return parseInt(_mouseOverXmailbox.innerHTML);}
572 this.getLastFrameMouseY =
function() {
return parseInt(_mouseOverYmailbox.innerHTML);}
573 this.resetFrameMouse =
function() { _mouseOverXmailbox.innerHTML = -1;_mouseOverYmailbox.innerHTML = -1;}
574 this.getWindowLayoutStr = _getWindowLayoutStr;
588 this.addWindow =
function(name,subname,url,unique,extraStep) {
589 Debug.log(name +
" - " + subname +
" - " + url +
" - " + unique,Debug.LOW_PRIORITY);
592 Debug.log(
"Adding window uniquely",Debug.LOW_PRIORITY);
593 for(var i=0;i<_windows.length;++i)
594 if(_windows[i].getWindowName() == name && _windows[i].getWindowSubName() == subname) {
595 Debug.log(
"Window creation failed. Not unique.",Debug.LOW_PRIORITY);
596 if(_windows[i].isMinimized()) {
597 Debug.log(_windows[i].getWindowSubName() +
"was minimized but will now be restored!");
598 _windows[i].unminimize();
601 Desktop.desktop.setForeWindow(_windows[i]);
606 if(_windows.length + _defaultWindowMinZindex >= _defaultWindowMaxZindex) {
607 Debug.log(
"FAILED -- Desktop Window Added - too many windows!",Debug.HIGH_PRIORITY);
611 if(name ==
"Security Settings") {
615 else if(name ==
"Edit User Data") {
620 window_width = _defaultWidth;
621 window_height = _defaultHeight;
626 var newWin = Desktop.createWindow(_winId++,_windows.length + _defaultWindowMinZindex,name,subname,url,
627 window_width,window_height,_dashboard.getDashboardWidth() + _currentLeft,_currentTop);
630 if(_currentLeft > _defaultLeft+_defaultOffsetTimes*_defaultLeftOffset) {
631 _currentLeft = _defaultLeft;
632 if(_currentTop > _defaultTop + (_defaultOffsetTimes+1)*_defaultTopOffset)
633 _currentTop = _defaultTop;
635 _currentTop = _defaultTop + _defaultTopOffset;
639 _currentLeft += _defaultLeftOffset;
640 _currentTop += _defaultTopOffset;
643 _windows.push(newWin);
645 _desktopElement.appendChild(newWin.windiv);
647 Debug.log(
"Desktop Window Added with id " + _windows[_windows.length-1].getWindowId(),Debug.LOW_PRIORITY);
649 _dashboard.updateWindows();
654 setTimeout(
function(){
655 Desktop.desktop.setForeWindow(newWin);
656 Debug.log(
"extraStep=" + extraStep);
660 Desktop.desktop.dashboard.windowDashboardOrganize();
663 Desktop.desktop.toggleFullScreen();
677 this.getWindowById =
function(id) {
678 for(var i=0;i<_windows.length;++i) {
679 if(_windows[i].getWindowId() == id)
return _windows[i];
690 this.setForeWindow =
function(win) {
694 for(var i=0;i<_windows.length-1;++i) {
696 for(var j=i+1;j<_windows.length;++j)
697 if(_windows[j].getWindowZ() < _windows[min].getWindowZ())
702 _windows[i] = _windows[min];
704 _windows[i].setWindowZ(i+_defaultWindowMinZindex);
706 _windows[_windows.length-1].setWindowZ(_windows.length-1+_defaultWindowMinZindex);
707 _windowZmailbox.innerHTML = _defaultWindowMaxZindex;
712 for(var i=0;win && i<=_windows.length;++i) {
715 var winToMov = i<_windows.length?_windows[i]:win;
716 winToMov.setWindowZ(i-1 + _defaultWindowMinZindex);
717 _windows[i-1] = winToMov;
719 else if(_windows[i] == win) found = 1;
723 Debug.log(
"Desktop Foreground window not Found!! Window: " +
724 win.getWindowSubName());
726 _dashboard.updateWindows();
734 this.closeWindowById =
function(id) {
735 var win = this.getWindowById(
id);
736 if(win == -1)
return -1;
742 this.maximizeWindowById =
function(id) {
743 var win = this.getWindowById(
id);
744 if(win == -1)
return -1;
745 this.setForeWindow(win);
746 this.toggleFullScreen();
751 this.toggleFullScreen =
function(e) {
752 if(!_getForeWindow())
return;
754 _getForeWindow().isMaximized() ? _getForeWindow().unmaximize(): _getForeWindow().maximize();
756 Desktop.desktop.redrawDashboardWindowButtons();
760 Debug.log(
"Full Screen Toggled",Debug.LOW_PRIORITY);
763 this.redrawDashboardWindowButtons =
function() {
764 _dashboard.redrawFullScreenButton();
765 _dashboard.redrawRefreshButton();
766 _dashboard.redrawShowDesktopButton();
769 this.refreshWindowById =
function(id) {
770 var win = this.getWindowById(
id);
771 if(win == -1)
return -1;
773 this.setForeWindow(win);
774 this.refreshWindow();
775 console.log(
"Finished refreshWindow() " +
id);
778 this.refreshWindow =
function(e) {
779 if(!_getForeWindow())
return;
782 var window = _getForeWindow();
783 var
id = window.getWindowId();
784 var z = window.getWindowZ();
785 var name = window.getWindowName();
786 var subname = window.getWindowSubName();
787 var url = window.getWindowUrl();
788 var width = window.getWindowWidth();
789 var height = window.getWindowHeight();
790 var x = window.getWindowX();
791 var y = window.getWindowY();
792 var isMax = window.isMaximized();
793 var isMin = window.isMinimized();
795 _closeWindow(window);
796 console.log(window,
id, z, name, width, height);
798 var newWindow = this.addWindow(name,subname,url);
799 newWindow.setWindowSizeAndPosition(x,y,width,height);
800 newWindow.setWindowZ(z);
803 newWindow.maximize();
805 newWindow.minimize();
814 this.minimizeWindowById =
function(id) {
815 var win = this.getWindowById(
id);
816 if(win == -1)
return -1;
818 this.setForeWindow(win);
819 this.toggleMinimize();
824 this.toggleMinimize =
function(e) {
825 if(!_getForeWindow())
return;
827 if(_getForeWindow().isMinimized())
828 _getForeWindow().unminimize();
830 _getForeWindow().minimize();
831 Debug.log(
"Minimize Toggled",Debug.LOW_PRIORITY);
837 this.clickedWindowDashboard =
function(id) {
838 var win = this.getWindowById(
id);
839 if(win == -1)
return -1;
840 if(_getForeWindow() != win) {
841 if(_getForeWindow().isMaximized()) this.toggleFullScreen();
842 this.setForeWindow(win);
843 if(_getForeWindow().isMinimized()) this.toggleMinimize();
847 this.toggleMinimize();
852 this.setDefaultWindowColor =
function(color) {
853 this.defaultWindowFrameColor = color;
854 _windowColorPostbox.innerHTML = this.defaultWindowFrameColor;
856 for(var i=0;i<_windows.length;++i)
857 _windows[i].windiv.style.backgroundColor =
this.defaultWindowFrameColor;
865 this.defaultLayoutSelect =
function(i) {
866 Debug.log(
"Desktop defaultLayoutSelect " + i,Debug.LOW_PRIORITY);
869 var numOfUserLayouts = 5;
870 var numOfSystemLayouts = 5;
871 if(i >= numOfSystemLayouts+1 &&
872 i <= numOfSystemLayouts+1+numOfUserLayouts)
873 layoutStr = _login.getUserDefaultLayout(i-(numOfSystemLayouts+1));
874 else if(i >= 0 && i <= numOfSystemLayouts)
875 layoutStr = _login.getSystemDefaultLayout(i);
878 Debug.log(
"Invalid layout index: " + i, Debug.HIGH_PRIORITY);
881 var layoutArr = layoutStr.split(
",");
884 var numOfWins = parseInt(layoutArr.length/numOfFields);
886 Debug.log(
"Desktop defaultLayoutSelect layout numOfFields=" + numOfFields);
887 Debug.log(
"Desktop defaultLayoutSelect layout " + numOfWins +
888 " windows - " + layoutStr);
891 Desktop.desktop.closeAllWindows();
906 var dw = Desktop.desktop.getDesktopContentWidth()/10000.0;
907 var dh = Desktop.desktop.getDesktopContentHeight()/10000.0;
908 var dx = Desktop.desktop.getDesktopContentX();
909 var dy = Desktop.desktop.getDesktopContentY();
910 for(i=0;i<numOfWins;++i)
912 Debug.log(
"adding " + layoutArr[i*numOfFields].substr(1) +
"-" + layoutArr[i*numOfFields+1],Debug.LOW_PRIORITY);
914 decodeURIComponent(layoutArr[i*numOfFields]),
915 decodeURIComponent(layoutArr[i*numOfFields+1]),
916 decodeURIComponent(layoutArr[i*numOfFields+2]),
918 _windows[_windows.length-1].setWindowSizeAndPosition(
919 layoutArr[i*numOfFields+3]*dw + dx,
920 layoutArr[i*numOfFields+4]*dh + dy,
921 layoutArr[i*numOfFields+5]*dw,
922 layoutArr[i*numOfFields+6]*dh);
924 if((layoutArr[i*numOfFields+7]|0) == 0)
925 _windows[_windows.length-1].minimize();
926 else if((layoutArr[i*numOfFields+7]|0) == 2)
927 _windows[_windows.length-1].maximize();
933 this.closeAllWindows =
function() {
934 Debug.log(
"Desktop closeAllWindows",Debug.LOW_PRIORITY);
936 while(_windows.length) _closeWindow(_windows[_windows.length-1]);
941 this.resetDesktop =
function(permissions) {
943 _needToLoginMailbox.innerHTML =
"";
944 _blockSystemCheckMailbox.innerHTML =
"";
947 if(permissions !== undefined)
948 Desktop.desktop.icons.resetWithPermissions(permissions);
951 if(!Desktop.desktop.login || !Desktop.desktop.login.getCookieCode(
true))
953 Desktop.desktop.login.setupLogin();
955 window.clearInterval(Desktop.desktop.checkMailboxTimer);
956 Desktop.desktop.checkMailboxTimer = setInterval(_checkMailboxes,
957 _MAILBOX_TIMER_PERIOD);
969 this.refreshDesktop =
function() {
972 for(var i=0; i<Desktop.desktop.getNumberOfWindows();++i)
974 Desktop.desktop.refreshWindowById(Desktop.desktop.getWindowByIndex(i));
982 this.actOnParameterAction =
function() {
992 var paramsStr = window.parent.window.location.search.substr(1);
994 var paramCnt = 5 + (Desktop.isWizardMode()?1:0);
995 var spliti, splitiOld = 0;
996 for(var i=0;i<paramCnt;++i)
1000 params.push(paramsStr.substr(splitiOld));
1004 spliti = paramsStr.indexOf(
'&', splitiOld);
1005 params.push(paramsStr.substr(splitiOld,spliti-splitiOld))
1006 splitiOld = spliti+1;
1010 var requestingWindowId =
"", windowPath =
"";
1011 var windowName, windowSubname, windowUnique, newWindowOps;
1012 for(var i=0;i<params.length;++i)
1014 spliti = params[i].indexOf(
'=');
1015 varPair = [params[i].substr(0,spliti),params[i].substr(spliti+1)];
1016 if(varPair[0] ==
"requestingWindowId")
1017 requestingWindowId = varPair[1];
1018 else if(varPair[0] ==
"windowPath")
1019 windowPath = decodeURIComponent(varPair[1]);
1020 else if(varPair[0] ==
"windowName")
1021 windowName = varPair[1];
1022 else if(varPair[0] ==
"windowSubname")
1023 windowSubname = varPair[1];
1024 else if(varPair[0] ==
"windowUnique")
1025 windowUnique = varPair[1];
1028 if(windowPath.indexOf(
"newWindowOps") >= 0)
1031 newWindowOps = windowPath.split(
'&')[1].split(
'=')[1];
1032 windowPath = windowPath.split(
'&')[0];
1054 if(requestingWindowId !=
"" && windowPath !=
"")
1057 Debug.log(
"_openWindowMailbox.innerHTML=" + _openWindowMailbox.innerHTML);
1058 Debug.log(
"requestingWindowId=" + requestingWindowId);
1059 Debug.log(
"windowPath=" + windowPath);
1060 if(newWindowOps) newWindowOps = newWindowOps.replace(/%22/g,
"\"");
1061 Debug.log(
"newWindowOps=" + newWindowOps);
1062 windowName = windowName.replace(/%20/g,
" ");
1063 Debug.log(
"windowName=" + windowName);
1064 windowSubname = windowSubname.replace(/%20/g,
" ");
1065 Debug.log(
"windowSubname=" + windowSubname);
1066 Debug.log(
"windowUnique=" + windowUnique);
1072 if(windowName.indexOf(
"Desktop.openLayout(") == 0)
1074 var layoutIndex = windowName.substr((
"Desktop.openLayout(").length,
1075 windowName.length-1-(
"Desktop.openLayout(").length) | 0;
1076 Debug.log(
"Opening layout... " + layoutIndex);
1078 if(pathUniquePair ===
1082 if(_firstCheckOfMailboxes)
1084 Debug.log(
"Perhaps user layout preferences have not been setup yet, try again at mailbox check.");
1090 _firstCheckOfMailboxes =
false;
1092 Desktop.desktop.dashboard.toggleWindowDashboard(0,
false);
1093 Desktop.desktop.defaultLayoutSelect(layoutIndex);
1099 if(windowSubname ==
"undefined" &&
1100 windowUnique ==
"undefined")
1102 Debug.log(
"Opening desktop window... " + windowName);
1105 var pathUniquePair = Desktop.desktop.icons.iconNameToPathMap[windowName];
1106 console.log(
"Desktop.desktop.icons.iconNameToPathMap",
1107 Desktop.desktop.icons.iconNameToPathMap);
1109 if(pathUniquePair ===
1113 if(_firstCheckOfMailboxes)
1115 Debug.log(
"Perhaps icons have not been setup yet, try again at mailbox check.");
1119 Debug.log(
"An error occurred opening the window named '" +
1120 windowName +
"' - it was not found in the Desktop icons. " +
1121 "Do you have permissions to access this window? Notify admins if the problem persists.",
1122 Debug.HIGH_PRIORITY);
1126 _openWindowMailbox.innerHTML =
"";
1129 var pathStr = pathUniquePair[0];
1131 if(windowPath !=
"undefined")
1133 Debug.log(
"Adding parameter path " + windowPath);
1135 if(pathStr.indexOf(
'&') > 0)
1137 else if(pathStr.indexOf(
'?') > 0 &&
1138 pathStr[pathStr.length-1] !=
'?')
1140 else if(pathStr.length &&
1141 pathStr[pathStr.lengh-1] !=
'?')
1143 windowPath = pathStr + windowPath;
1146 windowPath = pathStr;
1148 newWin = Desktop.desktop.addWindow(
1152 ((windowPath.indexOf(
'?') < 0)?
"?":
"&") +
1153 ((newWindowOps)?
"newWindowOps=" + newWindowOps:
""),
1154 eval(pathUniquePair[1]));
1158 _firstCheckOfMailboxes =
false;
1159 newWin = Desktop.desktop.addWindow(
1163 ((windowPath.indexOf(
'?') < 0)?
"?":
"&") +
1164 ((newWindowOps)?
"newWindowOps=" + newWindowOps:
""),
1165 eval(windowUnique));
1170 Desktop.desktop.dashboard.toggleWindowDashboard(0,
false);
1174 setTimeout(
function(){
1175 Desktop.desktop.setForeWindow(newWin);
1176 Desktop.desktop.toggleFullScreen();
1180 _openWindowMailbox.innerHTML =
"";
1189 _desktopElement = document.createElement(
"div");
1190 _desktopElement.setAttribute(
"id",
"Desktop");
1191 document.body.appendChild(_desktopElement);
1192 document.body.onmousemove = Desktop.handleBodyMouseMove;
1193 window.onmouseup = Desktop.handleWindowMouseUp;
1194 document.body.addEventListener(
'touchmove',Desktop.handleBodyTouchMove);
1195 document.body.addEventListener(
'touchend',Desktop.handleBodyTouchEnd);
1196 window.onresize = _handleDesktopResize;
1197 Desktop.desktop =
this;
1200 _windowZmailbox = document.createElement(
"div");
1201 _windowZmailbox.setAttribute(
"id",
"Desktop-windowZmailbox");
1202 _windowZmailbox.innerHTML = _defaultWindowMaxZindex;
1203 _windowZmailbox.style.display =
"none";
1204 _desktopElement.appendChild(_windowZmailbox);
1207 _mouseOverXmailbox = document.createElement(
"div");
1208 _mouseOverXmailbox.setAttribute(
"id",
"Desktop-mouseOverXmailbox");
1209 _mouseOverXmailbox.style.display =
"none";
1210 _desktopElement.appendChild(_mouseOverXmailbox);
1213 _mouseOverYmailbox = document.createElement(
"div");
1214 _mouseOverYmailbox.setAttribute(
"id",
"Desktop-mouseOverYmailbox");
1215 _mouseOverYmailbox.style.display =
"none";
1216 _desktopElement.appendChild(_mouseOverYmailbox);
1217 this.resetFrameMouse();
1220 var tmpHiddenDiv = document.createElement(
"div");
1221 tmpHiddenDiv.setAttribute(
"id",
"DesktopContent-cookieCodeMailbox");
1222 tmpHiddenDiv.style.display =
"none";
1223 _desktopElement.appendChild(tmpHiddenDiv);
1224 _updateTimeMailbox = document.createElement(
"div");
1225 _updateTimeMailbox.setAttribute(
"id",
"DesktopContent-updateTimeMailbox");
1226 _updateTimeMailbox.style.display =
"none";
1227 _desktopElement.appendChild(_updateTimeMailbox);
1228 _needToLoginMailbox = document.createElement(
"div");
1229 _needToLoginMailbox.setAttribute(
"id",
"DesktopContent-needToLoginMailbox");
1230 _needToLoginMailbox.style.display =
"none";
1231 _desktopElement.appendChild(_needToLoginMailbox);
1233 _blockSystemCheckMailbox = document.createElement(
"div");
1234 _blockSystemCheckMailbox.setAttribute(
"id",
"DesktopContent-blockSystemCheckMailbox");
1235 _blockSystemCheckMailbox.style.display =
"none";
1236 _desktopElement.appendChild(_blockSystemCheckMailbox);
1241 _openWindowMailbox = document.createElement(
"div");
1242 _openWindowMailbox.setAttribute(
"id",
"DesktopContent-openWindowMailbox");
1243 _openWindowMailbox.style.display =
"none";
1244 _desktopElement.appendChild(_openWindowMailbox);
1247 _updateSettingsMailbox = document.createElement(
"div");
1248 _updateSettingsMailbox.setAttribute(
"id",
"DesktopContent-updateSettingsMailbox");
1249 _updateSettingsMailbox.style.display =
"none";
1250 _updateSettingsMailbox.innerHTML =
"";
1251 _desktopElement.appendChild(_updateSettingsMailbox);
1252 _settingsLayoutMailbox = document.createElement(
"div");
1253 _settingsLayoutMailbox.setAttribute(
"id",
"DesktopContent-settingsLayoutMailbox");
1254 _settingsLayoutMailbox.style.display =
"none";
1255 _settingsLayoutMailbox.innerHTML =
"";
1256 _desktopElement.appendChild(_settingsLayoutMailbox);
1259 _windowColorPostbox = document.createElement(
"div");
1260 _windowColorPostbox.setAttribute(
"id",
"DesktopContent-windowColorPostbox");
1261 _windowColorPostbox.style.display =
"none";
1262 _windowColorPostbox.innerHTML = this.defaultWindowsFrameColor;
1263 _desktopElement.appendChild(_windowColorPostbox);
1267 this.dashboard = _dashboard = Desktop.createDashboard(_defaultDashboardZindex);
1268 _desktopElement.appendChild(_dashboard.dashboardElement);
1271 this.icons = _icons = Desktop.createIcons(0);
1272 _desktopElement.appendChild(_icons.iconsElement);
1274 _handleDesktopResize();
1276 this.checkMailboxTimer = setInterval(_checkMailboxes,_MAILBOX_TIMER_PERIOD);
1279 this.login = _login =
new Desktop.login(!(this.security == Desktop.SECURITY_TYPE_NONE));
1281 _desktopElement.appendChild(_login.loginDiv);
1283 Debug.log(
"Desktop Created",Debug.LOW_PRIORITY);
1285 Debug.log(
"Checking for any shortcut work from get parameters...",Debug.LOW_PRIORITY);
1286 Desktop.desktop.actOnParameterAction();
1295 Desktop.foreWinLastMouse = [-1,-1];
1296 Desktop.winManipMode = -1;
1297 Desktop.stretchAndMoveInterval = 0;
1298 Desktop.disableMouseDown = 0;
1305 Desktop.handleTouchStart =
function(touchEvent) {
1306 Desktop.disableMouseDown = 1;
1307 var touch = touchEvent.targetTouches[0];
1309 var winId = this.
id.split(
'-')[1];
1310 var isDashboard = (winId ==
"windowDashboard");
1313 win = Desktop.desktop.getWindowById(winId);
1314 if(win == -1)
return false;
1315 if(win.isMaximized()) {this.style.cursor =
"default";
return false;}
1318 if(Desktop.desktop.getForeWindow() != win)
1319 Desktop.desktop.setForeWindow(win);
1324 if(Desktop.foreWinLastMouse[0] == -1) {
1325 var locX = touch.pageX - this.offsetLeft;
1326 var locY = touch.pageY - this.offsetTop;
1330 Desktop.desktop.getForeWindow().hideFrame();
1332 Desktop.foreWinLastMouse = [touch.pageX,touch.pageY];
1334 if(locY < win.getWindowHeaderHeight()) {
1335 Desktop.winManipMode = 0;
1344 Desktop.handleBodyTouchEnd =
function(touchEvent) {Desktop.handleTouchEnd(touchEvent);}
1345 Desktop.handleTouchEnd =
function(touchEvent) {
1347 if(Desktop.foreWinLastMouse[0] != -1)
1349 Desktop.foreWinLastMouse = [-1,-1];
1350 Desktop.winManipMode = -1;
1351 if(Desktop.desktop.getForeWindow()) Desktop.desktop.getForeWindow().showFrame();
1358 Desktop.handleBodyTouchMove =
function(touchEvent) {Desktop.handleTouchMove(touchEvent);}
1359 Desktop.handleTouchMove =
function(touchEvent) {
1360 if(Desktop.winManipMode != -1 && Desktop.foreWinLastMouse[0] != -1)
1362 touchEvent.preventDefault();
1363 touchEvent.cancelBubble=
true;
1365 var touch = touchEvent.targetTouches[0];
1366 var delta = [touch.pageX-Desktop.foreWinLastMouse[0], touch.pageY-Desktop.foreWinLastMouse[1]];
1368 Desktop.desktop.getForeWindow().moveWindowByOffset(delta[0],delta[1]);
1369 Desktop.foreWinLastMouse = [touch.pageX,touch.pageY];
1376 Desktop.handleWindowMouseDown =
function(mouseEvent) {
1377 var winId = this.
id.split(
'-')[1];
1378 var isDashboard = (winId ==
"windowDashboard");
1381 win = Desktop.desktop.getWindowById(winId);
1382 if(win == -1)
return false;
1385 if(Desktop.desktop.getForeWindow() != win)
1386 Desktop.desktop.setForeWindow(win);
1390 if(!Desktop.disableMouseDown && Desktop.winManipMode != -1 &&
this.style.cursor !=
"default")
1393 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1394 if(!isDashboard) Desktop.desktop.getForeWindow().hideFrame();
1405 Desktop.handleWindowMouseUp =
function(mouseEvent) {
1407 if(Desktop.foreWinLastMouse[0] != -1)
1409 if(Desktop.stretchAndMoveInterval) {
1410 clearInterval(Desktop.stretchAndMoveInterval);
1411 Desktop.stretchAndMoveInterval = 0;
1414 Desktop.foreWinLastMouse = [-1,-1];
1415 Desktop.winManipMode = -1;
1416 if(Desktop.desktop.getForeWindow()) Desktop.desktop.getForeWindow().showFrame();
1420 Desktop.desktop.icons.closeFolder();
1425 Desktop.handleWindowMouseMove =
function(mouseEvent) {
1426 var winId = this.
id.split(
'-')[1];
1427 var isDashboard = (winId ==
"windowDashboard");
1430 win = Desktop.desktop.getWindowById(winId);
1431 if(win == -1)
return false;
1432 if(win.isMaximized()) {this.style.cursor =
"default";
return false;}
1436 if(Desktop.foreWinLastMouse[0] == -1) {
1437 var locX = mouseEvent.clientX - this.offsetLeft;
1438 var locY = mouseEvent.clientY - this.offsetTop;
1440 var hotCornerSz = 7;
1442 if(locX > Desktop.desktop.dashboard.getDashboardWidth() - hotCornerSz) {
1443 this.style.cursor =
"e-resize";
1444 Desktop.winManipMode = 100;
1447 this.style.cursor =
"default";
1450 if((locX < hotCornerSz && locY < hotCornerSz) ||
1451 (locX > win.getWindowWidth() - hotCornerSz && locY > win.getWindowHeight() - hotCornerSz)) {
1452 this.style.cursor =
"nw-resize";
1453 Desktop.winManipMode = locY < hotCornerSz?1:2;
1455 else if((locX > win.getWindowWidth() - hotCornerSz && locY < hotCornerSz) ||
1456 (locX < hotCornerSz && locY > win.getWindowHeight() - hotCornerSz)) {
1457 this.style.cursor =
"ne-resize";
1458 Desktop.winManipMode = locY < hotCornerSz?3:4;
1460 else if(locX < hotCornerSz) {
1461 this.style.cursor =
"w-resize";
1462 Desktop.winManipMode = 5;
1464 else if(locX > win.getWindowWidth() - hotCornerSz) {
1465 this.style.cursor =
"e-resize";
1466 Desktop.winManipMode = 6;
1468 else if(locY < hotCornerSz) {
1469 this.style.cursor =
"n-resize";
1470 Desktop.winManipMode = 7;
1472 else if(locY > win.getWindowHeight() - hotCornerSz) {
1473 this.style.cursor =
"s-resize";
1474 Desktop.winManipMode = 8;
1476 else if(locY < win.getWindowHeaderHeight()) {
1477 this.style.cursor =
"all-scroll";
1478 Desktop.winManipMode = 0;
1481 this.style.cursor =
"default";
1486 Desktop.handleBodyMouseMove(mouseEvent);
1491 Desktop._mouseMoveSubscribers = [];
1493 Desktop.mouseMoveSubscriber =
function(newHandler) {
1494 Desktop._mouseMoveSubscribers.push(newHandler);
1501 Desktop.handleBodyMouseMove =
function(mouseEvent) {
1504 for(var i=0; i<Desktop._mouseMoveSubscribers.length; ++i)
1505 Desktop._mouseMoveSubscribers[i](mouseEvent);
1507 Desktop.desktop.resetFrameMouse();
1510 if(Desktop.foreWinLastMouse[0] != -1 && Desktop.winManipMode == 100) {
1512 if(mouseEvent.which == 0)
1513 return Desktop.handleWindowMouseUp(mouseEvent);
1515 var delta = mouseEvent.clientX-Desktop.foreWinLastMouse[0];
1516 Desktop.desktop.dashboard.setDashboardWidth(Desktop.desktop.dashboard.getDashboardWidth()+delta);
1517 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1519 if(Desktop.stretchAndMoveInterval == 0)
1520 Desktop.stretchAndMoveInterval = setInterval(
1522 if(Desktop.desktop.getLastFrameMouseX() == -1)
return;
1524 var delta = Desktop.desktop.getLastFrameMouseX()-Desktop.foreWinLastMouse[0];
1525 Desktop.desktop.dashboard.setDashboardWidth(Desktop.desktop.dashboard.getDashboardWidth()+delta);
1526 Desktop.foreWinLastMouse = [Desktop.desktop.getLastFrameMouseX(),Desktop.desktop.getLastFrameMouseY()];
1533 if(!Desktop.desktop.getForeWindow())
return true;
1535 if(Desktop.foreWinLastMouse[0] != -1)
1537 if(mouseEvent.which == 0)
1538 return Desktop.handleWindowMouseUp(mouseEvent);
1540 var delta = [mouseEvent.clientX-Desktop.foreWinLastMouse[0], mouseEvent.clientY-Desktop.foreWinLastMouse[1]];
1542 Desktop.handleWindowManipulation(delta);
1544 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1546 if(Desktop.stretchAndMoveInterval == 0)
1547 Desktop.stretchAndMoveInterval = setInterval(
1549 if(Desktop.desktop.getLastFrameMouseX() == -1)
return;
1551 var delta = [Desktop.desktop.getLastFrameMouseX()-Desktop.foreWinLastMouse[0],
1552 Desktop.desktop.getLastFrameMouseY()-Desktop.foreWinLastMouse[1]];
1553 Desktop.handleWindowManipulation(delta);
1554 Desktop.foreWinLastMouse = [Desktop.desktop.getLastFrameMouseX(),Desktop.desktop.getLastFrameMouseY()];
1564 Desktop.handleWindowManipulation =
function(delta) {
1565 if(!Desktop.desktop.getForeWindow())
return false;
1567 var win = Desktop.desktop.getForeWindow();
1569 switch(Desktop.winManipMode) {
1571 win.moveWindowByOffset(delta[0],delta[1]);
1574 win.resizeAndPositionWindow(
1575 win.getWindowX() + delta[0],
1576 win.getWindowY() + delta[1],
1577 win.getWindowWidth() - delta[0],
1578 win.getWindowHeight() - delta[1]);
1581 win.resizeAndPositionWindow(
1584 win.getWindowWidth() + delta[0],
1585 win.getWindowHeight() + delta[1]);
1588 win.resizeAndPositionWindow(
1590 win.getWindowY() + delta[1],
1591 win.getWindowWidth() + delta[0],
1592 win.getWindowHeight() - delta[1]);
1595 win.resizeAndPositionWindow(
1596 win.getWindowX() + delta[0],
1598 win.getWindowWidth() - delta[0],
1599 win.getWindowHeight() + delta[1]);
1602 win.resizeAndPositionWindow(
1603 win.getWindowX() + delta[0],
1605 win.getWindowWidth() - delta[0],
1606 win.getWindowHeight());
1609 win.resizeAndPositionWindow(
1612 win.getWindowWidth() + delta[0],
1613 win.getWindowHeight());
1616 win.resizeAndPositionWindow(
1618 win.getWindowY() + delta[1],
1619 win.getWindowWidth(),
1620 win.getWindowHeight() - delta[1]);
1623 win.resizeAndPositionWindow(
1626 win.getWindowWidth(),
1627 win.getWindowHeight() + delta[1]);
1633 Desktop.handleWindowButtonDown =
function(mouseEvent) {
1634 mouseEvent.cancelBubble=
true;
1638 Desktop.handleWindowRefresh =
function(mouseEvent){
1639 Debug.log(
"Refresh " + this.
id.split(
'-')[1]);
1640 Desktop.desktop.refreshWindowById(this.
id.split(
'-')[1]);
1645 Desktop.handleFullScreenWindowRefresh =
function(mouseEvent){
1646 Debug.log(
"Refresh Full Screen Window");
1648 var foreWindowId = undefined;
1651 foreWindowId = Desktop.desktop.getForeWindow().getWindowId();
1655 Debug.log(
"Could not find foreground window, ignoring.");
1659 Desktop.desktop.resetDesktop();
1660 Desktop.desktop.refreshDesktop();
1662 var foreWindow = undefined;
1663 var isMaxWindow = undefined;
1681 for(var i = 0; i < Desktop.desktop.getNumberOfWindows(); i++)
1683 var window = Desktop.desktop.getWindowByIndex(0);
1684 var
id = window.getWindowId();
1686 Debug.log(
"name: " + i +
" " + window.getWindowName());
1687 Debug.log(
"ID: " +
id);
1689 var maximized = window.isMaximized();
1692 Desktop.desktop.setForeWindow(window);
1693 window = Desktop.desktop.refreshWindow();
1696 isMaxWindow = window;
1698 if(foreWindowId ==
id)
1699 foreWindow = window;
1714 Desktop.desktop.setForeWindow(foreWindow);
1716 Desktop.desktop.setForeWindow(foreWindow);
1731 Desktop.handleWindowMinimize =
function(mouseEvent) {
1732 Debug.log(
"minimize " + this.
id.split(
'-')[1]);
1733 Desktop.desktop.minimizeWindowById(this.
id.split(
'-')[1]);
1737 Desktop.handleWindowMaximize =
function(mouseEvent) {
1738 Debug.log(
"maximize " + this.
id.split(
'-')[1]);
1739 Desktop.desktop.maximizeWindowById(this.
id.split(
'-')[1]);
1743 Desktop.handleWindowClose =
function(mouseEvent) {
1745 Desktop.desktop.closeWindowById(this.
id.split(
'-')[1]);
1756 Desktop.XMLHttpRequest =
function(requestURL, data, returnHandler, reqIndex) {
1759 var req =
new XMLHttpRequest();
1761 req.onreadystatechange =
function() {
1762 if (req.readyState==4) {
1767 if(!Desktop.desktop.serverConnected)
1769 Desktop.desktop.serverConnected =
true;
1770 Desktop.desktop.dashboard.displayConnectionStatus(
true);
1772 Desktop.desktop.resetDesktop();
1777 if(req.responseText == Globals.REQ_NO_PERMISSION_RESPONSE)
1779 errStr =
"Request failed do to insufficient account permissions.";
1782 else if(req.responseText == Globals.REQ_NO_LOGIN_RESPONSE)
1784 errStr =
"Login has expired.";
1786 window.clearInterval(Desktop.desktop.checkMailboxTimer);
1797 if(Desktop.desktop.serverConnected)
1799 Desktop.desktop.serverConnected =
false;
1800 Desktop.desktop.dashboard.displayConnectionStatus(
false);
1803 errStr =
"Request Failed - Bad Address:\n" + requestURL;
1804 window.clearInterval(Desktop.desktop.checkMailboxTimer);
1810 errStr +=
"\n\n(Try refreshing the page, or alert ots admins if problem persists.)";
1811 Debug.log(
"Error: " + errStr,Debug.HIGH_PRIORITY);
1815 Debug.log(
"The user interface is disconnected from the ots Gateway server.", Debug.HIGH_PRIORITY);
1817 document.getElementById(
"DesktopDashboard-userWithLock").style.display =
"none";
1819 if(returnHandler) returnHandler(req,reqIndex,errStr);
1823 if(Desktop.desktop.login)
1824 data =
"CookieCode="+Desktop.desktop.login.getCookieCode()+
"&"+data;
1825 requestURL =
"/urn:xdaq-application:lid="+urnLid+
"/"+requestURL;
1827 req.open(
"POST",requestURL,
true);
1829 req.setRequestHeader(
"Content-Type",
"text/plain;charset=UTF-8");
1834 Desktop.getXMLAttributeValue =
function(req, name, attribute) {
1835 if(req && req.responseXML && req.responseXML.getElementsByTagName(name).length > 0)
1836 return req.responseXML.getElementsByTagName(name)[0].getAttribute(attribute);
1843 Desktop.getXMLValue =
function(req, name) {
1844 return Desktop.getXMLAttributeValue(req,name,
"value");
1849 Desktop.logout =
function () {
1850 if(Desktop.desktop && Desktop.desktop.login &&
1851 !Desktop.desktop.login.isBlackout())
1852 Desktop.desktop.login.logout();
1856 Desktop.formatTime =
function(t) {
1857 var date =
new Date(t * 1000);
1858 var mm = date.getMinutes() < 10?
"0"+date.getMinutes():date.getMinutes();
1859 var ss = date.getSeconds() < 10?
"0"+date.getSeconds():date.getSeconds();
1860 return date.getHours() +
":" + mm +
":" + ss;
1864 Desktop.closeSystemMessage =
function(id) {
1865 var el = document.getElementById(
"Desktop-systemMessageBox-" +
id);
1866 el.parentNode.removeChild(el);
1870 Desktop.isWizardMode =
function() {
1872 Debug.log(
"Desktop Security: " + Desktop.desktop.security);
1874 return !(!Desktop.desktop.security ||
1875 Desktop.desktop.security == Desktop.SECURITY_TYPE_DIGEST_ACCESS ||
1876 Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE);
1880 Desktop.openNewBrowserTab =
function(name,subname,windowPath,unique) {
1886 var i = windowPath.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
1887 var isAllNumbers =
true;
1888 for(i;i<windowPath.length;++i)
1890 Debug.log(windowPath[i]);
1892 if(windowPath[i] <
"0" || windowPath[i] >
"9")
1894 isAllNumbers =
false;
1901 Debug.log(
"DesktopWindow= " + windowPath);
1903 Debug.log(
"name= " + name);
1904 Debug.log(
"subname= " + subname);
1905 Debug.log(
"unique= " + unique);
1906 var search = window.parent.window.location.search;
1907 url = window.parent.window.location.pathname;
1909 var str =
"requestingWindowId=Desktop";
1910 str +=
"&windowName=" + name;
1911 str +=
"&windowSubname=" + subname;
1912 str +=
"&windowUnique=" + unique;
1913 str +=
"&windowPath=" + encodeURIComponent(windowPath);
1918 if(!Desktop.isWizardMode())
1920 var i = url.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
1921 var isAllNumbers =
true;
1922 for(i;i<url.length;++i)
1926 if(url[i] <
"0" || url[i] >
"9")
1928 isAllNumbers =
false;
1938 url += search.split(
'&')[0] +
"&" + str;
1941 Debug.log(
"DesktopContent.openNewBrowserTab= " + url);
1943 window.open(url,
'_blank');
1948 Desktop.desktopTooltip =
function() {
1950 DesktopContent.tooltip(
"Desktop Introduction",
1951 "Welcome to the <i>otsdaq</i> Desktop environment. This is your portal " +
1952 "to all of the possibilities of <i>otsdaq</i>.\n\n" +
1953 "Briefly, here are the features:" +
1955 "\n\t- <b>Desktop Window Icons:</b> " +
1957 "Click the rounded-square icons on your Desktop to open " +
1958 "a particular window. If you hold down your click (for a second), you " +
1959 "can open the window in fullscreen, or in a new tab, or even open the window " +
1960 "then tile it on the screen with all other open windows!" +
1963 "\n\t- <b>Desktop Dashboard (top pane):</b> " +
1965 "Along the top and left margins of the Desktop, you will find the Desktop " +
1966 "Dashboard - this section is an introduction to the top pane of the Dashboard. " +
1967 "The top pane of the Dashboard " +
1968 "is made of buttons and icons going from left to right:" +
1970 "\n\t- <b>Left Pane Toggler:</b> " +
1972 "The first button you will encounter in the top pane looks like a horizontal double-arrow " +
1973 "icon. This button toggles the display of the left pane of the Dashboard. Note when you " +
1974 "refresh the page, the state of the left pane persists!" +
1977 "\n\t- <b>Layouts Menu:</b> " +
1979 "The next button you will encounter in the top pane reads 'Layouts.' " +
1980 "This button gives you access to your Window Layout Presets. You will see 2 'System' presets there " +
1981 "which can be setup by uesrs with admin privileges. There are also 3 'User' presets which you can setup for " +
1982 "yourself in the User Settings window (get there with " +
1983 "the cog wheel icon in the upper-right of the Desktop)." +
1986 "\n\t- <b>Tile Desktop Windows:</b> " +
1988 "The next button you will encounter in the top pane reads 'Tile.' " +
1989 "This button will automatically tile all open Desktop Windows to fit in your browser window." +
1992 "\n\t- <b>Show Desktop:</b> " +
1994 "The next button you will encounter in the top pane reads 'Show Desktop.' " +
1995 "This button will minimize all open Desktop Windows which is nice " +
1996 "when you want to see all of your Desktop Icons again." +
1999 "\n\t- <b>Full Screen:</b> " +
2001 "The next button you will encounter in the top pane reads 'Full Screen.' " +
2002 "This button will maximize to full screen the Desktop Window that was last used (i.e. the window that has the focus)." +
2006 "\n\t- <b>Desktop Dashboard (left pane):</b> " +
2008 "Along the top and left margins of the Desktop, you will find the Desktop " +
2009 "Dashboard - this section is an introduction to the left pane of the Dashboard. " +
2010 "The left pane of the Dashboard " +
2011 "is a listing of all open Desktop Windows. If you click one of the buttons in the list, " +
2012 "the associated window " +
2013 "will be minimized or restored. If you hold down your click (for one second) you can choose " +
2014 "to minimize, maximize, or close the window!" +
2019 "\n\nRemember, if you would like to take a look at the available online documentation, " +
2020 "click the question mark at the top-right of the Desktop."