source: branches/Corsika7405Compatibility/datacenter/db/menu.js@ 20115

Last change on this file since 20115 was 9508, checked in by Daniela Dorner, 15 years ago
*** empty log message ***
File size: 7.8 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 != 'none')
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//show all lines on db website
111function showalllines(num)
112{
113 for (var i = 1 ; i < num+1 ; i++)
114 {
115 var el = document.getElementById("line"+i);
116 var img = document.getElementById("line"+i+"button");
117 if (el.style.display == 'none')
118 {
119 el.style.display='';
120 if (img)
121 {
122 img.src='minus.png';
123 img.alt='-';
124 }
125 }
126 }
127}
128
129
130//functions and arrays needed for the menu of plotdb.php
131primaries = new Array( "fSequenceFirst", "fRunNumber", "fDataSetNumber");
132
133//for each primary (run#, seq#, dataset#) two pulldowns exist
134//the first is needed when plotting versus primary ('prim' is chosen)
135//the second is only needed when plotting versus a second value ('val' is chosen)
136
137//shows the first pulldown for a given primary
138// and hides the ones of the other primaries
139// and hides the second one for the primary if needed
140//is called when a primary is chosen from the pulldown
141function showpulldown (id2)
142{
143 //loop over primaries
144 for (var i = 0 ; i < primaries.length ; i++)
145 {
146 //if primary is given id
147 if (primaries[i]==id2)
148 {
149 //show first pulldown
150 var el2 = document.getElementById(primaries[i]);
151 el2.style.display="inline";
152 //show pulldowns for limits
153 var el4 = document.getElementById(primaries[i]+"3");
154 el4.style.display="inline";
155 var el6 = document.getElementById(primaries[i]+"4");
156 el6.style.display="inline";
157 }
158 else
159 {
160 //hide first pulldown
161 var el2 = document.getElementById(primaries[i]);
162 el2.style.display="none";
163 //get element for second pulldown
164 var el3 = document.getElementById(primaries[i]+"2");
165 //if second pulldown is shown,
166 // hide second pulldown
167 // and show second pulldown for chosen primary (id2)
168 if (el3.style.display=='inline')
169 {
170 var el6 = document.getElementById(id2+"2");
171 el6.style.display="inline";
172 el3.style.display="none";
173 }
174 //hide pulldowns for limits
175 var el4 = document.getElementById(primaries[i]+"3");
176 el4.style.display="none";
177 var el5 = document.getElementById(primaries[i]+"4");
178 el5.style.display="none";
179 }
180 }
181}
182
183//shows the second pulldown and inputs for the ranges
184function showpulldown2 ()
185{
186 count=0;
187 for (var i = 0 ; i < primaries.length ; i++)
188 {
189 //get element
190 var el = document.getElementById(primaries[i]);
191 //if the first pulldown is shown, show also the second one
192 if (el.style.display=='inline')
193 {
194 var el2 = document.getElementById(primaries[i]+"2");
195 el2.style.display="inline";
196 }
197 else
198 count++;
199 }
200 //if no first pulldown is shown, i.e. the primary has not yet been chosen,
201 //all second pulldowns are shown
202 if (count==3)
203 for (var i = 0 ; i < primaries.length ; i++)
204 {
205 var el2 = document.getElementById(primaries[i]+"2");
206 el2.style.display="inline";
207 }
208
209 //show the inputs for the ranges for the second pulldown
210 //there is only one element for this (not one for each primary)
211 var el3 = document.getElementById("Range2");
212 el3.style.display="inline";
213}
214
215//hides the second pulldown and inputs for the ranges
216function hidepulldown2 ()
217{
218 for (var i = 0 ; i < primaries.length ; i++)
219 {
220 var el2 = document.getElementById(primaries[i]+"2");
221 el2.style.display="none";
222 }
223 var el3 = document.getElementById("Range2");
224 el3.style.display="none";
225}
226
227//show the element for inserting the second set
228function showset2()
229{
230 var el = document.getElementById("set2");
231 el.style.display="inline";
232}
233
234//hide the element for inserting the second set
235function hideset2()
236{
237 var el = document.getElementById("set2");
238 el.style.display="none";
239}
240
241
242
243//
244//functions for builddatasets.php
245//
246
247function selectallsequences(val)
248{
249 var sequs = document.getElementsByTagName("input");
250 for (var i=0; i<sequs.length; i++)
251 {
252 var sequname = sequs[i].name;
253 if (!sequname.match("^DSSeq[0-9]*$"))
254 continue;
255 var sequval = sequs[i].value;
256 if (sequval != val)
257 sequs[i].checked = false;
258 else
259 sequs[i].checked = true;
260 }
261}
262
Note: See TracBrowser for help on using the repository browser.