source: trunk/monitor/htdocs/asapmon.js@ 1826

Last change on this file since 1826 was 711, checked in by mar637, 19 years ago

removed hidden naming prefix, added source selection

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.4 KB
Line 
1var repopulate = function() {
2 unitswitch(document.getElementById('cunit').value);
3 baselineswitch();
4 checkbuttons("cdoppler",["doppler0","doppler1"]);
5 checkbuttons("cframe",["frame0","frame1"]);
6 selectFiles();
7 selectIFs();
8 selectSources();
9 var sumtext = document.getElementById('sum').value;
10 if (sumtext == "") {
11 document.getElementById('summary').style.display = 'none';
12 } else {
13 document.getElementById('summary').style.display = 'inline';
14 }
15 var csource = document.getElementById('csource').value;
16 if (csource == "") {
17 document.getElementById('sourcelbl').style.display = 'none';
18 } else {
19 document.getElementById('sourcelbl').style.display = 'inline';
20 }
21}
22
23function summaryPopUp() {
24 var sumtext = document.getElementById('sum').value;
25 if (sumtext == "") {return false;}
26 TheNewWin = window.open('','name','height=500,width=600,toolbar=no,directories=no,status=no,menubar=no');
27 TheNewWin.document.write('<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd"><html xmlns="http:\/\/www.w3.org\/1999\/xhtml">');
28 TheNewWin.document.write('<head><title>Popup<\/title><\/head><body style="overflow:hidden" bgcolor="#ffffff"><pre>');
29 TheNewWin.document.write(sumtext);
30 TheNewWin.document.write('</pre><hr \/> <p align="right"><a href="#" onclick="self.close();return false;">Close');
31 TheNewWin.document.write(' Window<\/a><\/p> <\/body><\/html>');
32 return false;
33}
34
35function checkbuttons(hiddenfields, fields){
36 var theval = document.getElementById(hiddenfields).value;
37 for (i=0; i<fields.length;++i ){
38 var elem = document.getElementById(fields[i]);
39 if ( elem.value == theval ) {
40 elem.checked = 'checked';
41 }
42 }
43}
44
45function selectSources() {
46 var sl = document.getElementById("sourcelist");
47 var cs = document.getElementById("csource").value;
48 var opts = sl.options;
49 for (k=0; k<opts.length;++k) {
50 if (opts[k].value == cs ) {
51 opts[k].selected = 'selected';
52 }
53 }
54 if (cs) {
55 var sourcediv = document.getElementById("sourcelbl");
56 sourcediv.style.display = "inline";
57 }
58}
59
60function selectFiles() {
61 var indeces = eval(document.getElementById("cfilesel").value);
62 var fl = document.getElementById("filelist");
63 var opts = fl.options;
64 for (k=0; k<indeces.length;++k) {
65 opts[indeces[k]].selected = 'selected';
66 }
67}
68
69function selectIFs() {
70 nif = eval(document.getElementById("nif").value);
71 for (i=0; i<nif.length;++i ) {
72 p0 = "cif"+nif[i]
73 p1 = "rest"+nif[i]
74 var ifsel = eval(document.getElementById(p0).value);
75 var f = document.getElementById(p1);
76 f.options[ifsel].selected = 'selected';
77 }
78}
79
80function baselineswitch() {
81 var fields = ["polyorder","baselinerange"];
82 var elem = document.getElementById("baseline");
83 for (i=0; i<fields.length; ++i) {
84 var cont = document.getElementById(fields[i]);
85 if (elem.checked) {
86 elem.value = 1;
87 cont.style.display = "block";
88 } else {
89 cont.style.display = "none";
90 elem.value = 0;
91 }
92 }
93}
94
95function clearunit() {
96 var fields = ["plotwindow","brangewindow"];
97 for (i=0; i<fields.length; ++i) {
98 var cont = document.getElementById(fields[i]);
99 cont.value = "";
100 }
101}
102
103function unitswitch(unitval) {
104 var fields = ["velframe","veldoppler","velrest"];
105 for (i=0; i<fields.length; ++i) {
106 var cont = document.getElementById(fields[i]);
107 if (unitval == "channel") {
108 cont.style.display = "none";
109 } else {
110 if (unitval == "GHz") {
111 if (fields[i] == "velrest" || fields[i] == "veldoppler") cont.style.display = "none";
112 else cont.style.display = "block";
113 } else {
114 cont.style.display = "block";
115 }
116 }
117 }
118 var ulblcont = document.getElementById("prangeunit");
119 ulblcont.innerHTML = "";
120 ulblcont.innerHTML = unitval;
121 var ulblcont = document.getElementById("brangeunit");
122 ulblcont.innerHTML = "";
123 ulblcont.innerHTML = unitval;
124 if ( unitval != document.getElementById('cunit').value ) {
125 clearunit();
126 }
127}
128
129
130function listFiles(name, serviceURL) {
131 var callback = (arguments.length == 3 ? arguments[2] : null);
132 var request = new Ajax.Request(serviceURL, {
133 parameters: "path=" + name,
134 onComplete: function(transport) {
135 var resolutions = processResolutions(transport.responseXML.documentElement);
136 if (callback != null) {
137 callback.process(resolutions);
138 } else {
139 return resolutions;
140 }
141 }
142 });
143}
144
145function processResolutions(result) {
146 //var results = result.getElementsByTagName("Listing");
147
148 var fnames = result.getElementsByTagName("File");
149 var files = [];
150 if (fnames.length > 0 ) {
151 for (i=0;i<fnames.length;++i) {
152 files.push(fnames[i].firstChild.nodeValue)
153 }
154 }
155 return files;
156}
157
158
159function insertFields() {
160 var opts = document.getElementById("directory");
161 var path = opts.selectedIndex;
162 scripturl = new String(window.document.location);
163 scripturl = scripturl.replace(/\w+\.py.*$/gi,"filelist.py");
164 listFiles(path,scripturl, callbackHandler);
165 return;
166}
167
168
169function invalidateSources() {
170 var opts = document.getElementById("sourcelist");
171 var fileopt = opts.options;
172 //clear
173 for (i=0;i<fileopt.length;++i) {
174 fileopt[i] = null;
175 }
176 fileopt.length = 0;
177 var sourcediv = document.getElementById("sourcelbl");
178 sourcediv.style.display = "none";
179}
180
181function invalidateFiles() {
182 insertFields();
183 invalidateSources();
184}
185
186var callbackHandler = {
187 process: function(parm) {
188 var opts = document.getElementById("filelist");
189 var fileopt = opts.options;
190 //clear
191 for (i=0;i<fileopt.length;++i) {
192 fileopt[i] = null;
193 }
194 fileopt.length = 0;
195 for (i=0;i<parm.length;++i) {
196 var opt = document.createElement("option");
197 opt.text = parm[i];
198 opt.value = i;
199 fileopt.add(opt);
200 }
201 // last file is selected
202 if (fileopt.length > 0)
203 opt.selected = fileopt.length-1;
204 }
205}
Note: See TracBrowser for help on using the repository browser.