From 34e8fe9b124f305b648fa1f5d8c98692c6dd58ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Marchal?= Date: Sat, 6 Mar 2021 12:30:44 +0100 Subject: [PATCH] Working "tous" filter for places --- scripts/explorer.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/explorer.js b/scripts/explorer.js index 41543f8..cb22b81 100644 --- a/scripts/explorer.js +++ b/scripts/explorer.js @@ -284,11 +284,7 @@ jQuery(document).ready(function($) { $('input[name="' + name + 's"]').change(function() { - // set back array with original available - if (this.checked) - params[name] = originalAvailableOptions[name + "s"]; - else - params[name] = [] + params[name] = []; // remove filter selectedOptions = gatherURLdata(); data = originalData; @@ -330,14 +326,33 @@ jQuery(document).ready(function($) }); } - function visualFilterListItem(name, param) + function visualFilterListItem(name) { + $('input[name="' + name + 's"]').change(function() + { + params[name] = []; // remove filter + if (this.checked) + { + $('select[name="' + name + '"] option[value=""]').prop('selected', true); + $('select[name="' + name + '"]').attr('disabled', 'disabled'); + } + else + $('select[name="' + name + '"]').removeAttr('disabled'); + + selectedOptions = gatherURLdata(); + data = originalData; + filterData(selectedOptions); + availableOptions = []; + availableOptions = gatherData(); + updateMenu(availableOptions); + }); + $('select[name="' + name + '"]').change(function() { if (this.value == "" && name == "place") - param.pop(); + params[name].pop(); else - param.push(this.value); + params[name].push(this.value); selectedOptions = gatherURLdata(); data = originalData; @@ -355,7 +370,8 @@ jQuery(document).ready(function($) visualFilterCheckboxItem("theme"); visualFilterCheckboxItem("dimension"); visualFilterCheckboxItem("help"); - visualFilterListItem("place", paramPlace); + + visualFilterListItem("place"); }); /*********************/