rem: window.dump("\nHIGHLIGHTING START\n"); window.dump(XRai.getPath(x) + " -> " + XRai.getPath(y) + "\n"); 
add: if (debug) window.dump("\nHIGHLIGHTING START\n"); if (debug) window.dump(XRai.getPath(x) + " -> " + XRai.getPath(y) + "\n"); 
context: XRai.highlight = function() {   if (docStatus != 0) return;   try {      var toremove = new Array();      var sel = XRai.getSelection();      if (sel == null) return;      var x = sel.x;      var y = sel.y;      XRai.history.push(new Array("H",XRai.getTimeString(),x,y));      if (debug)         XRai.history.push(new Array("H",XRai.getTimeString(),x,y));      if (debug) {         window.dump("\nHIGHLIGHTING START\n");         window.dump(XRai.getPath(x) + " -> " + XRai.getPath(y) + "\n");         XRai.log("Highlighting: " + XRai.getPath(x) + " -> " + XRai.getPath(y));      }      // (1) Find the previous highlighted passage (can be within)      var z = XRai.firstPassage;      while (z && (XRai.nextElementTo(z.end,x) != x) && !XRai.isIn(x,z.end) && XRai.isAfter(x,z.end)) {         if (debug) window.dump("Skipping conflicting passage is " + z.getPaths() +"\n");         z = z.next;      }      if (debug && z) {         window.dump("Next conflicting passage is " + z.getPaths() +"\n");      }      // Check for merge      if (z && XRai.nextElementTo(z.end,x) == x) {         x = z.start;      } else if (z && (XRai.isBetween(x,z.start,z.end) || XRai.isIn(x,z.end))) {         if (XRai.isBetween(y,z.start,z.end)) {            if (debug) window.dump("Highlight is within a single segment\n");            return;         }         x = z.start;      }      // (2) Unhighlight until we are in y      while (z && XRai.isAfter(y,z.end)) {         toremove.push(z);         z = z.next;         if (z) window.dump("Next conflicting passage is " + z.getPaths() +"\n");      }      // (3) Merge y with the current z      if (z && (XRai.isBetween(y,z.start,z.end) || (XRai.nextElementTo(y,z.start) == z.start))) {         y = z.end;         toremove.push(z);      }      // End of highlighting = add the passage      try {         for(var i = 0; i < toremove.length; i++) toremove[i].unhighlight();         new Passage(x,y);      } catch (error) {         alert("Unrecoverable error: you should stop assessing WITHOUT SAVING and fill a bug report\n\n" + error);         if (debug) throw error;         return;      }   } catch (error) {      alert("Recoverable error: you should save your work and fill a bug report\n\n" + error);      if (debug) throw error;      return;   }   XRai.updateSaveIcon();   if (debug) XRai.dumpPassages();}
meta: 8632	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8632/118a48a7c56edb8af49d2c17b204d65bb2149adb/article.js/clean/trunk/js/article.js