File:
[LON-CAPA] /
loncom /
cgi /
imagechoice.pl
Revision
1.2:
download - view:
text,
annotated -
select for diffs
Sat Apr 19 23:52:37 2003 UTC (21 years, 2 months ago) by
www
Branches:
MAIN
CVS tags:
HEAD
Toward bug #1274 - determines image height, width, image x and y position,
to be put into
formname: name of the form
formx: name of the input field for x
formy: same for y
formwidth: field for width
formheight: field for height
1: #!/usr/bin/perl
2: #
3: # $Id: imagechoice.pl,v 1.2 2003/04/19 23:52:37 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 $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'}))) {
47: my $output='';
48: if ($data{'formwidth'}) {
49: $output.='parent.'.$data{'formname'}.'.'.$data{'formwidth'}.
50: '.value=document.pickimg.width;';
51: }
52: if ($data{'formheight'}) {
53: $output.='parent.'.$data{'formname'}.'.'.$data{'formheight'}.
54: '.value=document.pickimg.height;';
55: }
56: if ($data{'formx'}) {
57: $output.='parent.'.$data{'formname'}.'.'.$data{'formx'}.
58: '.value='.$data{'x'}.';';
59: }
60: if ($data{'formy'}) {
61: $output.='parent.'.$data{'formname'}.'.'.$data{'formy'}.
62: '.value='.$data{'y'}.';';
63: }
64: print <<"ENDSUBM";
65: Content-type: text/html
66:
67: <html>
68: <script>
69: function submitthis() {
70: $output
71: }
72: </script>
73: <body bgcolor="#FFFFFF" onLoad="submitthis()">
74: <h3>Position Selected</h3>
75: <img name="pickimg" src="$filename" />
76: </body>
77: </html>
78: ENDSUBM
79: } else {
80: print <<"END";
81: Content-type: text/html
82:
83: <html>
84: <body bgcolor="#FFFFFF">
85: <h3>Select Position on Image</h3>
86: <form>
87: <input type="hidden" name="formname" value="$formname" />
88: <input type="hidden" name="formx" value="$formx" />
89: <input type="hidden" name="formy" value="$formy" />
90: <input type="hidden" name="formwidth" value="$formwidth" />
91: <input type="hidden" name="formheight" value="$formheight" />
92: <input type="hidden" name="file" value="$filename" />
93: <input type="image" src="$filename" />
94: </form>
95: </body>
96: </html>
97: END
98: }
99:
100:
101:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>