Diff for /loncom/interface/lonhtmlcommon.pm between versions 1.359 and 1.360

version 1.359, 2015/03/31 13:46:01 version 1.360, 2015/04/01 16:14:46
Line 1308  sub htmlareaselectactive { Line 1308  sub htmlareaselectactive {
     function startRichEditor(id) {      function startRichEditor(id) {
         // fix character entities inside <m>          // fix character entities inside <m>
         // NOTE: this is not fixing characters inside <parse>          // NOTE: this is not fixing characters inside <parse>
           // NOTE: < and > inside <chem> should fix automatically because there should not be a letter after <.
         var ta = document.getElementById(id);          var ta = document.getElementById(id);
         var value = ta.value;          var value = ta.value;
         var in_m = false; // in the m element          var in_m = false; // in the m element
Line 1351  sub htmlareaselectactive { Line 1352  sub htmlareaselectactive {
           
     function destroyRichEditor(id) {      function destroyRichEditor(id) {
     CKEDITOR.instances[id].destroy();      CKEDITOR.instances[id].destroy();
         // replace character entities &lt; and &gt; in <m>          // replace character entities &lt; and &gt; in <m> and <chem>
         // and "&amp;fctname(" by "&fctname("          // and "&amp;fctname(" by "&fctname("
         // and the quotes inside functions: "&fct(1, &quot;a&quot;)" -> "&fct(1, "a")"          // and the quotes inside functions: "&fct(1, &quot;a&quot;)" -> "&fct(1, "a")"
         var ta = document.getElementById(id);          var ta = document.getElementById(id);
         var value = ta.value;          var value = ta.value;
         var in_m = false; // in the m element          var in_element = false; // in the m or chem element
         var in_text = false; // in the text inside the m element          var tagname = ""; // m or chem
         var im = -1; // position of <m>          var in_text = false; // in the text inside the element
           var im = -1; // position of start tag
         var it = -1; // position of the text inside          var it = -1; // position of the text inside
         for (var i=0; i<value.length; i++) {          for (var i=0; i<value.length; i++) {
             if (value.substr(i, 2) == "<m") {              if (value.substr(i, 2) == "<m" || value.substr(i, 5) == "<chem") {
                 // ignore previous <m> if found twice                  // ignore previous tags if found twice
                 in_m = true;                  in_element = true;
                   if (value.substr(i, 2) == "<m")
                       tagname = "m";
                   else
                       tagname = "chem";
                 in_text = false;                  in_text = false;
                 im = i;                  im = i;
                 it = -1;                  it = -1;
             } else if (in_m) {              } else if (in_element) {
                 if (!in_text) {                  if (!in_text) {
                     if (value.charAt(i) == ">") {                      if (value.charAt(i) == ">") {
                         in_text = true;                          in_text = true;
                         it = i+1;                          it = i+1;
                     }                      }
                 } else if (value.substr(i, 4) == "</m>") {                  } else if (value.substr(i, 3+tagname.length) == "</"+tagname+">") {
                     in_m = false;                      in_element = false;
                     var text = value.substr(it, i-it);                      var text = value.substr(it, i-it);
                     var l1 = text.length;                      var l1 = text.length;
                     text = text.replace(/&lt;/g, "<");                      text = text.replace(/&lt;/g, "<");
                     text = text.replace(/&gt;/g, ">");                      text = text.replace(/&gt;/g, ">");
                     var l2 = text.length;                      var l2 = text.length;
                     value = value.substr(0, it) + text + "</m>" + value.substr(i+4);                      value = value.substr(0, it) + text + value.substr(i);
                     i = i + (l2-l1);                      i = i + (l2-l1);
                 }                  }
             }              }

Removed from v.1.359  
changed lines
  Added in v.1.360


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>