Fix "Tous" not filtering visually in explorer

This commit is contained in:
Théo Marchal 2021-03-06 01:22:59 +01:00
parent 44a5f52e94
commit 3fe24e502e

View File

@ -32,6 +32,7 @@ jQuery(document).ready(function($)
paramTag = (urlParams.get('tags') == null ? urlParams.getAll('tag') : urlParams.getAll('tags')); paramTag = (urlParams.get('tags') == null ? urlParams.getAll('tag') : urlParams.getAll('tags'));
paramPhoto = (urlParams.get('photos') == null ? urlParams.getAll('photo') : urlParams.getAll('photos')); paramPhoto = (urlParams.get('photos') == null ? urlParams.getAll('photo') : urlParams.getAll('photos'));
paramHelp = (urlParams.get('helps') == null ? urlParams.getAll('help') : urlParams.getAll('helps')); paramHelp = (urlParams.get('helps') == null ? urlParams.getAll('help') : urlParams.getAll('helps'));
params = { "year": paramYear, "month": paramMonth, "dimension": paramDimension, "genre": paramGenre, "theme": paramTheme, "place": paramPlace, "tag": paramTag, "photo": paramPhoto, "help": paramHelp }
$.getJSON("data.json", function(data) $.getJSON("data.json", function(data)
{ {
@ -183,14 +184,14 @@ jQuery(document).ready(function($)
{ {
selectedYears = []; selectedYears = [];
selectedDimensions = []; selectedDimensions = [];
selectedPhotos = paramPhoto; selectedPhotos = params.photo;
selectedMonths = paramMonth; selectedMonths = params.month;
selectedGenres = paramGenre; selectedGenres = params.genre;
selectedThemes = paramTheme; selectedThemes = params.theme;
selectedPlaces = paramPlace; selectedPlaces = params.place;
selectedTags = paramTag; selectedTags = params.tag;
selectedHelps = paramHelp; selectedHelps = params.help;
for (p of paramYear) for (p of params.year)
{ {
if (p == "50s") for (i = 1956; i <= 1959; i++) selectedYears.push(i); if (p == "50s") for (i = 1956; i <= 1959; i++) selectedYears.push(i);
if (p == "60s") for (i = 1960; i <= 1969; i++) selectedYears.push(i); if (p == "60s") for (i = 1960; i <= 1969; i++) selectedYears.push(i);
@ -200,7 +201,7 @@ jQuery(document).ready(function($)
if (p == "00s") for (i = 2000; i <= 2009; i++) selectedYears.push(i); if (p == "00s") for (i = 2000; i <= 2009; i++) selectedYears.push(i);
if (p == "10s") for (i = 2010; i <= 2016; i++) selectedYears.push(i); if (p == "10s") for (i = 2010; i <= 2016; i++) selectedYears.push(i);
} }
for (p of paramDimension) for (p of params.dimension)
{ {
if (p == "18") for (i = 18; i <= 19; i++) selectedDimensions.push(i); if (p == "18") for (i = 18; i <= 19; i++) selectedDimensions.push(i);
if (p == "20") for (i = 20; i <= 29; i++) selectedDimensions.push(i); if (p == "20") for (i = 20; i <= 29; i++) selectedDimensions.push(i);
@ -279,29 +280,45 @@ jQuery(document).ready(function($)
} }
handleTags(); handleTags();
function visualFilterCheckboxItem(name, param) function visualFilterCheckboxItem(name)
{ {
$('input[name="' + name + 's"]').change(function()
{
// set back array with original available
if (this.checked)
params[name] = originalAvailableOptions[name + "s"];
else
params[name] = []
selectedOptions = gatherURLdata();
data = originalData;
filterData(selectedOptions);
availableOptions = [];
availableOptions = gatherData();
updateMenu(availableOptions);
});
$('input[name="' + name + '"]').change(function() $('input[name="' + name + '"]').change(function()
{ {
if (this.checked) if (this.checked)
{ {
if (this.id == "exist") // photos special case if (this.id == "exist") // photos special case
{ {
param.push("bad"); params[name].push("bad");
param.push("ok"); params[name].push("ok");
param.push("good"); params[name].push("good");
} }
param.push(this.id); params[name].push(this.id);
} }
else else
{ {
if (this.id == "exist") // photos special case if (this.id == "exist") // photos special case
{ {
removeFromArray(param, "bad"); removeFromArray(params[name], "bad");
removeFromArray(param, "ok"); removeFromArray(params[name], "ok");
removeFromArray(param, "good"); removeFromArray(params[name], "good");
} }
removeFromArray(param, this.id); removeFromArray(params[name], this.id);
} }
selectedOptions = gatherURLdata(); selectedOptions = gatherURLdata();
@ -331,14 +348,13 @@ jQuery(document).ready(function($)
}); });
} }
visualFilterCheckboxItem("photo", paramPhoto); visualFilterCheckboxItem("photo");
visualFilterCheckboxItem("year", paramYear); visualFilterCheckboxItem("year");
visualFilterCheckboxItem("month", paramMonth); visualFilterCheckboxItem("month");
visualFilterCheckboxItem("genre", paramGenre); visualFilterCheckboxItem("genre");
visualFilterCheckboxItem("theme", paramTheme); visualFilterCheckboxItem("theme");
visualFilterCheckboxItem("dimension", paramDimension); visualFilterCheckboxItem("dimension");
visualFilterCheckboxItem("help", paramHelp); visualFilterCheckboxItem("help");
visualFilterListItem("place", paramPlace); visualFilterListItem("place", paramPlace);
}); });