aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/templates/gnqa_answer.html
diff options
context:
space:
mode:
authorAlexander Kabui2024-08-28 14:58:16 +0300
committerGitHub2024-08-28 14:58:16 +0300
commit0f4c9fbe37ed74022d9fad35352b59d948789818 (patch)
tree25c3644d14c346e9eac396e0de3c59dffd3f890f /gn2/wqflask/templates/gnqa_answer.html
parent72089330ca8b2f39174adb873c19919d2bd696f9 (diff)
downloadgenenetwork2-0f4c9fbe37ed74022d9fad35352b59d948789818.tar.gz
Revert "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, 13 insertions, 20 deletions
diff --git a/gn2/wqflask/templates/gnqa_answer.html b/gn2/wqflask/templates/gnqa_answer.html
index 41c1b338..0ddcfde7 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|safe }}
+ {{ answer }}
</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|safe }}</p>
+ <p class="node-references">{{ reference.comboTxt }}</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|safe }}</p>
+ <p class="node-references">{{reference.comboTxt}}</p>
<div>
{% if reference.pubmed %}
<details >
@@ -93,27 +93,20 @@
{% 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", handler: (target,obj)=> updateRatingHandler(target,obj,"upvote"), swap:"innerHTML",values: {'query': query, 'answer': answer}})});
+ 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.on("#downvote", "click", function(evt){
vote_count = htmx.find(".btn-danger") ? 0 : -1
- 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}})});
+ 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")
+ })});
</script>
{% endblock %}