Working filters ; cleaning needs to be done

This commit is contained in:
2021-03-03 09:38:55 +01:00
parent fece1eab16
commit 10dea8e993
3 changed files with 145 additions and 37 deletions

View File

@ -1,5 +1,7 @@
function generateMenu(availableOptions)
{
{
console.log("generate menu", availableOptions);
function createPhotoName(photo)
{
if (photo == "none") return "☆ inexistant";
@ -98,7 +100,10 @@ function generateMenu(availableOptions)
$(".box.places select").append('<option value="">Aucun</option');
for (place of availableOptions.places)
{
//console.log(place);
$(".box.places select").append('<option value="' + place + '">' + place + '</option');
}
$(".box.tags select").append('<option value="">Aucun</option');
for (tag of availableOptions.tags)
@ -111,14 +116,44 @@ function updateMenu(availableOptions)
function checkItem(name, array)
{
$('.'+name+' .item-cont span').each(function()
$('.' + name + ' .item-cont span input').each(function()
{
$(this).addClass("filter");
if (!array.includes($(this).prop("value")))
{
if ($(this).prop("value") != "all" && $(this).prop("value") != "exist")
$(this).parent().addClass("filter");
// special case for "exist" in photos
if ($(this).prop("value") == "exist")
{
if (array.includes("none") && ! (array.includes("bad") || array.includes("ok") || array.includes("good")))
$(this).parent().addClass("filter");
else
$(this).parent().removeClass("filter");
if (array.length == 0)
$(this).parent().addClass("filter");
}
}
else
$(this).parent().removeClass("filter");
});
for (a of array)
}
function checkListItem(name, array)
{
$('.' + name + ' select option').each(function()
{
$('.'+name+' .item-cont span input[id="'+a+'"]').parent().removeClass("filter");
}
if (!array.includes($(this).prop("value")))
{
if ($(this).prop("value") != "")
$(this).hide();
}
else
{
console.log("show");
$(this).show();
}
});
}
checkItem("photos", availableOptions.photos);
@ -129,16 +164,11 @@ function updateMenu(availableOptions)
checkItem("dimensions", availableOptions.dimensions);
checkItem("help", availableOptions.helps);
/*$('.photos .item-cont span').each(function()
{
$(this).addClass("filter");
});
for (a of availableOptions.photos)
{
$('.photos .item-cont span input[id="'+a+'"]').parent().removeClass("filter");
}*/
checkListItem("places", availableOptions.places);
checkListItem("tags", availableOptions.tags);
}
function URLGeneration(availableOptions)
{
// populate checkboxes depending on URL
@ -202,8 +232,9 @@ function URLGeneration(availableOptions)
URLlistSelector(".box.tags", "tag", paramTag, availableOptions.tags);
// URL special case for photos with "exist"
if (paramPhoto == "exist")
if (paramPhoto.includes("exist"))
{
console.log("paramPhoto!!!", paramPhoto);
$('input[id="exist"]').prop("checked", true);
$('input[id="bad"]').prop("checked", true); $('input[id="bad"]').prop("disabled", true);
$('input[id="ok"]').prop("checked", true); $('input[id="ok"]').prop("disabled", true);
@ -272,7 +303,7 @@ function userActionHandle(availableOptions)
allCheckBoxSelected("tags", "tag");
allCheckBoxSelected("photos", "photo");
allCheckBoxSelected("helps", "help");
listOptionSelected(".box.places", "place", availableOptions.places);
//listOptionSelected(".box.places", "place", availableOptions.places);
listOptionSelected(".box.tags", "tag", availableOptions.tags);
// special case for photos with "exist"