[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages/reactionresponse reaction_editor.html
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 20 Nov 2006 20:33:30 -0000
albertel Mon Nov 20 15:33:30 2006 EDT
Modified files:
/loncom/html/res/adm/pages/reactionresponse reaction_editor.html
Log:
- BUG 4808 (patch by Guy Ashkenazi)
Index: loncom/html/res/adm/pages/reactionresponse/reaction_editor.html
diff -u loncom/html/res/adm/pages/reactionresponse/reaction_editor.html:1.10 loncom/html/res/adm/pages/reactionresponse/reaction_editor.html:1.11
--- loncom/html/res/adm/pages/reactionresponse/reaction_editor.html:1.10 Sun Jul 2 21:13:51 2006
+++ loncom/html/res/adm/pages/reactionresponse/reaction_editor.html Mon Nov 20 15:33:30 2006
@@ -1,7 +1,7 @@
<!-- Chemical reaction editor developed by Guy Ashkenazi, guy@fh.huji.ac.il-->
<!--
- $Id: reaction_editor.html,v 1.10 2006/07/03 01:13:51 albertel Exp $
+ $Id: reaction_editor.html,v 1.11 2006/11/20 20:33:30 albertel Exp $
Copyright Michigan State University Board of Trustees
@@ -144,16 +144,12 @@
function html_component(string) {
var reactant = "";
var i = 0;
- level = 0;
+ level = -1;
var hydrate = string.split('.');
if (hydrate.length > 1)
return html_component(hydrate[0]) + "·" + html_component(hydrate[1]);
- for (;string.substring(i,i+1) == ' ';i++)
- ;
- for (;isDigit(string.substring(i,i+1)) || string.substring(i,i+1) == '/'; i++) // stoichiometric coefficient
- reactant += string.substring(i,i+1);
for (;i < string.length;i++)
reactant += html_char(string.substring(i,i+1));
@@ -161,6 +157,14 @@
}
function html_char(chr) {
+ if (level == -1) { // stoichiometric coefficient
+ if (isDigit(chr) || chr == '/')
+ return chr;
+ if (chr == ' ')
+ return "";
+ else
+ level = 0;
+ }
if (level == 0) { // baseline
if (isDigit(chr))
return chr.sub();
@@ -168,10 +172,12 @@
level = 1;
return "";
}
- if (chr == '+') // baseline or superscript
+ if (chr == '+') // baseline or superscript?
return "?";
if (chr == ' ')
return "";
+ if (chr == '(' || chr == '|') // coefficient
+ level = -1;
return chr;
}
if (level == 1) { // superscript