[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 27 Jul 2006 20:34:40 -0000
albertel Thu Jul 27 16:34:40 2006 EDT
Modified files:
/loncom/homework chemresponse.pm
Log:
- rework the Draw Molecule button to work in more instances
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.68 loncom/homework/chemresponse.pm:1.69
--- loncom/homework/chemresponse.pm:1.68 Sun Jul 2 21:16:04 2006
+++ loncom/homework/chemresponse.pm Thu Jul 27 16:34:40 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.68 2006/07/03 01:16:04 albertel Exp $
+# $Id: chemresponse.pm,v 1.69 2006/07/27 20:34:40 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -110,14 +110,15 @@
CHEMJS
my $start_page =
- &Apache::loncommon::start_page('Molecule Editor',$js,
+ &Apache::loncommon::start_page('Molecule Editor',undef,
{'only_body' => 1,
+ 'js_ready' => 1,
'bgcolor' => '#FFFFFF',});
- my $end_page =
- &Apache::loncommon::end_page();
-
+ my $end_page =
+ &Apache::loncommon::end_page({'js_ready' => 1,});
+
my $body=<<CHEMPAGE;
-$start_page
+$js
<center>
<form>
<table width="440"><tr>
@@ -155,17 +156,26 @@
<input type="button" value=" Help " onclick = "javascript:openHelpWindow()" />
</form>
</center>
-$end_page
CHEMPAGE
- $body=&HTML::Entities::encode($body,'<>&"');
- $body=~s/\n/ /g;
+ $body=&Apache::loncommon::js_ready($body);
my $nothing=&Apache::lonhtmlcommon::javascript_nothing();
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
my $display=&mt('Draw Molecule');
if (defined($shown_text)) { $display=&mt($shown_text); }
+ my $function =
+ 'LONCAPA_draw_molecule_'.&Apache::lonhtmlcommon::get_uniq_name();
my $result=<<CHEMINPUT;
-<input type="button" value="$display" onclick="javascript:editor=window.open($nothing,'jmeedit','width=500,height=500,menubar=no,scrollbars=no,resizable=yes');editor.$docopen;editor.document.write('$body');editor.document.close();editor.focus()" />
+<script type="text/javascript">
+ function $function() {
+ editor=window.open($nothing,'jmeedit','width=500,height=500,menubar=no,scrollbars=no,resizable=yes');
+ editor.$docopen;
+ editor.document.write('$start_page $body $end_page');
+ editor.document.close();
+ editor.focus();
+ }
+</script>
+<input type="button" value="$display" onclick="javascript:$function();void(0);" />
CHEMINPUT
return $result;
}