refresh
[phpmyadmin/crack.git] / left.js
blob3246d4f73ed746b685f267c6ae520b7defccc343
1 /* $Id$ */
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
12 // Test passed with:
13 // - Mozilla 0.8.1, 0.9.0, 0.9.1, 0.9.2 for Windows (js enabled
14 //    & disabled)
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
21 //   be changed
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';
33 /**
34  * Do reloads the frame if the window has been resized under Netscape4+
35  *
36  * @access  private
37  */
38 function reDo() {
39   if (innerWidth != origWidth || innerHeight != origHeight)
40     location.reload(true);
41 } // end of the 'reDo()' function
43 /**
44  * Positioned element resize bug under NS4+
45  */
46 if (isNS4) {
47   var origWidth  = innerWidth;
48   var origHeight = innerHeight;
49   onresize       = reDo;
53 /**
54  * Gets the id of the first collapsible room
55  *
56  * @param  string  the name of the first collapsible room
57  *
58  * @return  integer  the index number corresponding to this room
59  *
60  * @access  public
61  */
62 function nsGetIndex(el) {
63   var ind       = null;
64   var theLayers = document.layers;
65   var layersCnt = theLayers.length;
66   for (var i = 0; i < layersCnt; i++) {
67     if (theLayers[i].id == el) {
68       ind = i;
69       break;
70     }
71   }
72   return ind;
73 } // end of the 'nsGetIndex()' function
76 /**
77  * Positions layers under NS4+
78  *
79  * @access  public
80  */
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;
90       }
91     }
92   }
93 } // end of the 'nsArrangeList()' function
96 /**
97  * Expand databases at startup
98  *
99  * @access  public
100  */
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';
106   }
107 } // end of the 'nsShowAll()' function
111  * Collapses databases at startup
113  * @access  public
114  */
115 function initIt()
117   if (!capable || !isServer)
118     return;
120   if (isDOM) {
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';
128     }
129   } // end of the DOM case
130   else if (isIE4) {
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';
138     }
139   } // end of the IE4 case
140   else if (isNS4) {
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';
148       else
149         theLayers[i].visibility   = 'show';
150     }
151     nsArrangeList();
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
162  * @access  public
163  */
164 function expandBase(el, unexpand)
166   if (!capable)
167     return;
169   if (isDOM) {
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;
175     }
176     else if (unexpand) {
177       whichEl.style.display  = 'none';
178       whichIm.src            = imgClosed.src;
179     }
180   } // end of the DOM case
181   else if (isIE4) {
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;
187     }
188     else if (unexpand) {
189       whichEl.style.display  = 'none';
190       whichIm.src            = imgClosed.src;
191     }
192   } // end of the IE4 case
193   else if (isNS4) {
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;
199     }
200     else if (unexpand) {
201       whichEl.visibility  = 'hide';
202       whichIm.src         = imgClosed.src;
203     }
204     nsArrangeList();
205   } // end of the NS4 case
206 } // end of the 'expandBase()' function
210  * Add styles for positioned layers
211  */
212 if (capable) {
213   with (document) {
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
218     // to write().
219     if (isDOM) {
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}'
227                  + '<\/style>';
228       write(lstyle);
229     }
230     else {
231       write('<style type="text/css">');
232       write('div {color: #000000; }');
233       write('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
234       if (isIE4) {
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}');
239       }
240       else {
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}');
244       }
245       write('<\/style>');
246     }
247   }
249 else {
250   with (document) {
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}');
258     write('<\/style>');
259   }
260 } // end of adding styles
263 onload = initIt;