From ac95ba5b608cdce8f9fc632dbf1156f1707a3958 Mon Sep 17 00:00:00 2001 From: bruno Date: Thu, 22 Feb 2024 10:43:18 +0100 Subject: [PATCH] Add article creation frontend --- assets/script.js | 25 +++++++++++++++++++++++++ assets/style.css | 18 ++++++++++++++++++ templates/newsArticles.html | 13 ++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/assets/script.js b/assets/script.js index f0ffddb..faebc9e 100644 --- a/assets/script.js +++ b/assets/script.js @@ -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) { diff --git a/assets/style.css b/assets/style.css index a7c6249..a9dc5cb 100644 --- a/assets/style.css +++ b/assets/style.css @@ -364,4 +364,22 @@ body:has(.ye-span:hover) { background: url('/assets/images/ye.jpg') !important; background-repeat: repeat !important; background-size: 10% !important; +} + +#articlecreate { + position: fixed; + border: 5px solid var(--primary); + z-index: 5; +} + +#articlecreatecontainer{ + position: fixed; + width: 100vw; + height: 100vh; + z-index: 4; + backdrop-filter: blur(2px); +} + +.hidden { + display: none !important; } \ No newline at end of file diff --git a/templates/newsArticles.html b/templates/newsArticles.html index 8645f78..542be55 100644 --- a/templates/newsArticles.html +++ b/templates/newsArticles.html @@ -1,6 +1,17 @@

Adlerka študentské news

+
- __TEMPLATE__ARTICLES_HERE__
+
+ __TEMPLATE__ARTICLES_HERE__ +
+ +