Fixes to the PaintWeb cron task.
[moodle/mihaisucan.git] / lib / overlib / overlib_debug.js
blob68d83e8618ae996278e091473e18bad81bb77d8b
1 //\/////
2 //\  overLIB Debug Plugin
3 //\  This file requires overLIB 4.10 or later.
4 //\
5 //\  overLIB 4.05 - You may not remove or change this notice.
6 //\  Copyright Erik Bosrup 1998-2003. All rights reserved.
7 //\  Contributors are listed on the homepage.
8 //\  See http://www.bosrup.com/web/overlib/ for details.
9 //   $Revision$                $Date$
11 //\/////
12 //\mini
13 ////////
14 // PRE-INIT
15 // Ignore these lines, configuration is below.
16 ////////
17 if (typeof olInfo == 'undefined' || typeof olInfo.meets == 'undefined' || !olInfo.meets(4.10)) alert('overLIB 4.10 or later is required for the Debug Plugin.');
18 else {
19 var olZindex;
20 registerCommands('allowdebug');
21 ////////
22 // PLUGIN FUNCTIONS
23 ////////
24 // Parses Debug Parameters
25 function parseDebugExtras(pf, i, ar) {
26         var k =  i, v;
28         if (k < ar.length) {
29                 if (ar[k] == ALLOWDEBUG) { v = ar[k + 1]; if(typeof v == 'string') {v = ar[++k]; if (pf != 'ol_') setCanShowParm(v);} return k; }
30         }
32         return -1;
34 // Debug main routine
35 function showProperties() {
36         var args = showProperties.arguments, sho, shoObj, vis, lvl = 0, istrt = 0, theDiv = 'showProps', txt = '';
38         if (args.length == 0) return;
39         if (args.length % 2 && typeof args[0] == 'string') {
40                 istrt = 1;
41                 theDiv = args[0];
42         }
44         sho = createDivContainer(theDiv);
46         if (olNs4) {
47                 shoObj = sho;
48                 txt += '<table cellpadding="1" cellspacing="0" border="0" bgcolor="#000000"><tr><td>';
49         } else {
50                 with(sho.style) {
51                         backgroundColor = '#ffffcc';
52                         padding = '5px';
53                         border = '1px #000000 solid';
54                 }
55                 shoObj = sho.style;
56         }
58         lvl = getLayerLevel(theDiv);
60         if(typeof sho.position == 'undefined') {
61                 sho.position = new Pagelocation(10 + lvl*20, 10, 1);
62                 if(typeof olZindex == 'undefined') olZindex = getDivZindex();
63                 shoObj.zIndex = olZindex + 1 + lvl;
64         }
66         txt += '<table cellpadding="5" border="0" cellspacing="0"' + (olNs4 ? ' bgcolor="#ffffcc"' : '') + '>';
67         txt += '<tr><td><strong><A HREF="javascript:moveToBack(\'' + theDiv + '\');" title="Move to back">' + theDiv + '</A></strong></td><td align="RIGHT"><strong><a href="javascript:closeLayer(\'' + theDiv + '\');" TITLE="Close Layer' + (!olNs4 ? '" style="background-color: #CCCCCC; border:2px #333369 outset; padding: 2px;' : '') + '">X</a></strong></td></tr>';
68         txt += '<tr><td style="text-decoration: underline;"><strong>Item</strong></td><td style="text-decoration: underline;"><strong>Value</strong></td></tr>';
69         for (var i = istrt; i<args.length-1; i++) 
70                 txt += '<tr><td align="right"><strong>' + args[i] + ':&nbsp;</strong></td><td>' + args[++i] + '</td></tr>';
71         txt += '</table>' + (olNs4 ? '</td></tr></table>' : '');
73         if (olNs4) {
74                 sho.document.open();
75                 sho.document.write(txt);
76                 sho.document.close();
77         } else {
78                 if(olIe5&&isMac) sho.innerHTML = '';
79                 sho.innerHTML = txt;
80         }
82         showAllVisibleLayers();
84 function getLayerLevel(lyr) {
85         var i = 0;
87         if (typeof document.popups == 'undefined') {
88                 document.popups = new Array(lyr);
89         } else {
90                 var l = document.popups;
91                 for (var i = 0; i<l.length; i++) if (lyr == l[i]) break;
92                 if(i == l.length) l[l.length++] = lyr;
93         }
95         return i;
97 function getDivZindex(id) {
98         var obj;
100         if(id == '' || id == null) id = 'overDiv';
102         obj = layerReference(id);
103         obj = (olNs4 ? obj : obj.style);
105         return obj.zIndex;
107 function setCanShowParm(debugID) {
108         var lyr, pLyr;
110         if(typeof debugID != 'string') return;
112         pLyr = debugID.split(',');
113         for(var i = 0; i<pLyr.length; i++) {
114                 lyr = layerReference(pLyr[i]);
115                 if(lyr != null && typeof lyr.position != 'undefined') lyr.position.canShow = 1;
116         }
118 function Pagelocation(x, y, canShow) {
119         this.x = x;
120         this.y = y;
121   this.canShow = (canShow == null) ? 0 : canShow;
123 function showAllVisibleLayers(){
124         var lyr, lyrObj, l = document.popups;
126         for (var i = 0; i<l.length; i++) {
127                 lyr = layerReference(l[i]);
128                 lyrObj = (olNs4 ? lyr : lyr.style);
129     if(lyr.position.canShow) {
130                 positionLayer(lyrObj, lyr.position.x, lyr.position.y);
131                 lyrObj.visibility = 'visible';
132     }
133         }
135 function positionLayer(Obj, x, y) { // Obj is obj.style for IE/NS6+ but obj for NS4
136         Obj.left = x + (olIe4 ? eval(docRoot + '.scrollLeft') : window.pageXOffset) + (olNs4 ? 0 : 'px');
137         Obj.top = y + (olIe4 ? eval(docRoot + '.scrollTop') : window.pageYOffset) + (olNs4 ? 0 : 'px');
139 function closeLayer(lyrID) {
140         var lyr = layerReference(lyrID);
142   lyr.position.canShow = 0;
143         lyr = (olNs4 ? lyr : lyr.style);
144         lyr.visibility = 'hidden';
146 function moveToBack(layer) {
147         var l = document.popups, lyr, obj, i, x = 10, y = 10, dx = 20, z = olZindex + 1;
149         if(l.length == 1) return;
151         lyr = layerReference(layer);
152         lyr.position.x = x;
153         lyr.position.y = y;
154         obj = (olNs4 ? lyr : lyr.style);
155         obj.zIndex = z;
157         for (i = 0; i<l.length; i++) {
158                 if (layer == l[i]) continue;
159                 lyr = layerReference(l[i]);
160     if(lyr.position.canShow == 0) continue;
161                 obj = (olNs4 ? lyr : lyr.style);
162                 obj.zIndex += 1;
163                 lyr.position.x += dx;
164                 lyr.position.y = y;
165         }
167         showAllVisibleLayers();
169 function rawTxt(txt) {
170         if (typeof txt != 'string') return;
171         return txt.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
173 ////////
174 // PLUGIN REGISTRATIONS
175 ////////
176 registerCmdLineFunction(parseDebugExtras);