source: trunk/MagicSoft/Mars/datacenter/db/menu.js@ 8532

Last change on this file since 8532 was 8476, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
File size: 7.0 KB
Line 
1
2//functions and arrays needed for showing and hiding the menu on the db websites
3ids = new Array( "all", "info", "info2", "stat", "fail", "cal", "star", "limits", "ranges", "showquery");
4statarr = new Array( 1, 0, 0, 0, 0, 0, 0, 0, 0, 0);
5
6//function to get the input for fShowHide from the page
7//called each time, when an element is changed with showhide()
8//and when the page is reloaded
9function setdisplays ()
10{
11 //reset variable for fShowHide
12 var sh="";
13 for (var i = 0 ; i < ids.length ; i++)
14 {
15 //get element for each possible menu element
16 var d = document.getElementById(ids[i]);
17 //if element exists, check if it is currently displayed
18 //set the value in the status array accordingly
19 //0: element is not shown
20 //1: element is shown
21 if (d)
22 d.style.display == 'none' ? statarr[i]=0 : statarr[i]=1;
23 //set the value of 'all' to 0
24 //to make sure, that the whole menu is hidden in case of a query
25 if (i==0)
26 statarr[i]=0;
27 //add value to the variable for fShowHide
28 sh=sh+statarr[i];
29 }
30 //return variable for fShowHide
31 return sh;
32}
33
34//function to hide one element of the menu and adapt the button accordingly
35function hide(el,img)
36{
37 el.style.display="none";
38 if (img)
39 {
40 img.src='plus.png';
41 img.alt='+';
42 }
43}
44
45//function to show one element of the menu and adapt the button accordingly
46function show(el,img)
47{
48 el.style.display="block";
49 if (img)
50 {
51 img.src='minus.png';
52 img.alt='-';
53 }
54}
55
56//function to show or hide one element of the menu
57function showhide (id)
58{
59 //get menu element and button for the element that has to be changed
60 var el = document.getElementById(id);
61 var img = document.getElementById(id+"button");
62 //query current status and change it accordingly
63 if (el.style.display == 'block')
64 hide(el,img);
65 else
66 {
67 show(el,img);
68 //expand the whole menu, when one element is shown
69 if (id!="showquery")
70 {
71 var el2 = document.getElementById("all");
72 var img2 = document.getElementById("allbutton");
73 show(el2,img2);
74 }
75 }
76 //update the value of fShowHide (id sh)
77 var fShowHide = document.getElementById("sh");
78 fShowHide.value = setdisplays();
79}
80
81//function getting the info, how the menu is from fShowHide
82//is called when the page is loaded (s. index-header.html)
83function getdisplay()
84{
85 //get value of fShowHide
86 var stat = document.getElementById("sh");
87 statvalue=stat.value;
88 //set menu variables for each element accordingly
89 for (var i = 0 ; i < ids.length ; i++)
90 {
91 //get value of this element from fShowHide
92 var status = statvalue.slice(i,i+1);
93 //get elements of menu and button
94 var el = document.getElementById(ids[i]);
95 var img = document.getElementById(ids[i]+"button");
96 //not all element exist on each page
97 if (!el)
98 continue;
99 //show or hide element according to the status value
100 status==0 ? hide(el,img) : show(el,img);
101 }
102 //set the value of fShowHide (id sh)
103 // needed here to make sure, that the whole menu is hidden
104 // even if nothing has been expanded (needed since 'ranges'
105 // is expanded by default)
106 var fShowHide = document.getElementById("sh");
107 fShowHide.value = setdisplays();
108}
109
110
111//functions and arrays needed for the menu of plotdb.php
112primaries = new Array( "fSequenceFirst", "fRunNumber", "fDataSetNumber");
113
114//for each primary (run#, seq#, dataset#) two pulldowns exist
115//the first is needed when plotting versus primary ('prim' is chosen)
116//the second is only needed when plotting versus a second value ('val' is chosen)
117
118//shows the first pulldown for a given primary
119// and hides the ones of the other primaries
120// and hides the second one for the primary if needed
121//is called when a primary is chosen from the pulldown
122function showpulldown (id2)
123{
124 //loop over primaries
125 for (var i = 0 ; i < primaries.length ; i++)
126 {
127 //if primary is given id
128 if (primaries[i]==id2)
129 {
130 //show first pulldown
131 var el2 = document.getElementById(primaries[i]);
132 el2.style.display="inline";
133 //show pulldowns for limits
134 var el4 = document.getElementById(primaries[i]+"3");
135 el4.style.display="inline";
136 var el6 = document.getElementById(primaries[i]+"4");
137 el6.style.display="inline";
138 }
139 else
140 {
141 //hide first pulldown
142 var el2 = document.getElementById(primaries[i]);
143 el2.style.display="none";
144 //get element for second pulldown
145 var el3 = document.getElementById(primaries[i]+"2");
146 //if second pulldown is shown,
147 // hide second pulldown
148 // and show second pulldown for chosen primary (id2)
149 if (el3.style.display=='inline')
150 {
151 var el6 = document.getElementById(id2+"2");
152 el6.style.display="inline";
153 el3.style.display="none";
154 }
155 //hide pulldowns for limits
156 var el4 = document.getElementById(primaries[i]+"3");
157 el4.style.display="none";
158 var el5 = document.getElementById(primaries[i]+"4");
159 el5.style.display="none";
160 }
161 }
162}
163
164//shows the second pulldown and inputs for the ranges
165function showpulldown2 ()
166{
167 count=0;
168 for (var i = 0 ; i < primaries.length ; i++)
169 {
170 //get element
171 var el = document.getElementById(primaries[i]);
172 //if the first pulldown is shown, show also the second one
173 if (el.style.display=='inline')
174 {
175 var el2 = document.getElementById(primaries[i]+"2");
176 el2.style.display="inline";
177 }
178 else
179 count++;
180 }
181 //if no first pulldown is shown, i.e. the primary has not yet been chosen,
182 //all second pulldowns are shown
183 if (count==3)
184 for (var i = 0 ; i < primaries.length ; i++)
185 {
186 var el2 = document.getElementById(primaries[i]+"2");
187 el2.style.display="inline";
188 }
189
190 //show the inputs for the ranges for the second pulldown
191 //there is only one element for this (not one for each primary)
192 var el3 = document.getElementById("Range2");
193 el3.style.display="inline";
194}
195
196//hides the second pulldown and inputs for the ranges
197function hidepulldown2 ()
198{
199 for (var i = 0 ; i < primaries.length ; i++)
200 {
201 var el2 = document.getElementById(primaries[i]+"2");
202 el2.style.display="none";
203 }
204 var el3 = document.getElementById("Range2");
205 el3.style.display="none";
206}
207
208//show the element for inserting the second set
209function showset2()
210{
211 var el = document.getElementById("set2");
212 el.style.display="inline";
213}
214
215//hide the element for inserting the second set
216function hideset2()
217{
218 var el = document.getElementById("set2");
219 el.style.display="none";
220}
221
Note: See TracBrowser for help on using the repository browser.