This commit is contained in:
David Štaleker
2024-03-12 19:04:38 +01:00
parent dda4b613f8
commit c6d14525de
5 changed files with 128 additions and 4 deletions

View File

@@ -0,0 +1,74 @@
let indexLink = 0;
let links = [];
$(function(){
loadBoard();
});
function loadBoard(){
let guid = $('#inpGuidBoard').val();
$.blockUI();
$.ajax({
type: "GET",
url: "/Boards/View/?handler=Pages",
data: {
guid
},
success: function (data) {
if (data.successful){
indexLink = 0;
links = data.links;
if (links == null || links.length <= 0){
$('.div-placeholder').css('display', 'none');
$('.div-no-pages').css('display', '');
setTryAgainTimer();
} else {
$('.div-placeholder').css('display', '');
$('.div-no-pages').css('display', 'none');
showPage(false);
}
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function setTryAgainTimer(){
}
function showPage(showNext){
if (showNext){
indexLink += 1;
if (indexLink >= links.length){
loadBoard();
return;
}
}
let link = links[indexLink];
$('.div-placeholder').empty();
let element;
if (link.bulletinBoardPage.type == 3){
element = ` <iframe src="${link.bulletinBoardPage.externalLink}" title="page iframe" scrolling='no'></iframe> `;
} else {
let date = new Date();
element = `<img class='img-fluid' src="/bulletin-board-images/pages/${link.bulletinBoardPage.image}?${date.getTime()}" onerror="this.src='/img/imgNotExists.jpg'" alt="page image" />`;
}
$('.div-placeholder').append(element);
setTimeout(function () {
showPage(true);
}, link.duration * 1000);
}