From 13631eac935823b8ff835cf5f23e90e43e66b6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=AD=C3=B0ir=20Valberg=20Gu=C3=B0mundsson?= Date: Fri, 21 Apr 2017 19:09:46 +0200 Subject: [PATCH] Now also mark the filters accordingly to URL. --- .../static/js/event_instance_websocket.js | 18 ++++++++++ src/program/templates/schedule_base.html | 6 ++-- src/program/views.py | 35 ------------------- src/static_src/css/bornhack.css | 2 ++ 4 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/program/static/js/event_instance_websocket.js b/src/program/static/js/event_instance_websocket.js index e76ddf84..7619ceab 100644 --- a/src/program/static/js/event_instance_websocket.js +++ b/src/program/static/js/event_instance_websocket.js @@ -82,6 +82,7 @@ webSocketBridge.listen(function(payload, stream) { var location_parameter = findGetParameter('location') var locations = location_parameter != null ? location_parameter.split(',') : []; + toggleFilterBoxes(types, locations); render_schedule(types, locations); } }); @@ -220,3 +221,20 @@ filter.addEventListener('change', function(e) { render_schedule(types, event_locations); }); +function toggleFilterBoxes(types, locations) { + var type_input = Array.prototype.slice.call(document.querySelectorAll('.event-type-checkbox')); + type_input.map(function(box) { + if(types.includes(box.value)) { + box.checked = !box.checked; + } + return box; + }); + var location_input = Array.prototype.slice.call(document.querySelectorAll('.location-checkbox')); + location_input.map(function(box) { + if(locations.includes(box.value)) { + box.checked = !box.checked; + } + return box; + }); +} + diff --git a/src/program/templates/schedule_base.html b/src/program/templates/schedule_base.html index e9fa8f63..0bb7d31d 100644 --- a/src/program/templates/schedule_base.html +++ b/src/program/templates/schedule_base.html @@ -33,8 +33,7 @@ name="event-type-{{ type.slug }}" id="event-type-{{ type.slug }}" value="{{ type.slug }}" - class="form-control event-type-checkbox" - checked /> + class="form-control event-type-checkbox" />