Fix painting not working with filter
This commit is contained in:
parent
3a964098e7
commit
35b1e06dfc
@ -2,14 +2,17 @@ jQuery(document).ready(function($)
|
||||
{
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const pageId = urlParams.get('number');
|
||||
if (pageId > 1000)
|
||||
i = pageId - 1000 + 383 - 1; // inédit: index starts at 1000 // 383: total number of paintings except inédit
|
||||
else
|
||||
i = pageId - 1; // index is 0
|
||||
|
||||
$.getJSON("data.json", function(data)
|
||||
{
|
||||
if (!data[i]) // the number specified in URL does not exist
|
||||
var idx = 0; // search the index of the painting of filtered data
|
||||
for (i = 0; i < data.length; i++)
|
||||
{
|
||||
if (data[i].number == pageId)
|
||||
idx = i;
|
||||
}
|
||||
|
||||
if (!data[idx]) // the number specified in URL does not exist
|
||||
{
|
||||
$(".container").css("display", "none");
|
||||
$("#info").css("display", "none");
|
||||
@ -18,75 +21,75 @@ jQuery(document).ready(function($)
|
||||
|
||||
function GetNumber()
|
||||
{
|
||||
if (data[i].number > 1000)
|
||||
if (data[idx].number > 1000)
|
||||
return "Inédit";
|
||||
return data[i].number;
|
||||
return data[idx].number;
|
||||
}
|
||||
|
||||
// page title
|
||||
$("head title").append(GetNumber());
|
||||
|
||||
// photo
|
||||
if (data[i].photo != "none")
|
||||
$(".photo img").attr("src", "photos/paintings/normal/" + data[i].number + ".jpg");
|
||||
if (data[idx].photo != "none")
|
||||
$(".photo img").attr("src", "photos/paintings/normal/" + data[idx].number + ".jpg");
|
||||
else
|
||||
$(".photo img").attr("src", "images/unknown.jpg");
|
||||
$(".photo img").attr("alt", "Tableau " + data[i].number);
|
||||
$(".photo img").attr("alt", "Tableau " + data[idx].number);
|
||||
|
||||
// metadata
|
||||
$(".metadata .content.number").append(GetNumber());
|
||||
if (data[i].month != "—")
|
||||
$(".metadata .content.date").append(data[i].month + " " + data[i].year);
|
||||
if (data[idx].month != "—")
|
||||
$(".metadata .content.date").append(data[idx].month + " " + data[idx].year);
|
||||
else
|
||||
$(".metadata .content.date").append(data[i].year);
|
||||
$(".metadata .content.date").append(data[idx].year);
|
||||
|
||||
$(".metadata .content.dimension").append(data[i].dimension);
|
||||
$(".metadata .content.support").append(data[i].support);
|
||||
$(".metadata .content.genre").append(data[i].genre);
|
||||
$(".metadata .content.theme").append(data[i].theme);
|
||||
$(".metadata .content.place").append(data[i].place);
|
||||
$(".metadata .content.dimension").append(data[idx].dimension);
|
||||
$(".metadata .content.support").append(data[idx].support);
|
||||
$(".metadata .content.genre").append(data[idx].genre);
|
||||
$(".metadata .content.theme").append(data[idx].theme);
|
||||
$(".metadata .content.place").append(data[idx].place);
|
||||
|
||||
if (data[i].photo == "none") photoState = "aucune";
|
||||
if (data[i].photo == "bad") photoState = "mauvais";
|
||||
if (data[i].photo == "ok") photoState = "acceptable";
|
||||
if (data[i].photo == "good") photoState = "bon";
|
||||
if (data[idx].photo == "none") photoState = "aucune";
|
||||
if (data[idx].photo == "bad") photoState = "mauvais";
|
||||
if (data[idx].photo == "ok") photoState = "acceptable";
|
||||
if (data[idx].photo == "good") photoState = "bon";
|
||||
$(".metadata .content.photo").append(photoState);
|
||||
|
||||
if (data[i].help == "yes")
|
||||
if (data[idx].help == "yes")
|
||||
$(".metadata .content.help").append('<a href="informations.html"><strong>oui (!)</strong></a>');
|
||||
else
|
||||
$(".metadata .content.help").append("non");
|
||||
|
||||
if (data[i].tags != "—")
|
||||
$(".metadata .content.tag").append(data[i].tags);
|
||||
if (data[idx].tags != "—")
|
||||
$(".metadata .content.tag").append(data[idx].tags);
|
||||
else
|
||||
$(".metadata .content.tag").parent().css("display", "none");
|
||||
|
||||
if (data[i].comment != "—")
|
||||
$(".metadata .content.comment").append(data[i].comment);
|
||||
if (data[idx].comment != "—")
|
||||
$(".metadata .content.comment").append(data[idx].comment);
|
||||
else
|
||||
$(".metadata .content.comment").parent().css("display", "none");
|
||||
|
||||
if (data[i].photo != "none")
|
||||
$(".metadata .content.original a").attr("href", "photos/paintings/original/" + data[i].number + ".jpg");
|
||||
if (data[idx].photo != "none")
|
||||
$(".metadata .content.original a").attr("href", "photos/paintings/original/" + data[idx].number + ".jpg");
|
||||
else
|
||||
$(".metadata .content.original").parent().css("display", "none");
|
||||
|
||||
// cartel
|
||||
$("#info .title").append(data[i].title);
|
||||
if (data[i].month != "—")
|
||||
$("#info .year").append(data[i].month + " " + data[i].year);
|
||||
$("#info .title").append(data[idx].title);
|
||||
if (data[idx].month != "—")
|
||||
$("#info .year").append(data[idx].month + " " + data[idx].year);
|
||||
else
|
||||
$("#info .year").append(data[i].year);
|
||||
$("#info .year").append(data[idx].year);
|
||||
|
||||
format = data[i].paint + " sur " + data[i].support.toLowerCase();
|
||||
format = data[idx].paint + " sur " + data[idx].support.toLowerCase();
|
||||
|
||||
if (data[i].dimension != "—")
|
||||
format += " (" + data[i].dimension + ")";
|
||||
if (data[idx].dimension != "—")
|
||||
format += " (" + data[idx].dimension + ")";
|
||||
$("#info .format").append(format);
|
||||
|
||||
if (data[i].comment != "—")
|
||||
$("#info .comment").prepend(data[i].comment);
|
||||
if (data[idx].comment != "—")
|
||||
$("#info .comment").prepend(data[idx].comment);
|
||||
else
|
||||
$("#info .comment").css("display", "none");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user