3c89781b651b870cd2c08856116774e3a9a022e7
angie
  Wed Apr 27 14:08:38 2016 -0700
For gene autocomplete, highlight the part of each gene symbol that matches the search term.  refs #15277 note 223

diff --git src/hg/js/hgGateway.js src/hg/js/hgGateway.js
index 6fe61b0..9ec53ea 100644
--- src/hg/js/hgGateway.js
+++ src/hg/js/hgGateway.js
@@ -1272,43 +1272,55 @@
         // Unhide contents of Find Position section and adjust layout.
         $('#findPositionContents').show();
         // Set assembly menu's width to same as position input.
         var posWidth = $('#positionInput').outerWidth();
         var $select = $('#selectAssembly');
         $select.outerWidth(posWidth);
         // For some reason, it doesn't set it to posWidth, it sets it to posWidth-2...
         // detect and adjust.
         var weirdDiff = posWidth - $select.outerWidth();
         if (weirdDiff) {
             $select.outerWidth(posWidth + weirdDiff);
         }
         updateGoButtonPosition();
     }
 
+    function processHgSuggestResults(results, term) {
+        // Make matching part of the gene symbol bold
+        _.each(results, function(item) {
+            if (_.startsWith(item.value.toUpperCase(), term.toUpperCase())) {
+                item.value = '<b>' + item.value.substring(0, term.length) + '</b>' +
+                             item.value.substring(term.length);
+            }
+        });
+        return results;
+    }
+
     function updateFindPositionSection(uiState) {
         // Update the assembly menu, positionInput and description.
         var suggestUrl = null;
         if (uiState.suggestTrack) {
             suggestUrl = 'hgSuggest?db=' + uiState.db + '&prefix=';
         }
         setAssemblyOptions(uiState);
         if (uiState.position) {
             $('#positionDisplay').text(addCommasToPosition(uiState.position));
         }
         autocompleteCat.init($('#positionInput'),
                              { baseUrl: suggestUrl,
                                watermark: positionWatermark,
+                               onServerReply: processHgSuggestResults,
                                onSelect: onSelectGene,
                                enterSelectsIdentical: true,
                                onEnterTerm: goToHgTracks });
         selectedGene = null;
         setAssemblyDescriptionTitle(uiState.db, uiState.genome);
         updateDescription(uiState.description);
         if (uiState.db && $('#findPositionContents').css('display') === 'none') {
             initFindPositionContents();
         }
     }
 
     function removeDups(inList, isDup) {
         // Return a list with only unique items from inList, using isDup(a, b) -> true if a =~ b
         var inLength = inList.length;
         // inListDups is an array of boolean flags for marking duplicates, parallel to inList.