File:  [LON-CAPA] / loncom / cgi / imagechoice.pl
Revision 1.4: download - view: text, annotated - select for diffs
Sat May 10 22:59:04 2003 UTC (20 years, 11 months ago) by www
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, bz5969, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
Does coordinate pairs now.

    1: #!/usr/bin/perl
    2: #
    3: # $Id: imagechoice.pl,v 1.4 2003/05/10 22:59:04 www Exp $
    4: #
    5: # Copyright Michigan State University Board of Trustees
    6: #
    7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8: #
    9: # LON-CAPA is free software; you can redistribute it and/or modify
   10: # it under the terms of the GNU General Public License as published by
   11: # the Free Software Foundation; either version 2 of the License, or
   12: # (at your option) any later version.
   13: #
   14: # LON-CAPA is distributed in the hope that it will be useful,
   15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17: # GNU General Public License for more details.
   18: #
   19: # You should have received a copy of the GNU General Public License
   20: # along with LON-CAPA; if not, write to the Free Software
   21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22: #
   23: # /home/httpd/cgi-bin/plot.gif
   24: #
   25: # http://www.lon-capa.org/
   26: #
   27: use strict;
   28: 
   29: $|=1;
   30: 
   31: my %data;
   32: foreach (split/&/,$ENV{'QUERY_STRING'}) {
   33:     my ($name,$value)=split/=/;
   34:     $data{$name}=$value;
   35: }
   36: my $filename = $data{'file'};
   37: my $formname = $data{'formname'};
   38: my $formx = $data{'formx'};
   39: my $formy = $data{'formy'};
   40: my $mode=$data{'mode'};
   41: my $formwidth = $data{'formwidth'};
   42: my $formheight = $data{'formheight'};
   43: my $formcoord=$data{'formcoord'};
   44: # unescape filename
   45: $filename =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   46: 
   47: #
   48: # Single coordinate, defined - store it
   49: #
   50: if ((defined($data{'x'})) && (defined($data{'y'})) && 
   51:     ($mode ne 'pairtwo') && ($mode ne 'pairthree')) {
   52:     my $output='';
   53:     if ($data{'formwidth'}) {
   54: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formwidth'}.
   55: 	    '.value=document.pickimg.width;';
   56:     }
   57:     if ($data{'formheight'}) {
   58: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formheight'}.
   59: 	    '.value=document.pickimg.height;';
   60:     }
   61:     if ($data{'formx'}) {
   62: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formx'}.
   63: 	    '.value='.$data{'x'}.';';
   64:     }
   65:     if ($data{'formy'}) {
   66: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formy'}.
   67: 	    '.value='.$data{'y'}.';';
   68:     }
   69:     print <<"ENDSUBM";
   70: Content-type: text/html
   71: 
   72: <html>
   73: <script>
   74:     function submitthis() {
   75: 	$output
   76: 	self.close();
   77:     }
   78: </script>
   79: <body bgcolor="#FFFFFF" onLoad="submitthis()">
   80: <h3>Position Selected</h3>
   81: <img name="pickimg" src="$filename" />
   82: </body>
   83: </html>
   84: ENDSUBM
   85: #
   86: # Coordinate Pair, Second Coordinate
   87: #
   88: } elsif ($mode eq 'pairthree') {
   89:     my $output='';
   90:     my $outputpair="($data{'selx'},$data{'sely'})-($data{'x'},$data{'y'})";
   91:     if ($data{'formwidth'}) {
   92: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formwidth'}.
   93: 	    '.value=document.pickimg.width;';
   94:     }
   95:     if ($data{'formheight'}) {
   96: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formheight'}.
   97: 	    '.value=document.pickimg.height;';
   98:     }
   99:     if ($data{'formcoord'}) {
  100: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formcoord'}.
  101: 	    '.value="'.$outputpair.'";';
  102:     }
  103:     print <<"ENDCOORDSUB";
  104: Content-type: text/html
  105: 
  106: <html>
  107: <script>
  108:     function submitthis() {
  109: 	$output
  110: 	self.close();
  111:     }
  112: </script>
  113: <body bgcolor="#FFFFFF" onLoad="submitthis()">
  114: <h3>Coordinates Selected</h3>
  115: <img name="pickimg" src="$filename" />
  116: </body>
  117: </html>
  118: ENDCOORDSUB
  119: #
  120: # First and second call
  121: #
  122: } else {
  123:     my $heading='Position';
  124:     my $nextstage='';
  125:     if ($mode eq 'pair') {
  126:        $heading='First Coordinate';
  127:        $nextstage='<input type="hidden" name="mode" value="pairtwo" />';
  128:    } elsif ($mode eq 'pairtwo') {
  129:        $heading='Second Coordinate';
  130:        $nextstage=<<ENDNEXTSTAGE;
  131: <input type="hidden" name="mode" value="pairthree" />
  132: <input type="hidden" name="selx" value="$data{'x'}" />
  133: <input type="hidden" name="sely" value="$data{'y'}" />
  134: ENDNEXTSTAGE
  135:    }
  136:     print <<"END";
  137: Content-type: text/html
  138: 
  139: <html>
  140: <body bgcolor="#FFFFFF">
  141: <h3>Select $heading on Image</h3>
  142: <form>
  143: <input type="hidden" name="formname" value="$formname" />
  144: <input type="hidden" name="formx" value="$formx" />
  145: <input type="hidden" name="formy" value="$formy" />
  146: <input type="hidden" name="formcoord" value="$formcoord" />
  147: <input type="hidden" name="formwidth" value="$formwidth" />
  148: <input type="hidden" name="formheight" value="$formheight" />
  149: <input type="hidden" name="file" value="$filename" />
  150: $nextstage
  151: <input type="image" src="$filename" />
  152: </form>
  153: </body>
  154: </html>
  155: END
  156: }
  157: 
  158: 
  159: 

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