summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoderick142017-06-09 18:58:19 +0530
committercoderick142017-06-09 18:58:19 +0530
commitc6807a170dad16e89b2a736f90065b23a57c0b55 (patch)
treeb82f7b9de7ed61936ea429562054fe37a4822407
parentfb6c0b923325af7dc9b3b06bad8c0f2eb8c43ad1 (diff)
downloadSBHS-2018-Rpi-c6807a170dad16e89b2a736f90065b23a57c0b55.tar.gz
SBHS-2018-Rpi-c6807a170dad16e89b2a736f90065b23a57c0b55.tar.bz2
SBHS-2018-Rpi-c6807a170dad16e89b2a736f90065b23a57c0b55.zip
Fix bug related to context in toggleState
-rw-r--r--templates/admin/index.html19
1 files changed, 10 insertions, 9 deletions
diff --git a/templates/admin/index.html b/templates/admin/index.html
index 3bd5e45..e7ffe3b 100644
--- a/templates/admin/index.html
+++ b/templates/admin/index.html
@@ -23,7 +23,7 @@
{% for b in boards %}
<tr>
<td>{{ b.mid }}</td>
- <td><span style="cursor: pointer;" class="label label-{% if b.temp_offline %}warning{% elif b.online %}success{% else %}important{% endif %}">{% if b.temp_offline %}Temp Offline{% elif b.online %}Online{% else %}Offline{% endif %}</span></td>
+ <td><span style="cursor: pointer;" class="label label-{% if not b.online %}important{% elif b.temp_offline %}warning{% else %}success{% endif %}">{% if not b.online %}Offline{% elif b.temp_offline %}Temp Offline{% else %}Online{% endif %}</span></td>
<td><a href="{% url 'webcam_show_video_to_admin' b.mid %}" target="_blank">View image</a></td>
<td><a href="{% url 'admin_profile' b.mid %}">View</a></td>
<td><a href="{% url 'admin_logs' b.mid %}">Download</a></td>
@@ -42,8 +42,9 @@
function toggleState() {
var BASE_URL = window.location.origin;
if (window.confirm("Are you sure you want to toggle the state?")) {
- var board_class = $(this).attr("class");
- var selected_mid = $(this).parent().prev().html();
+ var element = $(this);
+ var board_class = element.attr("class");
+ var selected_mid = element.parent().prev().html();
var request = $.ajax({
url : BASE_URL + '/admin/toggledevice',
@@ -56,14 +57,14 @@
request.done(function(data){
if (data.status_code == 200) {
if (board_class.indexOf("label-success") > -1) {
- $(this).removeClass("label-success");
- $(this).addClass("label-warning");
- $(this).html("Temp Offline");
+ element.removeClass("label-success");
+ element.addClass("label-warning");
+ element.html("Temp Offline");
}
else {
- $(this).removeClass("label-warning");
- $(this).addClass("label-success");
- $(this).html("Online");
+ element.removeClass("label-warning");
+ element.addClass("label-success");
+ element.html("Online");
}
}
else {