2021-01-24 14:43:02 +00:00
|
|
|
jQuery(document).ready(function($)
|
|
|
|
{
|
|
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
|
|
const pageId = urlParams.get('number');
|
2021-02-10 21:21:02 +00:00
|
|
|
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
|
2021-01-24 14:43:02 +00:00
|
|
|
|
|
|
|
$.getJSON("data.json", function(data)
|
|
|
|
{
|
2021-02-10 21:21:02 +00:00
|
|
|
if (!data[i]) // the number specified in URL does not exist
|
|
|
|
{
|
|
|
|
$(".container").css("display", "none");
|
|
|
|
$("#info").css("display", "none");
|
|
|
|
$("article").append('<p class="center">Aucun tableau n\'existe pour cet index.</p>');
|
|
|
|
}
|
|
|
|
|
|
|
|
function GetNumber()
|
|
|
|
{
|
|
|
|
if (data[i].number > 1000)
|
|
|
|
return "Inédit";
|
|
|
|
return data[i].number;
|
|
|
|
}
|
|
|
|
|
2021-01-24 14:43:02 +00:00
|
|
|
// page title
|
2021-02-10 21:21:02 +00:00
|
|
|
$("head title").append(GetNumber());
|
2021-01-24 14:43:02 +00:00
|
|
|
|
|
|
|
// photo
|
|
|
|
if (data[i].photo != "none")
|
|
|
|
$(".photo img").attr("src", "photos/paintings/normal/" + data[i].number + ".jpg");
|
|
|
|
else
|
2021-02-12 19:53:40 +00:00
|
|
|
$(".photo img").attr("src", "images/unknown.jpg");
|
|
|
|
$(".photo img").attr("alt", "Tableau " + data[i].number);
|
2021-01-24 14:43:02 +00:00
|
|
|
|
|
|
|
// metadata
|
2021-02-10 21:21:02 +00:00
|
|
|
$(".metadata .content.number").append(GetNumber());
|
2021-02-10 17:39:46 +00:00
|
|
|
if (data[i].month != "—")
|
|
|
|
$(".metadata .content.date").append(data[i].month + " " + data[i].year);
|
|
|
|
else
|
|
|
|
$(".metadata .content.date").append(data[i].year);
|
2021-02-11 13:12:57 +00:00
|
|
|
|
2021-01-24 14:43:02 +00:00
|
|
|
$(".metadata .content.dimension").append(data[i].dimension);
|
|
|
|
$(".metadata .content.support").append(data[i].support);
|
2021-02-10 17:39:46 +00:00
|
|
|
$(".metadata .content.genre").append(data[i].genre);
|
2021-01-24 14:43:02 +00:00
|
|
|
$(".metadata .content.theme").append(data[i].theme);
|
|
|
|
$(".metadata .content.place").append(data[i].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";
|
|
|
|
$(".metadata .content.photo").append(photoState);
|
|
|
|
|
2021-02-10 17:39:46 +00:00
|
|
|
if (data[i].help == "yes")
|
|
|
|
$(".metadata .content.help").append('<a href="informations.html"><strong>oui (!)</strong></a>');
|
|
|
|
else
|
|
|
|
$(".metadata .content.help").append("non");
|
2021-01-24 14:43:02 +00:00
|
|
|
|
2021-02-11 13:12:57 +00:00
|
|
|
if (data[i].tags != "—")
|
|
|
|
$(".metadata .content.tag").append(data[i].tags);
|
|
|
|
else
|
|
|
|
$(".metadata .content.tag").parent().css("display", "none");
|
|
|
|
|
|
|
|
if (data[i].comment != "—")
|
|
|
|
$(".metadata .content.comment").append(data[i].comment);
|
|
|
|
else
|
|
|
|
$(".metadata .content.comment").parent().css("display", "none");
|
2021-01-24 14:43:02 +00:00
|
|
|
|
|
|
|
if (data[i].photo != "none")
|
|
|
|
$(".metadata .content.original a").attr("href", "photos/paintings/original/" + data[i].number + ".jpg");
|
|
|
|
else
|
|
|
|
$(".metadata .content.original").parent().css("display", "none");
|
|
|
|
|
|
|
|
// cartel
|
|
|
|
$("#info .title").append(data[i].title);
|
2021-02-10 17:39:46 +00:00
|
|
|
if (data[i].month != "—")
|
|
|
|
$("#info .year").append(data[i].month + " " + data[i].year);
|
|
|
|
else
|
|
|
|
$("#info .year").append(data[i].year);
|
2021-02-11 13:12:57 +00:00
|
|
|
|
|
|
|
format = data[i].paint + " sur " + data[i].support.toLowerCase();
|
|
|
|
|
|
|
|
if (data[i].dimension != "—")
|
|
|
|
format += " (" + data[i].dimension + ")";
|
2021-01-24 14:43:02 +00:00
|
|
|
$("#info .format").append(format);
|
2021-02-11 13:12:57 +00:00
|
|
|
|
|
|
|
if (data[i].comment != "—")
|
|
|
|
$("#info .comment").prepend(data[i].comment);
|
|
|
|
else
|
|
|
|
$("#info .comment").css("display", "none");
|
2021-01-24 14:43:02 +00:00
|
|
|
});
|
|
|
|
});
|