aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/templates/gnqa_answer.html
diff options
context:
space:
mode:
authorAlexander Kabui2024-08-28 14:39:59 +0300
committerGitHub2024-08-28 14:39:59 +0300
commit72089330ca8b2f39174adb873c19919d2bd696f9 (patch)
treebebe24b041a1118878a0b086856415b1bea48eeb /gn2/wqflask/templates/gnqa_answer.html
parent16f978ecdaf450cfa700bd6e78194831ed9a8f57 (diff)
parent842a758f31143a5934b2798a4d0f40f11a402919 (diff)
downloadgenenetwork2-72089330ca8b2f39174adb873c19919d2bd696f9.tar.gz
Merge pull request #847 from genenetwork/feature/gnqa-search-history
Feature/gnqa search history
Diffstat (limited to 'gn2/wqflask/templates/gnqa_answer.html')
-rw-r--r--gn2/wqflask/templates/gnqa_answer.html33
1 files changed, 20 insertions, 13 deletions
diff --git a/gn2/wqflask/templates/gnqa_answer.html b/gn2/wqflask/templates/gnqa_answer.html
index 0ddcfde7..41c1b338 100644
--- a/gn2/wqflask/templates/gnqa_answer.html
+++ b/gn2/wqflask/templates/gnqa_answer.html
@@ -3,10 +3,10 @@
<div class="row container gnqa-answer" style="margin-bottom: 1em">
<p class="row lead">
<mark style="font-family: 'Linux Libertine','Georgia','Times','Source Serif Pro',serif;"><b><i>{{ query }}</i></b></mark><br/>
- {{ answer }}
+ {{ answer|safe }}
</p>
<div class="rating row" data-doc-id="{{query}}">
- <button class="btn" id="upvote" data-toggle="tooltip" data-placement="top" title="Vote Up"><i class="fa fa-thumbs-up fa-sm fa-1x" aria-hidden="true"></i></button>
+ <button class="btn" id="upvote" data-toggle="tooltip" data-placement="top" title="Vote Up"><i class="fa fa-thumbs-up fa-sm fa-1x" aria-hidden="true"></i></button>
<button class="btn" id="downvote" data-toggle="tooltip" data-placement="top" title="Vote Down"><i class="fa fa-thumbs-down fa-sm fa-1x" aria-hidden="true"></i></button>
<sub id="rate" class="text-info">
</sub>
@@ -32,7 +32,7 @@
</div>
<div id="collapse{{reference.doc_id}}" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading{{reference.doc_id}}">
<div class="panel-body">
- <p class="node-references">{{ reference.comboTxt }}</p>
+ <p class="node-references">{{ reference.comboTxt|safe }}</p>
<div>
{% if reference.pubmed %}
<details open>
@@ -60,7 +60,7 @@
</div>
<div id="collapse{{reference.doc_id}}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading{{reference.doc_id}}">
<div class="panel-body">
- <p class="node-references">{{reference.comboTxt}}</p>
+ <p class="node-references">{{ reference.comboTxt|safe }}</p>
<div>
{% if reference.pubmed %}
<details >
@@ -93,20 +93,27 @@
{% block js %}
<script>
+ function updateRatingHandler(target, responseObj, args){
+ let {status, response} = responseObj.xhr
+ if (status==200 && args == "upvote"){
+ htmx.toggleClass(htmx.find('#upvote'), 'btn-success');
+ htmx.removeClass(htmx.find("#downvote"), "btn-danger");
+ }
+ else if(status == 200 && args == "downvote") {
+ htmx.toggleClass(htmx.find('#downvote'), 'btn-danger');
+ htmx.removeClass(htmx.find("#upvote"), "btn-success");
+ }
+ else {
+ alert(`Error occurred with status ${status} and Error ${response}` )
+}}
var query = {{ query|tojson }};
var answer = {{ answer|tojson }}
var {task_id} = {{ task_id|tojson }}
- htmx.on("#upvote", "click", function(evt){
+htmx.on("#upvote", "click", function(evt){
vote_count = htmx.find(".btn-success") ? 0 : 1
- htmx.ajax("POST", `/gnqna/rating/${task_id}/${vote_count}`, {target: "#rate", swap:"innerHTML",values: {'query': query, 'answer': answer}}).then(()=>{
- htmx.toggleClass(htmx.find('#upvote'), 'btn-success');
- htmx.removeClass(htmx.find("#downvote"), "btn-danger");
-})});
+ htmx.ajax("POST", `/gnqna/rating/${task_id}/${vote_count}`, {target: "#rate", handler: (target,obj)=> updateRatingHandler(target,obj,"upvote"), swap:"innerHTML",values: {'query': query, 'answer': answer}})});
htmx.on("#downvote", "click", function(evt){
vote_count = htmx.find(".btn-danger") ? 0 : -1
- htmx.ajax("POST", `/gnqna/rating/${task_id}/${vote_count}`, {target: "#rate", swap:"innerHTML",values: {'query': query, 'answer': answer}}).then(()=>{
- htmx.toggleClass(htmx.find('#downvote'), 'btn-danger');
- htmx.removeClass(htmx.find("#upvote"), "btn-success")
- })});
+ htmx.ajax("POST", `/gnqna/rating/${task_id}/${vote_count}`, {target: "#rate",handler: (target,obj)=> updateRatingHandler(target,obj,"downvote") , swap:"innerHTML",values: {'query': query, 'answer': answer}})});
</script>
{% endblock %}