[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages/annotator admannotations.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 10 Apr 2006 23:28:53 -0000


albertel		Mon Apr 10 19:28:53 2006 EDT

  Modified files:              
    /loncom/html/res/adm/pages/annotator	admannotations.pm 
  Log:
  - style police
  
  
Index: loncom/html/res/adm/pages/annotator/admannotations.pm
diff -u loncom/html/res/adm/pages/annotator/admannotations.pm:1.20 loncom/html/res/adm/pages/annotator/admannotations.pm:1.21
--- loncom/html/res/adm/pages/annotator/admannotations.pm:1.20	Mon Apr 10 19:26:48 2006
+++ loncom/html/res/adm/pages/annotator/admannotations.pm	Mon Apr 10 19:28:52 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # This will take annotations and then plug them into a page.
 #
-# $Id: admannotations.pm,v 1.20 2006/04/10 23:26:48 albertel Exp $
+# $Id: admannotations.pm,v 1.21 2006/04/10 23:28:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,8 +37,7 @@
 # --------------------------------------------------------------Put annotation
 
 sub write_annotation {
-    my $urlold=shift;
-    my $annotation=shift;
+    my ($urlold, $annotation) = @_;
     if ($annotation) { 
        &Apache::lonnet::put('nohist_annotations',{$urlold => $annotation});
     }
@@ -48,7 +47,7 @@
 # --------------------------------------------------------------Get annotation
 
 sub get_annotation {
-    my $urlnew=shift;
+    my ($urlnew) = @_;
     my %annotation=&Apache::lonnet::get('nohist_annotations',[$urlnew]);
     return %annotation;
 }
@@ -56,9 +55,9 @@
 # ------------------------------------------------------------Construct editor
 
 sub construct_editor {
-    my $annotation=shift;
+    my ($annotation,$urlnew) = @_;
     if ($annotation=~/^error:/) { $annotation=''; }
-    my $urlnew=shift;
+
     my $js = << ENDJS;
 <script type="text/javascript">
 var timeout;
@@ -103,12 +102,12 @@
 # ----------------------------------------------------Constructs error window
 
 sub construct_error {
-  my ($annot_error,$button_name) = @_;
-  my $start_page = &Apache::loncommon::start_page('Annotations',undef,
-						  {'only_body'   => 1,});
-  my $end_page =  &Apache::loncommon::end_page();
+    my ($annot_error,$button_name) = @_;
+    my $start_page = &Apache::loncommon::start_page('Annotations',undef,
+						    {'only_body'   => 1,});
+    my $end_page =  &Apache::loncommon::end_page();
 
-  return(<<END_HTML2)
+    return(<<END_HTML2)
 $start_page
  <center>
   <FORM name="annotInfo" method="post" action="/adm/annotations">
@@ -134,43 +133,43 @@
 # ---------------------------------------------------------------Main Handler
 
 sub handler {
-  my $r=shift;
+    my $r=shift;
   
-  $r->content_type('text/html');
-  $r->send_http_header;
-  return OK if $r->header_only;
-
-
-  my $page;
-  my %annot_hash;
-
-  my $urlold=$env{'form.urlold'};
-  $urlold=~s/^http\:\/\///;
-  $urlold=~s/^[^\/]+//;
-  $urlold=~s/\?.*$//;
-  my $urlnew=$env{'form.urlnew'};
-  $urlnew=~s/^http\:\/\///;
-  $urlnew=~s/^[^\/]+//;
-  $urlnew=~s/\?.*$//;
-  my $annotation=$env{'form.annotation'};
-
-  if ($urlold) {
-      write_annotation($urlold,$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 {
-	  if ($urlold eq $urlnew) {
-	      $annot_hash{$urlnew}=$annotation;
-	  } else {
-	      %annot_hash=get_annotation($urlnew);
-	  }
-	  $page=construct_editor($annot_hash{$urlnew},$env{'form.urlnew'});
-      }
-  }
-  $r->print($page);
-  return OK;
+    $r->content_type('text/html');
+    $r->send_http_header;
+    return OK if $r->header_only;
+
+
+    my $page;
+    my %annot_hash;
+
+    my $urlold=$env{'form.urlold'};
+    $urlold=~s/^http\:\/\///;
+    $urlold=~s/^[^\/]+//;
+    $urlold=~s/\?.*$//;
+    my $urlnew=$env{'form.urlnew'};
+    $urlnew=~s/^http\:\/\///;
+    $urlnew=~s/^[^\/]+//;
+    $urlnew=~s/\?.*$//;
+    my $annotation=$env{'form.annotation'};
+
+    if ($urlold) {
+	&write_annotation($urlold,$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 {
+	    if ($urlold eq $urlnew) {
+		$annot_hash{$urlnew}=$annotation;
+	    } else {
+		%annot_hash=&get_annotation($urlnew);
+	    }
+	    $page=&construct_editor($annot_hash{$urlnew},$env{'form.urlnew'});
+	}
+    }
+    $r->print($page);
+    return OK;
 }
 
 1;