106 lines
4.2 KiB
JavaScript
106 lines
4.2 KiB
JavaScript
jQuery(document).ready(function($)
|
|
{
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const pageId = urlParams.get('number');
|
|
|
|
$.getJSON("data.json", function(data)
|
|
{
|
|
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");
|
|
$("article").append('<p class="center">Aucun tableau n\'existe pour cet index.</p>');
|
|
}
|
|
|
|
function GetNumber()
|
|
{
|
|
if (data[idx].number > 1000)
|
|
return "Inédit";
|
|
return data[idx].number;
|
|
}
|
|
|
|
// page title
|
|
$("head title").append(GetNumber());
|
|
|
|
// photo
|
|
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[idx].number);
|
|
|
|
// metadata
|
|
$(".metadata .content.number").append(GetNumber());
|
|
if (data[idx].month != "—")
|
|
$(".metadata .content.date").append(data[idx].month + " " + data[idx].year);
|
|
else
|
|
$(".metadata .content.date").append(data[idx].year);
|
|
|
|
$(".metadata .content.dimension").append(data[idx].dimension);
|
|
$(".metadata .content.support").append(data[idx].support);
|
|
$(".metadata .content.genre").append('<a href="explorer.html?genre='+ data[idx].genre +'">' + data[idx].genre + '</a>');
|
|
$(".metadata .content.theme").append('<a href="explorer.html?theme='+ data[idx].theme +'">' + data[idx].theme + '</a>');
|
|
$(".metadata .content.place").append('<a href="explorer.html?place='+ data[idx].place +'">' + data[idx].place + '</a>');
|
|
|
|
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('<a href="explorer.html?photo='+ data[idx].photo +'">' + photoState + '</a>');
|
|
|
|
if (data[idx].help == "yes")
|
|
$(".metadata .content.help").append('<a class="metadata-help" href="informations.html">oui (!)</a>');
|
|
else
|
|
$(".metadata .content.help").append("non");
|
|
|
|
// split tags to have a link to each one of them
|
|
if (data[idx].tags != "—")
|
|
{
|
|
var splitTags = data[idx].tags.split(", ");
|
|
splitTags.forEach(function(tag, idx, array)
|
|
{
|
|
$(".metadata .content.tag").append('<a href="explorer.html?tag='+ tag +'">' + tag + '</a>');
|
|
|
|
if (idx != array.length - 1)
|
|
$(".metadata .content.tag").append(', ');
|
|
});
|
|
}
|
|
else
|
|
$(".metadata .content.tag").parent().css("display", "none");
|
|
|
|
if (data[idx].comment != "—")
|
|
$(".metadata .content.comment").append(data[idx].comment);
|
|
else
|
|
$(".metadata .content.comment").parent().css("display", "none");
|
|
|
|
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[idx].title);
|
|
if (data[idx].month != "—")
|
|
$("#info .year").append(data[idx].month + " " + data[idx].year);
|
|
else
|
|
$("#info .year").append(data[idx].year);
|
|
|
|
format = data[idx].paint + " sur " + data[idx].support.toLowerCase();
|
|
|
|
if (data[idx].dimension != "—")
|
|
format += " (" + data[idx].dimension + ")";
|
|
$("#info .format").append(format);
|
|
|
|
if (data[idx].comment != "—")
|
|
$("#info .comment").prepend(data[idx].comment);
|
|
else
|
|
$("#info .comment").css("display", "none");
|
|
});
|
|
}); |