--- rat/client/parameter.html 2001/03/21 15:42:15 1.7 +++ rat/client/parameter.html 2001/12/19 17:22:29 1.16 @@ -2,8 +2,35 @@ LON-CAPA @@ -247,6 +274,13 @@ function integereval() { if ((pscat=='pos') && (svalue==0)) { svalue=''; } + if (pscat.indexOf('inrange')!=-1) { + var rangeparts=new Array; + rangeparts=split('_',pscat); + rangeparts=split(',',rangeparts[1]); + if (svaluerangeparts[1]) { svalue=rangeparts[1]; } + } draw(); } @@ -277,13 +311,6 @@ function intervaldis() { +cmins+' mins '+csecs+' secs'); } - - -function afterproc() { - choicewrite('Error after rounding: ' - +''); -} - function draw() { choicestart(); choicewrite('
'); if (ptype=='tolerance') { // 0: pscat -// 1: after processing if (pscat=='default') { tablestart('Use default value or algorithm of resource'); } - if (pscat=='exact') { - tablestart('Accept only exact value, zero tolerance'); - afterproc(); - } if (pscat=='relative_sym') { // 2: percentage // 3: open tablestart('Percentage error, symmetric around value'); valline('Percentage',2,3); - afterproc(); + if ((svalue!='') && (typeof(svalue)!="undefined")) { + choices.document.forms.sch.val2.value=parseInt(svalue); + if (svalue.indexOf('+')!=-1) { + choices.document.forms.sch.val3.checked=true; + } + } } if (pscat=='relative') { // 2: left @@ -322,27 +349,47 @@ function draw() { tablestart('Percentage error, asymmetric around value'); valline('Upper percentage',2,3); valline('Lower percentage',4,5); - afterproc(); + var range=new Array; + if ((svalue!='') && (typeof(svalue)!="undefined")) { + range=svalue.split(','); + if (typeof(range[1])=='undefined') { range[1]=range[0]; } + choices.document.forms.sch.val2.value=parseFloat(range[0]); + if (range[0].indexOf('+')!=-1) { + choices.document.forms.sch.val3.checked=true; + } + choices.document.forms.sch.val4.value=parseFloat(range[1]); + if (range[1].indexOf('+')!=-1) { + choices.document.forms.sch.val5.checked=true; + } + } } if (pscat=='absolute_sym') { tablestart('Absolute error, symmetric around value'); valline('Value',2,3); - afterproc(); + if ((svalue!='') && (typeof(svalue)!="undefined")) { + choices.document.forms.sch.val2.value=parseFloat(svalue); + if (svalue.indexOf('+')!=-1) { + choices.document.forms.sch.val3.checked=true; + } + } } if (pscat=='absolute') { tablestart('Absolute error, asymmetric around value'); valline('Upper value',2,3); valline('Lower value',4,5); - afterproc(); - } - if (pscat=='sigdigits') { - tablestart('Agreement on significant digits'); - choicewrite('Number of digits: ' - +''); - -choicewrite('Accept if more digits given: ' - +''); - + var range=new Array; + if ((svalue!='') && (typeof(svalue)!="undefined")) { + range=svalue.split(','); + if (typeof(range[1])=='undefined') { range[1]=range[0]; } + choices.document.forms.sch.val2.value=parseFloat(range[0]); + if (range[0].indexOf('+')!=-1) { + choices.document.forms.sch.val3.checked=true; + } + choices.document.forms.sch.val4.value=parseFloat(range[1]); + if (range[1].indexOf('+')!=-1) { + choices.document.forms.sch.val5.checked=true; + } + } } } @@ -383,14 +430,35 @@ choicewrite(''); + choicewrite(''); } else { + if (pscat=='range') { + tablestart('Integer range'); + choicewrite('Lower Value:'+ + ''); + choicewrite('Upper Value:'+ + ''); + var range=new Array; + if ((svalue!='') && (typeof(svalue)!="undefined")) { + range=svalue.split(','); + if (typeof(range[1])=='undefined') { range[1]=range[0]; } + choices.document.forms.sch.val2.value=parseInt(range[0]); + choices.document.forms.sch.val4.value=parseInt(range[1]); + } + } else { if (pscat=='pos') { tablestart('Positive (non-zero) integer'); } if (pscat=='zeropos') { tablestart('Positive integer or zero'); } + if (pscat.indexOf('inrange')!=-1) { + var rangeparts=new Array; + rangeparts=split(',',pscat); + tablestart('Integer in the range ['+rangeparts[1]+']'); + } if (pscat=='any') { tablestart('Integer'); } @@ -399,6 +467,7 @@ choicewrite(''); choicewrite(''); } + } } if (ptype=='float') { @@ -459,6 +528,44 @@ function assemble() { if ((ptype=='date') && (pscat!='interval')) { svalue=Math.round(cdate.getTime()/1000); } + if (ptype=='tolerance') { + if (pscat=='relative_sym') { + svalue=choices.document.forms.sch.val2.value+'%'; + if (choices.document.forms.sch.val3.checked) { + svalue+='+'; + } + } + if (pscat=='absolute_sym') { + svalue=choices.document.forms.sch.val2.value; + if (choices.document.forms.sch.val3.checked) { + svalue+='+'; + } + } + if (pscat=='absolute') { + svalue=choices.document.forms.sch.val2.value; + if (choices.document.forms.sch.val3.checked) { + svalue+='+'; + } + svalue+=','+choices.document.forms.sch.val4.value; + if (choices.document.forms.sch.val5.checked) { + svalue+='+'; + } + } + if (pscat=='relative') { + svalue=choices.document.forms.sch.val2.value+'%'; + if (choices.document.forms.sch.val3.checked) { + svalue+='+'; + } + svalue+=','+choices.document.forms.sch.val4.value+'%'; + if (choices.document.forms.sch.val5.checked) { + svalue+='+'; + } + } + } + if ((ptype=='int') && (pscat=='range')) { + svalue=choices.document.forms.sch.val2.value+','+ + choices.document.forms.sch.val4.value; + } if (pscat=='default') { svalue=''; } stype=ptype+'_'+pscat; } @@ -477,8 +584,10 @@ function init() { if (pair[0]=='type') { subs=pair[1].split('_'); ptype=subs[0]; pscat=subs[1]; - if (subs[2]!=undefined) { pscat+='_'+subs[2]; } - if ((pscat=='') || (pscat==undefined)) { + if (typeof(subs[2])!="undefined") { + pscat+='_'+subs[2]; + } + if ((pscat=='') || (typeof(pscat)=="undefined")) { pscat='default'; } } @@ -491,21 +600,35 @@ function init() { svalue=pvalue; if (((ptype=='float') || (ptype=='string') || (ptype=='int')) && (pscat=='default') && - (svalue!=undefined) && (svalue!=0) && (svalue!='')) { pscat='any'; } + (typeof(svalue)!="undefined") && + (svalue!=0) && (svalue!='')) { pscat='any'; } + + if (ptype=='tolerance') { + var tperc=0; + var trange=0; + if (typeof(svalue)!='undefined') { + if (svalue.indexOf('%')!=-1) { tperc=1; } + if (svalue.indexOf(',')!=-1) { trange=1; } + if (trange) { + if (tperc) { pscat='relative'; } else { pscat='absolute'; } + } else { + if (tperc) { pscat='relative_sym'; } else { pscat='absolute_sym'; } + } + } + } this.window.selector.document.clear(); selwrite(''); - selwrite('

'+pname+'

'); + selwrite(''+pname+'
'); selwrite('