--- loncom/html/res/adm/pages/reactionresponse/reaction_editor.html 2003/07/01 21:06:37 1.3 +++ loncom/html/res/adm/pages/reactionresponse/reaction_editor.html 2005/03/29 17:57:52 1.9 @@ -1,7 +1,7 @@ return ''; @@ -73,8 +73,8 @@ function to_capa(string) { for (i = 0; i < products.length; i++) products[i] = capa_component(products[i]); - reactants.sort(); - products.sort(); +// reactants.sort(); +// products.sort(); for (i = 0; i < reactants.length-1; i++) { reaction += reactants[i]; @@ -135,17 +135,15 @@ function to_html(string) { reaction += html_component(reactants[i]); reaction += " + "; } - if (i < reactants.length) - reaction += html_component(reactants[i]); + reaction += html_component(reactants[i]); if (products.length > 0) { - reaction += rightarrow; + reaction += " "+rightarrow+" "; for (i = 0; i < products.length-1; i++) { reaction += html_component(products[i]); reaction += " + "; } - if (i < products.length) - reaction += html_component(products[i]); + reaction += html_component(products[i]); } return reaction; @@ -156,9 +154,13 @@ function html_component(string) { var i = 0; level = 0; + 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));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)); @@ -183,10 +185,14 @@ function html_char(chr) { if (level == 1) { // superscript if (isDigit(chr)) return chr.sup(); - if (chr == '+' || chr == '-') { + if (chr == '+') { level = 0; return chr.sup(); } + if (chr == '-') { + level = 0; + return ""; + } if (chr == ' ') { level = 0; return ""; @@ -224,14 +230,11 @@ function submitReaction() { } function setup() { - document.form.text.value=molecule; - if (id != '') { - document.form.submit.value='Insert reaction for Part ' + id; - parent.document.title='LON-CAPA Part '+id+' - Reaction Editor'; - } else { - document.form.submit.value='Insert reaction'; - parent.document.title='LON-CAPA - Reaction Editor'; - } + document.form.text.value=reaction; + parent.viewer.document.writeln('

'+to_html(document.form.text.value)+'
'); + parent.viewer.document.close(); + document.form.submit.value='Insert Answer'; + parent.document.title='LON-CAPA - Reaction Editor'; } function getCookie(document,name) {