Diff for /loncom/homework/imagechoice.pm between versions 1.8 and 1.9

version 1.8, 2005/04/07 06:56:21 version 1.9, 2005/08/25 19:33:14
Line 33  sub deletedata { Line 33  sub deletedata {
 }  }
   
 sub closewindow {  sub closewindow {
     my ($r,$output,$filename,$needimage)=@_;      my ($r,$output,$filename,$needimage,$display)=@_;
     if ($needimage) {      if ($needimage) {
  $needimage="<img name=\"pickimg\" src=\"$filename\" />";   $needimage="<img name=\"pickimg\" src=\"$filename\" />";
     }      }
Line 47  sub closewindow { Line 47  sub closewindow {
 </script>  </script>
 <body bgcolor="#FFFFFF" onLoad="submitthis()">  <body bgcolor="#FFFFFF" onLoad="submitthis()">
 <h3>Position Selected</h3>  <h3>Position Selected</h3>
   $display
 $needimage  $needimage
 </body>  </body>
 </html>  </html>
Line 69  sub storedata { Line 70  sub storedata {
  $needimage=1;   $needimage=1;
     }      }
   
       my $display;
     if ($type eq 'point') {      if ($type eq 'point') {
  my (undef,$x,$y)=split(':',$env{"imagechoice.$id.coords"});   my (undef,$x,$y)=split(':',$env{"imagechoice.$id.coords"});
  if ($env{"imagechoice.$id.formx"}) {   if ($env{"imagechoice.$id.formx"}) {
     $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formx"}.'.value='.$x.';';      $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formx"}.'.value='.$x.';';
       $display.="<p>The X coordinate is $x</p>\n";
  }   }
  if ($env{"imagechoice.$id.formy"}) {   if ($env{"imagechoice.$id.formy"}) {
     $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formy"}.'.value='.$y.';';      $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formy"}.'.value='.$y.';';
       $display.="<p>The Y coordinate is $y</p>\n";
  }   }
     } elsif ($type eq 'polygon' or $type eq 'box') {      } elsif ($type eq 'polygon' or $type eq 'box') {
  my $coordstr;   my $coordstr;
Line 83  sub storedata { Line 87  sub storedata {
     $coordstr.='('.shift(@coords).','.shift(@coords).')-';      $coordstr.='('.shift(@coords).','.shift(@coords).')-';
  }   }
  chop($coordstr);   chop($coordstr);
    $display.="<p>The selected coordinates are <tt>$coordstr</tt></p>\n";
  $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";';   $output.='opener.document.forms.'.$env{"imagechoice.$id.formname"}.'.'.$env{"imagechoice.$id.formcoord"}.'.value="'.$coordstr.'";';
     }      }
       if ($display) {
    $display.="<p>If this window fails to close you may need to manually replace the old coordinates with the above value.</p>\n";
       }
     &deletedata($id);      &deletedata($id);
     &closewindow($r,$output,$filename,$needimage);      &closewindow($r,$output,$filename,$needimage,$display);
 }  }
   
 sub getcoord {  sub getcoord {

Removed from v.1.8  
changed lines
  Added in v.1.9


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