Annotation of rat/client/parameter.html, revision 1.3
1.1 www 1: <html>
2: <!--
3: The LearningOnline Network with CAPA
4: Parameter Input Window
1.3 ! www 5: 06/16/00,06/17,11/17,11/18,11/23 Gerd Kortemeyer
1.1 www 6: -->
7: <head>
8: <title>LON-CAPA</title>
9: </head>
10:
11: <script>
12:
13: var ptype='';
14: var pvalue='';
15: var preturn='';
16: var pcode='';
1.2 www 17: var pscat='';
18: var pmarker='';
1.1 www 19: var pname='';
20:
21: var svalue;
1.2 www 22: var stype;
23: var smarker;
1.1 www 24:
25: var vars=new Array();
26:
1.2 www 27: var cdate=new Date();
28:
29: var csec;
30: var cmin;
31: var chour;
32: var cday;
33:
34: var months=new Array();
35:
36:
1.1 www 37: function selwrite(text) {
38: this.window.selector.document.write(text);
39: }
40:
41: function choicestart() {
42: this.window.choices.document.clear();
43: choicewrite('<html><body bgcolor="#FFFFFF">');
44: }
45:
46: function choiceend() {
47: choicewrite('</body></html>');
48: this.window.choices.document.close();
49: }
50:
51: function choicewrite(text) {
52: this.window.choices.document.write(text);
53: }
54:
55: function tablestart(headtext) {
56: choicewrite('<table><tr bgcolor="#AAFFAA"><th colspan=3>'+
57: headtext+'</th></tr>');
58: }
59:
60: function valline(text,id1,id2) {
61: choicewrite('<tr bgcolor="#AAFFAA"><td>'+text+
62: '</td><td><input type=text size=4 name=val'+
63: id1+'></td><td>incl:<input type=checkbox name=val'+
64: id2+'></td></tr>');
65: }
66:
1.2 www 67: function datecalc() {
68: var sform=choices.document.forms.sch;
69:
70: cdate.setHours(sform.hours.options[sform.hours.selectedIndex].value);
71: cdate.setMinutes(sform.minutes.options[sform.minutes.selectedIndex].value);
72: cdate.setSeconds(sform.minutes.options[sform.seconds.selectedIndex].value);
73: cdate.setDate(sform.date.options[sform.date.selectedIndex].value);
74: cdate.setMonth(sform.month.options[sform.month.selectedIndex].value);
75: cdate.setFullYear(sform.year.options[sform.year.selectedIndex].value);
76:
77: draw();
78: }
79:
80: function hour() {
81: var thishour=cdate.getHours();
82: var i; var j;
83: choicewrite('<select name=hours onChange="parent.datecalc();">');
84: for (i=0;i<=23;i++) {
85: choicewrite('<option value='+i);
86: if (i==thishour) {
87: choicewrite(' selected');
88: }
89: choicewrite('>');
90: if (i==12) { choicewrite('noon'); } else {
91: if (i==0) { choicewrite('midnight') } else {
92:
93: if (i<12) { choicewrite(i+' am'); } else {
94: j=i-12; choicewrite(j+' pm');
95: }
96:
97: }
98: }
99: choicewrite('</option>');
100: }
101: choicewrite('</select>');
102: }
103:
104: function minute() {
105: var thisminutes=cdate.getMinutes();
106: var i;
107: choicewrite('<select name=minutes onChange="parent.datecalc();">');
108: for (i=0;i<=59;i++) {
109: choicewrite('<option value='+i);
110: if (i==thisminutes) {
111: choicewrite(' selected');
112: }
113: choicewrite('>'+i+'</option>');
114: }
115: choicewrite('</select>');
116: }
117:
118: function second() {
119: var thisseconds=cdate.getSeconds();
120: var i;
121: choicewrite('<select name=seconds onChange="parent.datecalc();">');
122: for (i=0;i<=59;i++) {
123: choicewrite('<option value='+i);
124: if (i==thisseconds) {
125: choicewrite(' selected');
126: }
127: choicewrite('>'+i+'</option>');
128: }
129: choicewrite('</select>');
130: }
131:
132:
133: function date() {
134: var thisdate=cdate.getDate();
135: var i;
136: choicewrite('<select name=date onChange="parent.datecalc();">');
137: for (i=1;i<=31;i++) {
138: choicewrite('<option value='+i);
139: if (i==thisdate) {
140: choicewrite(' selected');
141: }
142: choicewrite('>'+i+'</option>');
143: }
144: choicewrite('</select>');
145: }
146:
147: function year() {
148: var thisyear=cdate.getFullYear();
149: var i;
150: choicewrite('<select name=year onChange="parent.datecalc();">');
151: for (i=thisyear-25;i<=thisyear+50;i++) {
152: choicewrite('<option value='+i);
153: if (i==thisyear) {
154: choicewrite(' selected');
155: }
156: choicewrite('>'+i+'</option>');
157: }
158: choicewrite('</select>');
159: }
160:
161: function month() {
162: var thismonth=cdate.getMonth();
163: var i;
164: choicewrite('<select name=month onChange="parent.datecalc();">');
165: for (i=0;i<=11;i++) {
166: choicewrite('<option value='+i);
167: if (i==thismonth) {
168: choicewrite(' selected');
169: }
170: choicewrite('>'+months[i]+'</option>');
171: }
172: choicewrite('</select>');
173: }
174:
175:
176: function intminute() {
177: var thisminutes=cmins;
178: var i;
179: choicewrite('<select name=minutes onChange="parent.intcalc();">');
180: for (i=0;i<=59;i++) {
181: choicewrite('<option value='+i);
182: if (i==thisminutes) {
183: choicewrite(' selected');
184: }
185: choicewrite('>'+i+'</option>');
186: }
187: choicewrite('</select>');
188: }
189:
190: function inthour() {
191: var thishours=chours;
192: var i;
193: choicewrite('<select name=hours onChange="parent.intcalc();">');
194: for (i=0;i<=23;i++) {
195: choicewrite('<option value='+i);
196: if (i==thishours) {
197: choicewrite(' selected');
198: }
199: choicewrite('>'+i+'</option>');
200: }
201: choicewrite('</select>');
202: }
203:
204: function intsecond() {
205: var thisseconds=csecs;
206: var i;
207: choicewrite('<select name=seconds onChange="parent.intcalc();">');
208: for (i=0;i<=59;i++) {
209: choicewrite('<option value='+i);
210: if (i==thisseconds) {
211: choicewrite(' selected');
212: }
213: choicewrite('>'+i+'</option>');
214: }
215: choicewrite('</select>');
216: }
217:
218:
219: function intday() {
220: var thisdate=cdays;
221: var i;
222: choicewrite('<select name=date onChange="parent.intcalc();">');
223: for (i=0;i<=31;i++) {
224: choicewrite('<option value='+i);
225: if (i==thisdate) {
226: choicewrite(' selected');
227: }
228: choicewrite('>'+i+'</option>');
229: }
230: choicewrite('</select>');
231: }
232:
233: function intcalc() {
234: var sform=choices.document.forms.sch;
235: svalue=((sform.date.options[sform.date.selectedIndex].value*24+
236: sform.hours.options[sform.hours.selectedIndex].value*1)*60+
237: sform.minutes.options[sform.minutes.selectedIndex].value*1)*60+
238: sform.seconds.options[sform.seconds.selectedIndex].value*1;
239: draw();
240: }
241:
242: function intervaldis() {
243: csecs=svalue;
244: cdays=Math.floor(csecs/86400);
245: csecs-=cdays*86400;
246: chours=Math.floor(csecs/3600);
247: csecs-=chours*3600;
248: cmins=Math.floor(csecs/60);
249: csecs-=cmins*60;
250: choicewrite(cdays+' days '+chours+' hours '
251: +cmins+' mins '+csecs+' secs');
252: }
253:
254:
255:
1.1 www 256: function afterproc() {
257: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>Error after rounding: '
258: +'<input type=checkbox name=val1></td></tr>');
259: }
260:
261: function draw() {
262: choicestart();
263: choicewrite('<form name=sch>');
264: if (ptype=='tolerance') {
1.2 www 265: // 0: pscat
1.1 www 266: // 1: after processing
1.2 www 267: if (pscat=='default') {
1.1 www 268: tablestart('Use default value or algorithm of resource');
269: }
1.2 www 270: if (pscat=='exact') {
1.1 www 271: tablestart('Accept only exact value, zero tolerance');
272: afterproc();
273: }
1.2 www 274: if (pscat=='relative_sym') {
1.1 www 275: // 2: percentage
276: // 3: open
277: tablestart('Percentage error, symmetric around value');
278: valline('Percentage',2,3);
279: afterproc();
280: }
1.2 www 281: if (pscat=='relative') {
1.1 www 282: // 2: left
283: // 3: open
284: // 4: right
285: // 5: open
286: tablestart('Percentage error, asymmetric around value');
287: valline('Upper percentage',2,3);
288: valline('Lower percentage',4,5);
289: afterproc();
290: }
1.2 www 291: if (pscat=='absolute_sym') {
1.1 www 292: tablestart('Absolute error, symmetric around value');
293: valline('Value',2,3);
294: afterproc();
295: }
1.2 www 296: if (pscat=='absolute') {
1.1 www 297: tablestart('Absolute error, asymmetric around value');
298: valline('Upper value',2,3);
299: valline('Lower value',4,5);
300: afterproc();
301: }
1.2 www 302: if (pscat=='sigdigits') {
1.1 www 303: tablestart('Agreement on significant digits');
304: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>Number of digits: '
305: +'<input type=text size=4 name=val2></td></tr>');
306:
307: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>Accept if more digits given: '
308: +'<input type=checkbox name=val3></td></tr>');
309:
310: }
311: }
312:
313: if (ptype=='date') {
1.2 www 314: if (pscat=='default') {
315: tablestart('Default value or none');
316: choicewrite('</table>');
317: } else {
318: if (pscat=='start') {
319: tablestart('Starting or opening date and time');
320: }
321: if (pscat=='end') {
322: tablestart('Ending or closing date and time');
323: }
324: if (pscat=='interval') {
325: tablestart('Time interval');
326: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>');
327: intervaldis();
328: choicewrite('</td></tr><tr bgcolor="#AAFFAA"><td>Time:'
329: +'</td><td colspan=2>');
330: intday();choicewrite('days ');
331: inthour();choicewrite('hours ');
332: intminute(); choicewrite('mins '); intsecond();
333: choicewrite('secs</td></tr></table>');
334: } else {
335: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>'
336: +cdate.toString()+
337: '</td></tr><tr bgcolor="#AAFFAA"><td>Date:</td><td colspan=2>');
338: month();date();year();
339: choicewrite('</td></tr><tr bgcolor="#AAFFAA"><td>Time:'
340: +'</td><td colspan=2>');hour();choicewrite('h ');minute();
341: choicewrite('m ');second();
342: choicewrite('s</td></tr></table>');
343: }
344: }
1.1 www 345: }
346:
347: if (ptype=='value') {
348: }
349:
350: if (ptype=='truefalse') {
351: }
352:
353: if (ptype=='check') {
354: }
355:
356: if (ptype=='radio') {
357: }
358: choicewrite('</table></form>');
359: choiceend();
360: }
361:
362: function sopt(va,text) {
363: selwrite('<option value="'+va+'"');
1.2 www 364: if (va==pscat) {
1.1 www 365: selwrite(' selected');
366: }
367: selwrite('>'+text+'</option>');
368: }
369:
370: function catchange() {
371: var sform=selector.document.forms.fsel.fcat;
1.2 www 372: pscat=sform.options[sform.selectedIndex].value;
1.1 www 373: draw();
374: }
375:
376: function assemble() {
1.2 www 377: if ((ptype=='date') && (pscat!='interval')) {
378: svalue=Math.round(cdate.getTime()/1000);
379: }
380: stype=ptype+'_'+pscat;
381: alert(stype+' '+svalue);
1.1 www 382: }
383:
384:
385: function init() {
386: var i;
1.2 www 387: var subs=new Array();
1.1 www 388: var namevalue=this.window.location.search.split('&');
389: namevalue[0]=namevalue[0].substr(1,namevalue[0].length-1);
390:
391: for (i=0;i<namevalue.length;i++) {
392: var pair=namevalue[i].split('=');
1.3 ! www 393: pair[1]=unescape(pair[1]);
1.1 www 394: if (pair[0]=='value') { pvalue=pair[1]; }
1.2 www 395: if (pair[0]=='type') { subs=pair[1].split('_');
396: ptype=subs[0];
397: pscat=subs[1];
398: if (subs[2]!=undefined) { pscat+='_'+subs[2]; }
399: if ((pscat=='') || (pscat==undefined))
400: { pscat='default'; }
401: }
1.1 www 402: if (pair[0]=='return') { preturn=pair[1]; }
403: if (pair[0]=='call') { pcode=pair[1]; }
1.2 www 404: if (pair[0]=='marker') { pmarker=pair[1]; }
1.1 www 405: if (pair[0]=='name') { pname=pair[1]; }
406: }
407:
408: svalue=pvalue;
409:
410: this.window.selector.document.clear();
411: selwrite('<html><body bgcolor="#FFFFFF">');
412:
413: selwrite('<form name="fsel"><h2>'+pname+'</h2>');
414: selwrite('<select name="fcat" onChange="parent.catchange();">');
415: if (ptype=='tolerance') {
416: sopt('default','Default');
417: sopt('exact','Exact Value (no tolerance)');
418: sopt('relative_sym','Relative Tolerance, Symmetric (percent)');
419: sopt('relative','Relative Tolerance (percentages)');
420: sopt('absolute_sym','Absolute Tolerance, Symmetric (value)');
421: sopt('absolute','Absolute Tolerance (values)');
422: sopt('sigdigits','Significant Digits (number)');
423: }
424:
425: if (ptype=='date') {
426: sopt('default','Default');
427: sopt('start','Starting Date');
428: sopt('end','Ending Date');
1.2 www 429: sopt('interval','Time Interval');
430:
431: if ((pvalue!='') && (pvalue!=undefined)) {
432: cdate.setTime(pvalue*1000);
433: }
434:
435: months[0]='January';
436: months[1]='February';
437: months[2]='March';
438: months[3]='April';
439: months[4]='May';
440: months[5]='June';
441: months[6]='July';
442: months[7]='August';
443: months[8]='September';
444: months[9]='October';
445: months[10]='November';
446: months[11]='December';
1.1 www 447: }
1.2 www 448:
1.1 www 449: if (ptype=='value') {
450: }
451:
452: if (ptype=='truefalse') {
453: }
454:
455: if (ptype=='check') {
456: }
457:
458: if (ptype=='radio') {
459: }
460:
461: selwrite('</select></form>');
462:
1.2 www 463: selwrite('<a href="javascript:parent.assemble();');
1.1 www 464: if (preturn!='') {
1.2 www 465: selwrite('parent.opener.'+preturn+'=parent.window.svalue;');
466: selwrite('parent.opener.'+preturn+'_type=parent.window.stype;');
467: }
468: if (pmarker!='') {
469: selwrite('parent.opener.'+pmarker+'=parent.window.pmarker;');
1.1 www 470: }
471: if (pcode!='') {
1.2 www 472: selwrite('parent.opener.'+pcode+';');
1.1 www 473: }
474: selwrite('">Store</a>');
475:
476: selwrite('</body></html>');
477: this.window.selector.document.close();
1.2 www 478: draw();
1.1 www 479:
480: }
481:
482: </script>
483:
1.2 www 484: <frameset rows="120,*" onLoad="init();">
1.1 www 485: <frame name=selector src="empty.html">
486: <frame name=choices src="empty.html">
487: </frameset>
488:
489:
490:
491: </html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>