forked from Adleraci/adlerka.top
Add article creation frontend
This commit is contained in:
@@ -173,6 +173,28 @@ async function initAjax() {
|
||||
await onPageLoad();
|
||||
}
|
||||
|
||||
async function togglearticlecreate(){
|
||||
let articleContainerElement = document.getElementById("articlecreatecontainer");
|
||||
|
||||
articleContainerElement.classList.toggle("hidden");
|
||||
}
|
||||
|
||||
async function submitarticle(){
|
||||
let articleTitleElement = document.getElementById("articletitleinput");
|
||||
let articleBodyElement = document.getElementById("articlebodyinput");
|
||||
await doAction("/newsarticle", {
|
||||
action: "addNewsArticle",
|
||||
title: articleTitleElement,
|
||||
body: articleBodyElement
|
||||
});
|
||||
}
|
||||
|
||||
async function articleInit(){
|
||||
let articleSubmitElement = document.getElementById("articlesubmit");
|
||||
await togglearticlecreate();
|
||||
articleSubmitElement.addEventListener("click", submitarticle);
|
||||
}
|
||||
|
||||
async function onPageLoad() {
|
||||
await restoreUserInfo();
|
||||
let currentSite = localStorage.getItem("currentSite");
|
||||
@@ -189,6 +211,9 @@ async function onPageLoad() {
|
||||
if (currentSite === "home" && currentPage === "account" && isLoggedIn()) {
|
||||
await showDashboardGreeting();
|
||||
}
|
||||
if (currentSite === "news" && currentPage === "index" && isLoggedIn()) {
|
||||
await articleInit();
|
||||
}
|
||||
}
|
||||
|
||||
async function navigateTo(site, page) {
|
||||
|
Reference in New Issue
Block a user