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