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);
32 window.onbeforeunload =
function() {
37 Desktop.SECURITY_TYPE_NONE =
"NoSecurity";
38 Desktop.SECURITY_TYPE_DIGEST_ACCESS =
"DigestAccessAuthentication";
45 Desktop.createDesktop =
function(security) {
47 if (typeof Debug ==
'undefined')
return 0;
49 if(
false === (
this instanceof Desktop.createDesktop)) {
52 return new Desktop.createDesktop(security);
137 var _defaultWindowMinZindex = 10;
138 var _defaultWindowMaxZindex = 10000;
139 var _defaultDashboardZindex = 11000;
140 var _defaultWidth = 620;
141 var _defaultHeight = 580;
142 var _defaultLeft = 200;
143 var _defaultTop = 70;
144 var _defaultLeftOffset = 50;
145 var _defaultTopOffset = 25;
146 var _defaultOffsetTimes = 5;
147 var _currentLeft = _defaultLeft;
148 var _currentTop = _defaultTop;
150 var _windows =
new Array();
152 var _dashboard, _icons, _windowZmailbox, _mouseOverXmailbox, _mouseOverYmailbox;
153 var _needToLoginMailbox, _updateTimeMailbox, _updateSettingsMailbox, _settingsLayoutMailbox, _openWindowMailbox, _blockSystemCheckMailbox;
154 var _windowColorPostbox;
155 var _MAILBOX_TIMER_PERIOD = 500;
157 var _SYS_MSG_SOUND_PATH =
"/WebPath/sounds/fx-System-Message.wav";
158 var _sysMsgSound =
new Audio(_SYS_MSG_SOUND_PATH);
165 var _sysMsgCounter = 0;
166 var _SYS_MSG_MAX_COUNT = 10;
168 var _firstCheckOfMailboxes =
true;
176 this.checkMailboxTimer;
177 this.serverConnected =
true;
178 this.security = security;
180 this.defaultWindowFrameColor =
"rgba(196,229,255,.9)";
186 var _handleDesktopResize =
function(event) {
187 _desktopElement.style.height = (window.innerHeight-_desktopElement.offsetTop) +
"px";
188 _desktopElement.style.width = (window.innerWidth-_desktopElement.offsetLeft) +
"px";
189 if(!_dashboard)
return;
190 _dashboard.redrawDashboard();
191 if(_login) _login.redrawLogin();
192 if(_icons) _icons.redrawIcons();
195 if(_windows.length && _windows[_windows.length-1].isMaximized()) {
196 var w = _windows[_windows.length-1];
197 w.setWindowSizeAndPosition(w.getWindowX(),w.getWindowY(),w.getWindowWidth(),w.getWindowHeight());
207 var _getWindowLayoutStr =
function() {
208 var dw = Desktop.desktop.getDesktopContentWidth()/10000.0;
209 var dh = Desktop.desktop.getDesktopContentHeight()/10000.0;
210 var dx = Desktop.desktop.getDesktopContentX();
211 var dy = Desktop.desktop.getDesktopContentY();
214 for(var i=0;i<_windows.length;++i)
216 if(_windows[i].getWindowName() ==
"Settings")
continue;
218 layout += (i?
",":
"") +
219 encodeURIComponent(_windows[i].getWindowName())
220 +
"," + encodeURIComponent(_windows[i].getWindowSubName())
221 +
"," + encodeURIComponent(_windows[i].getWindowUrl())
222 +
"," + (((_windows[i].getWindowX()-dx)/dw)|0)
223 +
"," + (((_windows[i].getWindowY()-dy)/dh)|0)
224 +
"," + ((_windows[i].getWindowWidth()/dw)|0)
225 +
"," + ((_windows[i].getWindowHeight()/dh)|0)
226 +
"," + (_windows[i].isMinimized()?
"0":(_windows[i].isMaximized()?
"2":
"1"));
234 var _scrambleEggs =
function(u) {
return u; }
236 var _getForeWindow =
function() {
return _windows.length?_windows[_windows.length-1]:0; }
238 var _closeWindow =
function(win) {
239 Desktop.desktop.setForeWindow(win);
240 win.windiv.parentNode.removeChild(win.windiv);
244 _windows.splice(_windows.length-1,1);
247 _dashboard.updateWindows();
255 var _checkMailboxes =
function(win)
259 if(_firstCheckOfMailboxes)
261 Debug.log(
"First check of mailboxes!");
263 Debug.log(
"Checking for any shortcut work from get parameters...",Debug.LOW_PRIORITY);
264 _firstCheckOfMailboxes =
false;
265 Desktop.desktop.actOnParameterAction();
270 if(_blockSystemCheckMailbox.innerHTML ==
"1")
272 Desktop.desktop.login.blackout(
true);
276 Desktop.desktop.login.blackout(
false);
286 if(_openWindowMailbox.innerHTML !=
"")
288 Debug.log(
"_openWindowMailbox.textContent=" + _openWindowMailbox.textContent);
291 var paramsStr = _openWindowMailbox.textContent;
294 var spliti, splitiOld = 0;
295 for(var i=0;i<paramCnt;++i)
299 params.push(paramsStr.substr(splitiOld));
303 spliti = paramsStr.indexOf(
'&', splitiOld);
304 params.push(paramsStr.substr(splitiOld,spliti-splitiOld))
305 splitiOld = spliti+1;
309 var requestingWindowId =
"", windowPath =
"";
310 var windowName, windowSubname, windowUnique;
311 for(var i=0;i<params.length;++i)
313 spliti = params[i].indexOf(
'=');
314 varPair = [params[i].substr(0,spliti),params[i].substr(spliti+1)];
315 if(varPair[0] ==
"requestingWindowId")
316 requestingWindowId = varPair[1];
317 else if(varPair[0] ==
"windowPath")
318 windowPath = varPair[1];
319 else if(varPair[0] ==
"windowName")
320 windowName = varPair[1];
321 else if(varPair[0] ==
"windowSubname")
322 windowSubname = varPair[1];
323 else if(varPair[0] ==
"windowUnique")
324 windowUnique = varPair[1];
326 if(requestingWindowId !=
"" && windowPath !=
"")
330 Debug.log(
"_openWindowMailbox.innerHTML=" + _openWindowMailbox.innerHTML);
331 Debug.log(
"requestingWindowId=" + requestingWindowId);
332 Debug.log(
"windowPath=" + windowPath);
333 while(windowPath.length && windowPath[0] ==
'?') windowPath = windowPath.substr(1);
334 Debug.log(
"modified windowPath=" + windowPath);
335 Debug.log(
"windowName=" + windowName);
336 Debug.log(
"windowSubname=" + windowSubname);
337 Debug.log(
"windowUnique=" + windowUnique);
343 if(windowSubname ==
"undefined" &&
344 windowUnique ==
"undefined")
346 Debug.log(
"Opening desktop window... " + windowName);
348 var pathUniquePair = Desktop.desktop.icons.iconNameToPathMap[windowName];
349 console.log(
"Desktop.desktop.icons.iconNameToPathMap",
350 Desktop.desktop.icons.iconNameToPathMap);
352 if(pathUniquePair ===
355 Debug.log(
"An error occurred opening the window named '" +
356 windowName +
"' - it was not found in the Desktop icons. " +
357 "Do you have permissions to access this window? Notify admins if the problem persists.",
358 Debug.HIGH_PRIORITY);
361 var str =
"requestingWindowId=" + requestingWindowId;
363 _openWindowMailbox.innerHTML = str;
368 var pathStr = pathUniquePair[0];
370 if(windowPath !=
"undefined")
372 Debug.log(
"Adding parameter path " + windowPath);
373 if(pathStr.indexOf(
'?') >= 0)
375 else if(pathStr.length)
377 windowPath = pathStr + windowPath;
380 windowPath = pathStr;
382 newWin = Desktop.desktop.addWindow(
386 eval(pathUniquePair[1]));
390 newWin = Desktop.desktop.addWindow(
398 setTimeout(
function(){ Desktop.desktop.setForeWindow(newWin); }, 200);
400 var str =
"requestingWindowId=" + requestingWindowId;
402 _openWindowMailbox.innerHTML = str;
410 if(!Desktop.desktop.login || !Desktop.desktop.login.getCookieCode(
true))
412 if(_needToLoginMailbox.innerHTML ==
"1")
413 _needToLoginMailbox.innerHTML =
"";
419 if(_windowZmailbox.innerHTML > _defaultWindowMaxZindex)
421 Desktop.desktop.setForeWindow();
427 if(_needToLoginMailbox.innerHTML ==
"1")
429 _needToLoginMailbox.innerHTML =
"";
430 if(!document.getElementById(
"Desktop-loginDiv") &&
431 !Desktop.desktop.login.isBlackout())
434 Debug.log(
"DesktopContent signaled new login needed!",Debug.HIGH_PRIORITY);
438 Debug.log(
"Ignoring desktop content need for login signal due to blackout.");
442 if(parseInt(_updateTimeMailbox.innerHTML) > parseInt(Desktop.desktop.login.getCookieTime()))
443 Desktop.desktop.login.updateCookieFromContent(parseInt(_updateTimeMailbox.innerHTML));
446 if(_updateSettingsMailbox.innerHTML !=
"")
452 if(_updateSettingsMailbox.innerHTML ==
"LAYOUT")
455 var layout = _getWindowLayoutStr();
456 _settingsLayoutMailbox.innerHTML = layout;
457 Debug.log(
"Desktop _updateSettingsMailbox " + layout,Debug.LOW_PRIORITY);
462 var xml = _updateSettingsMailbox.innerHTML;
464 req.responseXML = (
new window.DOMParser() ).parseFromString(xml,
"text/xml");
465 _login.applyUserPreferences(req);
468 _updateSettingsMailbox.innerHTML =
"";
473 if(_sysMsgCounter == _SYS_MSG_MAX_COUNT)
476 if(_blockSystemCheckMailbox.innerHTML ==
"1" ||
477 Desktop.desktop.login.isBlackout())
479 Debug.log(
"System blackout (likely rebooting)...");
483 Desktop.XMLHttpRequest(
"Request?RequestType=getSystemMessages",
"",_handleSystemMessages);
488 var _lastSystemMessage =
"";
491 var _handleSystemMessages =
function(req) {
499 userLock = Desktop.getXMLValue(req,
"username_with_lock");
500 Desktop.desktop.dashboard.displayUserLock(userLock);
502 var tmp = Desktop.getXMLValue(req,
"systemMessages");
509 if((tmpi = tmp.indexOf(_lastSystemMessage)) >= 0)
511 Debug.log(
"Desktop pretmp " + tmp);
512 Debug.log(
"Desktop _lastSystemMessage " + _lastSystemMessage);
513 Debug.log(
"Desktop tmp " + tmp.substr(tmpi+_lastSystemMessage.length+1));
514 tmp = tmp.substr(tmpi+_lastSystemMessage.length+1);
520 var msgArr = tmp.split(
"|");
521 Debug.log(
"Desktop msgArr.length " + msgArr.length);
523 if(msgArr.length < 2)
return;
525 Debug.log(
"Desktop _handleSystemMessages ========================== " + Desktop.formatTime(msgArr[0]) +
527 ,Debug.LOW_PRIORITY);
530 var sysMsgEl = document.createElement(
"div");
531 sysMsgEl.setAttribute(
"class",
"Desktop-systemMessageBox");
532 sysMsgEl.setAttribute(
"id",
"Desktop-systemMessageBox-" + _sysMsgId);
533 sysMsgEl.style.left = (50 + _sysMsgId % 5 * 10) +
"px";
534 sysMsgEl.style.top = (50 + _sysMsgId % 5 * 10) +
"px";
535 _desktopElement.appendChild(sysMsgEl);
539 for(var i=0;i<msgArr.length;i+=2)
541 str +=
"<div style='font-size:12px'>System Message Received at " + Desktop.formatTime(msgArr[i]) +
"</div>";
542 str +=
"<div>" + msgArr[i+1] +
"</div><br>";
543 _lastSystemMessage = msgArr[i] +
"|" + msgArr[i+1];
547 str +=
"<div style='float:right; margin-left:30px'>";
548 str +=
"<a href='Javascript:Desktop.closeSystemMessage(" + _sysMsgId +
");' " +
549 "title='Click here to dismiss system message'>Dismiss</a></div>";
551 sysMsgEl.innerHTML = str;
553 if(sysMsgEl.clientHeight > 300)
554 sysMsgEl.style.height = 300 +
"px";
564 this.getDesktopWidth =
function() {
return _desktopElement.clientWidth;}
565 this.getDesktopHeight =
function() {
return _desktopElement.clientHeight;}
566 this.getDesktopX =
function() {
return _desktopElement.offsetLeft;}
567 this.getDesktopY =
function() {
return _desktopElement.offsetTop;}
568 this.getDesktopContentX =
function() {
return _desktopElement.offsetLeft+_dashboard.getDashboardWidth();}
569 this.getDesktopContentY =
function() {
return _desktopElement.offsetTop+_dashboard.getDashboardHeight();}
570 this.getDesktopContentWidth =
function() {
return _desktopElement.clientWidth-_dashboard.getDashboardWidth();}
571 this.getDesktopContentHeight =
function() {
return _desktopElement.clientHeight-_dashboard.getDashboardHeight();}
572 this.getNumberOfWindows =
function() {
return _windows.length;}
573 this.getWindowNameByIndex =
function(i) {
return _windows[i].getWindowName();}
574 this.getWindowSubNameByIndex =
function(i) {
return _windows[i].getWindowSubName();}
575 this.getWindowByIndex =
function(i) {
return _windows[i];}
576 this.getForeWindow = _getForeWindow;
577 this.redrawDesktop = _handleDesktopResize;
578 this.getLastFrameMouseX =
function() {
return parseInt(_mouseOverXmailbox.innerHTML);}
579 this.getLastFrameMouseY =
function() {
return parseInt(_mouseOverYmailbox.innerHTML);}
580 this.resetFrameMouse =
function() { _mouseOverXmailbox.innerHTML = -1;_mouseOverYmailbox.innerHTML = -1;}
581 this.getWindowLayoutStr = _getWindowLayoutStr;
595 this.addWindow =
function(name,subname,url,unique,extraStep) {
596 Debug.log(name +
" - " + subname +
" - " + url +
" - " + unique,Debug.LOW_PRIORITY);
600 Debug.log(
"Opening stand-alone new tab",Debug.LOW_PRIORITY);
601 window.open(url,
'_blank');
606 Debug.log(
"Adding window uniquely",Debug.LOW_PRIORITY);
607 for(var i=0;i<_windows.length;++i)
608 if(_windows[i].getWindowName() == name && _windows[i].getWindowSubName() == subname) {
609 Debug.log(
"Window creation failed. Not unique.",Debug.LOW_PRIORITY);
610 if(_windows[i].isMinimized()) {
611 Debug.log(_windows[i].getWindowSubName() +
"was minimized but will now be restored!");
612 _windows[i].unminimize();
615 Desktop.desktop.setForeWindow(_windows[i]);
620 if(_windows.length + _defaultWindowMinZindex >= _defaultWindowMaxZindex) {
621 Debug.log(
"FAILED -- Desktop Window Added - too many windows!",Debug.HIGH_PRIORITY);
625 if(name ==
"Security Settings") {
629 else if(name ==
"Edit User Data") {
634 window_width = _defaultWidth;
635 window_height = _defaultHeight;
640 var newWin = Desktop.createWindow(_winId++,_windows.length + _defaultWindowMinZindex,name,subname,url,
641 window_width,window_height,_dashboard.getDashboardWidth() + _currentLeft,_currentTop);
644 if(_currentLeft > _defaultLeft+_defaultOffsetTimes*_defaultLeftOffset) {
645 _currentLeft = _defaultLeft;
646 if(_currentTop > _defaultTop + (_defaultOffsetTimes+1)*_defaultTopOffset)
647 _currentTop = _defaultTop;
649 _currentTop = _defaultTop + _defaultTopOffset;
653 _currentLeft += _defaultLeftOffset;
654 _currentTop += _defaultTopOffset;
657 _windows.push(newWin);
659 _desktopElement.appendChild(newWin.windiv);
661 Debug.log(
"Desktop Window Added with id " + _windows[_windows.length-1].getWindowId(),Debug.LOW_PRIORITY);
663 _dashboard.updateWindows();
668 setTimeout(
function(){
669 Desktop.desktop.setForeWindow(newWin);
670 Debug.log(
"extraStep=" + extraStep);
674 Desktop.desktop.dashboard.windowDashboardOrganize();
677 Desktop.desktop.toggleFullScreen();
691 this.getWindowById =
function(id) {
692 for(var i=0;i<_windows.length;++i) {
693 if(_windows[i].getWindowId() == id)
return _windows[i];
704 this.setForeWindow =
function(win) {
708 for(var i=0;i<_windows.length-1;++i) {
710 for(var j=i+1;j<_windows.length;++j)
711 if(_windows[j].getWindowZ() < _windows[min].getWindowZ())
716 _windows[i] = _windows[min];
718 _windows[i].setWindowZ(i+_defaultWindowMinZindex);
720 _windows[_windows.length-1].setWindowZ(_windows.length-1+_defaultWindowMinZindex);
721 _windowZmailbox.innerHTML = _defaultWindowMaxZindex;
726 for(var i=0;win && i<=_windows.length;++i) {
729 var winToMov = i<_windows.length?_windows[i]:win;
730 winToMov.setWindowZ(i-1 + _defaultWindowMinZindex);
731 _windows[i-1] = winToMov;
733 else if(_windows[i] == win) found = 1;
737 Debug.log(
"Desktop Foreground window not Found!! Window: " +
738 win.getWindowSubName());
740 _dashboard.updateWindows();
748 this.closeWindowById =
function(id) {
749 var win = this.getWindowById(
id);
750 if(win == -1)
return -1;
756 this.maximizeWindowById =
function(id) {
757 var win = this.getWindowById(
id);
758 if(win == -1)
return -1;
759 this.setForeWindow(win);
760 this.toggleFullScreen();
765 this.toggleFullScreen =
function(e) {
766 if(!_getForeWindow())
return;
768 _getForeWindow().isMaximized() ? _getForeWindow().unmaximize(): _getForeWindow().maximize();
770 Desktop.desktop.redrawDashboardWindowButtons();
774 Debug.log(
"Full Screen Toggled",Debug.LOW_PRIORITY);
777 this.redrawDashboardWindowButtons =
function() {
778 _dashboard.redrawFullScreenButton();
779 _dashboard.redrawRefreshButton();
780 _dashboard.redrawShowDesktopButton();
783 this.refreshWindowById =
function(id) {
784 var win = this.getWindowById(
id);
785 if(win == -1)
return -1;
787 this.setForeWindow(win);
788 this.refreshWindow();
789 console.log(
"Finished refreshWindow() " +
id);
792 this.windowHelpById =
function (id) {
793 var win = this.getWindowById(
id);
794 if (win == -1)
return -1;
796 this.setForeWindow(win);
797 var tempwin = Desktop.desktop.getForeWindow();
799 console.log(tempwin);
800 console.log(tempwin.windiv);
806 tooltipEl = tempwin.windiv.childNodes[2].childNodes[0].contentWindow.document.getElementById(
"otsDesktopWindowTooltipElement");
810 Debug.log(
"Ignoring error: " + e);
817 tooltipEl = tempwin.windiv.childNodes[2].childNodes[0].contentWindow.document.getElementsByTagName(
"frameset")[0].childNodes[0].contentWindow.document.getElementById(
"otsDesktopWindowTooltipElement");
821 Debug.log(
"Ignoring error: " + e);
829 DesktopContent.tooltip(
"ALWAYS",
"There is no tooltip for the " + tempwin.getWindowName() +
830 " window. Try visiting <a href='https://otsdaq.fnal.gov' target='_blank'>otsdaq.fnal.gov</a> for further assistance.");
834 DesktopContent.tooltip(
"ALWAYS", decodeURIComponent(tooltipEl.innerText));
838 this.refreshWindow =
function(e) {
839 if(!_getForeWindow())
return;
842 var window = _getForeWindow();
843 var
id = window.getWindowId();
844 var z = window.getWindowZ();
845 var name = window.getWindowName();
846 var subname = window.getWindowSubName();
847 var url = window.getWindowUrl();
848 var width = window.getWindowWidth();
849 var height = window.getWindowHeight();
850 var x = window.getWindowX();
851 var y = window.getWindowY();
852 var isMax = window.isMaximized();
853 var isMin = window.isMinimized();
855 _closeWindow(window);
856 console.log(window,
id, z, name, width, height);
858 var newWindow = this.addWindow(name,subname,url);
859 newWindow.setWindowSizeAndPosition(x,y,width,height);
860 newWindow.setWindowZ(z);
863 newWindow.maximize();
865 newWindow.minimize();
874 this.minimizeWindowById =
function(id) {
875 var win = this.getWindowById(
id);
876 if(win == -1)
return -1;
878 this.setForeWindow(win);
879 this.toggleMinimize();
884 this.toggleMinimize =
function(e) {
885 if(!_getForeWindow())
return;
887 if(_getForeWindow().isMinimized())
888 _getForeWindow().unminimize();
890 _getForeWindow().minimize();
891 Debug.log(
"Minimize Toggled",Debug.LOW_PRIORITY);
897 this.clickedWindowDashboard =
function(id) {
898 var win = this.getWindowById(
id);
899 if(win == -1)
return -1;
900 if(_getForeWindow() != win) {
901 if(_getForeWindow().isMaximized()) this.toggleFullScreen();
902 this.setForeWindow(win);
903 if(_getForeWindow().isMinimized()) this.toggleMinimize();
907 this.toggleMinimize();
912 this.setDefaultWindowColor =
function(color) {
913 this.defaultWindowFrameColor = color;
914 _windowColorPostbox.innerHTML = this.defaultWindowFrameColor;
916 for(var i=0;i<_windows.length;++i)
917 _windows[i].windiv.style.backgroundColor =
this.defaultWindowFrameColor;
925 this.defaultLayoutSelect =
function(i) {
926 Debug.log(
"Desktop defaultLayoutSelect " + i,Debug.LOW_PRIORITY);
929 var numOfUserLayouts = 5;
930 var numOfSystemLayouts = 5;
931 if(i >= numOfSystemLayouts+1 &&
932 i <= numOfSystemLayouts+1+numOfUserLayouts)
933 layoutStr = _login.getUserDefaultLayout(i-(numOfSystemLayouts+1));
934 else if(i >= 0 && i <= numOfSystemLayouts)
935 layoutStr = _login.getSystemDefaultLayout(i);
938 Debug.log(
"Invalid layout index: " + i, Debug.HIGH_PRIORITY);
941 var layoutArr = layoutStr.split(
",");
944 var numOfWins = parseInt(layoutArr.length/numOfFields);
946 Debug.log(
"Desktop defaultLayoutSelect layout numOfFields=" + numOfFields);
947 Debug.log(
"Desktop defaultLayoutSelect layout " + numOfWins +
948 " windows - " + layoutStr);
951 Desktop.desktop.closeAllWindows();
966 var dw = Desktop.desktop.getDesktopContentWidth()/10000.0;
967 var dh = Desktop.desktop.getDesktopContentHeight()/10000.0;
968 var dx = Desktop.desktop.getDesktopContentX();
969 var dy = Desktop.desktop.getDesktopContentY();
970 for(i=0;i<numOfWins;++i)
972 Debug.log(
"adding " + layoutArr[i*numOfFields].substr(1) +
"-" + layoutArr[i*numOfFields+1],Debug.LOW_PRIORITY);
974 decodeURIComponent(layoutArr[i*numOfFields]),
975 decodeURIComponent(layoutArr[i*numOfFields+1]),
976 decodeURIComponent(layoutArr[i*numOfFields+2]),
978 _windows[_windows.length-1].setWindowSizeAndPosition(
979 layoutArr[i*numOfFields+3]*dw + dx,
980 layoutArr[i*numOfFields+4]*dh + dy,
981 layoutArr[i*numOfFields+5]*dw,
982 layoutArr[i*numOfFields+6]*dh);
984 if((layoutArr[i*numOfFields+7]|0) == 0)
985 _windows[_windows.length-1].minimize();
986 else if((layoutArr[i*numOfFields+7]|0) == 2)
987 _windows[_windows.length-1].maximize();
993 this.closeAllWindows =
function() {
994 Debug.log(
"Desktop closeAllWindows",Debug.LOW_PRIORITY);
996 while(_windows.length) _closeWindow(_windows[_windows.length-1]);
1001 this.resetDesktop =
function(permissions) {
1003 _needToLoginMailbox.innerHTML =
"";
1004 _blockSystemCheckMailbox.innerHTML =
"";
1007 if(permissions !== undefined)
1008 Desktop.desktop.icons.resetWithPermissions(permissions);
1011 if(!Desktop.desktop.login || !Desktop.desktop.login.getCookieCode(
true))
1013 Desktop.desktop.login.setupLogin();
1015 window.clearInterval(Desktop.desktop.checkMailboxTimer);
1016 Desktop.desktop.checkMailboxTimer = setInterval(_checkMailboxes,
1017 _MAILBOX_TIMER_PERIOD);
1029 this.refreshDesktop =
function() {
1032 for(var i=0; i<Desktop.desktop.getNumberOfWindows();++i)
1034 Desktop.desktop.refreshWindowById(Desktop.desktop.getWindowByIndex(i));
1042 this.actOnParameterAction =
function() {
1052 var paramsStr = window.parent.window.location.search.substr(1);
1054 var paramCnt = 5 + (Desktop.isWizardMode()?1:0);
1055 var spliti, splitiOld = 0;
1056 for(var i=0;i<paramCnt;++i)
1060 params.push(paramsStr.substr(splitiOld));
1064 spliti = paramsStr.indexOf(
'&', splitiOld);
1065 params.push(paramsStr.substr(splitiOld,spliti-splitiOld))
1066 splitiOld = spliti+1;
1070 var requestingWindowId =
"", windowPath =
"";
1071 var windowName, windowSubname, windowUnique, newWindowOps;
1072 for(var i=0;i<params.length;++i)
1074 spliti = params[i].indexOf(
'=');
1075 varPair = [params[i].substr(0,spliti),params[i].substr(spliti+1)];
1076 if(varPair[0] ==
"requestingWindowId")
1077 requestingWindowId = varPair[1];
1078 else if(varPair[0] ==
"windowPath")
1079 windowPath = decodeURIComponent(varPair[1]);
1080 else if(varPair[0] ==
"windowName")
1081 windowName = varPair[1];
1082 else if(varPair[0] ==
"windowSubname")
1083 windowSubname = varPair[1];
1084 else if(varPair[0] ==
"windowUnique")
1085 windowUnique = varPair[1];
1088 if(windowPath.indexOf(
"newWindowOps") >= 0)
1091 newWindowOps = windowPath.split(
'&')[1].split(
'=')[1];
1092 windowPath = windowPath.split(
'&')[0];
1114 if(requestingWindowId !=
"" && windowPath !=
"")
1117 Debug.log(
"_openWindowMailbox.innerHTML=" + _openWindowMailbox.innerHTML);
1118 Debug.log(
"requestingWindowId=" + requestingWindowId);
1119 Debug.log(
"windowPath=" + windowPath);
1120 if(newWindowOps) newWindowOps = newWindowOps.replace(/%22/g,
"\"");
1121 Debug.log(
"newWindowOps=" + newWindowOps);
1122 windowName = windowName.replace(/%20/g,
" ");
1123 Debug.log(
"windowName=" + windowName);
1124 windowSubname = windowSubname.replace(/%20/g,
" ");
1125 Debug.log(
"windowSubname=" + windowSubname);
1126 Debug.log(
"windowUnique=" + windowUnique);
1132 if(windowName.indexOf(
"Desktop.openLayout(") == 0)
1134 var layoutIndex = windowName.substr((
"Desktop.openLayout(").length,
1135 windowName.length-1-(
"Desktop.openLayout(").length) | 0;
1136 Debug.log(
"Opening layout... " + layoutIndex);
1138 if(pathUniquePair ===
1142 if(_firstCheckOfMailboxes)
1144 Debug.log(
"Perhaps user layout preferences have not been setup yet, try again at mailbox check.");
1150 _firstCheckOfMailboxes =
false;
1152 Desktop.desktop.dashboard.toggleWindowDashboard(0,
false);
1153 Desktop.desktop.defaultLayoutSelect(layoutIndex);
1159 if(windowSubname ==
"undefined" &&
1160 windowUnique ==
"undefined")
1162 Debug.log(
"Opening desktop window... " + windowName);
1165 var pathUniquePair = Desktop.desktop.icons.iconNameToPathMap[windowName];
1166 console.log(
"Desktop.desktop.icons.iconNameToPathMap",
1167 Desktop.desktop.icons.iconNameToPathMap);
1169 if(pathUniquePair ===
1173 if(_firstCheckOfMailboxes)
1175 Debug.log(
"Perhaps icons have not been setup yet, try again at mailbox check.");
1179 Debug.log(
"An error occurred opening the window named '" +
1180 windowName +
"' - it was not found in the Desktop icons. " +
1181 "Do you have permissions to access this window? Notify admins if the problem persists.",
1182 Debug.HIGH_PRIORITY);
1186 _openWindowMailbox.innerHTML =
"";
1189 var pathStr = pathUniquePair[0];
1191 if(windowPath !=
"undefined")
1193 Debug.log(
"Adding parameter path " + windowPath);
1195 if(pathStr.indexOf(
'&') > 0)
1197 else if(pathStr.indexOf(
'?') > 0 &&
1198 pathStr[pathStr.length-1] !=
'?')
1200 else if(pathStr.length &&
1201 pathStr[pathStr.lengh-1] !=
'?')
1203 windowPath = pathStr + windowPath;
1206 windowPath = pathStr;
1208 newWin = Desktop.desktop.addWindow(
1212 ((windowPath.indexOf(
'?') < 0)?
"?":
"&") +
1213 ((newWindowOps)?
"newWindowOps=" + newWindowOps:
""),
1214 eval(pathUniquePair[1]));
1218 _firstCheckOfMailboxes =
false;
1219 newWin = Desktop.desktop.addWindow(
1223 ((windowPath.indexOf(
'?') < 0)?
"?":
"&") +
1224 ((newWindowOps)?
"newWindowOps=" + newWindowOps:
""),
1225 eval(windowUnique));
1230 Desktop.desktop.dashboard.toggleWindowDashboard(0,
false);
1234 setTimeout(
function(){
1235 Desktop.desktop.setForeWindow(newWin);
1236 Desktop.desktop.toggleFullScreen();
1240 _openWindowMailbox.innerHTML =
"";
1249 _desktopElement = document.createElement(
"div");
1250 _desktopElement.setAttribute(
"id",
"Desktop");
1251 document.body.appendChild(_desktopElement);
1252 document.body.onmousemove = Desktop.handleBodyMouseMove;
1253 window.onmouseup = Desktop.handleWindowMouseUp;
1254 document.body.addEventListener(
'touchmove',Desktop.handleBodyTouchMove);
1255 document.body.addEventListener(
'touchend',Desktop.handleBodyTouchEnd);
1256 window.onresize = _handleDesktopResize;
1257 Desktop.desktop =
this;
1260 _windowZmailbox = document.createElement(
"div");
1261 _windowZmailbox.setAttribute(
"id",
"Desktop-windowZmailbox");
1262 _windowZmailbox.innerHTML = _defaultWindowMaxZindex;
1263 _windowZmailbox.style.display =
"none";
1264 _desktopElement.appendChild(_windowZmailbox);
1267 _mouseOverXmailbox = document.createElement(
"div");
1268 _mouseOverXmailbox.setAttribute(
"id",
"Desktop-mouseOverXmailbox");
1269 _mouseOverXmailbox.style.display =
"none";
1270 _desktopElement.appendChild(_mouseOverXmailbox);
1273 _mouseOverYmailbox = document.createElement(
"div");
1274 _mouseOverYmailbox.setAttribute(
"id",
"Desktop-mouseOverYmailbox");
1275 _mouseOverYmailbox.style.display =
"none";
1276 _desktopElement.appendChild(_mouseOverYmailbox);
1277 this.resetFrameMouse();
1280 var tmpHiddenDiv = document.createElement(
"div");
1281 tmpHiddenDiv.setAttribute(
"id",
"DesktopContent-cookieCodeMailbox");
1282 tmpHiddenDiv.style.display =
"none";
1283 _desktopElement.appendChild(tmpHiddenDiv);
1284 _updateTimeMailbox = document.createElement(
"div");
1285 _updateTimeMailbox.setAttribute(
"id",
"DesktopContent-updateTimeMailbox");
1286 _updateTimeMailbox.style.display =
"none";
1287 _desktopElement.appendChild(_updateTimeMailbox);
1288 _needToLoginMailbox = document.createElement(
"div");
1289 _needToLoginMailbox.setAttribute(
"id",
"DesktopContent-needToLoginMailbox");
1290 _needToLoginMailbox.style.display =
"none";
1291 _desktopElement.appendChild(_needToLoginMailbox);
1293 _blockSystemCheckMailbox = document.createElement(
"div");
1294 _blockSystemCheckMailbox.setAttribute(
"id",
"DesktopContent-blockSystemCheckMailbox");
1295 _blockSystemCheckMailbox.style.display =
"none";
1296 _desktopElement.appendChild(_blockSystemCheckMailbox);
1301 _openWindowMailbox = document.createElement(
"div");
1302 _openWindowMailbox.setAttribute(
"id",
"DesktopContent-openWindowMailbox");
1303 _openWindowMailbox.style.display =
"none";
1304 _desktopElement.appendChild(_openWindowMailbox);
1307 _updateSettingsMailbox = document.createElement(
"div");
1308 _updateSettingsMailbox.setAttribute(
"id",
"DesktopContent-updateSettingsMailbox");
1309 _updateSettingsMailbox.style.display =
"none";
1310 _updateSettingsMailbox.innerHTML =
"";
1311 _desktopElement.appendChild(_updateSettingsMailbox);
1312 _settingsLayoutMailbox = document.createElement(
"div");
1313 _settingsLayoutMailbox.setAttribute(
"id",
"DesktopContent-settingsLayoutMailbox");
1314 _settingsLayoutMailbox.style.display =
"none";
1315 _settingsLayoutMailbox.innerHTML =
"";
1316 _desktopElement.appendChild(_settingsLayoutMailbox);
1319 _windowColorPostbox = document.createElement(
"div");
1320 _windowColorPostbox.setAttribute(
"id",
"DesktopContent-windowColorPostbox");
1321 _windowColorPostbox.style.display =
"none";
1322 _windowColorPostbox.innerHTML = this.defaultWindowsFrameColor;
1323 _desktopElement.appendChild(_windowColorPostbox);
1327 this.dashboard = _dashboard = Desktop.createDashboard(_defaultDashboardZindex);
1328 _desktopElement.appendChild(_dashboard.dashboardElement);
1331 this.icons = _icons = Desktop.createIcons(0);
1332 _desktopElement.appendChild(_icons.iconsElement);
1334 _handleDesktopResize();
1336 this.checkMailboxTimer = setInterval(_checkMailboxes,_MAILBOX_TIMER_PERIOD);
1339 this.login = _login =
new Desktop.login(!(this.security == Desktop.SECURITY_TYPE_NONE));
1341 _desktopElement.appendChild(_login.loginDiv);
1343 Debug.log(
"Desktop Created",Debug.LOW_PRIORITY);
1345 Debug.log(
"Checking for any shortcut work from get parameters...",Debug.LOW_PRIORITY);
1346 Desktop.desktop.actOnParameterAction();
1355 Desktop.foreWinLastMouse = [-1,-1];
1356 Desktop.winManipMode = -1;
1357 Desktop.stretchAndMoveInterval = 0;
1358 Desktop.disableMouseDown = 0;
1365 Desktop.handleTouchStart =
function(touchEvent) {
1366 Desktop.disableMouseDown = 1;
1367 var touch = touchEvent.targetTouches[0];
1369 var winId = this.
id.split(
'-')[1];
1370 var isDashboard = (winId ==
"windowDashboard");
1373 win = Desktop.desktop.getWindowById(winId);
1374 if(win == -1)
return false;
1375 if(win.isMaximized()) {this.style.cursor =
"default";
return false;}
1378 if(Desktop.desktop.getForeWindow() != win)
1379 Desktop.desktop.setForeWindow(win);
1384 if(Desktop.foreWinLastMouse[0] == -1) {
1385 var locX = touch.pageX - this.offsetLeft;
1386 var locY = touch.pageY - this.offsetTop;
1390 Desktop.desktop.getForeWindow().hideFrame();
1392 Desktop.foreWinLastMouse = [touch.pageX,touch.pageY];
1394 if(locY < win.getWindowHeaderHeight()) {
1395 Desktop.winManipMode = 0;
1404 Desktop.handleBodyTouchEnd =
function(touchEvent) {Desktop.handleTouchEnd(touchEvent);}
1405 Desktop.handleTouchEnd =
function(touchEvent) {
1407 if(Desktop.foreWinLastMouse[0] != -1)
1409 Desktop.foreWinLastMouse = [-1,-1];
1410 Desktop.winManipMode = -1;
1411 if(Desktop.desktop.getForeWindow()) Desktop.desktop.getForeWindow().showFrame();
1418 Desktop.handleBodyTouchMove =
function(touchEvent) {Desktop.handleTouchMove(touchEvent);}
1419 Desktop.handleTouchMove =
function(touchEvent) {
1420 if(Desktop.winManipMode != -1 && Desktop.foreWinLastMouse[0] != -1)
1422 touchEvent.preventDefault();
1423 touchEvent.cancelBubble=
true;
1425 var touch = touchEvent.targetTouches[0];
1426 var delta = [touch.pageX-Desktop.foreWinLastMouse[0], touch.pageY-Desktop.foreWinLastMouse[1]];
1428 Desktop.desktop.getForeWindow().moveWindowByOffset(delta[0],delta[1]);
1429 Desktop.foreWinLastMouse = [touch.pageX,touch.pageY];
1436 Desktop.handleWindowMouseDown =
function(mouseEvent) {
1437 var winId = this.
id.split(
'-')[1];
1438 var isDashboard = (winId ==
"windowDashboard");
1441 win = Desktop.desktop.getWindowById(winId);
1442 if(win == -1)
return false;
1445 if(Desktop.desktop.getForeWindow() != win)
1446 Desktop.desktop.setForeWindow(win);
1450 if(!Desktop.disableMouseDown && Desktop.winManipMode != -1 &&
this.style.cursor !=
"default")
1453 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1454 if(!isDashboard) Desktop.desktop.getForeWindow().hideFrame();
1465 Desktop.handleWindowMouseUp =
function(mouseEvent) {
1467 if(Desktop.foreWinLastMouse[0] != -1)
1469 if(Desktop.stretchAndMoveInterval) {
1470 clearInterval(Desktop.stretchAndMoveInterval);
1471 Desktop.stretchAndMoveInterval = 0;
1474 Desktop.foreWinLastMouse = [-1,-1];
1475 Desktop.winManipMode = -1;
1476 if(Desktop.desktop.getForeWindow()) Desktop.desktop.getForeWindow().showFrame();
1480 Desktop.desktop.icons.closeFolder();
1485 Desktop.handleWindowMouseMove =
function(mouseEvent) {
1486 var winId = this.
id.split(
'-')[1];
1487 var isDashboard = (winId ==
"windowDashboard");
1490 win = Desktop.desktop.getWindowById(winId);
1491 if(win == -1)
return false;
1492 if(win.isMaximized()) {this.style.cursor =
"default";
return false;}
1496 if(Desktop.foreWinLastMouse[0] == -1) {
1497 var locX = mouseEvent.clientX - this.offsetLeft;
1498 var locY = mouseEvent.clientY - this.offsetTop;
1500 var hotCornerSz = 7;
1502 if(locX > Desktop.desktop.dashboard.getDashboardWidth() - hotCornerSz) {
1503 this.style.cursor =
"e-resize";
1504 Desktop.winManipMode = 100;
1507 this.style.cursor =
"default";
1510 if((locX < hotCornerSz && locY < hotCornerSz) ||
1511 (locX > win.getWindowWidth() - hotCornerSz && locY > win.getWindowHeight() - hotCornerSz)) {
1512 this.style.cursor =
"nw-resize";
1513 Desktop.winManipMode = locY < hotCornerSz?1:2;
1515 else if((locX > win.getWindowWidth() - hotCornerSz && locY < hotCornerSz) ||
1516 (locX < hotCornerSz && locY > win.getWindowHeight() - hotCornerSz)) {
1517 this.style.cursor =
"ne-resize";
1518 Desktop.winManipMode = locY < hotCornerSz?3:4;
1520 else if(locX < hotCornerSz) {
1521 this.style.cursor =
"w-resize";
1522 Desktop.winManipMode = 5;
1524 else if(locX > win.getWindowWidth() - hotCornerSz) {
1525 this.style.cursor =
"e-resize";
1526 Desktop.winManipMode = 6;
1528 else if(locY < hotCornerSz) {
1529 this.style.cursor =
"n-resize";
1530 Desktop.winManipMode = 7;
1532 else if(locY > win.getWindowHeight() - hotCornerSz) {
1533 this.style.cursor =
"s-resize";
1534 Desktop.winManipMode = 8;
1536 else if(locY < win.getWindowHeaderHeight()) {
1537 this.style.cursor =
"all-scroll";
1538 Desktop.winManipMode = 0;
1541 this.style.cursor =
"default";
1546 Desktop.handleBodyMouseMove(mouseEvent);
1551 Desktop._mouseMoveSubscribers = [];
1553 Desktop.mouseMoveSubscriber =
function(newHandler) {
1554 Desktop._mouseMoveSubscribers.push(newHandler);
1561 Desktop.handleBodyMouseMove =
function(mouseEvent) {
1564 for(var i=0; i<Desktop._mouseMoveSubscribers.length; ++i)
1565 Desktop._mouseMoveSubscribers[i](mouseEvent);
1567 Desktop.desktop.resetFrameMouse();
1570 if(Desktop.foreWinLastMouse[0] != -1 && Desktop.winManipMode == 100) {
1572 if(mouseEvent.which == 0)
1573 return Desktop.handleWindowMouseUp(mouseEvent);
1575 var delta = mouseEvent.clientX-Desktop.foreWinLastMouse[0];
1576 Desktop.desktop.dashboard.setDashboardWidth(Desktop.desktop.dashboard.getDashboardWidth()+delta);
1577 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1579 if(Desktop.stretchAndMoveInterval == 0)
1580 Desktop.stretchAndMoveInterval = setInterval(
1582 if(Desktop.desktop.getLastFrameMouseX() == -1)
return;
1584 var delta = Desktop.desktop.getLastFrameMouseX()-Desktop.foreWinLastMouse[0];
1585 Desktop.desktop.dashboard.setDashboardWidth(Desktop.desktop.dashboard.getDashboardWidth()+delta);
1586 Desktop.foreWinLastMouse = [Desktop.desktop.getLastFrameMouseX(),Desktop.desktop.getLastFrameMouseY()];
1593 if(!Desktop.desktop.getForeWindow())
return true;
1595 if(Desktop.foreWinLastMouse[0] != -1)
1597 if(mouseEvent.which == 0)
1598 return Desktop.handleWindowMouseUp(mouseEvent);
1600 var delta = [mouseEvent.clientX-Desktop.foreWinLastMouse[0], mouseEvent.clientY-Desktop.foreWinLastMouse[1]];
1602 Desktop.handleWindowManipulation(delta);
1604 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1606 if(Desktop.stretchAndMoveInterval == 0)
1607 Desktop.stretchAndMoveInterval = setInterval(
1609 if(Desktop.desktop.getLastFrameMouseX() == -1)
return;
1611 var delta = [Desktop.desktop.getLastFrameMouseX()-Desktop.foreWinLastMouse[0],
1612 Desktop.desktop.getLastFrameMouseY()-Desktop.foreWinLastMouse[1]];
1613 Desktop.handleWindowManipulation(delta);
1614 Desktop.foreWinLastMouse = [Desktop.desktop.getLastFrameMouseX(),Desktop.desktop.getLastFrameMouseY()];
1624 Desktop.handleWindowManipulation =
function(delta) {
1625 if(!Desktop.desktop.getForeWindow())
return false;
1627 var win = Desktop.desktop.getForeWindow();
1629 switch(Desktop.winManipMode) {
1631 win.moveWindowByOffset(delta[0],delta[1]);
1634 win.resizeAndPositionWindow(
1635 win.getWindowX() + delta[0],
1636 win.getWindowY() + delta[1],
1637 win.getWindowWidth() - delta[0],
1638 win.getWindowHeight() - delta[1]);
1641 win.resizeAndPositionWindow(
1644 win.getWindowWidth() + delta[0],
1645 win.getWindowHeight() + delta[1]);
1648 win.resizeAndPositionWindow(
1650 win.getWindowY() + delta[1],
1651 win.getWindowWidth() + delta[0],
1652 win.getWindowHeight() - delta[1]);
1655 win.resizeAndPositionWindow(
1656 win.getWindowX() + delta[0],
1658 win.getWindowWidth() - delta[0],
1659 win.getWindowHeight() + delta[1]);
1662 win.resizeAndPositionWindow(
1663 win.getWindowX() + delta[0],
1665 win.getWindowWidth() - delta[0],
1666 win.getWindowHeight());
1669 win.resizeAndPositionWindow(
1672 win.getWindowWidth() + delta[0],
1673 win.getWindowHeight());
1676 win.resizeAndPositionWindow(
1678 win.getWindowY() + delta[1],
1679 win.getWindowWidth(),
1680 win.getWindowHeight() - delta[1]);
1683 win.resizeAndPositionWindow(
1686 win.getWindowWidth(),
1687 win.getWindowHeight() + delta[1]);
1693 Desktop.handleWindowButtonDown =
function(mouseEvent) {
1694 mouseEvent.cancelBubble=
true;
1698 Desktop.handleWindowRefresh =
function(mouseEvent){
1699 Debug.log(
"Refresh " + this.
id.split(
'-')[1]);
1700 Desktop.desktop.refreshWindowById(this.
id.split(
'-')[1]);
1704 Desktop.handleWindowHelp =
function (mouseEvent) {
1705 Debug.log(
"Help " + this.
id.split(
'-')[1]);
1706 Desktop.desktop.windowHelpById(this.
id.split(
'-')[1]);
1711 Desktop.handleFullScreenWindowRefresh =
function(mouseEvent){
1712 Debug.log(
"Refresh Full Screen Window");
1714 var foreWindowId = undefined;
1717 foreWindowId = Desktop.desktop.getForeWindow().getWindowId();
1721 Debug.log(
"Could not find foreground window, ignoring.");
1725 Desktop.desktop.resetDesktop();
1726 Desktop.desktop.refreshDesktop();
1728 var foreWindow = undefined;
1729 var isMaxWindow = undefined;
1747 for(var i = 0; i < Desktop.desktop.getNumberOfWindows(); i++)
1749 var window = Desktop.desktop.getWindowByIndex(0);
1750 var
id = window.getWindowId();
1752 Debug.log(
"name: " + i +
" " + window.getWindowName());
1753 Debug.log(
"ID: " +
id);
1755 var maximized = window.isMaximized();
1758 Desktop.desktop.setForeWindow(window);
1759 window = Desktop.desktop.refreshWindow();
1762 isMaxWindow = window;
1764 if(foreWindowId ==
id)
1765 foreWindow = window;
1780 Desktop.desktop.setForeWindow(foreWindow);
1782 Desktop.desktop.setForeWindow(foreWindow);
1797 Desktop.handleWindowMinimize =
function(mouseEvent) {
1798 Debug.log(
"minimize " + this.
id.split(
'-')[1]);
1799 Desktop.desktop.minimizeWindowById(this.
id.split(
'-')[1]);
1803 Desktop.handleWindowMaximize =
function(mouseEvent) {
1804 Debug.log(
"maximize " + this.
id.split(
'-')[1]);
1805 Desktop.desktop.maximizeWindowById(this.
id.split(
'-')[1]);
1809 Desktop.handleWindowClose =
function(mouseEvent) {
1811 Desktop.desktop.closeWindowById(this.
id.split(
'-')[1]);
1822 Desktop.XMLHttpRequest =
function(requestURL, data, returnHandler, reqIndex) {
1825 var req =
new XMLHttpRequest();
1827 req.onreadystatechange =
function() {
1828 if (req.readyState==4) {
1833 if(!Desktop.desktop.serverConnected)
1835 Desktop.desktop.serverConnected =
true;
1836 Desktop.desktop.dashboard.displayConnectionStatus(
true);
1838 Desktop.desktop.resetDesktop();
1843 if(req.responseText == Globals.REQ_NO_PERMISSION_RESPONSE)
1845 errStr =
"Request failed do to insufficient account permissions.";
1848 else if(req.responseText == Globals.REQ_NO_LOGIN_RESPONSE)
1850 errStr =
"Login has expired.";
1852 window.clearInterval(Desktop.desktop.checkMailboxTimer);
1863 if(Desktop.desktop.serverConnected)
1865 Desktop.desktop.serverConnected =
false;
1866 Desktop.desktop.dashboard.displayConnectionStatus(
false);
1869 errStr =
"Request Failed - Bad Address:\n" + requestURL;
1870 window.clearInterval(Desktop.desktop.checkMailboxTimer);
1876 errStr +=
"\n\n(Try refreshing the page, or alert ots admins if problem persists.)";
1877 Debug.log(
"Error: " + errStr,Debug.HIGH_PRIORITY);
1881 Debug.log(
"The user interface is disconnected from the ots Gateway server.", Debug.HIGH_PRIORITY);
1883 document.getElementById(
"DesktopDashboard-userWithLock").style.display =
"none";
1885 if(returnHandler) returnHandler(req,reqIndex,errStr);
1889 if(Desktop.desktop.login)
1890 data =
"CookieCode="+Desktop.desktop.login.getCookieCode()+
"&"+data;
1891 requestURL =
"/urn:xdaq-application:lid="+urnLid+
"/"+requestURL;
1893 req.open(
"POST",requestURL,
true);
1895 req.setRequestHeader(
"Content-Type",
"text/plain;charset=UTF-8");
1900 Desktop.getXMLAttributeValue =
function(req, name, attribute) {
1901 if(req && req.responseXML && req.responseXML.getElementsByTagName(name).length > 0)
1902 return req.responseXML.getElementsByTagName(name)[0].getAttribute(attribute);
1909 Desktop.getXMLValue =
function(req, name) {
1910 return Desktop.getXMLAttributeValue(req,name,
"value");
1915 Desktop.logout =
function () {
1916 if(Desktop.desktop && Desktop.desktop.login &&
1917 !Desktop.desktop.login.isBlackout())
1918 Desktop.desktop.login.logout();
1922 Desktop.formatTime =
function(t) {
1923 var date =
new Date(t * 1000);
1924 var mm = date.getMinutes() < 10?
"0"+date.getMinutes():date.getMinutes();
1925 var ss = date.getSeconds() < 10?
"0"+date.getSeconds():date.getSeconds();
1926 return date.getHours() +
":" + mm +
":" + ss;
1930 Desktop.closeSystemMessage =
function(id) {
1931 var el = document.getElementById(
"Desktop-systemMessageBox-" +
id);
1932 el.parentNode.removeChild(el);
1936 Desktop.isWizardMode =
function() {
1938 Debug.log(
"Desktop Security: " + Desktop.desktop.security);
1940 return !(!Desktop.desktop.security ||
1941 Desktop.desktop.security == Desktop.SECURITY_TYPE_DIGEST_ACCESS ||
1942 Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE);
1946 Desktop.openNewBrowserTab =
function(name,subname,windowPath,unique) {
1952 var i = windowPath.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
1953 var isAllNumbers =
true;
1954 for(i;i<windowPath.length;++i)
1956 Debug.log(windowPath[i]);
1958 if(windowPath[i] <
"0" || windowPath[i] >
"9")
1960 isAllNumbers =
false;
1967 Debug.log(
"DesktopWindow= " + windowPath);
1969 Debug.log(
"name= " + name);
1970 Debug.log(
"subname= " + subname);
1971 Debug.log(
"unique= " + unique);
1972 var search = window.parent.window.location.search;
1973 url = window.parent.window.location.pathname;
1975 var str =
"requestingWindowId=Desktop";
1976 str +=
"&windowName=" + name;
1977 str +=
"&windowSubname=" + subname;
1978 str +=
"&windowUnique=" + unique;
1979 str +=
"&windowPath=" + encodeURIComponent(windowPath);
1984 if(!Desktop.isWizardMode())
1986 var i = url.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
1987 var isAllNumbers =
true;
1988 for(i;i<url.length;++i)
1992 if(url[i] <
"0" || url[i] >
"9")
1994 isAllNumbers =
false;
2004 url += search.split(
'&')[0] +
"&" + str;
2007 Debug.log(
"DesktopContent.openNewBrowserTab= " + url);
2009 window.open(url,
'_blank');
2014 Desktop.desktopTooltip =
function() {
2016 DesktopContent.tooltip(
"Desktop Introduction",
2017 "Welcome to the <i>otsdaq</i> Desktop environment. This is your portal " +
2018 "to all of the possibilities of <i>otsdaq</i>.\n\n" +
2019 "Briefly, here are the features:" +
2021 "\n\t- <b>Desktop Window Icons:</b> " +
2023 "Click the rounded-square icons on your Desktop to open " +
2024 "a particular window. If you hold down your click (for a second), you " +
2025 "can open the window in fullscreen, or in a new tab, or even open the window " +
2026 "then tile it on the screen with all other open windows!" +
2029 "\n\t- <b>Desktop Dashboard (top pane):</b> " +
2031 "Along the top and left margins of the Desktop, you will find the Desktop " +
2032 "Dashboard - this section is an introduction to the top pane of the Dashboard. " +
2033 "The top pane of the Dashboard " +
2034 "is made of buttons and icons going from left to right:" +
2036 "\n\t- <b>Left Pane Toggler:</b> " +
2038 "The first button you will encounter in the top pane looks like a horizontal double-arrow " +
2039 "icon. This button toggles the display of the left pane of the Dashboard. Note when you " +
2040 "refresh the page, the state of the left pane persists!" +
2043 "\n\t- <b>Layouts Menu:</b> " +
2045 "The next button you will encounter in the top pane reads 'Layouts.' " +
2046 "This button gives you access to your Window Layout Presets. You will see 2 'System' presets there " +
2047 "which can be setup by uesrs with admin privileges. There are also 3 'User' presets which you can setup for " +
2048 "yourself in the User Settings window (get there with " +
2049 "the cog wheel icon in the upper-right of the Desktop)." +
2052 "\n\t- <b>Tile Desktop Windows:</b> " +
2054 "The next button you will encounter in the top pane reads 'Tile.' " +
2055 "This button will automatically tile all open Desktop Windows to fit in your browser window." +
2058 "\n\t- <b>Show Desktop:</b> " +
2060 "The next button you will encounter in the top pane reads 'Show Desktop.' " +
2061 "This button will minimize all open Desktop Windows which is nice " +
2062 "when you want to see all of your Desktop Icons again." +
2065 "\n\t- <b>Full Screen:</b> " +
2067 "The next button you will encounter in the top pane reads 'Full Screen.' " +
2068 "This button will maximize to full screen the Desktop Window that was last used (i.e. the window that has the focus)." +
2072 "\n\t- <b>Desktop Dashboard (left pane):</b> " +
2074 "Along the top and left margins of the Desktop, you will find the Desktop " +
2075 "Dashboard - this section is an introduction to the left pane of the Dashboard. " +
2076 "The left pane of the Dashboard " +
2077 "is a listing of all open Desktop Windows. If you click one of the buttons in the list, " +
2078 "the associated window " +
2079 "will be minimized or restored. If you hold down your click (for one second) you can choose " +
2080 "to minimize, maximize, or close the window!" +
2085 "\n\nRemember, if you would like to take a look at the available online documentation, " +
2086 "click the question mark at the top-right of the Desktop."