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