Annotation of loncom/cgi/imagechoice.pl, revision 1.3

1.1       www         1: #!/usr/bin/perl
                      2: #
1.3     ! www         3: # $Id: imagechoice.pl,v 1.2 2003/04/19 23:52:37 www Exp $
1.1       www         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 $formwidth = $data{'formwidth'};
                     41: my $formheight = $data{'formheight'};
                     42: # unescape filename
                     43: $filename =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
                     44: 
                     45: 
                     46: if ((defined($data{'x'})) && (defined($data{'y'}))) {
1.2       www        47:     my $output='';
                     48:     if ($data{'formwidth'}) {
1.3     ! www        49: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formwidth'}.
1.2       www        50: 	    '.value=document.pickimg.width;';
                     51:     }
                     52:     if ($data{'formheight'}) {
1.3     ! www        53: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formheight'}.
1.2       www        54: 	    '.value=document.pickimg.height;';
                     55:     }
                     56:     if ($data{'formx'}) {
1.3     ! www        57: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formx'}.
1.2       www        58: 	    '.value='.$data{'x'}.';';
                     59:     }
                     60:     if ($data{'formy'}) {
1.3     ! www        61: 	$output.='opener.document.forms.'.$data{'formname'}.'.'.$data{'formy'}.
1.2       www        62: 	    '.value='.$data{'y'}.';';
                     63:     }
1.1       www        64:     print <<"ENDSUBM";
                     65: Content-type: text/html
                     66: 
                     67: <html>
                     68: <script>
                     69:     function submitthis() {
1.2       www        70: 	$output
1.3     ! www        71: 	self.close();
1.1       www        72:     }
                     73: </script>
                     74: <body bgcolor="#FFFFFF" onLoad="submitthis()">
                     75: <h3>Position Selected</h3>
                     76: <img name="pickimg" src="$filename" />
                     77: </body>
                     78: </html>
                     79: ENDSUBM
                     80: } else {
                     81:     print <<"END";
                     82: Content-type: text/html
                     83: 
                     84: <html>
                     85: <body bgcolor="#FFFFFF">
                     86: <h3>Select Position on Image</h3>
                     87: <form>
                     88: <input type="hidden" name="formname" value="$formname" />
                     89: <input type="hidden" name="formx" value="$formx" />
                     90: <input type="hidden" name="formy" value="$formy" />
                     91: <input type="hidden" name="formwidth" value="$formwidth" />
                     92: <input type="hidden" name="formheight" value="$formheight" />
                     93: <input type="hidden" name="file" value="$filename" />
                     94: <input type="image" src="$filename" />
                     95: </form>
                     96: </body>
                     97: </html>
                     98: END
                     99: }
                    100: 
                    101: 
                    102: 

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