summaryrefslogtreecommitdiff
path: root/static/website/templates/get-question.html
diff options
context:
space:
mode:
Diffstat (limited to 'static/website/templates/get-question.html')
-rw-r--r--static/website/templates/get-question.html109
1 files changed, 100 insertions, 9 deletions
diff --git a/static/website/templates/get-question.html b/static/website/templates/get-question.html
index ea6bfa3..2c21c10 100644
--- a/static/website/templates/get-question.html
+++ b/static/website/templates/get-question.html
@@ -110,12 +110,35 @@
</div>
-{% for answer in answers %}
+
+{% for answer,ans_vote in main_list %}
<div class="row">
<div class="answer-wrapper col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="answer {% if user|can_edit:answer %}editable{% endif %}" id="answer{{answer.id}}">
-
+
+ <div class="votecell" style="padding-top: 0.0cm;">
+
+ <div class="ans-vote" >
+
+ {% ifequal ans_vote.0 0 %}
+ <img src="{% static 'website/images/up1-off.png' %}" class="ans-vote-up" id="{{ answer.id }}" title="This question shows research effort; it is useful and clear"/>
+ {% else %}
+ <img src="{% static 'website/images/up1-on.png' %}" class="ans-vote-up selected" id="{{ answer.id }}" title="This question shows research effort; it is useful and clear"/>
+ {% endifequal %}
+
+ <span class="vote-count-post" id="span{{ answer.id }}" >
+ {{ ans_vote.2 }}
+ </span>
+ {% ifequal ans_vote.1 0 %}
+ <img type="image" src="{% static 'website/images/down1-off.png' %}" class="ans-vote-down" id="{{ answer.id }}" title="This question does not show any research effort; it is not useful and unclear" />
+ {% else %}
+ <img src="{% static 'website/images/down1-on.png' %}" class="ans-vote-down selected" id="{{ answer.id }}" title="This question does not show any research effort; it is not useful and unclear"/>
+ {% endifequal %}
+ </div>
+ </div>
+
+
<div class="body" id="body{{ answer.id }}">
{{ answer.body|safe }}
</div>
@@ -261,7 +284,7 @@
{% endblock %}
{% block javascript %}
- <script src="{% static 'website/js/nicEdit.js' %}" type="text/javascript"></script>
+<script src="{% static 'website/js/nicEdit.js' %}" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({
@@ -270,7 +293,7 @@
}).panelInstance('id_body');
});
</script>
- <script src="{% static 'website/js/thread-user.js' %}"></script>
+
<script type="text/javascript">
$(document).ready(function() {
@@ -279,11 +302,9 @@
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
+ /* VOTE FOR QUESTION */
$('div.vote img.vote-up').click(function() {
-
-
-
var id = {{ question.pk }};
var vote_type = 'up';
@@ -346,11 +367,81 @@
}
});
-
+ /* VOTE FOR ANSWERS */
+
+ /* UP VOTE */
+ $('div.ans-vote img.ans-vote-up').click(function(event) {
+
+ var id = event.target.id;
+ var vote_type = 'up';
+
+ if ($('img#'+id).hasClass('selected')) {
+ var vote_action = 'recall-vote'
+
+ $.post('/ans_vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {
+
+ $('img#'+id).removeAttr('src')
+ .attr('src', '{% static 'website/images/up1-off.png' %}')
+ .removeClass('selected');
+
+ $('span#span'+id).html(response);
+ });
+ }
+
+ /* USER WISHES TO VOTE */
+ else {
+
+ var vote_action = 'vote'
+ $.post('/ans_vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {
+
+ $('img#'+id).removeAttr('src')
+ .attr('src', '{% static 'website/images/up1-on.png' %}')
+ .addClass('selected');
+
+ $('span#span'+id).html(response);
+ });
+ }
+
+ }); /* END OF UP VOTE FOR ANSWERS */
+
+ /* DOWNVOTE */
+
+ $('div.ans-vote img.ans-vote-down').click(function(event) {
+
+ var id = event.target.id;
+ var vote_type = 'down';
+
+ /* USER HAS ALREADY DOWN-VOTED */
+
+ if ($('div.ans-vote img.ans-vote-down').hasClass('selected')) {
+ var vote_action = 'recall-vote'
+
+ $.post('/ans_vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {
+
+ $('div.ans-vote img.ans-vote-down').removeAttr('src')
+ .attr('src', '{% static 'website/images/down1-off.png' %}')
+ .removeClass('selected');
+
+ $('div.ans-vote span#span'+id).html(response);
+ });
+ }
+ /* USER WISHES TO VOTE */
+ else {
+ var vote_action = 'vote'
+ $.post('/ans_vote_post/', {id:id, type:vote_type, action:vote_action}, function(response) {
+
+ $('div.ans-vote img.ans-vote-down').removeAttr('src')
+ .attr('src', '{% static 'website/images/down1-on.png' %}')
+ .addClass('selected');
+
+ $('div.ans-vote span#span'+id).html(response);
+ });
+ }
});
+ });
</script>
-
+ <script src="{% static 'website/js/thread-user.js' %}"></script>
<script src="{% static 'website/js/custom.js' %}"></script>
{% endblock %}