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, _mouseOverXmailbox, _mouseOverYmailbox;
155 var _updateSettingsMailbox,
156 _settingsLayoutMailbox;
159 var _MAILBOX_TIMER_PERIOD = 500;
161 var _SYS_MSG_SOUND_PATH =
"/WebPath/sounds/fx-System-Message.wav";
162 var _sysMsgSound =
new Audio(_SYS_MSG_SOUND_PATH);
169 var _sysMsgCounter = 0;
170 var _SYS_MSG_MAX_COUNT = 10;
172 var _firstCheckOfMailboxes =
true;
180 this.checkMailboxTimer;
181 this.serverConnected =
true;
182 this.security = security;
186 this.defaultWindowFrameColor =
"rgba(196,229,255,.9)";
193 var _handleDesktopResize =
function(event) {
194 _desktopElement.style.height = (window.innerHeight-_desktopElement.offsetTop) +
"px";
195 _desktopElement.style.width = (window.innerWidth-_desktopElement.offsetLeft) +
"px";
196 if(!_dashboard)
return;
197 _dashboard.redrawDashboard();
198 if(_login) _login.redrawLogin();
199 if(_icons) _icons.redrawIcons();
202 if(_windows.length && _windows[_windows.length-1].isMaximized()) {
203 var w = _windows[_windows.length-1];
204 w.setWindowSizeAndPosition(w.getWindowX(),w.getWindowY(),w.getWindowWidth(),w.getWindowHeight());
215 var _getWindowLayoutStr =
function() {
216 var dw = Desktop.desktop.getDesktopContentWidth()/10000.0;
217 var dh = Desktop.desktop.getDesktopContentHeight()/10000.0;
218 var dx = Desktop.desktop.getDesktopContentX();
219 var dy = Desktop.desktop.getDesktopContentY();
222 for(var i=0;i<_windows.length;++i)
224 if(_windows[i].getWindowName() ==
"Settings")
continue;
226 layout += (i?
",":
"") +
227 encodeURIComponent(_windows[i].getWindowName())
228 +
"," + encodeURIComponent(_windows[i].getWindowSubName())
229 +
"," + encodeURIComponent(_windows[i].getWindowUrl())
230 +
"," + (((_windows[i].getWindowX()-dx)/dw)|0)
231 +
"," + (((_windows[i].getWindowY()-dy)/dh)|0)
232 +
"," + ((_windows[i].getWindowWidth()/dw)|0)
233 +
"," + ((_windows[i].getWindowHeight()/dh)|0)
234 +
"," + (_windows[i].isMinimized()?
"0":(_windows[i].isMaximized()?
"2":
"1"));
243 var _scrambleEggs =
function(u) {
return u; }
246 var _getForeWindow =
function() {
return _windows.length?_windows[_windows.length-1]:0; }
249 var _closeWindow =
function(win) {
250 Desktop.desktop.setForeWindow(win);
251 win.windiv.parentNode.removeChild(win.windiv);
255 _windows.splice(_windows.length-1,1);
258 _dashboard.updateWindows();
266 var _checkMailboxes =
function(win)
268 window.clearTimeout(Desktop.desktop.checkMailboxTimer);
269 Desktop.desktop.checkMailboxTimer = window.setTimeout(_checkMailboxes,
270 _MAILBOX_TIMER_PERIOD);
274 if(_firstCheckOfMailboxes)
276 console.log(
"First check of mailboxes!");
278 console.log(
"Checking for any shortcut work from get parameters...");
279 _firstCheckOfMailboxes =
false;
280 Desktop.desktop.actOnParameterAction();
431 if(!Desktop.desktop.login || !Desktop.desktop.login.getCookieCode(
true))
469 if(_updateSettingsMailbox.innerHTML !=
"")
475 if(_updateSettingsMailbox.innerHTML ==
"LAYOUT")
478 var layout = _getWindowLayoutStr();
479 _settingsLayoutMailbox.innerHTML = layout;
480 Debug.log(
"Desktop _updateSettingsMailbox " + layout,Debug.LOW_PRIORITY);
485 var xml = _updateSettingsMailbox.innerHTML;
487 req.responseXML = (
new window.DOMParser() ).parseFromString(xml,
"text/xml");
488 _login.applyUserPreferences(req);
491 _updateSettingsMailbox.innerHTML =
"";
496 if(_sysMsgCounter == _SYS_MSG_MAX_COUNT)
500 Desktop.desktop.login.isBlackout())
502 Debug.log(
"System blackout (likely rebooting)...");
506 Desktop.XMLHttpRequest(
"Request?RequestType=getSystemMessages",
"",_handleSystemMessages);
511 var _lastSystemMessage =
"";
514 var _handleSystemMessages =
function(req)
523 userLock = Desktop.getXMLValue(req,
"username_with_lock");
524 Desktop.desktop.dashboard.displayUserLock(userLock);
526 var tmp = Desktop.getXMLValue(req,
"systemMessages");
533 if((tmpi = tmp.indexOf(_lastSystemMessage)) >= 0)
535 Debug.log(
"Desktop pretmp " + tmp);
536 Debug.log(
"Desktop _lastSystemMessage " + _lastSystemMessage);
537 Debug.log(
"Desktop tmp " + tmp.substr(tmpi+_lastSystemMessage.length+1));
538 tmp = tmp.substr(tmpi+_lastSystemMessage.length+1);
544 var msgArr = tmp.split(
"|");
545 Debug.log(
"Desktop msgArr.length " + msgArr.length);
547 if(msgArr.length < 2)
return;
549 Debug.log(
"Desktop _handleSystemMessages ========================== " + Desktop.formatTime(msgArr[0]) +
551 ,Debug.LOW_PRIORITY);
554 var sysMsgEl = document.createElement(
"div");
555 sysMsgEl.setAttribute(
"class",
"Desktop-systemMessageBox");
556 sysMsgEl.setAttribute(
"id",
"Desktop-systemMessageBox-" + _sysMsgId);
557 sysMsgEl.style.left = (50 + _sysMsgId % 5 * 10) +
"px";
558 sysMsgEl.style.top = (50 + _sysMsgId % 5 * 10) +
"px";
559 _desktopElement.appendChild(sysMsgEl);
563 for(var i=0;i<msgArr.length;i+=2)
565 str +=
"<div style='font-size:12px'>System Message Received at " + Desktop.formatTime(msgArr[i]) +
"</div>";
568 decodeURIComponent(msgArr[i+1]).replace(/[\u00A0-\u9999<>\&]/gim,
570 return '&#'+i.charCodeAt(0)+
';';
572 _lastSystemMessage = msgArr[i] +
"|" + msgArr[i+1];
576 str +=
"<div style='float:right; margin-left:30px'>";
577 str +=
"<a href='Javascript:Desktop.closeSystemMessage(" + _sysMsgId +
");' " +
578 "title='Click here to dismiss system message'>Dismiss</a></div>";
580 sysMsgEl.innerHTML = str;
582 if(sysMsgEl.clientHeight > 300)
583 sysMsgEl.style.height = 300 +
"px";
593 this.getDesktopWidth =
function() {
return _desktopElement.clientWidth;}
594 this.getDesktopHeight =
function() {
return _desktopElement.clientHeight;}
595 this.getDesktopX =
function() {
return _desktopElement.offsetLeft;}
596 this.getDesktopY =
function() {
return _desktopElement.offsetTop;}
597 this.getDesktopContentX =
function() {
return _desktopElement.offsetLeft+_dashboard.getDashboardWidth();}
598 this.getDesktopContentY =
function() {
return _desktopElement.offsetTop+_dashboard.getDashboardHeight();}
599 this.getDesktopContentWidth =
function() {
return _desktopElement.clientWidth-_dashboard.getDashboardWidth();}
600 this.getDesktopContentHeight =
function() {
return _desktopElement.clientHeight-_dashboard.getDashboardHeight();}
601 this.getNumberOfWindows =
function() {
return _windows.length;}
602 this.getWindowNameByIndex =
function(i) {
return _windows[i].getWindowName();}
603 this.getWindowSubNameByIndex =
function(i) {
return _windows[i].getWindowSubName();}
604 this.getWindowByIndex =
function(i) {
return _windows[i];}
605 this.getForeWindow = _getForeWindow;
606 this.redrawDesktop = _handleDesktopResize;
607 this.getLastFrameMouseX =
function() {
return parseInt(_mouseOverXmailbox);}
608 this.getLastFrameMouseY =
function() {
return parseInt(_mouseOverYmailbox);}
609 this.resetFrameMouse =
function() { _mouseOverXmailbox = -1;_mouseOverYmailbox = -1;}
610 this.getWindowLayoutStr = _getWindowLayoutStr;
625 this.addWindow =
function(name,subname,url,unique,extraStep)
627 Debug.log(name +
" - " + subname +
" - " + url +
" - " + unique,Debug.LOW_PRIORITY);
631 Debug.log(
"Opening stand-alone new tab",Debug.LOW_PRIORITY);
632 window.open(url,
'_blank');
638 Debug.log(
"Adding window uniquely",Debug.LOW_PRIORITY);
639 for(var i=0;i<_windows.length;++i)
640 if(_windows[i].getWindowName() == name && _windows[i].getWindowSubName() == subname)
642 Debug.log(
"Window creation failed. Not unique.",Debug.LOW_PRIORITY);
643 if(_windows[i].isMinimized())
645 Debug.log(_windows[i].getWindowSubName() +
"was minimized but will now be restored!");
646 _windows[i].unminimize();
649 Desktop.desktop.setForeWindow(_windows[i]);
654 if(_windows.length + _defaultWindowMinZindex >= _defaultWindowMaxZindex)
656 Debug.log(
"FAILED -- Desktop Window Added - too many windows!",Debug.HIGH_PRIORITY);
660 if(name ==
"Security Settings")
665 else if(name ==
"Edit User Data")
671 window_width = _defaultWidth;
672 window_height = _defaultHeight;
677 var newWin = Desktop.createWindow(_winId++,_windows.length + _defaultWindowMinZindex,name,subname,url,
678 window_width,window_height,_dashboard.getDashboardWidth() + _currentLeft,_currentTop);
681 if(_currentLeft > _defaultLeft+_defaultOffsetTimes*_defaultLeftOffset)
683 _currentLeft = _defaultLeft;
684 if(_currentTop > _defaultTop + (_defaultOffsetTimes+1)*_defaultTopOffset)
685 _currentTop = _defaultTop;
687 _currentTop = _defaultTop + _defaultTopOffset;
691 _currentLeft += _defaultLeftOffset;
692 _currentTop += _defaultTopOffset;
695 _windows.push(newWin);
697 _desktopElement.appendChild(newWin.windiv);
699 Debug.log(
"Desktop Window Added with id " + _windows[_windows.length-1].getWindowId(),Debug.LOW_PRIORITY);
701 _dashboard.updateWindows();
706 window.setTimeout(
function()
708 Desktop.desktop.setForeWindow(newWin);
709 Debug.log(
"extraStep=" + extraStep);
713 Desktop.desktop.dashboard.windowDashboardOrganize();
716 Desktop.desktop.toggleFullScreen();
729 this.getWindowById =
function(id)
731 for(var i=0;i<_windows.length;++i)
732 if(_windows[i].getWindowId() == id)
734 Debug.log(
"Window id="+
id+
" not found!",Debug.MED_PRIORITY);
741 this.setForeWindow =
function(win)
747 for(var i=0;i<_windows.length-1;++i)
750 for(var j=i+1;j<_windows.length;++j)
751 if(_windows[j].getWindowZ() < _windows[min].getWindowZ())
756 _windows[i] = _windows[min];
758 _windows[i].setWindowZ(i+_defaultWindowMinZindex);
760 _windows[_windows.length-1].setWindowZ(_windows.length-1+_defaultWindowMinZindex);
766 for(var i=0;win && i<=_windows.length;++i)
770 var winToMov = i<_windows.length?_windows[i]:win;
771 winToMov.setWindowZ(i-1 + _defaultWindowMinZindex);
772 _windows[i-1] = winToMov;
774 else if(_windows[i] == win) found = 1;
778 Debug.log(
"Desktop Foreground window not Found!! Window: " +
779 win.getWindowSubName());
781 _dashboard.updateWindows();
790 this.closeWindowById =
function(id)
792 var win = this.getWindowById(
id);
793 if(win == -1)
return -1;
800 this.maximizeWindowById =
function(id)
802 var win = this.getWindowById(
id);
803 if(win == -1)
return -1;
804 this.setForeWindow(win);
805 this.toggleFullScreen();
811 this.toggleFullScreen =
function(e)
813 if(!_getForeWindow())
return;
815 _getForeWindow().isMaximized() ? _getForeWindow().unmaximize(): _getForeWindow().maximize();
817 Desktop.desktop.redrawDashboardWindowButtons();
821 Debug.log(
"Full Screen Toggled",Debug.LOW_PRIORITY);
825 this.redrawDashboardWindowButtons =
function()
827 _dashboard.redrawFullScreenButton();
828 _dashboard.redrawRefreshButton();
829 _dashboard.redrawShowDesktopButton();
833 this.refreshWindowById =
function(id)
835 var win = this.getWindowById(
id);
836 if(win == -1)
return -1;
838 this.setForeWindow(win);
839 this.refreshWindow();
840 console.log(
"Finished refreshWindow() " +
id);
844 this.windowHelpById =
function (id)
846 var win = this.getWindowById(
id);
847 if (win == -1)
return -1;
849 this.setForeWindow(win);
850 var tempwin = Desktop.desktop.getForeWindow();
852 console.log(tempwin);
853 console.log(tempwin.windiv);
859 tooltipEl = tempwin.windiv.childNodes[2].childNodes[0].contentWindow.document.getElementById(
"otsDesktopWindowTooltipElement");
863 Debug.log(
"Ignoring error: " + e);
871 tooltipEl = tempwin.windiv.childNodes[2].childNodes[0].contentWindow.document.getElementsByTagName(
"frameset")[0].childNodes[0].contentWindow.document.getElementById(
"otsDesktopWindowTooltipElement");
875 Debug.log(
"Ignoring error: " + e);
883 DesktopContent.tooltip(
"ALWAYS",
"There is no tooltip for the " + tempwin.getWindowName() +
884 " window. Try visiting <a href='https://otsdaq.fnal.gov' target='_blank'>otsdaq.fnal.gov</a> for further assistance.");
888 DesktopContent.tooltip(
"ALWAYS", decodeURIComponent(tooltipEl.innerText));
893 this.refreshWindow =
function(e)
895 if(!_getForeWindow())
return;
898 var window = _getForeWindow();
899 var
id = window.getWindowId();
900 var z = window.getWindowZ();
901 var name = window.getWindowName();
902 var subname = window.getWindowSubName();
903 var url = window.getWindowUrl();
904 var width = window.getWindowWidth();
905 var height = window.getWindowHeight();
906 var x = window.getWindowX();
907 var y = window.getWindowY();
908 var isMax = window.isMaximized();
909 var isMin = window.isMinimized();
911 _closeWindow(window);
912 console.log(window,
id, z, name, width, height);
914 var newWindow = this.addWindow(name,subname,url);
915 newWindow.setWindowSizeAndPosition(x,y,width,height);
916 newWindow.setWindowZ(z);
919 newWindow.maximize();
921 newWindow.minimize();
931 this.minimizeWindowById =
function(id) {
932 var win = this.getWindowById(
id);
933 if(win == -1)
return -1;
935 this.setForeWindow(win);
936 this.toggleMinimize();
942 this.toggleMinimize =
function(e) {
943 if(!_getForeWindow())
return;
945 if(_getForeWindow().isMinimized())
946 _getForeWindow().unminimize();
948 _getForeWindow().minimize();
949 Debug.log(
"Minimize Toggled",Debug.LOW_PRIORITY);
958 this.clickedWindowDashboard =
function(id) {
959 var win = this.getWindowById(
id);
960 if(win == -1)
return -1;
961 if(_getForeWindow() != win) {
962 if(_getForeWindow().isMaximized()) this.toggleFullScreen();
963 this.setForeWindow(win);
964 if(_getForeWindow().isMinimized()) this.toggleMinimize();
968 this.toggleMinimize();
974 this.setDefaultWindowColor =
function(color) {
975 this.defaultWindowFrameColor = color;
978 for(var i=0;i<_windows.length;++i)
979 _windows[i].windiv.style.backgroundColor =
this.defaultWindowFrameColor;
987 this.defaultLayoutSelect =
function(i) {
988 Debug.log(
"Desktop defaultLayoutSelect " + i,Debug.LOW_PRIORITY);
991 var numOfUserLayouts = 5;
992 var numOfSystemLayouts = 5;
993 if(i >= numOfSystemLayouts+1 &&
994 i <= numOfSystemLayouts+1+numOfUserLayouts)
995 layoutStr = _login.getUserDefaultLayout(i-(numOfSystemLayouts+1));
996 else if(i >= 0 && i <= numOfSystemLayouts)
997 layoutStr = _login.getSystemDefaultLayout(i);
1000 Debug.log(
"Invalid layout index: " + i, Debug.HIGH_PRIORITY);
1003 var layoutArr = layoutStr.split(
",");
1005 var numOfFields = 8;
1006 var numOfWins = parseInt(layoutArr.length/numOfFields);
1008 Debug.log(
"Desktop defaultLayoutSelect layout numOfFields=" + numOfFields);
1009 Debug.log(
"Desktop defaultLayoutSelect layout " + numOfWins +
1010 " windows - " + layoutStr);
1013 Desktop.desktop.closeAllWindows();
1028 var dw = Desktop.desktop.getDesktopContentWidth()/10000.0;
1029 var dh = Desktop.desktop.getDesktopContentHeight()/10000.0;
1030 var dx = Desktop.desktop.getDesktopContentX();
1031 var dy = Desktop.desktop.getDesktopContentY();
1032 for(i=0;i<numOfWins;++i)
1034 Debug.log(
"adding " + layoutArr[i*numOfFields].substr(1) +
"-" + layoutArr[i*numOfFields+1],Debug.LOW_PRIORITY);
1036 decodeURIComponent(layoutArr[i*numOfFields]),
1037 decodeURIComponent(layoutArr[i*numOfFields+1]),
1038 decodeURIComponent(layoutArr[i*numOfFields+2]),
1040 _windows[_windows.length-1].setWindowSizeAndPosition(
1041 layoutArr[i*numOfFields+3]*dw + dx,
1042 layoutArr[i*numOfFields+4]*dh + dy,
1043 layoutArr[i*numOfFields+5]*dw,
1044 layoutArr[i*numOfFields+6]*dh);
1046 if((layoutArr[i*numOfFields+7]|0) == 0)
1047 _windows[_windows.length-1].minimize();
1048 else if((layoutArr[i*numOfFields+7]|0) == 2)
1049 _windows[_windows.length-1].maximize();
1056 this.closeAllWindows =
function()
1058 Debug.log(
"Desktop closeAllWindows",Debug.LOW_PRIORITY);
1060 while(_windows.length) _closeWindow(_windows[_windows.length-1]);
1066 this.resetDesktop =
function(permissions)
1068 Debug.log(
"reset desktop()");
1075 Desktop.desktop.icons.resetWithPermissions(permissions);
1078 if(!Desktop.desktop.serverConnected &&
1079 (!Desktop.desktop.login ||
1080 !Desktop.desktop.login.getCookieCode(
true)))
1082 Debug.log(
"Reset is setting up login...");
1083 Desktop.desktop.login.setupLogin();
1088 window.clearTimeout(Desktop.desktop.checkMailboxTimer);
1092 if(Desktop.desktop.login.getCookieCode(
true))
1093 Desktop.XMLHttpRequest(
"Request?RequestType=getSystemMessages",
"",
1094 _handleSystemMessages);
1100 this.refreshDesktop =
function()
1102 for(var i=0; i<Desktop.desktop.getNumberOfWindows();++i)
1103 Desktop.desktop.refreshWindowById(Desktop.desktop.getWindowByIndex(i));
1109 this.actOnParameterAction =
function()
1113 var paramsStr = window.parent.window.location.search.substr(1);
1115 var paramCnt = 5 + (Desktop.isWizardMode()?1:0);
1116 var spliti, splitiOld = 0;
1117 for(var i=0;i<paramCnt;++i)
1121 params.push(paramsStr.substr(splitiOld));
1125 spliti = paramsStr.indexOf(
'&', splitiOld);
1126 params.push(paramsStr.substr(splitiOld,spliti-splitiOld))
1127 splitiOld = spliti+1;
1131 var requestingWindowId =
"", windowPath =
"";
1132 var windowName, windowSubname, windowUnique, newWindowOps;
1133 for(var i=0;i<params.length;++i)
1135 spliti = params[i].indexOf(
'=');
1136 varPair = [params[i].substr(0,spliti),params[i].substr(spliti+1)];
1137 if(varPair[0] ==
"requestingWindowId")
1138 requestingWindowId = varPair[1];
1139 else if(varPair[0] ==
"windowPath")
1140 windowPath = decodeURIComponent(varPair[1]);
1141 else if(varPair[0] ==
"windowName")
1142 windowName = varPair[1];
1143 else if(varPair[0] ==
"windowSubname")
1144 windowSubname = varPair[1];
1145 else if(varPair[0] ==
"windowUnique")
1146 windowUnique = varPair[1];
1149 if(windowPath.indexOf(
"newWindowOps") >= 0)
1152 newWindowOps = windowPath.split(
'&')[1].split(
'=')[1];
1153 windowPath = windowPath.split(
'&')[0];
1175 if(requestingWindowId !=
"" && windowPath !=
"")
1179 Debug.log(
"requestingWindowId=" + requestingWindowId);
1180 Debug.log(
"windowPath=" + windowPath);
1181 if(newWindowOps) newWindowOps = newWindowOps.replace(/%22/g,
"\"");
1182 Debug.log(
"newWindowOps=" + newWindowOps);
1183 windowName = windowName.replace(/%20/g,
" ");
1184 Debug.log(
"windowName=" + windowName);
1185 windowSubname = windowSubname.replace(/%20/g,
" ");
1186 Debug.log(
"windowSubname=" + windowSubname);
1187 Debug.log(
"windowUnique=" + windowUnique);
1193 if(windowName.indexOf(
"Desktop.openLayout(") == 0)
1195 var layoutIndex = windowName.substr((
"Desktop.openLayout(").length,
1196 windowName.length-1-(
"Desktop.openLayout(").length) | 0;
1197 Debug.log(
"Opening layout... " + layoutIndex);
1199 if(pathUniquePair ===
1203 if(_firstCheckOfMailboxes)
1205 Debug.log(
"Perhaps user layout preferences have not been setup yet, try again at mailbox check.");
1211 _firstCheckOfMailboxes =
false;
1213 Desktop.desktop.dashboard.toggleWindowDashboard(0,
false);
1214 Desktop.desktop.defaultLayoutSelect(layoutIndex);
1220 if(windowSubname ==
"undefined" &&
1221 windowUnique ==
"undefined")
1223 Debug.log(
"Opening desktop window... " + windowName);
1226 var pathUniquePair = Desktop.desktop.icons.iconNameToPathMap[windowName];
1227 console.log(
"Desktop.desktop.icons.iconNameToPathMap",
1228 Desktop.desktop.icons.iconNameToPathMap);
1230 if(pathUniquePair ===
1234 if(_firstCheckOfMailboxes)
1236 Debug.log(
"Perhaps icons have not been setup yet, try again at mailbox check.");
1240 Debug.log(
"An error occurred opening the window named '" +
1241 windowName +
"' - it was not found in the Desktop icons. " +
1242 "Do you have permissions to access this window? Notify admins if the problem persists.",
1243 Debug.HIGH_PRIORITY);
1250 var pathStr = pathUniquePair[0];
1252 if(windowPath !=
"undefined")
1254 Debug.log(
"Adding parameter path " + windowPath);
1256 if(pathStr.indexOf(
'&') > 0)
1258 else if(pathStr.indexOf(
'?') > 0 &&
1259 pathStr[pathStr.length-1] !=
'?')
1261 else if(pathStr.length &&
1262 pathStr[pathStr.lengh-1] !=
'?')
1264 windowPath = pathStr + windowPath;
1267 windowPath = pathStr;
1269 newWin = Desktop.desktop.addWindow(
1273 ((windowPath.indexOf(
'?') < 0)?
"?":
"&") +
1274 ((newWindowOps)?
"newWindowOps=" + newWindowOps:
""),
1275 eval(pathUniquePair[1]));
1279 _firstCheckOfMailboxes =
false;
1280 newWin = Desktop.desktop.addWindow(
1284 ((windowPath.indexOf(
'?') < 0)?
"?":
"&") +
1285 ((newWindowOps)?
"newWindowOps=" + newWindowOps:
""),
1286 eval(windowUnique));
1291 Desktop.desktop.dashboard.toggleWindowDashboard(0,
false);
1295 window.setTimeout(
function(){
1296 Desktop.desktop.setForeWindow(newWin);
1297 Desktop.desktop.toggleFullScreen();
1310 _desktopElement = document.createElement(
"div");
1311 _desktopElement.setAttribute(
"id",
"Desktop");
1312 document.body.appendChild(_desktopElement);
1313 document.body.onmousemove = Desktop.handleBodyMouseMove;
1314 window.onmouseup = Desktop.handleWindowMouseUp;
1315 document.body.addEventListener(
'touchmove',Desktop.handleBodyTouchMove);
1316 document.body.addEventListener(
'touchend',Desktop.handleBodyTouchEnd);
1317 window.onresize = _handleDesktopResize;
1318 Desktop.desktop =
this;
1339 this.resetFrameMouse();
1369 _updateSettingsMailbox = document.createElement(
"div");
1370 _updateSettingsMailbox.setAttribute(
"id",
"DesktopContent-updateSettingsMailbox");
1371 _updateSettingsMailbox.style.display =
"none";
1372 _updateSettingsMailbox.innerHTML =
"";
1373 _desktopElement.appendChild(_updateSettingsMailbox);
1374 _settingsLayoutMailbox = document.createElement(
"div");
1375 _settingsLayoutMailbox.setAttribute(
"id",
"DesktopContent-settingsLayoutMailbox");
1376 _settingsLayoutMailbox.style.display =
"none";
1377 _settingsLayoutMailbox.innerHTML =
"";
1378 _desktopElement.appendChild(_settingsLayoutMailbox);
1389 window.addEventListener(
'message', event => {
1391 console.log(
"Parent event.data",event.data);
1393 if(event.data.windowId === undefined)
1395 Debug.log(
"Illegal window message received! Notify admins", Debug.HIGH_PRIORITY);
1400 switch(event.data.request)
1402 case "updateMouseoverXY":
1404 var el = document.getElementById(
"DesktopWindowFrame-" + event.data.windowId);
1407 _mouseOverXmailbox = parseInt(el.parentNode.parentNode.offsetLeft) +
1408 parseInt(el.offsetLeft) + parseInt(event.data.x);
1409 _mouseOverYmailbox = parseInt(el.parentNode.parentNode.offsetTop) +
1410 parseInt(el.offsetTop) + parseInt(event.data.y);
1414 _mouseOverXmailbox =
event.data.x|0;
1415 _mouseOverYmailbox =
event.data.y|0;
1417 console.log(
"updateMouseoverXY",_mouseOverXmailbox,_mouseOverYmailbox);
1419 case "makeForeWindow":
1421 Desktop.desktop.setForeWindow(this.getWindowById(event.data.windowId|0));
1423 case "openNewWindow":
1424 console.log(
"openNewWindow");
1426 var requestingWindowId =
event.data.windowId|0;
1427 var windowPath =
event.data.windowPath;
1428 var windowName =
event.data.windowName;
1429 var windowSubname =
event.data.windowSubname;
1430 var windowUnique =
event.data.windowUnique;
1432 if(windowPath !=
"")
1436 console.log(
"requestingWindowId=" + requestingWindowId);
1437 console.log(
"windowPath=" + windowPath);
1438 while(windowPath.length && windowPath[0] ==
'?') windowPath = windowPath.substr(1);
1439 console.log(
"modified windowPath=" + windowPath);
1440 console.log(
"windowName=" + windowName);
1441 console.log(
"windowSubname=" + windowSubname);
1442 console.log(
"windowUnique=" + windowUnique);
1448 if((windowSubname === undefined || windowSubname ==
"undefined") &&
1449 (windowUnique === undefined || windowUnique ==
"undefined"))
1451 console.log(
"Opening desktop window... " + windowName);
1453 var pathUniquePair = Desktop.desktop.icons.iconNameToPathMap[windowName];
1454 console.log(
"Desktop.desktop.icons.iconNameToPathMap",
1455 Desktop.desktop.icons.iconNameToPathMap);
1457 if(pathUniquePair ===
1460 Debug.log(
"An error occurred opening the window named '" +
1461 windowName +
"' - it was not found in the Desktop icons. " +
1462 "Do you have permissions to access this window? Notify admins if the problem persists.",
1463 Debug.HIGH_PRIORITY);
1473 var pathStr = pathUniquePair[0];
1475 if(windowPath !=
"undefined")
1477 Debug.log(
"Adding parameter path " + windowPath);
1478 if(pathStr.indexOf(
'?') >= 0)
1480 else if(pathStr.length)
1482 windowPath = pathStr + windowPath;
1485 windowPath = pathStr;
1487 newWin = Desktop.desktop.addWindow(
1491 eval(pathUniquePair[1]));
1495 newWin = Desktop.desktop.addWindow(
1499 eval(windowUnique));
1503 window.setTimeout(
function(){ Desktop.desktop.setForeWindow(newWin); }, 200);
1511 case "refreshIcons":
1512 console.log(
"refreshIcons");
1515 Desktop.desktop.icons.resetWithPermissions(
1519 case "startSystemBlackout":
1520 console.log(
"startSystemBlackout");
1522 Desktop.desktop.login.blackout(
true);
1524 case "stopSystemBlackout":
1525 console.log(
"stopSystemBlackout");
1526 Desktop.desktop.login.blackout(
false);
1528 case "getCookieCode":
1530 "cookieCode": Desktop.desktop.login.getCookieCode()
1532 console.log(
"getCookieCode");
1534 case "updateCookieCode":
1536 var delta = parseInt(event.data.cookieCodeTime) - parseInt(Desktop.desktop.login.getCookieTime());
1538 console.log(
"updateCookieCode",delta);
1541 Debug.log(
"Updating desktop cookie code from content window");
1542 Desktop.desktop.login.updateCookieFromContent(
1543 event.data.cookieCode,
1544 parseInt(event.data.cookieCodeTime));
1548 console.log(
"needToLogin");
1550 if(!document.getElementById(
"Desktop-loginDiv") &&
1551 !Desktop.desktop.login.isBlackout())
1554 Debug.log(
"DesktopContent signaled new login needed!",Debug.HIGH_PRIORITY);
1558 Debug.log(
"Ignoring desktop content need for login signal due to blackout.");
1562 Debug.log(
"Illegal window message request received! Notify admins", Debug.HIGH_PRIORITY);
1566 if(responseObject !== undefined)
1569 responseObject[
"windowId"] =
event.data.windowId;
1570 responseObject[
"request"] =
event.data.request +
"Response";
1571 console.log(
"responseObject",responseObject);
1572 this.getWindowById(event.data.windowId|0).getFrame().contentWindow.postMessage(
1573 responseObject,
"*");
1580 this.dashboard = _dashboard = Desktop.createDashboard(_defaultDashboardZindex);
1581 _desktopElement.appendChild(_dashboard.dashboardElement);
1584 this.icons = _icons = Desktop.createIcons(0);
1585 _desktopElement.appendChild(_icons.iconsElement);
1587 _handleDesktopResize();
1589 window.clearTimeout(this.checkMailboxTimer);
1590 this.checkMailboxTimer = window.setTimeout(_checkMailboxes,_MAILBOX_TIMER_PERIOD);
1593 this.login = _login =
new Desktop.login(!(this.security == Desktop.SECURITY_TYPE_NONE));
1595 _desktopElement.appendChild(_login.loginDiv);
1597 Debug.log(
"Desktop Created",Debug.LOW_PRIORITY);
1599 Debug.log(
"Checking for any shortcut work from get parameters...",Debug.LOW_PRIORITY);
1600 Desktop.desktop.actOnParameterAction();
1609 Desktop.foreWinLastMouse = [-1,-1];
1610 Desktop.winManipMode = -1;
1611 Desktop.stretchAndMoveInterval = 0;
1612 Desktop.disableMouseDown = 0;
1621 Desktop.handleTouchStart =
function(touchEvent)
1623 Desktop.disableMouseDown = 1;
1624 var touch = touchEvent.targetTouches[0];
1626 var winId = this.
id.split(
'-')[1];
1627 var isDashboard = (winId ==
"windowDashboard");
1631 win = Desktop.desktop.getWindowById(winId);
1632 if(win == -1)
return false;
1633 if(win.isMaximized()) {this.style.cursor =
"default";
return false;}
1636 if(Desktop.desktop.getForeWindow() != win)
1637 Desktop.desktop.setForeWindow(win);
1642 if(Desktop.foreWinLastMouse[0] == -1)
1644 var locX = touch.pageX - this.offsetLeft;
1645 var locY = touch.pageY - this.offsetTop;
1649 Desktop.desktop.getForeWindow().hideFrame();
1651 Desktop.foreWinLastMouse = [touch.pageX,touch.pageY];
1653 if(locY < win.getWindowHeaderHeight())
1655 Desktop.winManipMode = 0;
1665 Desktop.handleBodyTouchEnd =
function(touchEvent) {Desktop.handleTouchEnd(touchEvent);}
1666 Desktop.handleTouchEnd =
function(touchEvent)
1669 if(Desktop.foreWinLastMouse[0] != -1)
1671 Desktop.foreWinLastMouse = [-1,-1];
1672 Desktop.winManipMode = -1;
1673 if(Desktop.desktop.getForeWindow()) Desktop.desktop.getForeWindow().showFrame();
1681 Desktop.handleBodyTouchMove =
function(touchEvent) {Desktop.handleTouchMove(touchEvent);}
1682 Desktop.handleTouchMove =
function(touchEvent)
1684 if(Desktop.winManipMode != -1 && Desktop.foreWinLastMouse[0] != -1)
1686 touchEvent.preventDefault();
1687 touchEvent.cancelBubble=
true;
1689 var touch = touchEvent.targetTouches[0];
1690 var delta = [touch.pageX-Desktop.foreWinLastMouse[0], touch.pageY-Desktop.foreWinLastMouse[1]];
1692 Desktop.desktop.getForeWindow().moveWindowByOffset(delta[0],delta[1]);
1693 Desktop.foreWinLastMouse = [touch.pageX,touch.pageY];
1701 Desktop.handleWindowMouseDown =
function(mouseEvent)
1703 var winId = this.
id.split(
'-')[1];
1704 var isDashboard = (winId ==
"windowDashboard");
1708 win = Desktop.desktop.getWindowById(winId);
1709 if(win == -1)
return false;
1712 if(Desktop.desktop.getForeWindow() != win)
1713 Desktop.desktop.setForeWindow(win);
1717 if(!Desktop.disableMouseDown && Desktop.winManipMode != -1 &&
this.style.cursor !=
"default")
1720 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1721 if(!isDashboard) Desktop.desktop.getForeWindow().hideFrame();
1733 Desktop.handleWindowMouseUp =
function(mouseEvent)
1736 if(Desktop.foreWinLastMouse[0] != -1)
1738 if(Desktop.stretchAndMoveInterval)
1740 window.clearInterval(Desktop.stretchAndMoveInterval);
1741 Desktop.stretchAndMoveInterval = 0;
1744 var reqObject = {
"request":
"stopNeedingMouseXY"};
1745 for(var i=0;i<Desktop.desktop.getNumberOfWindows();++i)
1747 reqObject[
"windowId"] = Desktop.desktop.getWindowByIndex(i).getWindowId();
1748 Desktop.desktop.getWindowByIndex(i).getFrame().contentWindow.postMessage(
1753 Desktop.foreWinLastMouse = [-1,-1];
1754 Desktop.winManipMode = -1;
1755 if(Desktop.desktop.getForeWindow()) Desktop.desktop.getForeWindow().showFrame();
1759 Desktop.desktop.icons.closeFolder();
1765 Desktop.handleWindowMouseMove =
function(mouseEvent)
1767 var winId = this.
id.split(
'-')[1];
1768 var isDashboard = (winId ==
"windowDashboard");
1771 win = Desktop.desktop.getWindowById(winId);
1772 if(win == -1)
return false;
1773 if(win.isMaximized()) {this.style.cursor =
"default";
return false;}
1777 if(Desktop.foreWinLastMouse[0] == -1) {
1778 var locX = mouseEvent.clientX - this.offsetLeft;
1779 var locY = mouseEvent.clientY - this.offsetTop;
1781 var hotCornerSz = 7;
1783 if(locX > Desktop.desktop.dashboard.getDashboardWidth() - hotCornerSz) {
1784 this.style.cursor =
"e-resize";
1785 Desktop.winManipMode = 100;
1788 this.style.cursor =
"default";
1791 if((locX < hotCornerSz && locY < hotCornerSz) ||
1792 (locX > win.getWindowWidth() - hotCornerSz && locY > win.getWindowHeight() - hotCornerSz)) {
1793 this.style.cursor =
"nw-resize";
1794 Desktop.winManipMode = locY < hotCornerSz?1:2;
1796 else if((locX > win.getWindowWidth() - hotCornerSz && locY < hotCornerSz) ||
1797 (locX < hotCornerSz && locY > win.getWindowHeight() - hotCornerSz)) {
1798 this.style.cursor =
"ne-resize";
1799 Desktop.winManipMode = locY < hotCornerSz?3:4;
1801 else if(locX < hotCornerSz) {
1802 this.style.cursor =
"w-resize";
1803 Desktop.winManipMode = 5;
1805 else if(locX > win.getWindowWidth() - hotCornerSz) {
1806 this.style.cursor =
"e-resize";
1807 Desktop.winManipMode = 6;
1809 else if(locY < hotCornerSz) {
1810 this.style.cursor =
"n-resize";
1811 Desktop.winManipMode = 7;
1813 else if(locY > win.getWindowHeight() - hotCornerSz) {
1814 this.style.cursor =
"s-resize";
1815 Desktop.winManipMode = 8;
1817 else if(locY < win.getWindowHeaderHeight()) {
1818 this.style.cursor =
"all-scroll";
1819 Desktop.winManipMode = 0;
1822 this.style.cursor =
"default";
1827 Desktop.handleBodyMouseMove(mouseEvent);
1832 Desktop._mouseMoveSubscribers = [];
1835 Desktop.mouseMoveSubscriber =
function(newHandler)
1837 Desktop._mouseMoveSubscribers.push(newHandler);
1845 Desktop.handleBodyMouseMove =
function(mouseEvent)
1849 for(var i=0; i<Desktop._mouseMoveSubscribers.length; ++i)
1850 Desktop._mouseMoveSubscribers[i](mouseEvent);
1852 Desktop.desktop.resetFrameMouse();
1855 if(Desktop.foreWinLastMouse[0] != -1 && Desktop.winManipMode == 100) {
1857 if(mouseEvent.which == 0)
1858 return Desktop.handleWindowMouseUp(mouseEvent);
1860 var delta = mouseEvent.clientX-Desktop.foreWinLastMouse[0];
1861 Desktop.desktop.dashboard.setDashboardWidth(Desktop.desktop.dashboard.getDashboardWidth()+delta);
1862 Desktop.foreWinLastMouse = [mouseEvent.clientX,mouseEvent.clientY];
1864 if(Desktop.stretchAndMoveInterval == 0)
1867 var reqObject = {
"request":
"startNeedingMouseXY"};
1868 for(var i=0;i<Desktop.desktop.getNumberOfWindows();++i)
1870 reqObject[
"windowId"] = Desktop.desktop.getWindowByIndex(i).getWindowId();
1871 Desktop.desktop.getWindowByIndex(i).getFrame().contentWindow.postMessage(
1875 Desktop.stretchAndMoveInterval = window.setInterval(
1877 if(Desktop.desktop.getLastFrameMouseX() == -1)
return;
1879 var delta = Desktop.desktop.getLastFrameMouseX()-Desktop.foreWinLastMouse[0];
1880 Desktop.desktop.dashboard.setDashboardWidth(Desktop.desktop.dashboard.getDashboardWidth()+delta);
1881 Desktop.foreWinLastMouse = [Desktop.desktop.getLastFrameMouseX(),Desktop.desktop.getLastFrameMouseY()];
1889 if(!Desktop.desktop.getForeWindow())
return true;
1891 if(Desktop.foreWinLastMouse[0] != -1)
1893 if(mouseEvent.which == 0)
1894 return Desktop.handleWindowMouseUp(mouseEvent);
1896 var xy = [mouseEvent.clientX, mouseEvent.clientY];
1897 if(xy[0] < Desktop.desktop.getDesktopContentX() + 4)
1898 xy[0] = Desktop.desktop.getDesktopContentX() + 4;
1899 if(xy[1] < Desktop.desktop.getDesktopContentY() + 6)
1900 xy[1] = Desktop.desktop.getDesktopContentY() + 6;
1901 var delta = [xy[0]-Desktop.foreWinLastMouse[0], xy[1]-Desktop.foreWinLastMouse[1]];
1905 Desktop.handleWindowManipulation(delta);
1907 Desktop.foreWinLastMouse = [xy[0],xy[1]];
1909 if(Desktop.stretchAndMoveInterval == 0)
1912 var reqObject = {
"request":
"startNeedingMouseXY"};
1913 for(var i=0;i<Desktop.desktop.getNumberOfWindows();++i)
1915 reqObject[
"windowId"] = Desktop.desktop.getWindowByIndex(i).getWindowId();
1916 Desktop.desktop.getWindowByIndex(i).getFrame().contentWindow.postMessage(
1920 Desktop.stretchAndMoveInterval = window.setInterval(
1923 if(Desktop.desktop.getLastFrameMouseX() == -1)
return;
1925 var delta = [Desktop.desktop.getLastFrameMouseX()-Desktop.foreWinLastMouse[0],
1926 Desktop.desktop.getLastFrameMouseY()-Desktop.foreWinLastMouse[1]];
1927 Desktop.handleWindowManipulation(delta);
1928 Desktop.foreWinLastMouse = [Desktop.desktop.getLastFrameMouseX(),Desktop.desktop.getLastFrameMouseY()];
1939 Desktop.handleWindowManipulation =
function(delta)
1941 if(!Desktop.desktop.getForeWindow())
return false;
1943 var win = Desktop.desktop.getForeWindow();
1945 switch(Desktop.winManipMode) {
1947 win.moveWindowByOffset(delta[0],delta[1]);
1950 win.resizeAndPositionWindow(
1951 win.getWindowX() + delta[0],
1952 win.getWindowY() + delta[1],
1953 win.getWindowWidth() - delta[0],
1954 win.getWindowHeight() - delta[1]);
1957 win.resizeAndPositionWindow(
1960 win.getWindowWidth() + delta[0],
1961 win.getWindowHeight() + delta[1]);
1964 win.resizeAndPositionWindow(
1966 win.getWindowY() + delta[1],
1967 win.getWindowWidth() + delta[0],
1968 win.getWindowHeight() - delta[1]);
1971 win.resizeAndPositionWindow(
1972 win.getWindowX() + delta[0],
1974 win.getWindowWidth() - delta[0],
1975 win.getWindowHeight() + delta[1]);
1978 win.resizeAndPositionWindow(
1979 win.getWindowX() + delta[0],
1981 win.getWindowWidth() - delta[0],
1982 win.getWindowHeight());
1985 win.resizeAndPositionWindow(
1988 win.getWindowWidth() + delta[0],
1989 win.getWindowHeight());
1992 win.resizeAndPositionWindow(
1994 win.getWindowY() + delta[1],
1995 win.getWindowWidth(),
1996 win.getWindowHeight() - delta[1]);
1999 win.resizeAndPositionWindow(
2002 win.getWindowWidth(),
2003 win.getWindowHeight() + delta[1]);
2010 Desktop.handleWindowButtonDown =
function(mouseEvent)
2012 mouseEvent.cancelBubble=
true;
2017 Desktop.handleWindowRefresh =
function(mouseEvent)
2019 Debug.log(
"Refresh " + this.
id.split(
'-')[1]);
2020 Desktop.desktop.refreshWindowById(this.
id.split(
'-')[1]);
2025 Desktop.handleWindowHelp =
function (mouseEvent)
2027 Debug.log(
"Help " + this.
id.split(
'-')[1]);
2028 Desktop.desktop.windowHelpById(this.
id.split(
'-')[1]);
2033 Desktop.handleFullScreenWindowRefresh =
function(mouseEvent)
2035 Debug.log(
"Refresh Full Screen Window");
2037 var foreWindowId = undefined;
2040 foreWindowId = Desktop.desktop.getForeWindow().getWindowId();
2044 Debug.log(
"Could not find foreground window, ignoring.");
2048 Desktop.desktop.resetDesktop();
2049 Desktop.desktop.refreshDesktop();
2051 var foreWindow = undefined;
2052 var isMaxWindow = undefined;
2071 if(Desktop.desktop.getForeWindow() &&
2072 Desktop.desktop.getForeWindow().isMaximized())
2074 Debug.log(
"Refreshing just maximized window...");
2076 Desktop.desktop.refreshWindow();
2081 Debug.log(
"Refreshing all windows...");
2086 for(var i = 0; i < Desktop.desktop.getNumberOfWindows(); i++)
2088 var window = Desktop.desktop.getWindowByIndex(0);
2089 var
id = window.getWindowId();
2091 Debug.log(
"name: " + i +
" " + window.getWindowName());
2092 Debug.log(
"ID: " +
id);
2094 var maximized = window.isMaximized();
2096 Desktop.desktop.setForeWindow(window);
2097 window = Desktop.desktop.refreshWindow();
2099 if(foreWindowId ==
id)
2101 foreWindow = window;
2104 isMaxWindow = window;
2122 Desktop.desktop.setForeWindow(foreWindow);
2124 Desktop.desktop.setForeWindow(foreWindow);
2143 Desktop.handleWindowMinimize =
function(mouseEvent)
2145 Debug.log(
"minimize " + this.
id.split(
'-')[1]);
2146 Desktop.desktop.minimizeWindowById(this.
id.split(
'-')[1]);
2151 Desktop.handleWindowMaximize =
function(mouseEvent)
2153 Debug.log(
"maximize " + this.
id.split(
'-')[1]);
2154 Desktop.desktop.maximizeWindowById(this.
id.split(
'-')[1]);
2159 Desktop.handleWindowClose =
function(mouseEvent)
2162 Desktop.desktop.closeWindowById(this.
id.split(
'-')[1]);
2174 Desktop.XMLHttpRequest =
function(requestURL, data, returnHandler, reqIndex)
2178 var req =
new XMLHttpRequest();
2180 req.onreadystatechange =
function()
2182 if (req.readyState==4)
2188 if(!Desktop.desktop.serverConnected)
2190 Desktop.desktop.serverConnected =
true;
2191 Desktop.desktop.dashboard.displayConnectionStatus(
true);
2193 Desktop.desktop.resetDesktop();
2198 if(req.responseText == Globals.REQ_NO_PERMISSION_RESPONSE)
2200 errStr =
"Request failed do to insufficient account permissions.";
2203 else if(req.responseText == Globals.REQ_NO_LOGIN_RESPONSE)
2205 errStr =
"Login has expired.";
2207 window.clearTimeout(Desktop.desktop.checkMailboxTimer);
2218 if(Desktop.desktop.serverConnected)
2220 Desktop.desktop.serverConnected =
false;
2221 Desktop.desktop.dashboard.displayConnectionStatus(
false);
2224 errStr =
"Request Failed - Bad Address:\n" + requestURL;
2225 window.clearTimeout(Desktop.desktop.checkMailboxTimer);
2231 errStr +=
"\n\n(Try refreshing the page, or alert ots admins if problem persists.)";
2232 Debug.log(
"Error: " + errStr,Debug.HIGH_PRIORITY);
2233 Debug.log(
"Error occurred from req = " + requestURL);
2237 Debug.log(
"The user interface is disconnected from the ots Gateway server.",
2238 Debug.HIGH_PRIORITY);
2241 document.getElementById(
"DesktopDashboard-userWithLock").style.display =
"none";
2243 if(returnHandler) returnHandler(req,reqIndex,errStr);
2247 if(Desktop.desktop.login)
2248 data =
"CookieCode="+Desktop.desktop.login.getCookieCode()+
"&"+data;
2249 requestURL =
"/urn:xdaq-application:lid=" + urnLid_ +
"/" + requestURL;
2251 req.open(
"POST",requestURL,
true);
2253 req.setRequestHeader(
"Content-Type",
"text/plain;charset=UTF-8");
2259 Desktop.getXMLAttributeValue =
function(req, name, attribute)
2261 if(req && req.responseXML && req.responseXML.getElementsByTagName(name).length > 0)
2262 return req.responseXML.getElementsByTagName(name)[0].getAttribute(attribute);
2270 Desktop.getXMLValue =
function(req, name)
2272 return Desktop.getXMLAttributeValue(req,name,
"value");
2278 Desktop.logout =
function ()
2280 if(Desktop.desktop && Desktop.desktop.login &&
2281 !Desktop.desktop.login.isBlackout())
2282 Desktop.desktop.login.logout();
2287 Desktop.formatTime =
function(t)
2289 var date =
new Date(t * 1000);
2290 var mm = date.getMinutes() < 10?
"0"+date.getMinutes():date.getMinutes();
2291 var ss = date.getSeconds() < 10?
"0"+date.getSeconds():date.getSeconds();
2292 return date.getHours() +
":" + mm +
":" + ss;
2297 Desktop.closeSystemMessage =
function(id)
2299 var el = document.getElementById(
"Desktop-systemMessageBox-" +
id);
2300 el.parentNode.removeChild(el);
2305 Desktop.isWizardMode =
function()
2310 return !(!Desktop.desktop.security ||
2311 Desktop.desktop.security == Desktop.SECURITY_TYPE_DIGEST_ACCESS ||
2312 Desktop.desktop.security == Desktop.SECURITY_TYPE_NONE);
2317 Desktop.openNewBrowserTab =
function(name,subname,windowPath,unique)
2324 var i = windowPath.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
2325 var isAllNumbers =
true;
2326 for(i;i<windowPath.length;++i)
2328 Debug.log(windowPath[i]);
2330 if(windowPath[i] <
"0" || windowPath[i] >
"9")
2332 isAllNumbers =
false;
2339 Debug.log(
"DesktopWindow= " + windowPath);
2341 Debug.log(
"name= " + name);
2342 Debug.log(
"subname= " + subname);
2343 Debug.log(
"unique= " + unique);
2344 var search = window.parent.window.location.search;
2345 url = window.parent.window.location.pathname;
2347 var str =
"requestingWindowId=Desktop";
2348 str +=
"&windowName=" + name;
2349 str +=
"&windowSubname=" + subname;
2350 str +=
"&windowUnique=" + unique;
2351 str +=
"&windowPath=" + encodeURIComponent(windowPath);
2356 if(!Desktop.isWizardMode())
2358 var i = url.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
2359 var isAllNumbers =
true;
2360 for(i;i<url.length;++i)
2364 if(url[i] <
"0" || url[i] >
"9")
2366 isAllNumbers =
false;
2376 url += search.split(
'&')[0] +
"&" + str;
2379 Debug.log(
"DesktopContent.openNewBrowserTab= " + url);
2381 window.open(url,
'_blank');
2387 Desktop.desktopTooltip =
function()
2390 DesktopContent.tooltip(
"Desktop Introduction",
2391 "Welcome to the <i>otsdaq</i> Desktop environment. This is your portal " +
2392 "to all of the possibilities of <i>otsdaq</i>.\n\n" +
2393 "Briefly, here are the features:" +
2395 "\n\t- <b>Desktop Window Icons:</b> " +
2397 "Click the rounded-square icons on your Desktop to open " +
2398 "a particular window. If you hold down your click (for a second), you " +
2399 "can open the window in fullscreen, or in a new tab, or even open the window " +
2400 "then tile it on the screen with all other open windows!" +
2403 "\n\t- <b>Desktop Dashboard (top pane):</b> " +
2405 "Along the top and left margins of the Desktop, you will find the Desktop " +
2406 "Dashboard - this section is an introduction to the top pane of the Dashboard. " +
2407 "The top pane of the Dashboard " +
2408 "is made of buttons and icons going from left to right:" +
2410 "\n\t- <b>Left Pane Toggler:</b> " +
2412 "The first button you will encounter in the top pane looks like a horizontal double-arrow " +
2413 "icon. This button toggles the display of the left pane of the Dashboard. Note when you " +
2414 "refresh the page, the state of the left pane persists!" +
2417 "\n\t- <b>Layouts Menu:</b> " +
2419 "The next button you will encounter in the top pane reads 'Layouts.' " +
2420 "This button gives you access to your Window Layout Presets. You will see 2 'System' presets there " +
2421 "which can be setup by uesrs with admin privileges. There are also 3 'User' presets which you can setup for " +
2422 "yourself in the User Settings window (get there with " +
2423 "the cog wheel icon in the upper-right of the Desktop)." +
2426 "\n\t- <b>Tile Desktop Windows:</b> " +
2428 "The next button you will encounter in the top pane reads 'Tile.' " +
2429 "This button will automatically tile all open Desktop Windows to fit in your browser window." +
2432 "\n\t- <b>Show Desktop:</b> " +
2434 "The next button you will encounter in the top pane reads 'Show Desktop.' " +
2435 "This button will minimize all open Desktop Windows which is nice " +
2436 "when you want to see all of your Desktop Icons again." +
2439 "\n\t- <b>Full Screen:</b> " +
2441 "The next button you will encounter in the top pane reads 'Full Screen.' " +
2442 "This button will maximize to full screen the Desktop Window that was last used (i.e. the window that has the focus)." +
2446 "\n\t- <b>Desktop Dashboard (left pane):</b> " +
2448 "Along the top and left margins of the Desktop, you will find the Desktop " +
2449 "Dashboard - this section is an introduction to the left pane of the Dashboard. " +
2450 "The left pane of the Dashboard " +
2451 "is a listing of all open Desktop Windows. If you click one of the buttons in the list, " +
2452 "the associated window " +
2453 "will be minimized or restored. If you hold down your click (for one second) you can choose " +
2454 "to minimize, maximize, or close the window!" +
2459 "\n\nRemember, if you would like to take a look at the available online documentation, " +
2460 "click the question mark at the top-right of the Desktop."