[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm inputtags.pm /interface loncommon.pm /xml scripttag.pm

www www at source.lon-capa.org
Sat Dec 10 13:11:06 EST 2011


www		Sat Dec 10 18:11:06 2011 EDT

  Modified files:              
    /loncom/homework	functionplotresponse.pm inputtags.pm 
    /loncom/interface	loncommon.pm 
    /loncom/xml	scripttag.pm 
  Log:
  Eliminate some copy/paste coding
  
  
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.89 loncom/homework/functionplotresponse.pm:1.90
--- loncom/homework/functionplotresponse.pm:1.89	Fri Dec  9 22:04:51 2011
+++ loncom/homework/functionplotresponse.pm	Sat Dec 10 18:10:56 2011
@@ -1,7 +1,7 @@
 # LearningOnline Network with CAPA
 # Functionplot responses
 #
-# $Id: functionplotresponse.pm,v 1.89 2011/12/09 22:04:51 www Exp $
+# $Id: functionplotresponse.pm,v 1.90 2011/12/10 18:10:56 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1289,31 +1289,16 @@
             ($env{'form.answer_output_mode'} ne 'tex') &&
             ($Apache::lonhomework::viewgrades == 'F')) {
       my (undef,undef,$udom,$uname)=&Apache::lonnet::whichuser();
-      my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
-      my $start_page = &Apache::loncommon::start_page('Rules Log', undef,
-                                               {'only_body' => 1,
-                                                'bgcolor'   => '#FFFFFF',
-                                                'js_ready'  => 1,});
-      my $end_page = &Apache::loncommon::end_page({'js_ready' => 1,});
       $uname =~s/\W//g;
       $udom  =~s/\W//g;
       my $function_name =
                 join('_','LONCAPA_scriptvars',$uname,$udom,
                      $env{'form.counter'},$Apache::lonxml::curdepth);
-      my $rulelogcontent= $start_page.
-              &Apache::loncommon::start_scrollbox('700px','680px','480px').
-             '<pre>'.
-              $Apache::functionplotresponse::ruleslog.
-              '</pre>'.
-              &Apache::loncommon::end_scrollbox().
-              $end_page;
-      $rulelogcontent=~s/\'/\\'/gs;
       &Apache::lonxml::add_script_result(
-          &Apache::loncommon::modal_adhoc_script($function_name,700,500,$rulelogcontent).
-              "<a href=\"javascript:$function_name();void(0);\">".&mt('Rules Log')."</a><br />"
-                                        );
-        }
-
+          &Apache::loncommon::modal_adhoc_window($function_name,700,500,
+             '<pre>'.$Apache::functionplotresponse::ruleslog.'</pre>',
+              &mt('Rules Log'))."<br />");
+  }
   return $result;
 }
 
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.297 loncom/homework/inputtags.pm:1.298
--- loncom/homework/inputtags.pm:1.297	Thu Dec  8 02:59:34 2011
+++ loncom/homework/inputtags.pm	Sat Dec 10 18:10:56 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.297 2011/12/08 02:59:34 www Exp $
+# $Id: inputtags.pm,v 1.298 2011/12/10 18:10:56 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1647,27 +1647,14 @@
 	'<tr>'.'<th>'.&mt('Submission #').'</th><th>'.&mt('Try').
 	'</th><th colspan="'.scalar(@Apache::inputtags::response).'">'.
 	&mt('Submitted Answer').'</th>';
-    $output =&Apache::loncommon::start_scrollbox('420px','400px','400px').
-             '<table class="LC_prior_tries">'.$headers.$output.'</table>'.
-             &Apache::loncommon::end_scrollbox();
-    #return $output;
-    $output = &Apache::loncommon::js_ready($output); 
+    $output ='<table class="LC_prior_tries">'.$headers.$output.'</table>';
 
     my $tries_text = &get_tries_text('link');
-    my $start_page =
-	&Apache::loncommon::start_page($tries_text, undef,
-				       {'only_body'      => 1,
-					'bgcolor'        => '#FFFFFF',
-					'js_ready'       => 1,
-				        'inherit_jsmath' => 1, });
-    my $end_page =
-	&Apache::loncommon::end_page({'js_ready' => 1,});
     my $prefix = $env{'form.request.prefix'};
     $prefix =~ tr{.}{_};
     my $function_name = "LONCAPA_previous_tries_".$prefix.
 	$Apache::lonxml::curdepth.'_'.$env{'form.counter'};
-    my $result = &Apache::loncommon::modal_adhoc_script($function_name,420,410,$start_page.$output.$end_page).
-    "<a href=\"javascript:$function_name();void(0);\">".&mt($tries_text)."</a><br />";
+    my $result = &Apache::loncommon::modal_adhoc_window($function_name,420,410,$output,&mt($tries_text))."<br />";
     return $result;
 }
 
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1034 loncom/interface/loncommon.pm:1.1035
--- loncom/interface/loncommon.pm:1.1034	Fri Dec  9 01:04:27 2011
+++ loncom/interface/loncommon.pm	Sat Dec 10 18:11:00 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1034 2011/12/09 01:04:27 www Exp $
+# $Id: loncommon.pm,v 1.1035 2011/12/10 18:11:00 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -7056,6 +7056,20 @@
 ENDADHOC
 }
 
+sub modal_adhoc_window {
+    my ($funcname,$width,$height,$content,$linktext)=@_;
+    my $innerwidth=$width-20;
+    $content=&js_ready(
+               &start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}).
+                 &start_scrollbox($width.'px',$innerwidth.'px',$height.'px').
+                    $content.
+                 &end_scrollbox().
+               &end_page()
+             );
+    return &modal_adhoc_script($funcname,$width,$height,$content).
+         "<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>";
+}
+
 sub html_encode {
     my ($result) = @_;
 
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.158 loncom/xml/scripttag.pm:1.159
--- loncom/xml/scripttag.pm:1.158	Fri Dec  9 22:04:55 2011
+++ loncom/xml/scripttag.pm	Sat Dec 10 18:11:05 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.158 2011/12/09 22:04:55 www Exp $
+# $Id: scripttag.pm,v 1.159 2011/12/10 18:11:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -102,30 +102,15 @@
 	    ($Apache::lonhomework::viewgrades == 'F')) {
 	    $Apache::lonxml::evaluate--;
 	    my (undef,undef,$udom,$uname)=&Apache::lonnet::whichuser();
-	    my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
-	    my $start_page =
-		&Apache::loncommon::start_page('Script Vars', undef,
-					       {'only_body' => 1,
-						'bgcolor'   => '#FFFFFF',
-						'js_ready'  => 1,});
-	    my $end_page =
-		&Apache::loncommon::end_page({'js_ready' => 1,});
-
 	    $uname =~s/\W//g;
 	    $udom  =~s/\W//g;
 	    my $function_name = 
 		join('_','LONCAPA_scriptvars',$uname,$udom,
 		     $env{'form.counter'},$Apache::lonxml::curdepth);
-            my $scriptblocklog=$start_page.
-                               &Apache::loncommon::start_scrollbox('500px','480px','480px').
-                               '<pre>'.&Apache::run::dump($target,$safeeval).'</pre>'.
-                               &Apache::loncommon::end_scrollbox().
-                               $end_page;
-            $scriptblocklog=~s/\'/\\'/gs;
             &Apache::lonxml::add_script_result(
-	             &Apache::loncommon::modal_adhoc_script($function_name,500,500,$scriptblocklog).
-                     "<a href=\"javascript:$function_name();void(0);\">".&mt('Script Vars')."</a><br />"
-                                              );
+	             &Apache::loncommon::modal_adhoc_window($function_name,500,500,
+                            '<pre>'.&Apache::run::dump($target,$safeeval).'</pre>',
+                            &mt('Script Vars'))."<br />");
 	}
     } elsif ($target eq "edit" ) {
       #&Apache::run::run($bodytext,$safeeval);




More information about the LON-CAPA-cvs mailing list