af3a143571e5aa064eab75c34f9444b35413b562
chmalee
  Tue Nov 30 15:28:15 2021 -0800
Add snippet support to trix searching. Required changing the
wordPos from the first highest matching wordIndex to the
wordIndex of the actual span. Have trixContextIndex create a
second level index for fast retrieval of line offsets in
original text file used by ixIxx. Create a simple UI for navigating
hgFind search results.

diff --git src/hg/js/utils.js src/hg/js/utils.js
index 813daf9..230728b 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -1,24 +1,33 @@
 // Utility JavaScript
 
 // "use strict";
 
 // Don't complain about line break before '||' etc:
 /* jshint -W014 */
 
 var debug = false;
 
+/* Support these formats for range specifiers.  Note the ()'s around chrom,
+ * start and end portions for substring retrieval: */
+var canonicalRangeExp = /^([\w._#-]+)[\s]*:[\s]*([-0-9,]+)[\s]*[-_][\s]*([0-9,]+)$/;
+var gbrowserRangeExp =  /^([\w._#-]+)[\s]*:[\s]*([0-9,]+)[\s]*\.\.[\s]*([0-9,]+)$/;
+var lengthRangeExp =    /^([\w._#-]+)[\s]*:[\s]*([0-9,]+)[\s]*\+[\s]*([0-9,]+)$/;
+var bedRangeExp =       /^([\w._#-]+)[\s]+([0-9,]+)[\s]+([0-9,]+)$/;
+var sqlRangeExp =       /^([\w._#-]+)[\s]*\|[\s]*([0-9,]+)[\s]*\|[\s]*([0-9,]+)$/;
+var singleBaseExp =     /^([\w._#-]+)[\s]*:[\s]*([0-9,]+)$/;
+
 function copyToClipboard(ev) {
     /* copy a piece of text to clipboard. event.target is some DIV or SVG that is an icon. 
      * The attribute data-target of this element is the ID of the element that contains the text to copy. 
      * see C function printCopyToClipboardButton(iconId, targetId);
      * */
      
     var targetId = ev.target.getAttribute("data-target");
     var textEl = document.getElementById(targetId);
     var text = textEl.innerText;
 
     var textArea = document.createElement("textarea");
     textArea.value = text;
     // Avoid scrolling to bottom
     textArea.style.top = "0";
     textArea.style.left = "0";