@@ -105,40 +111,42 @@ END_HTML2
sub handler {
my $r=shift;
- my $url_old;
- my $annotation;
- my $page;
- my $url_new;
- my %annot_hash;
+
$r->content_type('text/html');
$r->send_http_header;
- if ($url_old=param("url_old")) {
- $annotation=param("annotation");
- write_annotation($url_old,$annotation);
+ return OK if $r->header_only;
+
+
+ my $page;
+ my %annot_hash;
+
+ my $urlold=$ENV{'form.urlold'};
+ $urlold=~s/^http\:\/\///;
+ $urlold=~s/^[^\/]+//;
+ my $urlnew=$ENV{'form.urlnew'};
+ $urlnew=~s/^http\:\/\///;
+ $urlnew=~s/^[^\/]+//;
+ my $annotation=$ENV{'form.annotation'};
+
+ if ($urlold) {
+ write_annotation($urlold,$annotation);
}
- if (defined(param("url_new"))) {
- $url_new=param("url_new");
- if ($url_new eq "") {
- $page=construct_error("Cannot annotate current window. Please point your browser to a Lon-CAPA page and then 'continue'.","coninue");
- } else {
- if ($url_old eq $url_new) {
- %annot_hash=($url_new => $annotation);
+ if (exists($ENV{'form.urlnew'})) {
+ unless ($urlnew) {
+ $page=construct_error("Cannot annotate current window. Please point your browser to a LON-CAPA page and then 'continue'.","continue");
} else {
- %annot_hash=get_annotation($url_new);
+ if ($urlold eq $urlnew) {
+ $annot_hash{$urlnew}=$annotation;
+ } else {
+ %annot_hash=get_annotation($urlnew);
+ }
+ $page=construct_editor($annot_hash{$urlnew},$ENV{'form.urlnew'});
}
- if (exists($annot_hash{"con_lost"})) {
- $page=construct_error("Connection broken with home server. Please contact your system administrator.","try again");
- } else {
- $page=construct_editor($url_new,%annot_hash);
- }
- }
- $r->print($page);
- } else {
- $page=construct_error("Cannot annotate current window. Please point your browser to a Lon-CAPA page and then 'continue'.","coninue");
- $r->print($page);
}
+ $r->print($page);
return OK;
}
1;
__END__
+