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 to 1.0-RC1 for Windows (js enabled & disabled)
14 // - IE5, 5.01, 5.5, 6.0 for Windows
15 // - Netscape 4.75 to 4.78 for Windows
17 // Test failed (crappy DOM implementations) with:
18 // - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
19 // - Opera 5.10 to 6.01 for windows, Opera 5+ for Linux: 'style.display' can't
21 // - Konqueror 2+, 3: 'style.display' can't be changed
24 var isExpanded = false;
26 var imgOpened = new Image(9,9);
27 imgOpened.src = 'images/minus.png';
28 var imgClosed = new Image(9,9);
29 imgClosed.src = 'images/plus.png';
33 * Do reloads the frame if the window has been resized under Netscape4+
38 if (innerWidth != origWidth || innerHeight != origHeight)
39 location.reload(true);
40 } // end of the 'reDo()' function
43 * Positioned element resize bug under NS4+
46 var origWidth = innerWidth;
47 var origHeight = innerHeight;
53 * Gets the id of the first collapsible room
55 * @param string the name of the first collapsible room
57 * @return integer the index number corresponding to this room
61 function nsGetIndex(el) {
63 var theLayers = document.layers;
64 var layersCnt = theLayers.length;
65 for (var i = 0; i < layersCnt; i++) {
66 if (theLayers[i].id == el) {
72 } // end of the 'nsGetIndex()' function
76 * Positions layers under NS4+
80 function nsArrangeList() {
81 if (typeof(firstInd) != 'undefined' && firstInd != null) {
82 var theLayers = document.layers;
83 var layersCnt = theLayers.length;
84 var nextY = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
85 for (var i = firstInd + 1; i < layersCnt; i++) {
86 if (theLayers[i].visibility != 'hide') {
87 theLayers[i].pageY = nextY;
88 nextY += theLayers[i].document.height;
92 } // end of the 'nsArrangeList()' function
96 * Expand databases at startup
100 function nsShowAll() {
101 var theLayers = document.layers;
102 var layersCnt = theLayers.length;
103 for (i = firstInd; i < layersCnt; i++) {
104 theLayers[i].visibility = 'show';
106 } // end of the 'nsShowAll()' function
110 * Collapses databases at startup
116 if (!capable || !isServer)
120 var tempCollCnt = null;
124 tempColl = document.getElementsByTagName('DIV');
125 tempCollCnt = tempColl.length;
126 for (i = 0; i < tempCollCnt; i++) {
127 if (tempColl[i].id == expandedDb)
128 tempColl[i].style.display = 'block';
129 else if (tempColl[i].className == 'child')
130 tempColl[i].style.display = 'none';
132 } // end of the DOM case
134 tempColl = document.all.tags('DIV');
135 tempCollCnt = tempColl.length;
136 for (i = 0; i < tempCollCnt; i++) {
137 if (tempColl(i).id == expandedDb)
138 tempColl(i).style.display = 'block';
139 else if (tempColl(i).className == 'child')
140 tempColl(i).style.display = 'none';
142 } // end of the IE4 case
144 var theLayers = document.layers;
145 var layersCnt = theLayers.length;
146 for (i = 0; i < layersCnt; i++) {
147 if (theLayers[i].id == expandedDb)
148 theLayers[i].visibility = 'show';
149 else if (theLayers[i].id.indexOf('Child') != -1)
150 theLayers[i].visibility = 'hide';
152 theLayers[i].visibility = 'show';
155 } // end of the NS4 case
156 } // end of the 'initIt()' function
160 * Collapses/expands a database when the user require this to be done
162 * @param string the name of the database to act on
163 * @param boolean whether to expand or to collapse the database content
167 function expandBase(el, unexpand)
176 whichEl = document.getElementById(el + 'Child');
177 whichIm = document.getElementById(el + 'Img');
178 if (whichEl.style.display == 'none' && whichIm) {
179 whichEl.style.display = 'block';
180 whichIm.src = imgOpened.src;
183 whichEl.style.display = 'none';
184 whichIm.src = imgClosed.src;
186 } // end of the DOM case
188 whichEl = document.all(el + 'Child');
189 whichIm = document.images.item(el + 'Img');
190 if (whichEl.style.display == 'none') {
191 whichEl.style.display = 'block';
192 whichIm.src = imgOpened.src;
195 whichEl.style.display = 'none';
196 whichIm.src = imgClosed.src;
198 } // end of the IE4 case
200 whichEl = document.layers[el + 'Child'];
201 whichIm = document.layers[el + 'Parent'].document.images['imEx'];
202 if (whichEl.visibility == 'hide') {
203 whichEl.visibility = 'show';
204 whichIm.src = imgOpened.src;
207 whichEl.visibility = 'hide';
208 whichIm.src = imgClosed.src;
211 } // end of the NS4 case
212 } // end of the 'expandBase()' function
216 * Hilight/un-hilight a database when the mouse pass over/out it
218 * @param string the name of the database to act on
219 * @param boolean the color to be used
223 function hilightBase(el, theColor)
225 if (!isDOM && !isIE4) {
230 var whichTables = null;
233 whichDb = document.getElementById(el + 'Parent');
234 whichTables = document.getElementById(el + 'Child');
237 whichDb = document.all(el + 'Parent');
238 whichTables = document.all(el + 'Child');
241 if (typeof(whichDb.style) == 'undefined') {
244 else if (whichTables) {
245 whichDb.style.backgroundColor = theColor;
246 whichTables.style.backgroundColor = theColor;
249 whichDb.style.backgroundColor = theColor;
253 } // end of the 'hilightBase()' function
255 window.onload = initIt;