2 //\ overLIB Debug Plugin
3 //\ This file requires overLIB 4.10 or later.
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.
15 // Ignore these lines, configuration is below.
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.');
20 registerCommands('allowdebug');
24 // Parses Debug Parameters
25 function parseDebugExtras(pf
, i
, ar
) {
29 if (ar
[k
] == ALLOWDEBUG
) { v
= ar
[k
+ 1]; if(typeof v
== 'string') {v
= ar
[++k
]; if (pf
!= 'ol_') setCanShowParm(v
);} return k
; }
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') {
44 sho
= createDivContainer(theDiv
);
48 txt
+= '<table cellpadding="1" cellspacing="0" border="0" bgcolor="#000000"><tr><td>';
51 backgroundColor
= '#ffffcc';
53 border
= '1px #000000 solid';
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
;
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
] + ': </strong></td><td>' + args
[++i
] + '</td></tr>';
71 txt
+= '</table>' + (olNs4
? '</td></tr></table>' : '');
75 sho
.document
.write(txt
);
78 if(olIe5
&&isMac
) sho
.innerHTML
= '';
82 showAllVisibleLayers();
84 function getLayerLevel(lyr
) {
87 if (typeof document
.popups
== 'undefined') {
88 document
.popups
= new Array(lyr
);
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
;
97 function getDivZindex(id
) {
100 if(id
== '' || id
== null) id
= 'overDiv';
102 obj
= layerReference(id
);
103 obj
= (olNs4
? obj
: obj
.style
);
107 function setCanShowParm(debugID
) {
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;
118 function Pagelocation(x
, y
, canShow
) {
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';
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
);
154 obj
= (olNs4
? lyr
: lyr
.style
);
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
);
163 lyr
.position
.x
+= dx
;
167 showAllVisibleLayers();
169 function rawTxt(txt
) {
170 if (typeof txt
!= 'string') return;
171 return txt
.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""
;");
174 // PLUGIN REGISTRATIONS
176 registerCmdLineFunction(parseDebugExtras);