4 // These scripts were originally found on cooltype.com.
5 // Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com
7 // Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
8 // compatibility for phpMyAdmin
10 // Rewritten and put in a libray 2nd May 2001 by Loïc Chapeaux
13 // - Mozilla 0.8.1, 0.9.0, 0.9.1, 0.9.2 for Windows (js enabled
15 // - IE5, 5.01, 5.5 for Windows
16 // - Netscape 4.75 for Windows
18 // Test failed (crappy DOM implementations) with:
19 // - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
20 // - Opera 5.10 to 5.12 for windows, Opera 5+ for Linux: 'style.display' can't
22 // - Konqueror 2+: 'style.display' can't be changed
25 var isExpanded = false;
27 var imgOpened = new Image(9,9);
28 imgOpened.src = 'images/minus.gif';
29 var imgClosed = new Image(9,9);
30 imgClosed.src = 'images/plus.gif';
34 * Do reloads the frame if the window has been resized under Netscape4+
39 if (innerWidth != origWidth || innerHeight != origHeight)
40 location.reload(true);
41 } // end of the 'reDo()' function
44 * Positioned element resize bug under NS4+
47 var origWidth = innerWidth;
48 var origHeight = innerHeight;
54 * Gets the id of the first collapsible room
56 * @param string the name of the first collapsible room
58 * @return integer the index number corresponding to this room
62 function nsGetIndex(el) {
64 var theLayers = document.layers;
65 var layersCnt = theLayers.length;
66 for (var i = 0; i < layersCnt; i++) {
67 if (theLayers[i].id == el) {
73 } // end of the 'nsGetIndex()' function
77 * Positions layers under NS4+
81 function nsArrangeList() {
82 if (firstInd != null) {
83 var theLayers = document.layers;
84 var layersCnt = theLayers.length;
85 var nextY = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
86 for (var i = firstInd + 1; i < layersCnt; i++) {
87 if (theLayers[i].visibility != 'hide') {
88 theLayers[i].pageY = nextY;
89 nextY += theLayers[i].document.height;
93 } // end of the 'nsArrangeList()' function
97 * Expand databases at startup
101 function nsShowAll() {
102 var theLayers = document.layers;
103 var layersCnt = theLayers.length;
104 for (i = firstInd; i < layersCnt; i++) {
105 theLayers[i].visibility = 'show';
107 } // end of the 'nsShowAll()' function
111 * Collapses databases at startup
117 if (!capable || !isServer)
121 var tempColl = document.getElementsByTagName('DIV');
122 var tempCollCnt = tempColl.length;
123 for (var i = 0; i < tempCollCnt; i++) {
124 if (tempColl[i].id == expandedDb)
125 tempColl[i].style.display = 'block';
126 else if (tempColl[i].className == 'child')
127 tempColl[i].style.display = 'none';
129 } // end of the DOM case
131 tempColl = document.all.tags('DIV');
132 var tempCollCnt = tempColl.length;
133 for (var i = 0; i < tempCollCnt; i++) {
134 if (tempColl(i).id == expandedDb)
135 tempColl(i).style.display = 'block';
136 else if (tempColl(i).className == 'child')
137 tempColl(i).style.display = 'none';
139 } // end of the IE4 case
141 var theLayers = document.layers;
142 var layersCnt = theLayers.length;
143 for (var i = 0; i < layersCnt; i++) {
144 if (theLayers[i].id == expandedDb)
145 theLayers[i].visibility = 'show';
146 else if (theLayers[i].id.indexOf('Child') != -1)
147 theLayers[i].visibility = 'hide';
149 theLayers[i].visibility = 'show';
152 } // end of the NS4 case
153 } // end of the 'initIt()' function
157 * Collapses/expands a database when the user require this to be done
159 * @param string the name of the room to act on
160 * @param boolean whether to expand or to collapse the database content
164 function expandBase(el, unexpand)
170 var whichEl = document.getElementById(el + 'Child');
171 var whichIm = document.getElementById(el + 'Img');
172 if (whichEl.style.display == 'none' && whichIm) {
173 whichEl.style.display = 'block';
174 whichIm.src = imgOpened.src;
177 whichEl.style.display = 'none';
178 whichIm.src = imgClosed.src;
180 } // end of the DOM case
182 var whichEl = document.all(el + 'Child');
183 var whichIm = document.images.item(el + 'Img');
184 if (whichEl.style.display == 'none') {
185 whichEl.style.display = 'block';
186 whichIm.src = imgOpened.src;
189 whichEl.style.display = 'none';
190 whichIm.src = imgClosed.src;
192 } // end of the IE4 case
194 var whichEl = document.layers[el + 'Child'];
195 var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
196 if (whichEl.visibility == 'hide') {
197 whichEl.visibility = 'show';
198 whichIm.src = imgOpened.src;
201 whichEl.visibility = 'hide';
202 whichIm.src = imgClosed.src;
205 } // end of the NS4 case
206 } // end of the 'expandBase()' function
210 * Add styles for positioned layers
214 // Brian Birtles : This is not the ideal method of doing this
215 // but under the 7th June '00 Mozilla build (and many before
216 // it) Mozilla did not treat text between <style> tags as
217 // style information unless it was written with the one call
220 var lstyle = '<style type="text/css">'
221 + 'div {color: #000000;}'
222 + '.heada {font-family: ' + fontFamily + '; font-size: 10pt}'
223 + '.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration:none; display: block}'
224 + '.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; text-decoration:none; display: none}'
225 + '.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt;}'
226 + '.tblItem:hover {color: #FF0000; text-decoration: underline}'
231 write('<style type="text/css">');
232 write('div {color: #000000; }');
233 write('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
235 write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}');
236 write('.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; text-decoration: none; display: none}');
237 write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt}');
238 write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
241 write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; position: absolute; visibility: hidden}');
242 write('.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; position: absolute; visibility: hidden}');
243 write('.item, .tblItem {color: #333399; text-decoration: none}');
251 write('<style type="text/css">');
252 write('div {color: #000000; }');
253 write('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
254 write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none}');
255 write('.child {font-family: ' + fontFamily + '; font-size: 8pt; color: #333399; text-decoration: none}');
256 write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}');
257 write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
260 } // end of adding styles