File:  [LON-CAPA] / rat / client / parameter.html
Revision 1.30: download - view: text, annotated - select for diffs
Mon Jun 6 16:06:25 2005 UTC (18 years, 11 months ago) by www
Branches: MAIN
CVS tags: HEAD
Having default minutes and seconds did not make much sense

    1: <html>
    2: <!--
    3: The LearningOnline Network with CAPA
    4: Parameter Input Window
    5: //
    6: // $Id: parameter.html,v 1.30 2005/06/06 16:06:25 www Exp $
    7: //
    8: // Copyright Michigan State University Board of Trustees
    9: //
   10: // This file is part of the LearningOnline Network with CAPA (LON-CAPA).
   11: //
   12: // LON-CAPA is free software; you can redistribute it and/or modify
   13: // it under the terms of the GNU General Public License as published by
   14: // the Free Software Foundation; either version 2 of the License, or
   15: // (at your option) any later version.
   16: //
   17: // LON-CAPA is distributed in the hope that it will be useful,
   18: // but WITHOUT ANY WARRANTY; without even the implied warranty of
   19: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20: // GNU General Public License for more details.
   21: //
   22: // You should have received a copy of the GNU General Public License
   23: // along with LON-CAPA; if not, write to the Free Software
   24: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   25: //
   26: // /home/httpd/html/adm/gpl.txt
   27: //
   28: // http://www.lon-capa.org/
   29: //
   30: -->
   31: <head>
   32: <title>LON-CAPA</title>
   33: </head>
   34: 
   35: <script>
   36: 
   37: var ptype='';
   38: var pvalue='';
   39: var preturn='';
   40: var pcode='';
   41: var pscat='';
   42: var pmarker='';
   43: var pname='';
   44: 
   45: var svalue;
   46: var stype;
   47: var smarker;
   48: 
   49: var vars=new Array();
   50: 
   51: var cdate=new Date();
   52: 
   53: var csec;
   54: var cmin;
   55: var chour;
   56: var cday;
   57: 
   58: var months=new Array();
   59: 
   60: 
   61: function selwrite(text) {
   62:   this.window.selector.document.write(text);
   63: }
   64: 
   65: function choicestart() {
   66:   this.window.choices.document.clear();
   67:   choicewrite('<html><body bgcolor="#FFFFFF">');
   68: }
   69: 
   70: function choiceend() {
   71:   choicewrite('</body></html>');
   72:   this.window.choices.document.close();
   73: }
   74: 
   75: function choicewrite(text) {
   76:   this.window.choices.document.write(text);
   77: }
   78: 
   79: function tablestart(headtext) {
   80:   choicewrite('<table><tr bgcolor="#AAFFAA"><th colspan=3>'+
   81:               headtext+'</th></tr>');
   82: }
   83: 
   84: function valline(text,id1,id2) {
   85:   choicewrite('<tr bgcolor="#AAFFAA"><td>'+text+
   86:               '</td><td><input type=text size=4 name=val'+
   87:               id1+'></td><td>incl:<input type=checkbox name=val'+
   88:               id2+'></td></tr>');
   89: }
   90: 
   91: function datecalc() {
   92:     var sform=choices.document.forms.sch;
   93: 
   94:     cdate.setHours(sform.hours.options[sform.hours.selectedIndex].value);
   95:     cdate.setMinutes(sform.minutes.options[sform.minutes.selectedIndex].value);
   96:     cdate.setSeconds(sform.minutes.options[sform.seconds.selectedIndex].value);
   97:     cdate.setDate(sform.date.options[sform.date.selectedIndex].value);
   98:     cdate.setMonth(sform.month.options[sform.month.selectedIndex].value);
   99:     cdate.setFullYear(sform.year.options[sform.year.selectedIndex].value);
  100: 
  101:     draw();
  102: }
  103: 
  104: function hour() {
  105:    var thishour=cdate.getHours();
  106:     var i; var j;
  107:     choicewrite('<select name=hours onChange="parent.datecalc();">');
  108:     for (i=0;i<=23;i++) {
  109:         choicewrite('<option value='+i);
  110:         if (i==thishour) {
  111:             choicewrite(' selected');
  112:         }
  113:         choicewrite('>');
  114:         if (i==12) { choicewrite('noon'); } else {
  115:            if (i==0) { choicewrite('midnight') } else {
  116:               
  117:                  if (i<12) { choicewrite(i+' am'); } else {
  118:                     j=i-12; choicewrite(j+' pm');
  119:                  }
  120:               
  121:            }
  122:         }
  123:         choicewrite('</option>');
  124:     }
  125:     choicewrite('</select>');
  126: }
  127: 
  128: function minute() {
  129:    var thisminutes=cdate.getMinutes();
  130:     var i;
  131:     choicewrite('<select name=minutes onChange="parent.datecalc();">');
  132:     for (i=0;i<=59;i++) {
  133:         choicewrite('<option value='+i);
  134:         if (i==thisminutes) {
  135:             choicewrite(' selected');
  136:         }
  137:         choicewrite('>'+i+'</option>');
  138:     }
  139:     choicewrite('</select>');
  140: } 
  141: 
  142: function second() {
  143:    var thisseconds=cdate.getSeconds();
  144:     var i;
  145:     choicewrite('<select name=seconds onChange="parent.datecalc();">');
  146:     for (i=0;i<=59;i++) {
  147:         choicewrite('<option value='+i);
  148:         if (i==thisseconds) {
  149:             choicewrite(' selected');
  150:         }
  151:         choicewrite('>'+i+'</option>');
  152:     }
  153:     choicewrite('</select>');
  154: } 
  155: 
  156: 
  157: function date() {
  158:    var thisdate=cdate.getDate();
  159:     var i;
  160:     choicewrite('<select name=date onChange="parent.datecalc();">');
  161:     for (i=1;i<=31;i++) {
  162:         choicewrite('<option value='+i);
  163:         if (i==thisdate) {
  164:             choicewrite(' selected');
  165:         }
  166:         choicewrite('>'+i+'</option>');
  167:     }
  168:     choicewrite('</select>');
  169: }
  170: 
  171: function year() {
  172:    var thisyear=cdate.getFullYear();
  173:    var nowdate=new Date();
  174:    var nowyear=nowdate.getFullYear();
  175:    var loweryear=thisyear-2;
  176:    var upperyear=thisyear+5;
  177:    if (thisyear>nowyear) { loweryear=nowyear-2; }
  178:    if (thisyear<nowyear) { upperyear=nowyear+5; } 
  179:     var i;
  180:     choicewrite('<select name=year onChange="parent.datecalc();">');
  181:     for (i=loweryear;i<=upperyear;i++) {
  182:         choicewrite('<option value='+i);
  183:         if (i==thisyear) {
  184:             choicewrite(' selected');
  185:         }
  186:         choicewrite('>'+i+'</option>');
  187:     }
  188:     choicewrite('</select>');
  189: }
  190: 
  191: function month() {
  192:     var thismonth=cdate.getMonth();
  193:     var i;
  194:     choicewrite('<select name=month onChange="parent.datecalc();">');
  195:     for (i=0;i<=11;i++) {
  196:         choicewrite('<option value='+i);
  197:         if (i==thismonth) {
  198:             choicewrite(' selected');
  199:         }
  200:         choicewrite('>'+months[i]+'</option>');
  201:     }
  202:     choicewrite('</select>');
  203: }
  204:     
  205:     
  206: function intminute() {
  207:    var thisminutes=cmins;
  208:     var i;
  209:     choicewrite('<select name=minutes onChange="parent.intcalc();">');
  210:     for (i=0;i<=59;i++) {
  211:         choicewrite('<option value='+i);
  212:         if (i==thisminutes) {
  213:             choicewrite(' selected');
  214:         }
  215:         choicewrite('>'+i+'</option>');
  216:     }
  217:     choicewrite('</select>');
  218: } 
  219: 
  220: function inthour() {
  221:    var thishours=chours;
  222:     var i;
  223:     choicewrite('<select name=hours onChange="parent.intcalc();">');
  224:     for (i=0;i<=23;i++) {
  225:         choicewrite('<option value='+i);
  226:         if (i==thishours) {
  227:             choicewrite(' selected');
  228:         }
  229:         choicewrite('>'+i+'</option>');
  230:     }
  231:     choicewrite('</select>');
  232: } 
  233: 
  234: function intsecond() {
  235:    var thisseconds=csecs;
  236:     var i;
  237:     choicewrite('<select name=seconds onChange="parent.intcalc();">');
  238:     for (i=0;i<=59;i++) {
  239:         choicewrite('<option value='+i);
  240:         if (i==thisseconds) {
  241:             choicewrite(' selected');
  242:         }
  243:         choicewrite('>'+i+'</option>');
  244:     }
  245:     choicewrite('</select>');
  246: } 
  247: 
  248: 
  249: function intday() {
  250:    var thisdate=cdays;
  251:     var i;
  252:     choicewrite('<select name=date onChange="parent.intcalc();">');
  253:     for (i=0;i<=31;i++) {
  254:         choicewrite('<option value='+i);
  255:         if (i==thisdate) {
  256:             choicewrite(' selected');
  257:         }
  258:         choicewrite('>'+i+'</option>');
  259:     }
  260:     choicewrite('</select>');
  261: }
  262: 
  263: function intcalc() {
  264:     var sform=choices.document.forms.sch;
  265:     svalue=((sform.date.options[sform.date.selectedIndex].value*24+
  266:              sform.hours.options[sform.hours.selectedIndex].value*1)*60+
  267:              sform.minutes.options[sform.minutes.selectedIndex].value*1)*60+
  268:              sform.seconds.options[sform.seconds.selectedIndex].value*1;
  269:     draw();
  270: }
  271: 
  272: function integereval() {
  273:    svalue=choices.document.forms.sch.intval.value;
  274:    svalue=Math.round(svalue);
  275:    if (pscat=='zeropos') { svalue=Math.abs(svalue); }
  276:    if ((pscat=='pos') && (svalue==0)) {
  277:       svalue='';
  278:    }
  279:    if (pscat.indexOf('inrange')!=-1) {
  280:       var rangeparts=new Array;
  281:       rangeparts=split('_',pscat);
  282:       rangeparts=split(',',rangeparts[1]);
  283:       if (svalue<rangeparts[0]) { svalue=rangeparts[0]; }
  284:       if (svalue>rangeparts[1]) { svalue=rangeparts[1]; }
  285:    }
  286:    draw();
  287: }
  288: 
  289: function floateval() {
  290:    svalue=choices.document.forms.sch.floatval.value;
  291:    svalue=1.0*svalue;
  292:    if (pscat=='pos') { svalue=Math.abs(svalue); }
  293:    if ((pscat=='zeroone') && ((svalue<0) || (svalue>1))) {
  294:       svalue='';
  295:    }
  296:    draw();
  297: }
  298: 
  299: function stringeval() {
  300:    svalue=choices.document.forms.sch.stringval.value;
  301:    draw();
  302: }
  303: 
  304: function radiostringeval(newval) {
  305:    svalue=newval;
  306:    draw();
  307: }
  308: 
  309: function callradiostringeval(newval) {
  310:    return 'onChange="parent.radiostringeval(\''
  311:           +newval+'\')" onClick="parent.radiostringeval(\''
  312:           +newval+'\')"';
  313: }
  314: 
  315: function intervaldis() {
  316:     csecs=svalue;
  317:     cdays=Math.floor(csecs/86400);
  318:     csecs-=cdays*86400;
  319:     chours=Math.floor(csecs/3600);
  320:     csecs-=chours*3600;
  321:     cmins=Math.floor(csecs/60);
  322:     csecs-=cmins*60;
  323:     choicewrite(cdays+' days '+chours+' hours '
  324:                +cmins+' mins '+csecs+' secs');
  325: }
  326: 
  327: function pickcolor(picked) {
  328:   svalue=picked;
  329:   draw();
  330: }
  331: 
  332: function colorfield(ir,ig,ib) {
  333:    var col=new Array;
  334:    col=["00","11","22","44","66","88","AA","CC","DD","EE","FF"];
  335:    var color='#'+col[ir]+col[ig]+col[ib];
  336:    var selection="<font color='"+color+"'>X</font>";
  337:    if (color==svalue) { selection="<font color='#"+col[10-ir]+col[10-ig]+col[10-ib]+"'>X</font>"; }
  338:    choicewrite('<td bgcolor="'+color+'"><a href="javascript:parent.pickcolor('+"'"+
  339:                color+"'"+')">'+selection+'</a></td>');
  340:                
  341: }    
  342: 
  343: function draw() {
  344:    choicestart();
  345:    choicewrite('<form name=sch');
  346:    if (ptype=='int') {
  347:       choicewrite(' action="javascript:integereval();"');
  348:    }
  349:    if (ptype=='float') {
  350:       choicewrite(' action="javascript:floateval();"');
  351:    }
  352:    if (ptype=='string') {
  353:       choicewrite(' action="javascript:stringeval();"');
  354:    }
  355:    choicewrite('>');
  356:    if (ptype=='tolerance') {
  357: // 0: pscat
  358:       if (pscat=='default') {
  359:          tablestart('Use default value or algorithm of resource');
  360:       }
  361:       if (pscat=='relative_sym') {
  362: // 2: percentage
  363: // 3: open
  364:          tablestart('Percentage error, symmetric around value');
  365:          valline('Percentage',2,3);
  366:          if ((svalue!='') && (typeof(svalue)!="undefined")) {
  367:             choices.document.forms.sch.val2.value=parseInt(svalue);
  368:             if (svalue.indexOf('+')!=-1) {
  369:                choices.document.forms.sch.val3.checked=true;
  370:             }
  371:          }
  372:       }
  373:       if (pscat=='relative') {
  374: // 2: left
  375: // 3: open
  376: // 4: right
  377: // 5: open
  378:          tablestart('Percentage error, asymmetric around value');
  379:          valline('Upper percentage',2,3);
  380:          valline('Lower percentage',4,5);
  381:          var range1=new Array;
  382:          if ((svalue!='') && (typeof(svalue)!="undefined")) {
  383:             range1=svalue.split(',');
  384:             if (typeof(range1[1])=='undefined') { range1[1]=range1[0]; }
  385:             choices.document.forms.sch.val2.value=parseFloat(range1[0]);
  386:             if (range1[0].indexOf('+')!=-1) {
  387:                choices.document.forms.sch.val3.checked=true;
  388:             }
  389:             choices.document.forms.sch.val4.value=parseFloat(range1[1]);
  390:             if (range1[1].indexOf('+')!=-1) {
  391:                choices.document.forms.sch.val5.checked=true;
  392:             }
  393:          }
  394:       }
  395:       if (pscat=='absolute_sym') {
  396:          tablestart('Absolute error, symmetric around value');
  397:          valline('Value',2,3);
  398:          if ((svalue!='') && (typeof(svalue)!="undefined")) {
  399:             choices.document.forms.sch.val2.value=parseFloat(svalue);
  400:             if (svalue.indexOf('+')!=-1) {
  401:                choices.document.forms.sch.val3.checked=true;
  402:             }
  403:          }
  404:       }
  405:       if (pscat=='absolute') {
  406:          tablestart('Absolute error, asymmetric around value');
  407:          valline('Upper value',2,3);
  408:          valline('Lower value',4,5);
  409:          var range2=new Array;
  410:          if ((svalue!='') && (typeof(svalue)!="undefined")) {
  411:             range=svalue.split(',');
  412:             if (typeof(range2[1])=='undefined') { range2[1]=range2[0]; }
  413:             choices.document.forms.sch.val2.value=parseFloat(range2[0]);
  414:             if (range2[0].indexOf('+')!=-1) {
  415:                choices.document.forms.sch.val3.checked=true;
  416:             }
  417:             choices.document.forms.sch.val4.value=parseFloat(range2[1]);
  418:             if (range2[1].indexOf('+')!=-1) {
  419:                choices.document.forms.sch.val5.checked=true;
  420:             }
  421:          }
  422:       }
  423:    }
  424: 
  425:    if (ptype=='date') {
  426:      if (pscat=='default') {
  427:          tablestart('Default value or none');
  428:          choicewrite('</table>');
  429:      } else {
  430:       if (pscat=='start') {
  431:          tablestart('Date and time');
  432:       }
  433:       if (pscat=='end') {
  434:          tablestart('Date and time');
  435:       }
  436:       if (pscat=='interval') {
  437:          tablestart('Time interval');
  438:          choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>');
  439:          intervaldis();
  440:          choicewrite('</td></tr><tr bgcolor="#AAFFAA"><td>Time:'
  441:          +'</td><td colspan=2>');
  442:          intday();choicewrite('days ');
  443:          inthour();choicewrite('hours ');
  444:          intminute(); choicewrite('mins '); intsecond();
  445:          choicewrite('secs</td></tr></table>');         
  446:       } else { 
  447:          choicewrite('<tr bgcolor="#AAFFAA"><td colspan=3>'
  448:          +cdate.toString()+
  449:          '</td></tr><tr bgcolor="#AAFFAA"><td>Date:</td><td colspan=2>');
  450:          month();date();year();
  451:          choicewrite('</td></tr><tr bgcolor="#AAFFAA"><td>Time:'
  452:          +'</td><td colspan=2>');hour();choicewrite('h ');minute();
  453:          choicewrite('m ');second();
  454:          choicewrite('s</td></tr></table>');
  455:       }
  456:      }
  457:    }
  458: 
  459:    if (ptype=='int') {
  460:       var pscatparts=new Array;
  461:       pscatparts=pscat.split(',');
  462:       pscat=pscatparts[0];
  463:       if (pscat=='default') {
  464:          tablestart('Default value or none');
  465:          choicewrite('</table>');
  466:       } else {
  467:        if (pscat=='range') {
  468:          tablestart('Integer range');      
  469:          choicewrite('<tr bgcolor="#AAFFAA"><td>Lower Value:'+
  470:               '</td><td colspan=2><input type=text size=4 name=val2'+
  471:               '></td></tr>');
  472:          choicewrite('<tr bgcolor="#AAFFAA"><td>Upper Value:'+
  473:               '</td><td colspan=2><input type=text size=4 name=val4'+
  474:               '></td></tr></table>');
  475:          var range=new Array;
  476:          if ((svalue!='') && (typeof(svalue)!="undefined")) {
  477:             range=svalue.split(',');
  478:             if (typeof(range[1])=='undefined') { range[1]=range[0]; }
  479:             choices.document.forms.sch.val2.value=parseInt(range[0]);
  480:             choices.document.forms.sch.val4.value=parseInt(range[1]);
  481:          }
  482:        } else {
  483:         if (pscat=='pos') {
  484:            tablestart('Positive (non-zero) integer');
  485:         }
  486:         if (pscat=='zeropos') {
  487:            tablestart('Positive integer or zero');
  488:         }
  489:         if (pscat.indexOf('inrange')!=-1) {
  490:            var rangeparts=new Array;
  491:            rangeparts=split(',',pscat);
  492:            tablestart('Integer in the range ['+rangeparts[1]+']');
  493:         }
  494:         if (pscat=='any') {
  495:            tablestart('Integer');
  496:         }
  497:         choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  498:         choicewrite('<input name=intval size=10 value="'+svalue+
  499:                     '" name=intval onChange="parent.integereval()">');
  500:         choicewrite('</td></table>');
  501:       }
  502:      }
  503:    }
  504: 
  505:    if (ptype=='float') {
  506:       if (pscat=='default') {
  507:          tablestart('Default value or none');
  508:          choicewrite('</table>');         
  509:       } else {
  510:         if (pscat=='pos') {
  511:            tablestart('Positive floating point number or zero');
  512:         }
  513:         if (pscat=='zeroone') {
  514:            tablestart('Floating point number between zero and one');
  515:         }
  516:         if (pscat=='any') {
  517:            tablestart('Floating point number');
  518:         }
  519:         choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  520:         choicewrite('<input name=floatval size=10 value="'+svalue+
  521:                     '" name=floatval onChange="parent.floateval()">');
  522:         choicewrite('</td></table>');
  523:       }
  524:    }
  525: 
  526:    if (ptype=='string') {
  527:       if (pscat=='default') {
  528:          tablestart('Default value or none');
  529:          choicewrite('</table>');         
  530:       } else {
  531:         if ((pscat=='any') || (pscat=='') || (typeof(pscat)=='undefined')) {
  532:            tablestart('Text');
  533: 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  534:            choicewrite('<input name="stringval" size="20" value="'+svalue+
  535:                     '" type="text" onChange="parent.stringeval()">');
  536:         }
  537:         if (pscat=='yesno') {
  538:            tablestart('Yes/No');
  539: 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  540:            choicewrite('<input name="stringval" value="yes"'+
  541:                   ' type="radio" '+callradiostringeval('yes'));
  542:            if (svalue=='yes') { choicewrite(' checked'); }
  543:            choicewrite('> Yes<br />');
  544:            choicewrite('<input name="stringval" value="no"'+
  545:                   ' type="radio" '+callradiostringeval('no'));
  546:            if (svalue=='no') { choicewrite(' checked'); }
  547:            choicewrite('> No<br />');
  548:         }
  549:         if (pscat=='examtype') {
  550:            tablestart('Exam Type');
  551: 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  552:            choicewrite('<input name="stringval" value="online"'+
  553:                 ' type="radio" '+callradiostringeval('online'));
  554:            if (svalue=='online') { choicewrite(' checked'); }
  555:            choicewrite('> Online<br />');
  556:            choicewrite('<input name="stringval" value="checkout"'+
  557:               ' type="radio" '+callradiostringeval('checkout'));
  558:            if (svalue=='checkout') { choicewrite(' checked'); }
  559:            choicewrite('> Check out<br />');
  560:        }
  561:         if (pscat=='questiontype') {
  562:            tablestart('Question Type');
  563: 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  564:            choicewrite('<input name="stringval" value="problem"'+
  565:                ' type="radio" '+callradiostringeval('problem'));
  566:            if (svalue=='problem') { choicewrite(' checked'); }
  567:            choicewrite('> Standard Problem<br />');
  568:            choicewrite('<input name="stringval" value="quiz"'+
  569:                   ' type="radio" '+callradiostringeval('quiz'));
  570:            if (svalue=='quiz') { choicewrite(' checked'); }
  571:            choicewrite('> Quiz<br />');
  572:            choicewrite('<input name="stringval" value="exam"'+
  573:                   ' type="radio" '+callradiostringeval('exam'));
  574:            if (svalue=='exam') { choicewrite(' checked'); }
  575:            choicewrite('> Exam<br />');
  576:            choicewrite('<input name="stringval" value="assess"'+
  577:                 ' type="radio" '+callradiostringeval('assess'));
  578:            if (svalue=='assess') { choicewrite(' checked'); }
  579:            choicewrite('> Assessment<br />');
  580:            choicewrite('<input name="stringval" value="survey"'+
  581:                 ' type="radio" '+callradiostringeval('survey'));
  582:            if (svalue=='survey') { choicewrite(' checked'); }
  583:            choicewrite('> Survey<br />');
  584:            choicewrite('<input name="stringval" value="form"'+
  585:                   ' type="radio" '+callradiostringeval('form'));
  586:            if (svalue=='form') { choicewrite(' checked'); }
  587:            choicewrite('> Input Form<br />');
  588:            choicewrite('<input name="stringval" value="library"'+
  589:                ' type="radio" '+callradiostringeval('library'));
  590:            if (svalue=='library') { choicewrite(' checked'); }
  591:            choicewrite('> Library<br />');
  592:         }
  593:         if (pscat=='ip') {
  594:            tablestart('IP Number/Name');
  595: 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  596:            choicewrite('<input name="stringval" size="20" value="'+svalue+
  597:                     '" onChange="parent.stringeval()">');
  598:         }
  599:         if (pscat=='fileext') {
  600:             tablestart('Allowed File Extensions');
  601: 	   choicewrite('<tr bgcolor="#AAFFAA"><td>Value:</td><td colspan=2>');
  602:            choicewrite('<input name="radstringval" value="txt"'+
  603:                ' type="radio" '+callradiostringeval('txt'));
  604:            if (svalue=='txt') { choicewrite(' checked'); }
  605:            choicewrite('> Plain Text<br />');
  606:            choicewrite('<input name="radstringval" value="png,jpg,jpeg,gif"'+
  607:                ' type="radio" '+callradiostringeval('png,jpg,jpeg,gif'));
  608:            if (svalue=='png,jpg,jpeg,gif') { choicewrite(' checked'); }
  609:            choicewrite('> Picture File<br />');
  610:            choicewrite('<input name="radstringval" value="doc,xls,ppt"'+
  611:                ' type="radio" '+callradiostringeval('doc,xls,ppt'));
  612:            if (svalue=='doc,xls,ppt') { choicewrite(' checked'); }
  613:            choicewrite('> Office Document<br />');
  614:            choicewrite('<input name="stringval" size="20" value="'+svalue+
  615:                     '" onChange="parent.stringeval()">');
  616:        }
  617:         choicewrite('</td></table>');
  618:       }
  619:    }
  620:    
  621:    if (ptype=='color') {
  622:       tablestart('Choose a Color');
  623:       choicewrite('<table>');
  624:       if (svalue) {
  625:          choicewrite('<tr><td colspan="9">Current choice:</td><td bgcolor="'+
  626:                      svalue+'" colspan="2">&nbsp;</td></tr>');
  627:       }
  628:       for (var ir=0; ir<=10; ir++) {
  629:           for (var ig=0; ig<=10; ig++) {
  630:               choicewrite('<tr>');
  631:               for (var ib=0; ib<=10; ib++) {
  632:                   colorfield(ir,ig,ib);
  633: 	      }
  634:               choicewrite('</tr>');
  635: 	  }	      
  636:       }
  637:       choicewrite('</table></td></table>');
  638:    }
  639: 
  640:    choicewrite('</table></form>');
  641:    choiceend();
  642: }
  643: 
  644: function sopt(va,text) {
  645:    selwrite('<option value="'+va+'"');
  646:    if (va==pscat) {
  647:      selwrite(' selected');
  648:    }
  649:    selwrite('>'+text+'</option>');
  650: }
  651: 
  652: function catchange() {
  653:    var sform=selector.document.forms.fsel.fcat;
  654:    pscat=sform.options[sform.selectedIndex].value;
  655:    draw();
  656: }
  657: 
  658: function assemble() {
  659:     if ((ptype=='date') && (pscat!='interval')) {
  660:         svalue=Math.round(cdate.getTime()/1000);
  661:     }
  662:     if (ptype=='tolerance') {
  663:        if (pscat=='relative_sym') {
  664:           svalue=choices.document.forms.sch.val2.value+'%';
  665:           if (choices.document.forms.sch.val3.checked) {
  666:              svalue+='+';
  667:           }
  668:        }
  669:        if (pscat=='absolute_sym') {
  670:           svalue=choices.document.forms.sch.val2.value;
  671:           if (choices.document.forms.sch.val3.checked) {
  672:              svalue+='+';
  673:           }
  674:        }
  675:        if (pscat=='absolute') {
  676:           svalue=choices.document.forms.sch.val2.value;
  677:           if (choices.document.forms.sch.val3.checked) {
  678:              svalue+='+';
  679:           }
  680:           svalue+=','+choices.document.forms.sch.val4.value;
  681:           if (choices.document.forms.sch.val5.checked) {
  682:              svalue+='+';
  683:           }
  684:        }
  685:        if (pscat=='relative') {
  686:           svalue=choices.document.forms.sch.val2.value+'%';
  687:           if (choices.document.forms.sch.val3.checked) {
  688:              svalue+='+';
  689:           }
  690:           svalue+=','+choices.document.forms.sch.val4.value+'%';
  691:           if (choices.document.forms.sch.val5.checked) {
  692:              svalue+='+';
  693:           }
  694:        }
  695:     }
  696:     if ((ptype=='int') && (pscat=='range')) {
  697:           svalue=choices.document.forms.sch.val2.value+','+
  698:                  choices.document.forms.sch.val4.value;
  699:     }
  700:     if (pscat=='default') { svalue=''; }
  701:     stype=ptype+'_'+pscat;
  702: }
  703: 
  704: 
  705: function init() {
  706:   var i;
  707:   var subs=new Array();
  708:   var namevalue=this.window.location.search.split('&');
  709:   namevalue[0]=namevalue[0].substr(1,namevalue[0].length-1);
  710: 
  711:   for (i=0;i<namevalue.length;i++) {
  712:      var pair=namevalue[i].split('=');
  713:      pair[1]=unescape(pair[1]);
  714:      if (pair[0]=='value') { pvalue=pair[1]; }
  715:      if (pair[0]=='type') { subs=pair[1].split('_');
  716:                             ptype=subs[0];
  717:                             pscat=subs[1];
  718:                             if (typeof(subs[2])!="undefined") { 
  719:                                pscat+='_'+subs[2]; 
  720:                             }
  721:                             if ((pscat=='') || (typeof(pscat)=="undefined")) { 
  722:                                pscat='default';
  723:                             }
  724:                            }
  725:      if (pair[0]=='return') { preturn=pair[1]; }
  726:      if (pair[0]=='call') { pcode=pair[1]; }
  727:      if (pair[0]=='marker') { pmarker=pair[1]; }
  728:      if (pair[0]=='name') { pname=pair[1]; }
  729:   }
  730: 
  731:   svalue=pvalue;
  732:   if (((ptype=='float') || (ptype=='string') || (ptype=='int')) &&
  733:       (pscat=='default') && 
  734:       (typeof(svalue)!="undefined") && 
  735:       (svalue!=0) && (svalue!='')) { pscat='any'; }
  736: 
  737:   if (ptype=='tolerance') {
  738:      var tperc=0;
  739:      var trange=0;
  740:      if (typeof(svalue)!='undefined') {
  741:         if (svalue.indexOf('%')!=-1) { tperc=1;  }
  742:         if (svalue.indexOf(',')!=-1) { trange=1; }
  743:         if (trange) {
  744:            if (tperc) { pscat='relative'; } else { pscat='absolute'; }
  745:         } else {
  746:            if (tperc) { pscat='relative_sym'; } else { pscat='absolute_sym'; }
  747:         }
  748:      }
  749:   }
  750: 
  751:   this.window.selector.document.clear();
  752:   selwrite('<html><body bgcolor="#FFFFFF">');
  753: 
  754:   selwrite('<form name="fsel"><b>'+pname+'</b><br>');
  755:   selwrite('<select name="fcat" onChange="parent.catchange();">');
  756: 
  757:   if (ptype=='tolerance') {
  758:      sopt('default','Default');
  759:      sopt('relative_sym','Relative Tolerance, Symmetric (percent)');
  760:      sopt('relative','Relative Tolerance (percentages)');
  761:      sopt('absolute_sym','Absolute Tolerance, Symmetric (value)');
  762:      sopt('absolute','Absolute Tolerance (values)');
  763:   }
  764: 
  765:   if (ptype=='date') {
  766:      sopt('default','Default');
  767:      sopt('start','Starting Date');
  768:      sopt('end','Ending Date');
  769:      sopt('interval','Time Interval');
  770:      
  771:      if ((pvalue!='') && (typeof(pvalue)!="undefined")) {
  772:         cdate.setTime(pvalue*1000);
  773:      } else {        
  774:         cdate.setSeconds(0);
  775:         cdate.setMinutes(0);
  776:      }
  777:  
  778:      months[0]='January';
  779:      months[1]='February';
  780:      months[2]='March';
  781:      months[3]='April';
  782:      months[4]='May';
  783:      months[5]='June';
  784:      months[6]='July';
  785:      months[7]='August';
  786:      months[8]='September';
  787:      months[9]='October';
  788:      months[10]='November';
  789:      months[11]='December';
  790:   }
  791:    
  792:   if (ptype=='int') {
  793:      sopt('default','Default');
  794:      sopt('pos','Positive Integer, Not Zero');
  795:      sopt('zeropos','Positive Integer or Zero');
  796:      sopt('inrange','Integer in Range');
  797:      sopt('range','Range of Integers');
  798:      sopt('any','Integer');
  799:   }
  800: 
  801:   if (ptype=='float') {
  802:      sopt('default','Default');
  803:      sopt('zeroone','Floating Point between 0 and 1');
  804:      sopt('pos','Positive Floating Point');
  805:      sopt('any','Floating Point');
  806: 
  807:   }
  808: 
  809:   if (ptype=='string') {
  810:      sopt('default','Default');
  811:      sopt('any','String Value');
  812:   }
  813: 
  814:   if (ptype=='color') {
  815:      sopt('default','Use Default Color');
  816:      sopt('custom','Use Custom Color');
  817:   }
  818: 
  819:   selwrite('</select></form>');
  820: 
  821:   selwrite('<a href="javascript:parent.assemble();');
  822:   if (preturn!='') {
  823:      selwrite(
  824:       'parent.opener.document.'+preturn+'_value.value=parent.window.svalue;');
  825:      selwrite(
  826:       'parent.opener.document.'+preturn+'_type.value=parent.window.stype;');
  827:   }
  828:   if (pmarker!='') {
  829:      selwrite(
  830:      'parent.opener.document.'+preturn+'_marker.value=parent.window.pmarker;');
  831:   }
  832:   if (pcode!='') {
  833:      selwrite('parent.opener.'+pcode+'();');
  834:   }
  835:   selwrite('">Store</a>&nbsp;&nbsp;');
  836: 
  837:   selwrite('<a href="javascript:');
  838:      selwrite(
  839:       'parent.opener.document.'+preturn+'_value.value='+"'';");
  840:   if (pmarker!='') {
  841:      selwrite(
  842:      'parent.opener.document.'+preturn+'_marker.value=parent.window.pmarker;');
  843:   }
  844:   if (pcode!='') {
  845:      selwrite('parent.opener.'+pcode+'();');
  846:   }
  847:   selwrite('">Delete</a>&nbsp;&nbsp;');
  848:  
  849:   selwrite('<a href="javascript:');
  850: // Old code :
  851: //----------------------------------------------------------------------
  852: //  if (preturn!='') {
  853: //     selwrite('parent.opener.document.'+preturn+'_value.value='+"'';");
  854: //     selwrite('parent.opener.document.'+preturn+'_type.value='+"'';");
  855: // }
  856: //  if (pmarker!='') {
  857: //     selwrite('parent.opener.document.'+preturn+'_marker.value='+"'';");
  858: //  }
  859: //  if (pcode!='') {
  860: //     selwrite('parent.opener.'+pcode+'();');
  861: //  }
  862: //----------------------------------------------------------------------
  863: // Just close the window to 'cancel' the operation.  There are javascript
  864: // errors in the above commented out code that I have not been able to 
  865: // track down.  I think they reside in 'parent.opener.'+pcode+'();'
  866: //
  867:   selwrite('this.parent.close();');
  868:   selwrite('">Cancel</a>'); 
  869:  
  870:   selwrite('</body></html>');
  871:   this.window.selector.document.close();
  872:   draw();
  873:   
  874: }
  875: 
  876: </script>
  877: 
  878: <frameset rows="120,*" onLoad="init();">
  879: <frame name=selector src="empty.html">
  880: <frame name=choices src="empty.html">
  881: </frameset>
  882: 
  883: 
  884: 
  885: </html>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>