Diff for /loncom/homework/functionplotresponse.pm between versions 1.45 and 1.46

version 1.45, 2010/11/23 23:14:20 version 1.46, 2010/11/23 23:55:01
Line 330  ENDYOFFAXISLABEL Line 330  ENDYOFFAXISLABEL
 }  }
   
 sub plot_script {  sub plot_script {
    my ($id,$function,$fixed,$label,$xmin,$xmax)=@_;     my ($id,$function,$fixed,$label,$color,$xmin,$xmax)=@_;
    $label=~s/\W//g;     $label=~s/\W//g;
    if (($label) && ($label!~/^[A-Za-z]/)) {     if (($label) && ($label!~/^[A-Za-z]/)) {
       $label='C'.$label;        $label='C'.$label;
Line 342  sub plot_script { Line 342  sub plot_script {
       $Apache::functionplotresponse::counter++;        $Apache::functionplotresponse::counter++;
       $label='C'.$Apache::functionplotresponse::counter;        $label='C'.$Apache::functionplotresponse::counter;
    }     }
      my $rc=0;
      my $gc=0;
      my $bc=0;
      if ($color) {
         my ($rh,$gh,$bh)=($color=~/(..)(..)(..)/);
         $rc=hex($rh);
         $gc=hex($gh);
         $bc=hex($bh);
      }
    if ($fixed) {     if ($fixed) {
       return "document.ggbApplet_$id.evalCommand('$label=Function[$function,$xmin,$xmax]');\n".        return "document.ggbApplet_$id.evalCommand('$label=Function[$function,$xmin,$xmax]');\n".
              ($visible?'':"document.ggbApplet_$id.setLabelVisible('$label', false);\n");               ($visible?'':"document.ggbApplet_$id.setLabelVisible('$label', false);\n").
                ($color?"document.ggbApplet_$id.setColor('$label',$rc,$gc,$bc);\n":'');
    } else {     } else {
        return "document.ggbApplet_$id.evalCommand('y=$function')";         return "document.ggbApplet_$id.evalCommand('y=$function');\n";
    }     }
 }  }
   
Line 384  sub start_backgroundplot { Line 394  sub start_backgroundplot {
    my $internalid = $Apache::inputtags::part.'_'.$Apache::inputtags::response[-1];     my $internalid = $Apache::inputtags::part.'_'.$Apache::inputtags::response[-1];
    my $function=&Apache::lonxml::get_param('function',$parstack,$safeeval);     my $function=&Apache::lonxml::get_param('function',$parstack,$safeeval);
    my $label=&Apache::lonxml::get_param('label',$parstack,$safeeval);     my $label=&Apache::lonxml::get_param('label',$parstack,$safeeval);
      my $color=&Apache::lonxml::get_param('color',$parstack,$safeeval);
      $color=~s/[^a-fA-F0-9]//gs;
      unless (length($color)==6) { $color=''; }
    my $fixed=(&Apache::lonxml::get_param('fixed',$parstack,$safeeval)=~/on|true|yes|1/i?1:0);     my $fixed=(&Apache::lonxml::get_param('fixed',$parstack,$safeeval)=~/on|true|yes|1/i?1:0);
     
    unless ($function) { $function="0"; }     unless ($function) { $function="0"; }
    if ($target eq 'web') {     if ($target eq 'web') {
       my ($xmin,$xmax,$ymin,$ymax)=&boundaries($parstack,$safeeval,-3);        my ($xmin,$xmax,$ymin,$ymax)=&boundaries($parstack,$safeeval,-3);
       $result.=&plot_script($internalid,$function,$fixed,$label,$xmin,$xmax);        $result.=&plot_script($internalid,$function,$fixed,$label,$color,$xmin,$xmax);
    } elsif ($target eq 'edit') {     } elsif ($target eq 'edit') {
         $result=&Apache::edit::tag_start($target,$token,'Background Function Plot').          $result=&Apache::edit::tag_start($target,$token,'Background Function Plot').
              &Apache::edit::text_arg('Function:','function',               &Apache::edit::text_arg('Function:','function',
                                      $token,'16').                                       $token,'16').
              &Apache::edit::text_arg('Label on Plot:','label',               &Apache::edit::text_arg('Label on Plot:','label',
                                      $token,'8').                                       $token,'8').
                &Apache::edit::text_arg('Color (hex code):','color',
                                        $token,'8').
              &Apache::edit::select_arg('Fixed location:','fixed',               &Apache::edit::select_arg('Fixed location:','fixed',
                                   ['yes','no'],$token).                                    ['yes','no'],$token).
              &Apache::edit::end_row();               &Apache::edit::end_row();
   } elsif ($target eq 'modified') {    } elsif ($target eq 'modified') {
     my $constructtag=&Apache::edit::get_new_args($token,$parstack,      my $constructtag=&Apache::edit::get_new_args($token,$parstack,
                                                  $safeeval,'function','label','fixed');                                                   $safeeval,'function','label','color','fixed');
     if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }      if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
   }    }
   return $result;    return $result;

Removed from v.1.45  
changed lines
  Added in v.1.46


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