116 var DesktopContent = DesktopContent || {};
118 if (typeof Debug ==
'undefined')
119 alert(
'ERROR: Debug is undefined! Must include Debug.js before DesktopContent.js');
120 if (typeof Globals ==
'undefined')
121 alert(
'ERROR: Globals is undefined! Must include Globals.js before DesktopContent.js');
171 DesktopContent._theWindowId = -1;
173 DesktopContent._isFocused =
false;
174 DesktopContent._theWindow;
175 DesktopContent._theDesktopWindow;
186 DesktopContent._updateMouseOverMailboxTimer = 0;
187 DesktopContent._windowMouseX = -1;
188 DesktopContent._windowMouseY = -1;
190 DesktopContent._serverOrigin =
"";
191 DesktopContent._localOrigin =
"";
192 DesktopContent._serverUrnLid = 0;
193 DesktopContent._localUrnLid = 0;
195 DesktopContent._cookieCodeMailbox = 0;
196 DesktopContent._updateTimeMailbox = 0;
197 DesktopContent._lastCookieCode = 0;
198 DesktopContent._lastCookieTime = 0;
199 DesktopContent._updateCookieCodeTimer = 0;
201 DesktopContent._needToLoginMailbox =
false;
203 DesktopContent._blockSystemCheckMailbox =
false;
204 DesktopContent._windowColorPostbox;
205 DesktopContent._dashboardColorPostbox;
206 DesktopContent._desktopColor;
208 DesktopContent._verifyPopUp = 0;
209 DesktopContent._verifyPopUpId =
"DesktopContent-verifyPopUp";
212 DesktopContent._sequence = 0;
214 DesktopContent._mouseMoveSubscribers = [];
215 DesktopContent._pageInitCalled =
false;
222 DesktopContent.init =
function()
224 if(typeof Desktop !==
'undefined')
return;
227 DesktopContent._theWindow =
self;
228 while(tmpCnt++ < 5 && DesktopContent._theWindow &&
229 DesktopContent._theWindow.window.name.search(
"DesktopWindowFrame") < 0)
230 DesktopContent._theWindow = DesktopContent._theWindow.parent;
232 DesktopContent._theWindow = DesktopContent._theWindow.window;
233 DesktopContent._theDesktopWindow = DesktopContent._theWindow.parent.window;
262 window.onfocus = DesktopContent.handleFocus;
263 window.onmousedown = DesktopContent.handleFocus;
264 window.onscroll = DesktopContent.handleScroll;
265 window.onblur = DesktopContent.handleBlur;
266 window.onmousemove = DesktopContent.mouseMove;
268 DesktopContent._theWindow.focus();
292 Debug.log(
"Window URL " + window.location.href);
293 DesktopContent._localUrnLid = DesktopContent.getParameter(0,
"urn");
294 if(typeof DesktopContent._localUrnLid ==
'undefined')
295 DesktopContent._localUrnLid = 0;
296 DesktopContent._localOrigin = window.location.origin;
298 Debug.log(
"Local Application URN-LID #" + DesktopContent._localUrnLid);
299 Debug.log(
"Local Application Origin = " + DesktopContent._localOrigin);
304 DesktopContent._sequence = DesktopContent.getDesktopParameter(0,
"code");
305 if(!DesktopContent._sequence || DesktopContent._sequence ==
"")
306 DesktopContent._sequence = 0;
308 Debug.log(
"In Wizard Mode with Sequence=" + DesktopContent._sequence);
312 Debug.log(
"Could not find wiz mode sequence. Assuming normal mode.");
313 DesktopContent._sequence = 0;
324 DesktopContent._theWindow.addEventListener(
'message', event => {
326 console.log(
"Child event.data",event.data);
329 if(!event.data.windowId)
331 Debug.log(
"Illegal message received!");
335 if(!event.data.request)
337 if(DesktopContent._pageInitCalled)
return;
338 DesktopContent._pageInitCalled =
true;
340 Debug.log(
"First message from Gateway Desktop received!");
342 DesktopContent._theWindowId =
event.data.windowId;
343 DesktopContent._serverUrnLid =
event.data.gatewayURN;
344 DesktopContent._serverOrigin =
event.data.gatewayOrigin;
346 DesktopContent._dashboardColorPostbox =
event.data.dashboardColor;
347 DesktopContent._desktopColor =
event.data.desktopColor;
348 DesktopContent._windowColorPostbox =
event.data.windowFrameColor;
351 if(event.data.cookieCode)
353 DesktopContent._cookieCodeMailbox =
event.data.cookieCode;
356 function localUpdateCookieCode()
358 window.clearTimeout(DesktopContent._updateCookieCodeTimer);
360 Debug.log(
"localUpdateCookieCode");
361 var deltaTime = parseInt((
new Date()).getTime()) -
362 parseInt(DesktopContent._updateTimeMailbox);
365 Debug.log(
"Requesting updated cooking code from desktop");
367 DesktopContent._theDesktopWindow.postMessage(
369 "windowId": DesktopContent._theWindowId,
370 "request":
"getCookieCode"
374 Debug.log(
"No need to update deltaTime=" + deltaTime);
376 DesktopContent._updateCookieCodeTimer = window.setTimeout(
377 localUpdateCookieCode,30*1000 );
381 localUpdateCookieCode();
383 else if(!DesktopContent._sequence)
384 Debug.log(
"No cookie code and no sequence!");
386 Debug.log(
"The Desktop Window ID = " + DesktopContent._theWindowId);
387 Debug.log(
"Gateway Supervisor Application URN-LID #" + DesktopContent._serverUrnLid);
388 Debug.log(
"Gateway Supervisor Application Origin = " + DesktopContent._serverOrigin);
392 Debug.log(
"Calling page init!");
405 Debug.log(
"Request or Response!");
407 if(DesktopContent._theWindowId != event.data.windowId)
409 Debug.med(
"Impossible desktop message violation! Notify admins. May happen if users click around during window refresh?");
413 switch(event.data.request)
415 case "getCookieCode" +
"Response":
416 DesktopContent._cookieCodeMailbox =
event.data.cookieCode;
417 console.log(
"getCookieCode" +
"Response");
420 DesktopContent._needToLoginMailbox =
false;
421 console.log(
"loginNotify",DesktopContent._needToLoginMailbox);
423 case "startNeedingMouseXY":
424 DesktopContent._desktopNeedsMouseXY =
true;
425 console.log(
"_desktopNeedsMouseXY", DesktopContent._desktopNeedsMouseXY);
427 case "stopNeedingMouseXY":
428 DesktopContent._desktopNeedsMouseXY =
false;
429 console.log(
"_desktopNeedsMouseXY", DesktopContent._desktopNeedsMouseXY);
432 Debug.log(
"Illegal response received from Desktop! Notify admins", Debug.HIGH_PRIORITY);
446 DesktopContent.getParameter =
function(index,name)
449 var params = (window.location.search.substr(1)).split(
'&');
454 for(index=0;index<params.length;++index)
456 spliti = params[index].indexOf(
'=');
457 if(spliti < 0)
continue;
458 vs = [params[index].substr(0,spliti),params[index].substr(spliti+1)];
459 if(decodeURIComponent(vs[0]) == name)
460 return decodeURIComponent(vs[1]);
466 if(index >= params.length)
return;
468 spliti = params[index].indexOf(
'=');
469 if(spliti < 0)
return;
470 vs = [params[index].substr(0,spliti),params[index].substr(spliti+1)];
471 return decodeURIComponent(vs[1]);
478 DesktopContent.getDesktopParameter =
function(index, name)
483 var win = DesktopContent._theWindow;
485 win = window.parent.window;
487 win = win.parent.parent.window;
488 var params = (win.location.search.substr(1)).split(
'&');
489 if(index >= params.length)
return;
494 for(var index=0;index<params.length;++index)
496 spliti = params[index].indexOf(
'=');
497 if(spliti < 0)
continue;
498 vs = [params[index].substr(0,spliti),params[index].substr(spliti+1)];
500 return decodeURIComponent(vs[1]);
505 spliti = params[index].indexOf(
'=');
506 if(spliti < 0)
return;
507 vs = [params[index].substr(0,spliti),params[index].substr(spliti+1)];
508 return decodeURIComponent(vs[1]);
512 Debug.log(
"Ignoring get desktop parameter error :" + e);
521 DesktopContent.getDesktopWindowParameter =
function(index, name)
525 var win = DesktopContent._theWindow;
529 win = win.parent.window;
532 var searchStr = win.location.search.substr(1);
533 var i = searchStr.indexOf(
"=securityType");
534 if(i > 0) searchStr = searchStr.substr(0,i) +
'&' + searchStr.substr(i+1);
536 var params = ((searchStr)).split(
'&');
537 if(index >= params.length)
return;
542 for(var index=0;index<params.length;++index)
544 spliti = params[index].indexOf(
'=');
545 if(spliti < 0)
continue;
546 vs = [params[index].substr(0,spliti),params[index].substr(spliti+1)];
548 return decodeURIComponent(vs[1]);
553 spliti = params[index].indexOf(
'=');
554 if(spliti < 0)
return;
555 vs = [params[index].substr(0,spliti),params[index].substr(spliti+1)];
556 return decodeURIComponent(vs[1]);
561 DesktopContent.handleFocus =
function(e)
564 if(DesktopContent._theWindowId < 0)
return;
566 Debug.log(
"Focus DesktopContent._isFocused " + DesktopContent._isFocused);
567 DesktopContent._isFocused =
true;
570 DesktopContent._theDesktopWindow.postMessage(
572 "windowId": DesktopContent._theWindowId,
573 "request":
"makeForeWindow"
580 DesktopContent.handleBlur =
function(e)
583 DesktopContent._isFocused =
false;
585 DesktopContent.handleScroll =
function(e)
590 DesktopContent.mouseMove =
function(mouseEvent,onlyDesktopFunction)
596 for(var i=0; !onlyDesktopFunction && i<DesktopContent._mouseMoveSubscribers.length; ++i)
597 DesktopContent._mouseMoveSubscribers[i](mouseEvent);
599 if(!DesktopContent._theWindow)
return;
601 DesktopContent._windowMouseX = parseInt(mouseEvent.clientX);
602 DesktopContent._windowMouseY = parseInt(mouseEvent.clientY);
604 if(DesktopContent._desktopNeedsMouseXY)
605 localUpdateMouseOverMailbox();
615 function localUpdateMouseOverMailbox()
617 console.log(
"Update desktop mouse");
619 DesktopContent._theDesktopWindow.postMessage(
621 "windowId": DesktopContent._theWindowId,
622 "request":
"updateMouseoverXY",
623 "x": DesktopContent._windowMouseX,
624 "y": DesktopContent._windowMouseY
638 DesktopContent.mouseMoveSubscriber =
function(newHandler)
640 DesktopContent._mouseMoveSubscribers.push(newHandler);
644 DesktopContent.init();
653 DesktopContent._arrayOfFailedHandlers =
new Array();
658 DesktopContent._loadBox = 0;
659 DesktopContent._loadBoxId =
"DesktopContent-load-box";
660 DesktopContent._loadBoxTimer = 0;
661 DesktopContent._loadBoxRequestStack = 0;
667 DesktopContent.showLoading =
function(nextFunction)
673 window.setTimeout(
function()
676 DesktopContent.hideLoading();
686 if(DesktopContent._loadBoxRequestStack++)
690 if(!DesktopContent._loadBox)
693 var el = document.getElementById(DesktopContent._loadBoxId);
696 var body = document.getElementsByTagName(
"BODY")[0];
700 window.setTimeout(
function() { Debug.errorPop(err,severity)}, 1000);
705 el = document.createElement(
"div");
706 el.setAttribute(
"id", DesktopContent._loadBoxId);
707 el.style.display =
"none";
710 str +=
"<table height='100%' width='100%'><td id='" +
711 DesktopContent._loadBoxId +
"-td'>Loading...</td></table>";
713 body.appendChild(el);
721 css +=
"#" + DesktopContent._loadBoxId +
723 "position: absolute; display: none; border: 2px solid gray;" +
724 "background-color: rgba(0,0,0,0.8); overflow-y: auto;" +
725 "overflow-x: auto; padding: 5px; -moz-border-radius: 2px;" +
726 "-webkit-border-radius: 2px; border-radius: 2px;" +
727 "font-size: 18px; z-index: 2147483647;" +
729 "font-family: 'Comfortaa', arial; text-align: left;" +
730 "left: 8px; top: 8px; margin-right: 8px; height:400px; " +
732 css +=
"#" + DesktopContent._loadBoxId +
" table" +
734 "background-color: rgba(0,0,0,0.8);" +
747 var style = document.createElement(
'style');
749 if (style.styleSheet) {
750 style.styleSheet.cssText = css;
752 style.appendChild(document.createTextNode(css));
755 document.getElementsByTagName(
'head')[0].appendChild(style);
757 DesktopContent._loadBox = el;
767 if(typeof DesktopContent !=
'undefined')
769 WW = DesktopContent.getWindowWidth();
770 WH = DesktopContent.getWindowHeight();
772 else if(typeof Desktop !=
'undefined' && Desktop.desktop)
774 WW = DesktopContent.getDesktopWidth();
775 WH = DesktopContent.getDesktopHeight();
778 var X = DesktopContent.getWindowScrollLeft() + (WW - W - 4)/2;
779 var Y = DesktopContent.getWindowScrollTop() + (WH - H -4)/2;
782 DesktopContent._loadBox.style.left = (X) +
"px";
783 DesktopContent._loadBox.style.top = (Y) +
"px";
784 DesktopContent._loadBox.style.width = (W) +
"px";
785 DesktopContent._loadBox.style.height = (H) +
"px";
787 DesktopContent._loadBox.style.display =
"block";
791 var loadBoxStr =
"..";
792 var el = document.getElementById(DesktopContent._loadBoxId +
"-td");
793 el.innerHTML =
"Loading" + loadBoxStr;
796 var loadBoxAnimationFunction =
function() {
797 if(loadBoxStr.length > 3) loadBoxStr =
"";
800 el.innerHTML =
"Loading" + loadBoxStr;
803 window.clearInterval(DesktopContent._loadBoxTimer);
804 DesktopContent._loadBoxTimer = window.setInterval(loadBoxAnimationFunction, 300);
808 DesktopContent._loadBoxHideTimer = 0;
809 DesktopContent.hideLoading =
function()
811 window.setTimeout(localHideLoadBox, 300);
814 function localHideLoadBox()
816 if(--DesktopContent._loadBoxRequestStack)
819 window.clearInterval(DesktopContent._loadBoxTimer);
821 document.getElementById(DesktopContent._loadBoxId).style.display =
"none";
852 DesktopContent.XMLHttpRequest =
function(requestURL, data, returnHandler,
853 reqParam, progressHandler, callHandlerOnErr, doNotShowLoadingOverlay,
854 targetSupervisor, ignoreSystemBlock, doNotOfferSequenceChange)
858 var sequence = DesktopContent._sequence;
862 var callerLocation =
"";
865 callerLocation = (
new Error).stack.split(
"\n")[2];
866 var tmpCallerLocation = callerLocation.slice(0,callerLocation.indexOf(
' ('));
867 callerLocation = callerLocation.slice(tmpCallerLocation.length+2,
868 callerLocation.length-1);
874 if((!ignoreSystemBlock && DesktopContent._blockSystemCheckMailbox)
875 || DesktopContent._needToLoginMailbox)
879 errStr =
"The system appears to be down.";
880 errStr +=
" (Try reconnecting/reloading the page, or alert ots admins if problem persists.)";
882 if(!callHandlerOnErr)
883 Debug.log(
"Error: " + errStr,Debug.HIGH_PRIORITY);
887 if(DesktopContent._arrayOfFailedHandlers.length < 2)
889 for(var rh in DesktopContent._arrayOfFailedHandlers)
890 if(DesktopContent._arrayOfFailedHandlers[rh] == returnHandler)
892 errStr =
"Blocking multiple error responses to same handler. \nRecurring error should be handled by returnHandler: " + returnHandler;
894 if(!callHandlerOnErr)
895 Debug.log(errStr.substr(0,200) +
"...",Debug.HIGH_PRIORITY);
902 errStr =
"Quiet Mode. Blocking multiple error responses to ALL handlers. \nRecurring error should be handled by returnHandler:" + returnHandler;
903 Debug.log(errStr.substr(0,200) +
"...",Debug.HIGH_PRIORITY);
907 if(!found && !callHandlerOnErr)
908 DesktopContent._arrayOfFailedHandlers.push(returnHandler);
911 if(returnHandler && !found && callHandlerOnErr)
912 returnHandler(req, reqParam, errStr);
916 req =
new XMLHttpRequest();
918 if(progressHandler) req.upload.addEventListener(
"progress", progressHandler,
false);
922 var timeoutFunction =
function()
924 Debug.log(
"It has been 60 seconds.. still waiting for a response. " +
925 "Is there an infinite loop occuring at the server? " +
926 "Or is this just a really long request..",
927 Debug.HIGH_PRIORITY);
928 timeoutTimer = window.setTimeout(timeoutFunction, 60000);
930 timeoutTimer = window.setTimeout(timeoutFunction, 60000);
933 req.onreadystatechange =
function() {
935 if (req.readyState==4)
937 window.clearTimeout(timeoutTimer);
939 if(!doNotShowLoadingOverlay)
940 DesktopContent.hideLoading();
946 DesktopContent._lastCookieTime = parseInt((
new Date()).getTime());
949 if(req.responseText == Globals.REQ_NO_PERMISSION_RESPONSE)
951 errStr =
"Request failed due to insufficient account permissions.";
953 if(!doNotOfferSequenceChange && DesktopContent._sequence)
955 Debug.log(
"In wiz mode, attempting to fix access code on the fly...");
957 DesktopContent.popUpVerification(
958 errStr +
"<br><br>Please enter a valid access code: ",
960 function(newSequence)
962 DesktopContent._sequence = newSequence.trim();
963 Debug.log(
"Resulting sequence code: " + DesktopContent._sequence);
965 if(DesktopContent._sequence)
967 Debug.log(
"Retrying request with new access code...");
968 DesktopContent.XMLHttpRequest(requestURL, data, returnHandler,
969 reqParam, progressHandler, callHandlerOnErr, doNotShowLoadingOverlay,
970 targetSupervisor, ignoreSystemBlock);
974 DesktopContent._sequence =
"a";
990 else if(req.responseText == Globals.REQ_USER_LOCKOUT_RESPONSE)
992 errStr =
"Request failed because another user has locked ots. Put your mouse over the lock icon at the top of the dashboard to see who.";
995 else if(req.responseText == Globals.REQ_NO_LOGIN_RESPONSE)
997 errStr =
"Login has expired.";
999 if(ignoreSystemBlock || !DesktopContent._blockSystemCheckMailbox)
1001 DesktopContent._needToLoginMailbox =
true;
1002 if(DesktopContent._theDesktopWindow)
1003 DesktopContent._theDesktopWindow.postMessage(
1005 "windowId": DesktopContent._theWindowId,
1006 "request":
"needToLogin"
1011 else if(req.responseText == Globals.REQ_LOCK_REQUIRED_RESPONSE)
1013 errStr =
"Request failed because the request requires the user to lockout the system. Please take over the lock in the Settings area to proceed.";
1018 if(!req.responseXML)
1020 errStr =
"Request response is invalid XML!";
1026 DesktopContent._lastCookieCode = DesktopContent.getXMLValue(req,
'CookieCode');
1027 if (typeof DesktopContent._lastCookieCode ==
'undefined')
1029 errStr =
"Request Failed - Missing Cookie in Response.";
1031 if(ignoreSystemBlock || !DesktopContent._blockSystemCheckMailbox)
1033 DesktopContent._needToLoginMailbox =
true;
1034 if(DesktopContent._theDesktopWindow)
1035 DesktopContent._theDesktopWindow.postMessage(
1037 "windowId": DesktopContent._theWindowId,
1038 "request":
"needToLogin"
1043 else if(DesktopContent._lastCookieCode !=
"AllowNoUser")
1046 Debug.log(
"Updating cookie code.");
1048 var deltaTime = DesktopContent._lastCookieTime - DesktopContent._updateTimeMailbox;
1049 DesktopContent._cookieCodeMailbox = DesktopContent._lastCookieCode;
1051 if(DesktopContent._theDesktopWindow && deltaTime > 5*1000 )
1053 Debug.log(
"Posting cookie code to desktop.");
1055 DesktopContent._updateTimeMailbox = DesktopContent._lastCookieTime;
1056 DesktopContent._theDesktopWindow.postMessage(
1058 "windowId": DesktopContent._theWindowId,
1059 "request":
"updateCookieCode",
1060 "cookieCode": DesktopContent._cookieCodeMailbox,
1061 "cookieCodeTime": DesktopContent._updateTimeMailbox
1077 else if(req.status == 0)
1081 errStr =
"Request was interrupted (Status=0). " +
1082 "Likely this means the server crashed (or the desktop window making the request was closed), " +
1083 " in the middle of a request. " +
1084 "\n(It also could mean 'potential security risk' like a cross-domain request) ";
1090 errStr =
"Request Failed (code: " + req.status +
1091 ") - Bad Address: " + origin +
"?urn=" + urn +
1093 Debug.log(errStr,Debug.HIGH_PRIORITY);
1097 if(DesktopContent._arrayOfFailedHandlers.length < 2)
1099 for(var rh in DesktopContent._arrayOfFailedHandlers)
1100 if(DesktopContent._arrayOfFailedHandlers[rh] == returnHandler)
1102 errStr =
"Blocking multiple error responses to same handler. \nDoes target exist? Here is the (would be) returnHandler: \n\n" + returnHandler;
1103 Debug.log(errStr.substr(0,200) +
"...",Debug.HIGH_PRIORITY);
1104 found =
true;
break;
1109 errStr =
"Quiet Mode. Blocking multiple error responses to ALL handlers. \nDoes target exist? Here is the (would be) returnHandler: \n\n " + returnHandler;
1110 Debug.log(errStr.substr(0,200) +
"...",Debug.HIGH_PRIORITY);
1113 if(!found) DesktopContent._arrayOfFailedHandlers.push(returnHandler);
1118 var errArr = (callHandlerOnErr || !req.responseXML)?[]:DesktopContent.getXMLRequestErrors(req);
1119 if(errArr.length && !callHandlerOnErr)
1121 for(var i=0;i<errArr.length;++i)
1123 errStr += (i?
"\n\n":
"") + errArr[i];
1125 console.log(
"Initial request location: \n" + callerLocation);
1126 Debug.log(
"Error: " + errArr[i],
1127 (ignoreSystemBlock || requestURL.indexOf(
"TooltipRequest?") >= 0)?
1129 Debug.HIGH_PRIORITY);
1132 else if(errStr !=
"")
1134 errStr +=
"\n\n(Try refreshing the page, or alert ots admins if problem persists.)";
1136 console.log(
"Initial request location: \n" + callerLocation);
1137 Debug.log(
"Error: " + errStr,
1138 (callHandlerOnErr ||
1139 ignoreSystemBlock ||
1140 requestURL.indexOf(
"TooltipRequest?") >= 0)?
1142 Debug.HIGH_PRIORITY);
1148 if(returnHandler && (errStr==
"" || callHandlerOnErr))
1150 returnHandler(req, reqParam, errStr);
1173 var cc = DesktopContent._cookieCodeMailbox;
1174 reqData =
"CookieCode="+cc+((data===undefined)?
"":(
"&"+data));
1178 reqData =
"sequence="+sequence+((data===undefined)?
"":(
"&"+data));
1182 var urn = DesktopContent._localUrnLid;
1183 var origin = DesktopContent._localOrigin;
1185 if(!urn || targetSupervisor)
1187 urn = DesktopContent._serverUrnLid;
1188 origin = DesktopContent._serverOrigin;
1192 if(!doNotShowLoadingOverlay)
1193 DesktopContent.showLoading();
1196 var reqURL = origin+
"/urn:xdaq-application:lid="+urn+
"/"+requestURL;
1198 req.open(
"POST", reqURL,
true);
1199 req.setRequestHeader(
"Content-Type",
"text/plain;charset=UTF-8");
1217 DesktopContent.getXMLRequestErrors =
function(req) {
1219 if(!req || !req.responseXML)
1220 return [
"Unknown error occured " +
1221 "(XML response may have been illegal)!"];
1223 var errNodes = DesktopContent.getXMLChildren(req,
"Error");
1225 for(var i=0;i<errNodes.length;++i)
1226 errArr.push(errNodes[i].getAttribute(
"value"));
1232 DesktopContent.getXMLAttributeValue =
function(req, name, attribute) {
1234 if(el = DesktopContent.getXMLNode(req,name))
1235 return el.getAttribute(attribute);
1236 else if(name ==
"Error" &&
1237 (!req || !req.responseXML))
1238 return "Unknown error occured " +
1239 "(XML response may have been illegal)!";
1247 DesktopContent.getXMLValue =
function(req, name) {
1248 if(!req)
return undefined;
1251 return req.getAttribute(
"value");
1253 return DesktopContent.getXMLAttributeValue(req,name,
"value");
1259 DesktopContent.getXMLChildren =
function(req, nodeName) {
1261 if(req && req.responseXML)
1262 req = req.responseXML;
1263 return req.getElementsByTagName(nodeName);
1270 DesktopContent.getXMLNode =
function(req, name) {
1272 if(req && req.responseXML)
1273 req = req.responseXML;
1280 els = req.getElementsByTagName(name);
1282 catch(e) {
return undefined;}
1306 DesktopContent.getXMLDataNode =
function(req, name) {
1307 return DesktopContent.getXMLNode(
"DATA");
1313 DesktopContent.tooltipConditionString =
function(str) {
1314 return str.replace(/<INDENT>/g,
1315 "<div style='margin-left:60px;'>").replace(/<\/INDENT>/g,
1316 "</div>").replace(/<TAB>/g,
1317 "<div style='margin-left:60px;'>").replace(/<\/TAB>/g,
1330 DesktopContent.tooltip =
function(id,tip,alwaysShow) {
1332 if(typeof Desktop !==
'undefined')
1334 DesktopContent._serverUrnLid = urnLid_;
1335 DesktopContent._serverOrigin = serverOrigin_;
1337 DesktopContent._sequence = DesktopContent.getDesktopParameter(0,
"code");
1338 if(!DesktopContent._sequence || DesktopContent._sequence ==
"")
1339 DesktopContent._sequence = 0;
1341 Debug.log(
"In Wizard Mode with Sequence=" + DesktopContent._sequence);
1345 var srcStackString,srcFunc,srcFile;
1347 if(Debug.BROWSER_TYPE == 1)
1349 srcStackString = (
new Error).stack.split(
"\n")[2];
1350 srcFunc = srcStackString.trim().split(
' ')[1];
1352 else if(Debug.BROWSER_TYPE == 2)
1354 srcStackString = (
new Error).stack.split(
"\n")[1];
1355 srcFunc = srcStackString.trim().split(
'@')[0];
1358 srcFile = srcStackString.substr(srcStackString.lastIndexOf(
'/')+1);
1359 if(srcFile.indexOf(
'?') >= 0)
1360 srcFile = srcFile.substr(0,srcFile.indexOf(
'?'));
1361 if(srcFile.indexOf(
':') >= 0)
1362 srcFile.substr(0,srcFile.indexOf(
':'));
1365 if(tip === undefined)
1367 Debug.log(
"Undefined tooltip string at " + srcStackString +
"\n" +
1368 srcFunc +
"\n" + srcFile +
".\n\n Tooltip Usage: <id> <tip>", Debug.HIGH_PRIORITY);
1376 for(var i=0;i<oldId.length;++i)
1377 if((oldId[i] >=
'a' && oldId[i] <=
'z') ||
1378 (oldId[i] >=
'A' && oldId[i] <=
'Z') ||
1379 (oldId[i] >=
'0' && oldId[i] <=
'9'))
1383 if(alwaysShow ||
id ==
"ALWAYS")
1384 localFinishTooltip();
1386 DesktopContent.XMLHttpRequest(
1387 "TooltipRequest?RequestType=check" +
1388 "&srcFunc=" + srcFunc +
1389 "&srcFile=" + srcFile +
1400 function localFinishTooltip(req)
1403 var showTooltip = !req ||
1404 DesktopContent.getXMLValue(req,
"ShowTooltip");
1415 str +=
"<input type='checkbox' " +
1416 "id='DesktopContent-tooltip-SetNeverShowCheckbox-above-" +
1419 "DesktopContent.tooltipSetAlwaysShow(\"" +
1422 id +
"\", this.checked);" +
"'>";
1424 str +=
"<a onclick='" +
1425 "var el = document.getElementById(\"" +
1426 "DesktopContent-tooltip-SetNeverShowCheckbox-above-" +
1428 "el.checked = !el.checked;" +
1429 "DesktopContent.tooltipSetAlwaysShow(\"" +
1432 id +
"\", el.checked);" +
1434 str +=
"Never show the Tooltip below, or...";
1440 str +=
"<input type='checkbox' " +
1441 "id='DesktopContent-tooltip-SetNeverShowCheckbox-hour-" +
1444 "DesktopContent.tooltipSetAlwaysShow(\"" +
1447 id +
"\", 0 /*neverShow*/, this.checked);" +
"'>";
1449 str +=
"<a onclick='" +
1450 "var el = document.getElementById(\"" +
1451 "DesktopContent-tooltip-SetNeverShowCheckbox-hour-" +
1453 "el.checked = !el.checked;" +
1454 "DesktopContent.tooltipSetAlwaysShow(\"" +
1457 id +
"\", 0 /*neverShow*/, el.checked);" +
1459 str +=
"Silence this Tooltip for a week (can be reset in Settings):";
1468 str +=
"<center><b>'" + oldId +
"' Tooltip</b></center><br>";
1473 str += DesktopContent.tooltipConditionString(tip);
1480 str +=
"<input type='checkbox' " +
1481 "id='DesktopContent-tooltip-SetNeverShowCheckbox-below-" +
1484 "DesktopContent.tooltipSetAlwaysShow(\"" +
1487 id +
"\", this.checked);" +
"'>";
1489 str +=
"<a onclick='" +
1490 "var el = document.getElementById(\"" +
1491 "DesktopContent-tooltip-SetNeverShowCheckbox-below-" +
1493 "el.checked = !el.checked;" +
1494 "DesktopContent.tooltipSetAlwaysShow(\"" +
1497 id +
"\", el.checked);" +
1499 str +=
"Never show the Tooltip above.";
1504 Debug.log(
"srcStackString " + srcStackString);
1505 Debug.log(str,Debug.TIP_PRIORITY);
1513 DesktopContent.setWindowTooltip =
function(tip)
1515 var windowTooltipElement = document.createElement(
"div");
1516 windowTooltipElement.setAttribute(
"id",
"otsDesktopWindowTooltipElement");
1517 windowTooltipElement.setAttribute(
"style",
"display:none");
1519 windowTooltipElement.innerText = encodeURIComponent(tip);
1520 document.body.appendChild(windowTooltipElement);
1526 DesktopContent.setSecurityOn =
function(on) {
1527 console.log(
"Reached");
1528 DesktopContent.XMLHttpRequest(
1529 "ToggleSecurityCodeGeneration?RequestType=TurnGenerationOn" +
1532 ,DesktopContent.toggleSecurityCodeGenerationHandler
1538 DesktopContent.toggleSecurityCodeGenerationHandler =
function(req) {
1539 var status = DesktopContent.getXMLValue(req,
"Status");
1540 Debug.log(
"Status: " + status);
1541 if (status ==
"Generation_Success") {
1542 Debug.log(
"Successfully switched to using authentication sequence!");
1543 Debug.closeErrorPop();
1544 Debug.log(
"If you wish to return to the default security generation, you can use the 'Reset User Information' in the " +
1545 "'Edit User Data' app.");
1546 Debug.log(
"Plase refer to the console for the new link!", Debug.INFO_PRIORITY);
1553 DesktopContent.tooltipSetAlwaysShow =
function(srcFunc,srcFile,id,neverShow,temporarySilence) {
1554 Debug.log(
"neverShow = " + neverShow +
" tempSilence = " + temporarySilence);
1556 if(temporarySilence)
1558 DesktopContent.XMLHttpRequest(
1559 "TooltipRequest?RequestType=setNeverShow" +
1560 "&srcFunc=" + srcFunc +
1561 "&srcFile=" + srcFile +
1563 "&doNeverShow=" + (neverShow?1:0) +
1564 "&temporarySilence=" + (temporarySilence?1:0)
1566 ,0,0,0,0,
true,
true);
1568 if(temporarySilence)
return;
1571 document.getElementById(
"DesktopContent-tooltip-SetNeverShowCheckbox-below-" +
1572 id).checked = neverShow;
1573 document.getElementById(
"DesktopContent-tooltip-SetNeverShowCheckbox-above-" +
1574 id).checked = neverShow;
1585 DesktopContent.popUpVerification =
function(prompt, func, val, bgColor,
1586 textColor, borderColor, getUserInput, dialogWidth, cancelFunc,
1587 yesButtonText, noAutoComplete, defaultUserInputValue) {
1596 if(DesktopContent._verifyPopUp)
1597 DesktopContent._verifyPopUp.parentNode.removeChild(DesktopContent._verifyPopUp);
1600 if(val != undefined)
1601 prompt = prompt.replace(/REPLACE/g, val);
1608 if(!bgColor) bgColor =
"rgb(255,241,189)";
1609 if(!textColor) textColor =
"black";
1610 if(!borderColor) borderColor =
"black";
1611 if(!dialogWidth) dialogWidth = 200;
1616 css +=
"#" + DesktopContent._verifyPopUpId +
" " +
1617 "{position: absolute; z-index: 10000; border-radius: 5px; padding: 10px;" +
1618 "background-color: " + bgColor +
"; border: 2px solid " + borderColor +
";" +
1619 "color: " + textColor +
";text-align: center; overflow: auto;" +
1622 css +=
"#" + DesktopContent._verifyPopUpId +
"-text " +
1624 "color: " + textColor +
";width: " + dialogWidth +
"px; padding-bottom: 10px;" +
1627 css +=
"#" + DesktopContent._verifyPopUpId +
" *" +
1629 "color: " + textColor +
";" +
1631 css +=
"#" + DesktopContent._verifyPopUpId +
" input" +
1633 "cursor: pointer;" +
1637 var style = document.createElement(
'style');
1639 if (style.styleSheet) {
1640 style.styleSheet.cssText = css;
1642 style.appendChild(document.createTextNode(css));
1645 document.getElementsByTagName(
'head')[0].appendChild(style);
1648 var body = document.getElementsByTagName(
"BODY")[0];
1650 var el = document.createElement(
"div");
1651 el.setAttribute(
"id", DesktopContent._verifyPopUpId);
1652 el.onmouseup =
function(e) {e.stopPropagation();};
1653 el.onmousedown =
function(e) {e.stopPropagation();};
1654 el.onmouseover =
function(e) {e.stopPropagation();};
1656 var userInputStr =
"";
1659 "<input type='text' id='DesktopContent_popUpUserInput' " +
1660 "onclick='event.stopPropagation();'" +
1661 (noAutoComplete?
"autocomplete='off' ":
"") +
1663 (defaultUserInputValue!==undefined?defaultUserInputValue:
"") +
"' " +
1666 var str =
"<div id='" + DesktopContent._verifyPopUpId +
"-text'>" +
1667 prompt +
"<br>" + userInputStr +
"</div>" +
1668 "<input type='submit' value='" +
1669 (yesButtonText?yesButtonText:
"Yes") +
1671 "onclick='event.stopPropagation();' " +
1673 " " +
1674 "<input type='submit' " +
1675 "onclick='event.stopPropagation();' " +
1680 el.getElementsByTagName(
'input')[0 + (getUserInput?1:0)].onmouseup =
1681 function(event){
event.stopPropagation(); DesktopContent.clearPopUpVerification(func);};
1683 el.getElementsByTagName(
'input')[1 + (getUserInput?1:0)].onmouseup =
1684 function(event){
event.stopPropagation(); DesktopContent.clearPopUpVerification(cancelFunc);};
1688 DesktopContent._verifyPopUp = el;
1689 el.style.left =
"-1000px";
1690 body.appendChild(el);
1695 var tel = el.getElementsByTagName(
'input')[0];
1697 tel.setSelectionRange(0,tel.value.length);
1703 if(event.keyCode == 13)
1705 Debug.log(
"Accepting enter key");
1706 event.preventDefault();
1707 event.stopPropagation();
1708 DesktopContent.clearPopUpVerification(func);
1710 else if(event.keyCode == 27)
1712 Debug.log(
"Accepting escape key");
1713 event.preventDefault();
1714 event.stopPropagation();
1715 DesktopContent.clearPopUpVerification(cancelFunc);
1720 el.getElementsByTagName(
'input')[0].focus();
1726 if(event.keyCode == 13)
1728 Debug.log(
"Accepting enter key");
1729 event.preventDefault();
1730 event.stopPropagation();
1731 DesktopContent.clearPopUpVerification(func);
1733 else if(event.keyCode == 27)
1735 Debug.log(
"Accepting escape key");
1736 event.preventDefault();
1737 event.stopPropagation();
1738 DesktopContent.clearPopUpVerification(cancelFunc);
1743 var w = el.offsetWidth;
1744 var h = el.offsetHeight;
1745 var x = DesktopContent.getMouseX();
1746 var y = DesktopContent.getMouseY();
1753 while(x+w > DesktopContent.getWindowWidth())
1755 if(y > DesktopContent.getWindowHeight()/2 + h/2)
1757 while(y+h > DesktopContent.getWindowHeight())
1763 Debug.log(
"X: " + x +
1768 el.style.left = (DesktopContent.getWindowScrollLeft() + x) +
"px";
1769 el.style.top = (DesktopContent.getWindowScrollTop() + y) +
"px";
1774 DesktopContent.clearPopUpVerification =
function(func) {
1778 var userEl = document.getElementById(
"DesktopContent_popUpUserInput");
1779 var param = userEl?userEl.value:undefined;
1782 if(DesktopContent._verifyPopUp) DesktopContent._verifyPopUp.parentNode.removeChild(DesktopContent._verifyPopUp);
1783 DesktopContent._verifyPopUp = 0;
1806 DesktopContent.setPopUpPosition =
function(el,w,h,padding,border,
1807 margin,doNotResize,offsetUp) {
1809 Debug.log(
"DesktopContent.setPopUpPosition");
1811 if(padding === undefined) padding = 10;
1812 if(border === undefined) border = 1;
1813 if(margin === undefined) margin = 0;
1820 DesktopContent.setPopUpPosition.stopPropagation =
function(event) {
1822 event.stopPropagation();
1828 DesktopContent.setPopUpPosition.popupResize =
function() {
1834 window.removeEventListener(
"resize",DesktopContent.setPopUpPosition.popupResize);
1835 window.removeEventListener(
"scroll",DesktopContent.setPopUpPosition.popupResize);
1839 catch(err) {
return;}
1845 var ww = DesktopContent.getWindowWidth()-(padding+border)*2;
1846 var wh = DesktopContent.getWindowHeight()-(padding+border)*2;
1850 var ah = el.offsetHeight;
1852 if(w === undefined || h === undefined)
1854 w = ww - (margin)*2;
1855 h = wh - (margin)*2;
1859 x = (DesktopContent.getWindowScrollLeft() + ((ww-w)/2));
1860 y = (DesktopContent.getWindowScrollTop() + ((wh-h)/2)) - (offsetUp|0) - 100;
1862 if(y < DesktopContent.getWindowScrollTop() +
1864 y = DesktopContent.getWindowScrollTop() + margin +
1868 if(w > ww-margin-padding)
1869 x = -DesktopContent.getWindowScrollLeft();
1870 if(ah > wh-margin-padding)
1871 y = -DesktopContent.getWindowScrollTop();
1873 el.style.left = x +
"px";
1874 el.style.top = y +
"px";
1876 DesktopContent.setPopUpPosition.popupResize();
1879 el.style.width = w +
"px";
1880 el.style.height = h +
"px";
1892 el.style.position =
"absolute";
1893 el.style.zIndex =
"10000";
1894 el.style.border =
"1px solid #770000";
1895 el.style.backgroundColor =
"#efeaea";
1896 el.style.textAlign =
"center";
1897 el.style.padding =
"10px";
1898 el.style.color =
"black";
1902 window.addEventListener(
"resize",DesktopContent.setPopUpPosition.popupResize);
1903 window.addEventListener(
"scroll",DesktopContent.setPopUpPosition.popupResize);
1905 el.addEventListener(
"keydown",DesktopContent.setPopUpPosition.stopPropagation);
1906 el.addEventListener(
"mousemove",DesktopContent.setPopUpPosition.stopPropagation);
1907 el.addEventListener(
"mousemove",DesktopContent.mouseMove);
1909 el.style.overflow =
"auto";
1911 return {
"w" : w,
"h" : h,
"x" : x,
"y" : y};
1917 DesktopContent.parseColor =
function(colorStr)
1922 var m = colorStr.split(
"(")[1].split(
")")[0].split(
",");
1923 if( m)
return "rgb("+m[0]+
","+m[1]+
","+m[2]+
")";
1924 else throw new Error(
"Color "+colorStr+
" could not be parsed.");
1931 DesktopContent.getColorAsRGBA =
function(colorStr)
1935 var div = document.createElement(
'div');
1938 div.style.color = colorStr;
1939 div.style.display =
"none";
1940 document.body.appendChild(div);
1942 m = getComputedStyle(div).color.split(
"(")[1].split(
")")[0].split(
",");
1944 document.body.removeChild(div);
1946 if(m && m.length == 3)
return "rgba("+m[0]+
","+m[1]+
","+m[2]+
",255)";
1947 else if(m && m.length == 4)
return "rgba("+m[0]+
","+m[1]+
","+m[2]+
","+m[3]+
")";
1948 else throw new Error(
"Color "+colorStr+
" could not be parsed.");
1953 DesktopContent.getWindowWidth =
function() {
return window.innerWidth-1; }
1954 DesktopContent.getWindowHeight =
function() {
return window.innerHeight-1; }
1955 DesktopContent.getBodyWidth =
function() {
return document.body.offsetWidth; }
1956 DesktopContent.getBodyHeight =
function() {
return document.body.offsetHeight; }
1957 DesktopContent.getWindowScrollLeft =
function() {
return document.documentElement.scrollLeft || document.body.scrollLeft || 0; }
1958 DesktopContent.getWindowScrollTop =
function() {
return document.documentElement.scrollTop || document.body.scrollTop || 0; }
1959 DesktopContent.getMouseX =
function() {
return DesktopContent._windowMouseX | 0; }
1960 DesktopContent.getMouseY =
function() {
return DesktopContent._windowMouseY | 0; }
1961 DesktopContent.getDefaultWindowColor =
function() {
1963 if(!DesktopContent._windowColorPostbox || !DesktopContent._desktopColor)
1966 Debug.log(
"Color post boxes not setup! So giving default.",Debug.MED_PRIORITY);
1967 return "rgb(178,210,240)";
1970 wrgba = DesktopContent._windowColorPostbox.split(
"(")[1].split(
")")[0].split(
",");
1971 drgb = DesktopContent._desktopColor.split(
"(")[1].split(
")")[0].split(
",");
1973 drgb[i] = (drgb[i]*(1-wrgba[3]) + wrgba[i]*wrgba[3])|0;
1974 return "rgb("+drgb[0]+
","+drgb[1]+
","+drgb[2]+
")";
1979 DesktopContent.getDefaultDashboardColor =
function() {
return DesktopContent.parseColor(DesktopContent._dashboardColorPostbox); }
1980 DesktopContent.getDefaultDesktopColor =
function() {
1981 if(!DesktopContent._desktopColor)
1984 Debug.log(
"Color post boxes not setup! So giving default.",Debug.MED_PRIORITY);
1985 return "rgb(15,34,105)";
1987 Debug.log(
"Returning desktop color");
1988 return DesktopContent._desktopColor;
1993 DesktopContent.getUsername =
function() {
1995 DesktopContent.XMLHttpRequest(
1996 "Request?RequestType=GetUserDisplayName",
2004 return dispName.substr(dispName.indexOf(
",")+2);
2012 DesktopContent.openNewWindow =
function(name,subname,windowPath,unique,completeHandler) {
2014 Debug.log(
"DesktopContent.openNewWindow= " + windowPath);
2015 Debug.log(
"name= " + name);
2016 Debug.log(
"subname= " + subname);
2017 Debug.log(
"unique= " + unique);
2020 DesktopContent._theDesktopWindow.postMessage(
2022 "windowId": DesktopContent._theWindowId,
2023 "request":
"openNewWindow",
2025 "windowSubname": subname,
2026 "windowUnique": unique,
2027 "windowPath": windowPath
2131 DesktopContent.openNewBrowserTab =
function(name,subname,windowPath,unique)
2134 if(windowPath !== undefined)
2137 if(windowPath[0] ==
'?')
2138 windowPath = windowPath.substr(1);
2144 var i = windowPath.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
2145 var isAllNumbers =
true;
2146 for(i;i<windowPath.length;++i)
2150 if(windowPath[i] <
"0" || windowPath[i] >
"9")
2152 isAllNumbers =
false;
2161 Debug.log(
"An error occurred while trying to open the window. " +
2162 "The window path seems to be invalid:[" + DesktopContent.getExceptionLineNumber(e) +
"]: " + e, Debug.HIGH_PRIORITY);
2166 Debug.log(
"DesktopWindow= " + windowPath);
2168 Debug.log(
"name= " + name);
2169 Debug.log(
"subname= " + subname);
2170 Debug.log(
"unique= " + unique);
2173 url = DesktopContent._serverOrigin +
2174 "/urn:xdaq-application:lid="+DesktopContent._serverUrnLid+
"/";
2178 var str =
"requestingWindowId=" + DesktopContent._theWindowId;
2179 str +=
"&windowName=" + name;
2180 str +=
"&windowSubname=" + subname;
2181 str +=
"&windowUnique=" + unique;
2182 str +=
"&windowPath=" + windowPath;
2185 if(DesktopContent._sequence)
2186 url +=
"Verify?code=" + DesktopContent._sequence +
"&" + str;
2233 Debug.log(
"DesktopContent.openNewBrowserTab= " + url);
2235 window.open(url,
'_blank');
2241 if(windowPath !== undefined)
2244 if(windowPath[0] ==
'?')
2245 windowPath = windowPath.substr(1);
2251 var i = windowPath.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
2252 var isAllNumbers =
true;
2253 for(i;i<windowPath.length;++i)
2257 if(windowPath[i] <
"0" || windowPath[i] >
"9")
2259 isAllNumbers =
false;
2268 Debug.log(
"An error occurred while trying to open the window. " +
2269 "The window path seems to be invalid:[" + DesktopContent.getExceptionLineNumber(e) +
"]: " + e, Debug.HIGH_PRIORITY);
2273 Debug.log(
"DesktopWindow= " + windowPath);
2275 Debug.log(
"name= " + name);
2276 Debug.log(
"subname= " + subname);
2277 Debug.log(
"unique= " + unique);
2279 var search = DesktopContent._theWindow.parent.parent.window.location.search;
2280 url = DesktopContent._theWindow.parent.parent.window.location.pathname;
2282 var str =
"requestingWindowId=" + DesktopContent._theWindowId;
2283 str +=
"&windowName=" + name;
2284 str +=
"&windowSubname=" + subname;
2285 str +=
"&windowUnique=" + unique;
2286 str +=
"&windowPath=" + windowPath;
2293 var i = url.indexOf(
"urn:xdaq-application:lid=") + (
"urn:xdaq-application:lid=").length;
2294 var isAllNumbers =
true;
2295 for(i;i<url.length;++i)
2299 if(url[i] <
"0" || url[i] >
"9")
2301 isAllNumbers =
false;
2312 var i = search.indexOf(
"requestingWindowId");
2314 search = search.substr(0,i);
2317 if(search.substr(0,6) ==
"?code=")
2319 i = search.substr(
'&');
2320 search =
"?code=" + DesktopContent._sequence +
2321 (i>0?search.substr(i):
"");
2325 if(search.length && search[search.length-1] !=
'?'
2326 && search[search.length-1] !=
'&')
2328 url += search + str;
2331 Debug.log(
"DesktopContent.openNewBrowserTab= " + url);
2333 window.open(url,
'_blank');
2342 DesktopContent.addDesktopIcon =
function(caption, altText,
2343 folderPath, unique, permissionString,
2344 imageURL, windowContentURL, linkedApp, parameters) {
2346 var iconParameters =
"";
2347 if(parameters && parameters.length)
2349 if(typeof parameters ===
"string")
2350 iconParameters = parameters;
2352 for(var i in parametersObject)
2354 iconParameters += encodeURIComponent(i) +
"=" +
2355 encodeURIComponent(iconParameters[i]) +
"&";
2359 Debug.log(
"iconParameters = " + iconParameters);
2361 var iconLinkedApp =
"";
2362 var iconLinkedAppLID = 0;
2365 if((linkedApp|0) > 0)
2366 iconLinkedAppLID = linkedApp|0;
2368 iconLinkedApp = linkedApp;
2371 var req =
"Request?RequestType=addDesktopIcon"
2373 +
"&iconCaption=" + encodeURIComponent(caption)
2374 +
"&iconAltText=" + encodeURIComponent(altText)
2375 +
"&iconFolderPath=" + encodeURIComponent(folderPath)
2376 +
"&iconPermissions=" + encodeURIComponent(permissionString)
2377 +
"&iconImageURL=" + encodeURIComponent(imageURL)
2378 +
"&iconWindowURL=" + encodeURIComponent(windowContentURL)
2379 +
"&iconEnforceOneWindowInstance=" + (unique?
"1":
"0")
2380 + (iconLinkedAppLID?
2381 (
"&iconLinkedAppLID=" + iconLinkedAppLID):
2382 (
"&iconLinkedApp=" + iconLinkedApp)
2385 Debug.log(
"Create Icon req = " + req);
2387 DesktopContent.XMLHttpRequest(req,
2389 "iconParameters=" + encodeURIComponent(iconParameters)
2393 Debug.log(
"Successfully added icon '" +
2395 "!'",Debug.INFO_PRIORITY);
2398 if(activateSystemConfigHandler)
2400 activateSystemConfigHandler(req);
2411 DesktopContent._theDesktopWindow.postMessage(
2413 "windowId": DesktopContent._theWindowId,
2414 "request":
"refreshIcons"
2425 DesktopContent.systemBlackout =
function(doBlackout)
2427 Debug.log(
"systemBlackout =" + doBlackout);
2429 DesktopContent._theDesktopWindow.postMessage(
2431 "windowId": DesktopContent._theWindowId,
2432 "request": (doBlackout?
"startSystemBlackout":
"stopSystemBlackout")
2439 DesktopContent.getDesktopWindowTitle =
function()
2441 return DesktopContent._theWindow.parent.document.getElementById(
2442 "DesktopWindowHeader-" +
2443 DesktopContent._theWindow.name.split(
'-')[1]).innerHTML;
2446 DesktopContent.getExceptionLineNumber =
function(e)
2451 return e.stack.split(
'\n')[1].split(
':')[4].split(
')')[0]|0; }
2452 catch(newError) {
return -1; }