From 8d487bfad2bfaf0234c51ec8233d800426e7d23a Mon Sep 17 00:00:00 2001
From: coderick14
Date: Fri, 9 Jun 2017 18:58:19 +0530
Subject: Fix bug related to context in toggleState
---
templates/admin/index.html | 19 ++++++++++---------
1 file 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 %}
{{ b.mid }} |
- {% if b.temp_offline %}Temp Offline{% elif b.online %}Online{% else %}Offline{% endif %} |
+ {% if not b.online %}Offline{% elif b.temp_offline %}Temp Offline{% else %}Online{% endif %} |
View image |
View |
Download |
@@ -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 {
--
cgit