diff options
-rw-r--r-- | gn2/wqflask/templates/gsearch_gene.html | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gn2/wqflask/templates/gsearch_gene.html b/gn2/wqflask/templates/gsearch_gene.html index 40e18323..13b56b42 100644 --- a/gn2/wqflask/templates/gsearch_gene.html +++ b/gn2/wqflask/templates/gsearch_gene.html @@ -287,14 +287,29 @@ {% if do_ai_search %} <script type='text/javascript'> function ai_content_div(search_term, search_result, search_uri) { - let header = search_result.slice(0, 75); + let header_length = 40; + let max_header_length = 180; + while (header_length <= search_result.length) { + let next_dot = search_result.indexOf(".", header_length+1); + + if (next_dot > max_header_length) { + let next_comma = search_result.indexOf(",", header_length+1); + if (next_comma > max_header_length) { + break; + } + header_length = next_comma; + } else { + header_length = next_dot; + } + } + let header = search_result.slice(0, header_length+1); return ` <div class="col-sm-6"> <div class="panel panel-info"> <div class="panel-heading" role="tab" id="ai_heading"> <h4 class="panel-title"> <a id="panel-title-content" class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#ai_results" aria-expanded="false" aria-controls="ai_results"> - ${header}... (Click for more details) + ${header} ... (Click for more details) </a> </h4> </div> |