Annotation of rat/client/parameter.html, revision 1.10
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.10 ! www 6: 03/21/01,03/24,06/26 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: }
1.10 ! www 250: if (pscat.indexOf('range')!=-1) {
! 251: var rangeparts=new Array;
! 252: rangeparts=split('_',pscat);
! 253: rangeparts=split('...',rangeparts[1]);
! 254: if (svalue<rangeparts[0]) { svalue=rangeparts[0]; }
! 255: if (svalue>rangeparts[1]) { svalue=rangeparts[1]; }
! 256: }
1.6 www 257: draw();
258: }
259:
260: function floateval() {
261: svalue=choices.document.forms.sch.floatval.value;
262: svalue=1.0*svalue;
263: if (pscat=='pos') { svalue=Math.abs(svalue); }
264: if ((pscat=='zeroone') && ((svalue<0) || (svalue>1))) {
265: svalue='';
266: }
267: draw();
268: }
269:
270: function stringeval() {
271: svalue=choices.document.forms.sch.stringval.value;
272: draw();
273: }
274:
1.2 www 275: function intervaldis() {
276: csecs=svalue;
277: cdays=Math.floor(csecs/86400);
278: csecs-=cdays*86400;
279: chours=Math.floor(csecs/3600);
280: csecs-=chours*3600;
281: cmins=Math.floor(csecs/60);
282: csecs-=cmins*60;
283: choicewrite(cdays+' days '+chours+' hours '
284: +cmins+' mins '+csecs+' secs');
285: }
286:
287:
288:
1.1 www 289: function afterproc() {
290: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>Error after rounding: '
291: +'<input type=checkbox name=val1></td></tr>');
292: }
293:
294: function draw() {
295: choicestart();
1.6 www 296: choicewrite('<form name=sch');
297: if (ptype=='int') {
298: choicewrite(' action="javascript:integereval();"');
299: }
300: if (ptype=='float') {
301: choicewrite(' action="javascript:floateval();"');
302: }
303: if (ptype=='string') {
304: choicewrite(' action="javascript:stringeval();"');
305: }
306: choicewrite('>');
1.1 www 307: if (ptype=='tolerance') {
1.2 www 308: // 0: pscat
1.1 www 309: // 1: after processing
1.2 www 310: if (pscat=='default') {
1.1 www 311: tablestart('Use default value or algorithm of resource');
312: }
1.2 www 313: if (pscat=='exact') {
1.1 www 314: tablestart('Accept only exact value, zero tolerance');
315: afterproc();
316: }
1.2 www 317: if (pscat=='relative_sym') {
1.1 www 318: // 2: percentage
319: // 3: open
320: tablestart('Percentage error, symmetric around value');
321: valline('Percentage',2,3);
322: afterproc();
323: }
1.2 www 324: if (pscat=='relative') {
1.1 www 325: // 2: left
326: // 3: open
327: // 4: right
328: // 5: open
329: tablestart('Percentage error, asymmetric around value');
330: valline('Upper percentage',2,3);
331: valline('Lower percentage',4,5);
332: afterproc();
333: }
1.2 www 334: if (pscat=='absolute_sym') {
1.1 www 335: tablestart('Absolute error, symmetric around value');
336: valline('Value',2,3);
337: afterproc();
338: }
1.2 www 339: if (pscat=='absolute') {
1.1 www 340: tablestart('Absolute error, asymmetric around value');
341: valline('Upper value',2,3);
342: valline('Lower value',4,5);
343: afterproc();
344: }
1.2 www 345: if (pscat=='sigdigits') {
1.1 www 346: tablestart('Agreement on significant digits');
347: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>Number of digits: '
348: +'<input type=text size=4 name=val2></td></tr>');
349:
1.6 www 350: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>Accept if more digits given: '
1.1 www 351: +'<input type=checkbox name=val3></td></tr>');
352:
353: }
354: }
355:
356: if (ptype=='date') {
1.2 www 357: if (pscat=='default') {
358: tablestart('Default value or none');
359: choicewrite('</table>');
360: } else {
361: if (pscat=='start') {
362: tablestart('Starting or opening date and time');
363: }
364: if (pscat=='end') {
365: tablestart('Ending or closing date and time');
366: }
367: if (pscat=='interval') {
368: tablestart('Time interval');
369: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>');
370: intervaldis();
371: choicewrite('</td></tr><tr bgcolor="#AAFFAA"><td>Time:'
372: +'</td><td colspan=2>');
373: intday();choicewrite('days ');
374: inthour();choicewrite('hours ');
375: intminute(); choicewrite('mins '); intsecond();
376: choicewrite('secs</td></tr></table>');
377: } else {
378: choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>'
379: +cdate.toString()+
380: '</td></tr><tr bgcolor="#AAFFAA"><td>Date:</td><td colspan=2>');
381: month();date();year();
382: choicewrite('</td></tr><tr bgcolor="#AAFFAA"><td>Time:'
383: +'</td><td colspan=2>');hour();choicewrite('h ');minute();
384: choicewrite('m ');second();
385: choicewrite('s</td></tr></table>');
386: }
387: }
1.1 www 388: }
389:
1.6 www 390: if (ptype=='int') {
391: if (pscat=='default') {
392: tablestart('Default value or none');
393: choicewrite('</table>');
394: } else {
395: if (pscat=='pos') {
396: tablestart('Positive (non-zero) integer');
397: }
398: if (pscat=='zeropos') {
399: tablestart('Positive integer or zero');
400: }
1.10 ! www 401: if (pscat.indexOf('range')!=-1) {
! 402: var rangeparts=new Array;
! 403: rangeparts=split('_',pscat);
! 404: tablestart('Integer in the range ['+rangeparts[1]+']');
! 405: }
1.6 www 406: if (pscat=='any') {
407: tablestart('Integer');
408: }
409: choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
410: choicewrite('<input name=intval size=10 value="'+svalue+
411: '" name=intval onChange="parent.integereval()">');
412: choicewrite('</td></table>');
413: }
1.1 www 414: }
415:
1.6 www 416: if (ptype=='float') {
417: if (pscat=='default') {
418: tablestart('Default value or none');
419: choicewrite('</table>');
420: } else {
421: if (pscat=='pos') {
422: tablestart('Positive floating point number or zero');
423: }
424: if (pscat=='zeroone') {
425: tablestart('Floating point number between zero and one');
426: }
427: if (pscat=='any') {
428: tablestart('Floating point number');
429: }
430: choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
431: choicewrite('<input name=floatval size=10 value="'+svalue+
432: '" name=floatval onChange="parent.floateval()">');
433: choicewrite('</td></table>');
434: }
1.1 www 435: }
436:
1.6 www 437: if (ptype=='string') {
438: if (pscat=='default') {
439: tablestart('Default value or none');
440: choicewrite('</table>');
441: } else {
442: if (pscat=='any') {
443: tablestart('Text');
444: }
445: choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
446: choicewrite('<input name=intval size=20 value="'+svalue+
447: '" name=stringval onChange="parent.stringeval()">');
448: choicewrite('</td></table>');
449: }
1.1 www 450: }
451:
452: choicewrite('</table></form>');
453: choiceend();
454: }
455:
456: function sopt(va,text) {
457: selwrite('<option value="'+va+'"');
1.2 www 458: if (va==pscat) {
1.1 www 459: selwrite(' selected');
460: }
461: selwrite('>'+text+'</option>');
462: }
463:
464: function catchange() {
465: var sform=selector.document.forms.fsel.fcat;
1.2 www 466: pscat=sform.options[sform.selectedIndex].value;
1.1 www 467: draw();
468: }
469:
470: function assemble() {
1.2 www 471: if ((ptype=='date') && (pscat!='interval')) {
472: svalue=Math.round(cdate.getTime()/1000);
473: }
1.6 www 474: if (pscat=='default') { svalue=''; }
1.2 www 475: stype=ptype+'_'+pscat;
1.1 www 476: }
477:
478:
479: function init() {
480: var i;
1.2 www 481: var subs=new Array();
1.1 www 482: var namevalue=this.window.location.search.split('&');
483: namevalue[0]=namevalue[0].substr(1,namevalue[0].length-1);
484:
485: for (i=0;i<namevalue.length;i++) {
486: var pair=namevalue[i].split('=');
1.3 www 487: pair[1]=unescape(pair[1]);
1.1 www 488: if (pair[0]=='value') { pvalue=pair[1]; }
1.2 www 489: if (pair[0]=='type') { subs=pair[1].split('_');
490: ptype=subs[0];
491: pscat=subs[1];
1.10 ! www 492: if (subs[2]!=undefined) { pscat+='_'+subs[2]; }
! 493: if ((pscat=='') || (pscat==undefined)) {
1.6 www 494: pscat='default';
495: }
1.2 www 496: }
1.1 www 497: if (pair[0]=='return') { preturn=pair[1]; }
498: if (pair[0]=='call') { pcode=pair[1]; }
1.2 www 499: if (pair[0]=='marker') { pmarker=pair[1]; }
1.1 www 500: if (pair[0]=='name') { pname=pair[1]; }
501: }
502:
503: svalue=pvalue;
1.6 www 504: if (((ptype=='float') || (ptype=='string') || (ptype=='int')) &&
505: (pscat=='default') &&
1.10 ! www 506: (svalue!=undefined) && (svalue!=0) && (svalue!='')) { pscat='any'; }
1.1 www 507:
508: this.window.selector.document.clear();
509: selwrite('<html><body bgcolor="#FFFFFF">');
510:
1.8 www 511: selwrite('<form name="fsel"><b>'+pname+'</b><br>');
1.1 www 512: selwrite('<select name="fcat" onChange="parent.catchange();">');
513: if (ptype=='tolerance') {
514: sopt('default','Default');
515: sopt('exact','Exact Value (no tolerance)');
516: sopt('relative_sym','Relative Tolerance, Symmetric (percent)');
517: sopt('relative','Relative Tolerance (percentages)');
518: sopt('absolute_sym','Absolute Tolerance, Symmetric (value)');
519: sopt('absolute','Absolute Tolerance (values)');
520: sopt('sigdigits','Significant Digits (number)');
521: }
522:
523: if (ptype=='date') {
524: sopt('default','Default');
525: sopt('start','Starting Date');
526: sopt('end','Ending Date');
1.2 www 527: sopt('interval','Time Interval');
528:
1.10 ! www 529: if ((pvalue!='') && (pvalue!=undefined)) {
1.2 www 530: cdate.setTime(pvalue*1000);
531: }
532:
533: months[0]='January';
534: months[1]='February';
535: months[2]='March';
536: months[3]='April';
537: months[4]='May';
538: months[5]='June';
539: months[6]='July';
540: months[7]='August';
541: months[8]='September';
542: months[9]='October';
543: months[10]='November';
544: months[11]='December';
1.1 www 545: }
1.2 www 546:
1.6 www 547: if (ptype=='int') {
548: sopt('default','Default');
549: sopt('pos','Positive Integer, Not Zero');
550: sopt('zeropos','Positive Integer or Zero');
1.10 ! www 551: sopt('range','Integer Range');
1.6 www 552: sopt('any','Integer');
1.1 www 553: }
554:
1.6 www 555: if (ptype=='float') {
556: sopt('default','Default');
557: sopt('zeroone','Floating Point between 0 and 1');
558: sopt('pos','Positive Floating Point');
559: sopt('any','Floating Point');
1.1 www 560:
561: }
562:
1.6 www 563: if (ptype=='string') {
564: sopt('default','Default');
565: sopt('string','String Value');
1.1 www 566: }
567:
568: selwrite('</select></form>');
569:
1.2 www 570: selwrite('<a href="javascript:parent.assemble();');
1.1 www 571: if (preturn!='') {
1.4 www 572: selwrite(
573: 'parent.opener.document.'+preturn+'_value.value=parent.window.svalue;');
574: selwrite(
575: 'parent.opener.document.'+preturn+'_type.value=parent.window.stype;');
1.2 www 576: }
577: if (pmarker!='') {
1.4 www 578: selwrite(
579: 'parent.opener.document.'+preturn+'_marker.value=parent.window.pmarker;');
1.1 www 580: }
581: if (pcode!='') {
1.4 www 582: selwrite('parent.opener.'+pcode+'();');
1.1 www 583: }
1.4 www 584: selwrite('">Store</a> ');
1.5 www 585:
586: selwrite('<a href="javascript:');
587: selwrite(
588: 'parent.opener.document.'+preturn+'_value.value='+"'';");
589: if (pmarker!='') {
590: selwrite(
591: 'parent.opener.document.'+preturn+'_marker.value=parent.window.pmarker;');
592: }
593: if (pcode!='') {
594: selwrite('parent.opener.'+pcode+'();');
595: }
596: selwrite('">Delete</a> ');
1.4 www 597:
598: selwrite('<a href="javascript:');
599: if (preturn!='') {
600: selwrite('parent.opener.document.'+preturn+'_value.value='+"'';");
601: selwrite('parent.opener.document.'+preturn+'_type.value='+"'';");
602: }
603: if (pmarker!='') {
604: selwrite('parent.opener.document.'+preturn+'_marker.value='+"'';");
605: }
606: if (pcode!='') {
607: selwrite('parent.opener.'+pcode+'();');
608: }
609: selwrite('">Cancel</a>');
1.1 www 610:
611: selwrite('</body></html>');
612: this.window.selector.document.close();
1.2 www 613: draw();
1.1 www 614:
615: }
616:
617: </script>
618:
1.2 www 619: <frameset rows="120,*" onLoad="init();">
1.1 www 620: <frame name=selector src="empty.html">
621: <frame name=choices src="empty.html">
622: </frameset>
623:
624:
625:
626: </html>
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>