forked from Adleraci/adlerka.top
Make it autorefresh
This commit is contained in:
parent
4b288b48c8
commit
cd46a52f83
@ -1,4 +1,5 @@
|
|||||||
let UserInfo = {};
|
let UserInfo = {};
|
||||||
|
let PageIntervals = [];
|
||||||
|
|
||||||
function isLoggedIn(){
|
function isLoggedIn(){
|
||||||
return UserInfo.Email && UserInfo.Email.length > 0;
|
return UserInfo.Email && UserInfo.Email.length > 0;
|
||||||
@ -179,8 +180,23 @@ async function togglearticlecreate(){
|
|||||||
articleContainerElement.classList.toggle("hidden");
|
articleContainerElement.classList.toggle("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
async function renderarticle(articledata){
|
async function renderarticles(){
|
||||||
|
let template = document.querySelector('template[data-template-name="article"]').content.toString();
|
||||||
|
let articles = await doAction(
|
||||||
|
"/newsarticle",
|
||||||
|
{
|
||||||
|
action: "getNewsArticles"
|
||||||
|
},
|
||||||
|
"Články načítané",
|
||||||
|
"Nastala chyba pri načítavaní článkov",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
let articleout = "";
|
||||||
|
for (const article of articles) {
|
||||||
|
articleout += template.replace("__TEMPLATE_ARTICLE_TITLE__", article.Title).replace("__TEMPLATE_ARTICLE_AUTHOR__", article.WrittenByName).replace("__TEMPLATE_ARTICLE_DATE__", article.WrittenAt).replace("__TEMPLATE_ARTICLE_BODY__", article.Body)
|
||||||
|
}
|
||||||
|
document.getElementById("articleslist").innerHTML = articleout;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submitarticle(){
|
async function submitarticle(){
|
||||||
@ -206,12 +222,18 @@ async function articleInit(){
|
|||||||
togglearticlecreate();
|
togglearticlecreate();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
PageIntervals.push(setInterval(renderarticles, 300000));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onPageLoad() {
|
async function onPageLoad() {
|
||||||
await restoreUserInfo();
|
await restoreUserInfo();
|
||||||
let currentSite = localStorage.getItem("currentSite");
|
let currentSite = localStorage.getItem("currentSite");
|
||||||
let currentPage = localStorage.getItem("currentPage");
|
let currentPage = localStorage.getItem("currentPage");
|
||||||
|
|
||||||
|
for(let interval of PageIntervals) {
|
||||||
|
clearInterval(interval);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentSite === "home" && currentPage === "settings") {
|
if (currentSite === "home" && currentPage === "settings") {
|
||||||
if (document.getElementById("user-settings")) {
|
if (document.getElementById("user-settings")) {
|
||||||
await populateUserInfoFields(UserInfo);
|
await populateUserInfoFields(UserInfo);
|
||||||
|
Loading…
Reference in New Issue
Block a user