diff options
author | coderick14 | 2017-06-09 18:58:19 +0530 |
---|---|---|
committer | coderick14 | 2017-06-09 18:58:19 +0530 |
commit | 8d487bfad2bfaf0234c51ec8233d800426e7d23a (patch) | |
tree | d6b9bf6376aeee722a06face12dfd82966881876 /templates/admin/index.html | |
parent | 9b0686fef3eccfb477341171a16c8ec8376b4c4c (diff) | |
download | SBHS-2018-Rpi-8d487bfad2bfaf0234c51ec8233d800426e7d23a.tar.gz SBHS-2018-Rpi-8d487bfad2bfaf0234c51ec8233d800426e7d23a.tar.bz2 SBHS-2018-Rpi-8d487bfad2bfaf0234c51ec8233d800426e7d23a.zip |
Fix bug related to context in toggleState
Diffstat (limited to 'templates/admin/index.html')
-rw-r--r-- | templates/admin/index.html | 19 |
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 { |