LocalStorage used for Explorer view

This commit is contained in:
Théo Marchal 2022-08-04 14:15:51 +02:00
parent 5ed5aff945
commit 8d39956724
2 changed files with 32 additions and 1 deletions

View File

@ -32,6 +32,7 @@ jQuery(document).ready(function($)
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'));
paramView = (urlParams.get('view'));
params = { "year": paramYear, "month": paramMonth, "dimension": paramDimension, "genre": paramGenre, "theme": paramTheme, "place": paramPlace, "tag": paramTag, "photo": paramPhoto, "help": paramHelp }
$.getJSON("data.json", function(data)
@ -522,6 +523,35 @@ jQuery(document).ready(function($)
$("article.explorer p.result").css("display", "none");
}
function setGallery()
{
$("table").hide();
$("#gallery").show();
window.localStorage.setItem('explorer-view', 'gallery');
}
function setTable()
{
$("#gallery").hide();
$("table").show();
window.localStorage.setItem('explorer-view', 'table');
}
if (paramView == "gallery")
setGallery();
else if (paramView == "table")
setTable();
else
{
if (res)
{
explorerView = window.localStorage.getItem('explorer-view');
if (explorerView == "gallery")
setGallery();
else if (explorerView == "table")
setTable();
}
}
// fancybox configuration
$.getScript("scripts/fancybox.js", function() {

View File

@ -335,16 +335,17 @@ function userActionHandle(availableOptions)
}
// change display: gallery/table
$(".style-select.frame").click(function()
{
$("table").hide();
$("#gallery").show();
window.localStorage.setItem('explorer-view', 'gallery');
});
$(".style-select.list").click(function()
{
$("#gallery").hide();
$("table").show();
window.localStorage.setItem('explorer-view', 'table');
});
}