// remove place and tag from url when unnecessary function onSubmit() { $("select[name=place]").each(function() { if ($(this).val() == "") $(this).remove(); }); $("select[name=tag]").each(function() { if ($(this).val() == "") $(this).remove(); }); return true; } jQuery(document).ready(function($) { // get URL parameters urlParams = new URLSearchParams(window.location.search); paramYear = (urlParams.get('years') == null ? urlParams.getAll('year') : urlParams.getAll('years')); paramMonth = (urlParams.get('months') == null ? urlParams.getAll('month') : urlParams.getAll('months')); paramDimension = (urlParams.get('dimensions') == null ? urlParams.getAll('dimension') : urlParams.getAll('dimensions')); paramGenre = (urlParams.get('genres') == null ? urlParams.getAll('genre') : urlParams.getAll('genres')); paramTheme = (urlParams.get('themes') == null ? urlParams.getAll('theme') : urlParams.getAll('themes')); paramPlace = (urlParams.get('places') == null ? urlParams.getAll('place') : urlParams.getAll('places')); paramTag = (urlParams.get('tags') == null ? urlParams.getAll('tag') : urlParams.getAll('tags')); paramPhoto = (urlParams.get('photos') == null ? urlParams.getAll('photo') : urlParams.getAll('photos')); paramHelp = (urlParams.get('helps') == null ? urlParams.getAll('help') : urlParams.getAll('helps')); $.getJSON("data.json", function(data) { /**********/ /** MENU **/ /**********/ var genres = []; var themes = []; var places = []; var tags = []; function generateMenu() { for (i of data) { if (genres.indexOf(i.genre) === -1 && i.genre != "" && i.genre != "—") genres.push(i.genre); if (themes.indexOf(i.theme) === -1 && i.theme != "" && i.theme != "—") themes.push(i.theme); if (places.indexOf(i.place) === -1 && i.place != "" && i.place != "—") places.push(i.place); if (tags.indexOf(i.tags) === -1 && i.tags != "" && i.tags != "—") { splitTags = i.tags.split(", "); for (splitTag of splitTags) { if (tags.indexOf(splitTag) === -1) { tags.push(splitTag); } } } } genres.sort(); themes.sort(); places.sort(Intl.Collator().compare); tags.sort(Intl.Collator().compare); for (genre of genres) { html = '\n'; html += ''; $(".box.genres .item-cont").append(html); } for (theme of themes) { html = '\n'; html += ''; $(".box.themes .item-cont").append(html); } $(".box.places select").append('