diff options
author | John Nduli | 2024-09-17 17:16:24 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-09-18 08:32:23 +0300 |
commit | 37fc1e0c473822ee208d59840d9785a6c03e4d30 (patch) | |
tree | b1be881e48164c729a6904333af22bdecad3f53a | |
parent | 2e8bfa4da0f6aeaa3e882b1bc46831d9dbd281d5 (diff) | |
download | genenetwork2-37fc1e0c473822ee208d59840d9785a6c03e4d30.tar.gz |
feat: split header on sentences or commas
-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> |