26 var Debug = Debug || {};
34 Debug.lastLogger =
"";
36 Debug.prependMessage =
"";
39 Debug.HIGH_PRIORITY = {
"DEBUG_PRIORITY":0};
40 Debug.WARN_PRIORITY = {
"DEBUG_PRIORITY":1};
41 Debug.INFO_PRIORITY = {
"DEBUG_PRIORITY":2};
42 Debug.TIP_PRIORITY = {
"DEBUG_PRIORITY":3};
43 Debug.MED_PRIORITY = {
"DEBUG_PRIORITY":50};
44 Debug.LOW_PRIORITY = {
"DEBUG_PRIORITY":100};
49 Debug.BROWSER_TYPE_OTHER = 0;
50 Debug.BROWSER_TYPE_CHROME = 1;
51 Debug.BROWSER_TYPE_FIREFOX = 2;
52 Debug.BROWSER_TYPE = Debug.BROWSER_TYPE_OTHER;
54 var tmp = (
new Error).stack;
56 Debug.BROWSER_TYPE = Debug.BROWSER_TYPE_CHROME;
57 else if(tmp[0] ==
'@')
58 Debug.BROWSER_TYPE = Debug.BROWSER_TYPE_FIREFOX;
60 console.log(
"Browser type = ", Debug.BROWSER_TYPE);
68 Debug.FontInconsolata =
new FontFace(
'Inconsolata',
'url(/WebPath/fonts/inconsolata/Inconsolata-Regular.ttf)');
69 document.fonts.add(Debug.FontInconsolata);
70 }
catch(e){console.log(
"Ignoring font errors: " + e);}
73 Debug.FontComfortaa =
new FontFace(
'Comfortaa',
'url(/WebPath/fonts/comfortaa/Comfortaa-Regular.ttf)');
74 document.fonts.add(Debug.FontComfortaa);
75 }
catch(e){console.log(
"Ignoring font errors: " + e);}
78 Debug.FontInconsolataBold =
new FontFace(
'Inconsolata-Bold',
'url(/WebPath/fonts/inconsolata/Inconsolata-Bold.ttf)');
79 document.fonts.add(Debug.FontInconsolataBold);
80 }
catch(e){console.log(
"Ignoring font errors: " + e);}
83 Debug.FontComfortaaBold =
new FontFace(
'Comfortaa-Bold',
'url(/WebPath/fonts/comfortaa/Comfortaa-Bold.ttf)');
84 document.fonts.add(Debug.FontComfortaaBold);
85 }
catch(e){console.log(
"Ignoring font errors: " + e);}
88 Debug.FontComfortaaLight =
new FontFace(
'Comfortaa-Light',
'url(/WebPath/fonts/comfortaa/Comfortaa-Light.ttf)');
89 document.fonts.add(Debug.FontComfortaaLight);
90 }
catch(e){console.log(
"Ignoring font errors: " + e);}
95 Debug.logv = varObj =>
97 var keys = Object.keys(varObj);
98 Debug.log(keys[0] +
" \t= ",varObj[keys[0]]);
102 Debug.presetPriority = Debug.LOW_PRIORITY.DEBUG_PRIORITY;
103 Debug.err =
function() {
104 Debug.presetPriority = Debug.HIGH_PRIORITY.DEBUG_PRIORITY;
105 if(Debug.BROWSER_TYPE == 1)
107 Debug.lastLogger = (
new Error).stack.split(
"\n")[2];
108 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
' ('));
109 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+2,
110 Debug.lastLogger.length-1);
112 else if(Debug.BROWSER_TYPE == 2)
114 Debug.lastLogger = (
new Error).stack.split(
"\n")[1];
115 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
'@'));
116 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+1,
117 Debug.lastLogger.length);
119 Debug.log.apply(null,arguments);
121 Debug.warn =
function() {
122 Debug.presetPriority = Debug.WARN_PRIORITY.DEBUG_PRIORITY;
123 if(Debug.BROWSER_TYPE == 1)
125 Debug.lastLogger = (
new Error).stack.split(
"\n")[2];
126 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
' ('));
127 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+2,
128 Debug.lastLogger.length-1);
130 else if(Debug.BROWSER_TYPE == 2)
132 Debug.lastLogger = (
new Error).stack.split(
"\n")[1];
133 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
'@'));
134 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+1,
135 Debug.lastLogger.length);
137 Debug.log.apply(null,arguments);
139 Debug.info =
function() {
140 Debug.presetPriority = Debug.INFO_PRIORITY.DEBUG_PRIORITY;
141 if(Debug.BROWSER_TYPE == 1)
143 Debug.lastLogger = (
new Error).stack.split(
"\n")[2];
144 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
' ('));
145 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+2,
146 Debug.lastLogger.length-1);
148 else if(Debug.BROWSER_TYPE == 2)
150 Debug.lastLogger = (
new Error).stack.split(
"\n")[1];
151 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
'@'));
152 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+1,
153 Debug.lastLogger.length);
155 Debug.log.apply(null,arguments);
157 Debug.med =
function() {
158 Debug.presetPriority = Debug.MED_PRIORITY.DEBUG_PRIORITY;
159 if(Debug.BROWSER_TYPE == 1)
161 Debug.lastLogger = (
new Error).stack.split(
"\n")[2];
162 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
' ('));
163 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+2,
164 Debug.lastLogger.length-1);
166 else if(Debug.BROWSER_TYPE == 2)
168 Debug.lastLogger = (
new Error).stack.split(
"\n")[1];
169 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
'@'));
170 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+1,
171 Debug.lastLogger.length);
173 Debug.log.apply(null,arguments);
181 Debug.log = console.log.bind(window.console);
188 Debug.log =
function()
191 var num = Debug.presetPriority;
192 var argsInStr = arguments.length;
193 if(arguments.length > 1 &&
194 arguments[arguments.length-1] !== undefined &&
195 arguments[arguments.length-1].DEBUG_PRIORITY !== undefined)
197 num = arguments[arguments.length-1].DEBUG_PRIORITY;
200 Debug.presetPriority = Debug.LOW_PRIORITY.DEBUG_PRIORITY;
203 var useStrOnly =
false;
205 if(argsInStr == 1 && typeof(arguments[0]) ==
"string")
208 for(var i=0;i<argsInStr;++i)
209 str += arguments[i] +
' ';
215 returnStr = localCallOutDebugLocales(str);
220 if(Debug.level < 0) Debug.level = 0;
221 if(Debug.mode && num <= Debug.level)
223 str = Debug.prependMessage + str;
226 (num==0?
"High":(num==1?
"Warn":(num==2?
"Info":
"Tip")))
227 :(num<99?
"Med":
"Low");
230 if(!Debug.lastLogger || Debug.lastLogger.length == 0)
232 if(Debug.BROWSER_TYPE == 1)
234 Debug.lastLogger = (
new Error).stack.split(
"\n")[2];
235 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
' ('));
236 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+2,
237 Debug.lastLogger.length-1);
239 else if(Debug.BROWSER_TYPE == 2)
241 Debug.lastLogger = (
new Error).stack.split(
"\n")[1];
242 Debug.lastLog = Debug.lastLogger.slice(0,Debug.lastLogger.indexOf(
'@'));
243 Debug.lastLogger = Debug.lastLogger.slice(Debug.lastLog.length+1,
244 Debug.lastLogger.length);
248 var source = window.location.href;
249 source = source.substr(source.lastIndexOf(
'/'));
250 source = source.substr(0,source.indexOf(
'?'));
253 console.log(
"%c" + type +
"-Priority" +
254 ":\t " + Debug.lastLog +
" from " + source +
":\n" +
255 Debug.lastLogger +
"::\t" + str,
256 num == 0?
"color:#F30;"
257 :(num == 1?
"color:#F70"
258 :(num < 99?
"color:#092":
"color:#333")));
261 var consoleArguments = [];
262 consoleArguments.push(
"%c" + type +
"-Priority" +
263 ":\t " + Debug.lastLog +
" from " + source +
":\n" +
264 Debug.lastLogger +
"::\t");
265 consoleArguments.push(num == 0?
"color:#F30;"
266 :(num == 1?
"color:#F70"
267 :(num < 99?
"color:#092":
"color:#333")));
269 for(var i=0;i<argsInStr;++i)
270 consoleArguments.push(arguments[i]);
273 console.log.apply(null,consoleArguments);
283 Debug.lastLogger =
"";
286 Debug.errorPop(str,num);
293 function localCallOutDebugLocales(str)
300 while((j = str.indexOf(
'[',i)) > 0 && (k = str.indexOf(
']',i)) > 0)
315 if((str[j-3] ==
'.' && str[j-2] ==
'h') ||
316 ((str[j-4] ==
'.' || str[j-4] ==
'i') &&
317 str[j-3] ==
'c' && str[j-2] ==
'c'))
320 for(l = j-3; l >= i; --l)
321 if(!((str[l] >=
'a' && str[l] <=
'z') ||
322 (str[l] >=
'A' && str[l] <=
'Z') ||
323 (str[l] >=
'0' && str[l] <=
'9') ||
335 returnStr += str.substr(i,l-i);
338 returnStr +=
"<br><label class='" +
339 Debug._errBoxId +
"-localCallOut'>";
342 returnStr += str.substr(l,k+1-l);
345 returnStr +=
"</label><br>";
348 while(k+1 < str.length &&
349 (str[k+1] ==
'\n' || str[k+1] ==
'\t')) ++k;
353 returnStr += str.substr(i,k+1-i);
365 returnStr += str.substr(i);
376 console.log =
function(){};
377 Debug.log =
function(){};
378 Debug.logv =
function(){};
379 Debug.err =
function(){};
380 Debug.warn =
function(){};
381 Debug.info =
function(){};
382 Debug.med =
function(){};
387 Debug.log(
"Debug mode is on at level: " + Debug.level);
388 Debug.log(
"This is an example for posterity that is not printed due to debug priority.",Debug.level+1);
397 Debug._errBoxId =
"Debug-error-box";
398 Debug._errBoxOffX = 0;
399 Debug._errBoxOffY = 0;
400 Debug._errBoxOffW = 0;
401 Debug._errBoxOffH = 0;
404 Debug._ERR_TRUNCATION_LENGTH = 10000;
409 Debug.errorPopConditionString =
function(str) {
412 for(var i=0;i<str.length && i<Debug._ERR_TRUNCATION_LENGTH; ++i)
415 else if(str[i] ==
'\t')
416 rstr +=
" ";
419 if(str.length > Debug._ERR_TRUNCATION_LENGTH)
420 rstr +=
"...<<< MESSAGE TRUNCATED >>>";
428 Debug.errorPop =
function(err,severity)
431 var errBoxAlpha =
"1.0";
437 var el = document.getElementById(Debug._errBoxId);
440 var body = document.getElementsByTagName(
"BODY")[0];
444 window.setTimeout(
function() { Debug.errorPop(err,{
"DEBUG_PRIORITY":severity})}, 1000);
449 el = document.createElement(
"div");
450 el.setAttribute(
"id", Debug._errBoxId);
451 el.style.display =
"none";
452 var str =
"<a class='" +
454 "-header' onclick='javascript:Debug.closeErrorPop();event.stopPropagation();' onmousemove='event.stopPropagation();' onmouseup='event.stopPropagation();' onmousedown='event.stopPropagation();'>Close Errors</a>";
458 "-moveBar' style='" +
459 "position:absolute;width:100%;height:15px;top:0;left:0;background-color:rgb(191, 191, 191);cursor:move;" +
460 "outline: none; /* to stop firefox selection*/ -webkit-user-select: none; /* prevent selection*/ -moz-user-select: none; user-select: none;" +
462 "onmousedown='javascript:Debug.handleErrorMoveStart(event);event.stopPropagation();' " +
463 "title='Click and drag to reposition this popup window.' " +
467 "<div style='color:white;font-size:16px;padding-bottom:5px;'>" +
468 "Note: Newest messages are at the top." +
469 "<label style='color:white;font-size:11px;'><br>(Press [ESC] to close and [SHIFT + ESC] to re-open)</font>" +
470 "<div id='downloadIconDiv' onclick='Debug.downloadMessages()' onmouseup='event.stopPropagation();' onmousedown='event.stopPropagation();' title='Download messages to text file.' style='float: right; margin: -10px 30px -100px -100px; cursor: pointer'>" +
472 "<div style='display: block; margin-left: 3px; height:7px; width: 6px; background-color: white;'></div>" +
473 "<div style='display: block; width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-top: 8px solid white;'></div>" +
474 "<div style='position: relative; top: 5px; width: 12px; height: 2px; display: block; background-color: white;'></div>" +
484 str +=
"<div class='" + Debug._errBoxId +
"-resizeBarLeft' " +
486 "background-color:rgb(191, 191, 191);position:absolute;width:15px;height:15px;top:-1000px;left:0;cursor:nesw-resize;" +
487 "outline: none; /* to stop firefox selection*/ -webkit-user-select: none; /* prevent selection*/ -moz-user-select: none; user-select: none;" +
489 "onmousedown='javascript:Debug.handleErrorResizeStart(event,1,1);event.stopPropagation();' " +
490 "title='Click and drag to resize vertically this popup window.' " +
492 str +=
"<div class='" + Debug._errBoxId +
"-resizeBar' " +
494 "background-color:transparent;position:absolute;width:100%;height:5px;top:-1000px;left:15px;cursor:ns-resize;" +
495 "outline: none; /* to stop firefox selection*/ -webkit-user-select: none; /* prevent selection*/ -moz-user-select: none; user-select: none;" +
497 "onmousedown='javascript:Debug.handleErrorResizeStart(event);event.stopPropagation();' " +
498 "title='Click and drag to resize this popup window.' " +
500 str +=
"<div class='" + Debug._errBoxId +
"-resizeBarRight' " +
502 "background-color:rgb(191, 191, 191);position:absolute;width:15px;height:15px;top:-1000px;left:0;cursor:nwse-resize;" +
503 "outline: none; /* to stop firefox selection*/ -webkit-user-select: none; /* prevent selection*/ -moz-user-select: none; user-select: none;" +
505 "onmousedown='javascript:Debug.handleErrorResizeStart(event,1);event.stopPropagation();' " +
506 "title='Click and drag to resize this popup window.' " +
509 body.appendChild(el);
511 el.onmousemove =
function(){
513 DesktopContent.mouseMove(event,
true );
516 if(Debug._errBoxOffResizeStartY == -1 &&
517 Debug._errBoxOffMoveStartX == -1 &&
518 Debug._errBoxOffResizeStartX == -1)
519 event.stopPropagation();
521 el.onmousedown =
function(){console.log(
"debug down");
event.stopPropagation();}
522 el.onmouseup =
function(){console.log(
"debug up");
event.stopPropagation();}
525 function localDebugKeyDownListener(e)
530 if(!e.shiftKey && e.keyCode == 27)
534 Debug.closeErrorPop();
536 else if(e.shiftKey && e.keyCode == 27)
540 Debug.bringBackErrorPop();
544 document.body.removeEventListener(
"keydown",localDebugKeyDownListener);
545 document.body.addEventListener(
"keydown",localDebugKeyDownListener);
552 css +=
"#" + Debug._errBoxId +
" *" +
553 "{font-family: 'Comfortaa', arial;" +
554 "font-weight: 200;" +
556 "color: rgb(255,200,100);" +
557 "-webkit-user-select: text;" +
558 "-moz-user-select: text;" +
559 "user-select: text;" +
564 css +=
"#" + Debug._errBoxId +
" a" +
565 ", #" + Debug._errBoxId +
" center b" +
566 "{color: white; text-decoration: none; font-weight: bold;" +
567 "font-size: 18px; font-family: 'Comfortaa', arial;" +
569 css +=
"#" + Debug._errBoxId +
" a:hover" +
570 "{text-decoration: underline;" +
575 css +=
"#" + Debug._errBoxId +
" i" +
576 ", #" + Debug._errBoxId +
" u" +
578 "font-size: 18px; font-family: 'Comfortaa', arial;" +
580 css +=
"#" + Debug._errBoxId +
" b" +
582 "font-weight: bold;" +
583 "color: rgb(255, 231, 187);" +
587 css +=
"#" + Debug._errBoxId +
589 "position: absolute; display: none; border: 2px solid gray;" +
590 "background-color: rgba(153,0,51, " + errBoxAlpha +
"); overflow-y: hidden;" +
591 "overflow-x: hidden; padding: 5px; -moz-border-radius: 2px;" +
592 "-webkit-border-radius: 2px; border-radius: 2px;" +
593 "font-size: 18px; z-index: 2147483647;" +
594 "font-family: 'Comfortaa', arial; text-align: center;" +
595 "left: 8px; top: 8px; margin-right: 8px; " +
599 css +=
"#" + Debug._errBoxId +
"-err" +
601 "color: rgb(255,200,100); font-size: 18px;" +
602 "font-family: 'Comfortaa', arial;" +
603 "left: 8px; top: 8px; margin-right: 8px;" +
604 "margin-bottom:-12px;" +
605 "text-align: left;" +
606 "overflow-y: scroll;" +
607 "overflow-x: auto;" +
609 "-webkit-user-select: text;" +
610 "-moz-user-select: text;" +
611 "user-select: text;" +
614 css +=
"#" + Debug._errBoxId +
"-err i" +
616 ",#" + Debug._errBoxId +
"-err u" +
619 "color: rgb(255,200,100); font-size: 18px;" +
620 "font-family: 'Comfortaa', arial;" +
621 "text-align: left;" +
622 "-webkit-user-select: text;" +
623 "-moz-user-select: text;" +
624 "user-select: text;" +
630 "#" + Debug._errBoxId +
"-err div" +
632 "color: rgb(255,200,100); font-size: 18px;" +
633 "font-family: 'Comfortaa', arial;" +
634 "left: 8px, top: 8px; margin-right: 8px;" +
635 "text-align: left;" +
636 "-webkit-user-select: text;" +
637 "-moz-user-select: text;" +
638 "user-select: text;" +
641 css +=
"#" + Debug._errBoxId +
"-err b" +
643 "color: rgb(255,225,200); font-size: 18px;" +
644 "font-family: 'Comfortaa', arial;" +
645 "text-align: left;" +
646 "-webkit-user-select: text;" +
647 "-moz-user-select: text;" +
648 "user-select: text;" +
651 css +=
"#" + Debug._errBoxId +
" ." + Debug._errBoxId +
"-localCallOut" +
652 "{font-size: 10px;}\n\n";
655 var style = document.createElement(
'style');
657 if (style.styleSheet) {
658 style.styleSheet.cssText = css;
660 style.appendChild(document.createTextNode(css));
663 document.getElementsByTagName(
'head')[0].appendChild(style);
665 window.removeEventListener(
"resize",localResize);
666 window.removeEventListener(
"scroll",localScroll);
667 window.removeEventListener(
"mouseup",Debug.handleErrorMoveStop);
668 window.removeEventListener(
"mousemove",Debug.handleErrorMove);
669 window.addEventListener(
"resize",localResize);
670 window.addEventListener(
"scroll",localScroll);
671 window.addEventListener(
"mouseup",Debug.handleErrorMoveStop);
672 window.addEventListener(
"mousemove",Debug.handleErrorMove);
679 var el = document.getElementById(Debug._errBoxId +
"-err");
680 var str = el.innerHTML;
682 var wasAlreadyContent =
false;
686 wasAlreadyContent =
true;
688 var tstr = d.toLocaleTimeString();
689 tstr = tstr.substring(0,tstr.lastIndexOf(
' ')) +
690 (tstr[tstr.length-2]==
'A'?
"am":
"pm");
692 if(severity == Debug.TIP_PRIORITY.DEBUG_PRIORITY)
694 (wasAlreadyContent?
"<br>...<br>":
"") +
695 "<label style='color:white;font-size:16px;'>" +
696 d.toLocaleDateString() +
697 " " + tstr +
" (Tip) :</label><br>" +
698 Debug.errorPopConditionString(err);
700 str =
"<label style='color:white;font-size:16px;'>" +
701 d.toLocaleDateString() +
703 (severity == Debug.INFO_PRIORITY.DEBUG_PRIORITY ?
'(Info)':
'')+
704 (severity == Debug.WARN_PRIORITY.DEBUG_PRIORITY ?
'(Warning)':
'') +
706 Debug.errorPopConditionString(err) +
707 (wasAlreadyContent?
"<br>...<br>":
"") +
713 function localResize()
715 Debug._errBoxOffX = 0;
716 Debug._errBoxOffY = 0;
717 Debug._errBoxOffH = 0;
718 Debug._errBoxOffW = 0;
719 Debug.handleErrorResize();
721 function localScroll()
723 Debug.handleErrorResize();
725 Debug.handleErrorResize();
728 Debug._errBox.style.display =
"block";
732 var els = document.getElementsByClassName(Debug._errBoxId +
"-header");
736 case Debug.TIP_PRIORITY.DEBUG_PRIORITY:
738 if(wasAlreadyContent &&
739 (el.innerHTML ==
"Close Errors" ||
740 el.innerHTML ==
"Close Warnings" ||
741 el.innerHTML ==
"Close Info"))
743 el.innerHTML =
"Close Tooltip";
744 Debug._errBox.style.backgroundColor =
"rgba(0, 49, 99, " + errBoxAlpha +
")";
746 case Debug.INFO_PRIORITY.DEBUG_PRIORITY:
748 if(wasAlreadyContent &&
749 (el.innerHTML ==
"Close Errors" ||
750 el.innerHTML ==
"Close Warnings"))
752 el.innerHTML =
"Close Info";
753 Debug._errBox.style.backgroundColor =
"rgba(0,153,51, " + errBoxAlpha +
")";
755 case Debug.WARN_PRIORITY.DEBUG_PRIORITY:
757 if(wasAlreadyContent &&
758 el.innerHTML ==
"Close Errors")
760 el.innerHTML =
"Close Warnings";
761 Debug._errBox.style.backgroundColor =
"rgba(160, 79, 0, " + errBoxAlpha +
")";
764 el.innerHTML =
"Close Errors";
765 Debug._errBox.style.backgroundColor =
"rgba(153,0,51, " + errBoxAlpha +
")";
767 els[1].innerHTML = el.innerHTML;
770 Debug._errBoxLastContent =
"";
773 Debug.closeErrorPop =
function()
775 document.getElementById(Debug._errBoxId).style.display =
"none";
776 Debug._errBoxLastContent = document.getElementById(Debug._errBoxId +
"-err").innerHTML;
777 document.getElementById(Debug._errBoxId +
"-err").innerHTML =
"";
781 Debug.bringBackErrorPop =
function()
783 document.getElementById(Debug._errBoxId +
"-err").innerHTML = Debug._errBoxLastContent;
784 document.getElementById(Debug._errBoxId).style.display =
"block";
788 Debug._errBoxOffMoveStartX = -1;
789 Debug._errBoxOffMoveStartY;
790 Debug._errBoxOffResizeStartX = -1;
791 Debug._errBoxOffResizeStartY = -1;
793 Debug.handleErrorMoveStart =
function(e)
795 Debug.log(
"Move Start");
796 Debug._errBoxOffMoveStartX = e.screenX - Debug._errBoxOffX;
797 Debug._errBoxOffMoveStartY = e.screenY - Debug._errBoxOffY;
801 Debug.handleErrorResizeStart =
function(e,resizeW,moveLeft)
803 Debug.log(
"Resize Start");
804 Debug._errBoxOffResizeStartY = e.screenY - Debug._errBoxOffH;
807 Debug._errBoxOffMoveStartX = e.screenX - Debug._errBoxOffX;
808 Debug._errBoxOffResizeStartX = e.screenX + Debug._errBoxOffW;
811 Debug._errBoxOffResizeStartX = e.screenX - Debug._errBoxOffW;
816 Debug.handleErrorMoveStop =
function(e)
818 if(Debug._errBoxOffResizeStartY != -1)
820 Debug.log(
"Resize Stop");
821 Debug._errBoxOffH = e.screenY - Debug._errBoxOffResizeStartY;
822 Debug._errBoxOffResizeStartY = -1;
824 if(Debug._errBoxOffMoveStartX != -1)
826 Debug._errBoxOffX = e.screenX - Debug._errBoxOffMoveStartX;
827 Debug._errBoxOffW = Debug._errBoxOffResizeStartX - e.screenX;
828 Debug._errBoxOffMoveStartX = -1;
829 Debug._errBoxOffResizeStartX = -1;
831 else if(Debug._errBoxOffResizeStartX != -1)
833 Debug._errBoxOffW = e.screenX - Debug._errBoxOffResizeStartX;
834 Debug._errBoxOffResizeStartX = -1;
836 Debug.handleErrorResize();
838 else if(Debug._errBoxOffMoveStartX != -1)
840 Debug.log(
"Move Stop");
841 Debug._errBoxOffX = e.screenX - Debug._errBoxOffMoveStartX;
842 Debug._errBoxOffY = e.screenY - Debug._errBoxOffMoveStartY;
843 Debug._errBoxOffMoveStartX = -1;
844 Debug.handleErrorResize();
850 Debug.handleErrorMove =
function(e) {
853 if(Debug._errBoxOffMoveStartX == -1 &&
854 Debug._errBoxOffResizeStartY == -1)
return;
858 Debug._errBoxOffMoveStartX = -1;
859 Debug._errBoxOffResizeStartY = -1;
860 Debug._errBoxOffResizeStartX = -1;
864 if(Debug._errBoxOffResizeStartY != -1)
866 Debug.log(
"Resize " + e.buttons);
867 Debug._errBoxOffH = e.screenY - Debug._errBoxOffResizeStartY;
869 if(Debug._errBoxOffMoveStartX != -1)
871 Debug._errBoxOffX = e.screenX - Debug._errBoxOffMoveStartX;
872 Debug._errBoxOffW = Debug._errBoxOffResizeStartX - e.screenX;
874 else if(Debug._errBoxOffResizeStartX != -1)
875 Debug._errBoxOffW = e.screenX - Debug._errBoxOffResizeStartX;
877 Debug.handleErrorResize();
879 else if(Debug._errBoxOffMoveStartX != -1)
881 Debug.log(
"Move " + e.buttons);
882 Debug._errBoxOffX = e.screenX - Debug._errBoxOffMoveStartX;
883 Debug._errBoxOffY = e.screenY - Debug._errBoxOffMoveStartY;
884 Debug.handleErrorResize();
890 Debug.handleErrorResize =
function()
894 var offX = document.documentElement.scrollLeft || document.body.scrollLeft || 0;
895 var offY = document.documentElement.scrollTop || document.body.scrollTop || 0;
900 if(typeof DesktopContent !=
'undefined')
902 w = (DesktopContent.getWindowWidth()-16-14);
903 screenh = (DesktopContent.getWindowHeight()-16-14);
905 else if(typeof Desktop !=
'undefined' && Desktop.desktop)
907 w = (Desktop.desktop.getDesktopWidth()-16-14);
908 screenh = (Desktop.desktop.getDesktopHeight()-16-14);
921 if(w + Debug._errBoxOffW < 200)
923 Debug._errBoxOffW = 200 - w;
925 w += Debug._errBoxOffW;
927 var h = (screenh - 20) + Debug._errBoxOffH;
930 Debug._errBoxOffH = -200;
935 if(Debug._errBoxOffX + w > screenw)
936 Debug._errBoxOffX = screenw - w;
937 if(Debug._errBoxOffX < minx)
938 Debug._errBoxOffX = minx;
939 if(Debug._errBoxOffY + h > screenh)
940 Debug._errBoxOffY = screenh - h;
941 if(Debug._errBoxOffY < 0)
942 Debug._errBoxOffY = 0;
944 Debug._errBox.style.width = (w) +
"px";
945 Debug._errBox.style.height = (h) +
"px";
946 Debug._errBox.style.left = (Debug._errBoxOffX + offX + 8) +
"px";
947 Debug._errBox.style.top = (Debug._errBoxOffY + offY + 8) +
"px";
948 Debug._errBox.style.marginRight = -(w+10) +
"px";
949 Debug._errBox.style.marginBottom = -(h+80) +
"px";
952 var el = document.getElementsByClassName(Debug._errBoxId +
"-resizeBar")[0];
953 el.style.top = (h+6) +
"px";
954 el = document.getElementsByClassName(Debug._errBoxId +
"-resizeBarLeft")[0];
955 el.style.top = (h+6-10) +
"px";
956 el = document.getElementsByClassName(Debug._errBoxId +
"-resizeBarRight")[0];
957 el.style.left = (w-5) +
"px";
958 el.style.top = (h+6-10) +
"px";
960 el = document.getElementsByClassName(Debug._errBoxId +
"-err")[0];
961 el.style.height = (h-115) +
"px";
966 Debug.downloadMessages =
function() {
968 console.log(
"downloading messages...");
971 var dataStr =
"data:text/txt;charset=utf-8,";
973 var lines = Debug._errBox.innerText.split(
'\n');
974 for(var i=2;i<lines.length-2;++i)
976 dataStr += encodeURIComponent(lines[i] +
"\n");
979 var link = document.createElement(
"a");
980 link.setAttribute(
"href", dataStr);
981 link.setAttribute(
"style",
"display:none");
982 link.setAttribute(
"download",
"otsdaq_Messages_download.txt");
983 document.body.appendChild(link);
987 link.parentNode.removeChild(link);