From 6b141395bf4d5be0e55567f58f2432d8ba3b8d30 Mon Sep 17 00:00:00 2001 From: eichehome Date: Sun, 23 Jan 2022 12:09:51 +0100 Subject: [PATCH] =?UTF-8?q?Kommentare=20in=20main.js=20Habe=20die=20Kommen?= =?UTF-8?q?tare=20und=20Beschreibungen=20der=20Parameter=20in=20Main.js=20?= =?UTF-8?q?hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/main.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index 4cfe1a1..bb22c72 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -14,9 +14,13 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + document.addEventListener('DOMContentLoaded', init); + +/** + * Initiale Methode, die alles startet + */ function init() { //forceHttps(); actrivateMessage(); @@ -24,16 +28,26 @@ function init() { windowReload(); } +/** + * Diese Methode stellt das Protokoll fals nötig auf https:// um + */ function forceHttps() { if (location.protocol != 'https:') { location.href = 'https://' + location.hostname + location.pathname; } } +/** + * Diese Methode lässt die Status-/Fehlermeldung(en) erscheinen + */ function actrivateMessage() { - document.querySelectorAll('.modal').forEach((modal)=>{modal.style.position = 'fixed'}); + document.querySelectorAll('.modal').forEach((modal) => { modal.style.position = 'fixed' }); } +/** + * Diese Methode extrahiert den Dateinamen aus der Adresse + * @returns {string} Der Dateinamen + */ function getFileName() { let pathname = location.pathname; let fileNameRegEx = /[a-z]+\.[a-z]+/i; @@ -41,12 +55,18 @@ function getFileName() { return (fileName === null)?'index.php':fileName[0]; } +/** + * Diese Methode lässt die Status-/Fehlermeldung(en) verschwinden + */ function hideMessage() { if (getFileName() != 'check.php') { document.querySelectorAll('.modal').forEach((modal) => { modal.style.display = 'none' }); } } +/** + * Diese Methode startet auf der Seite check.php den Countdown + */ function windowReload() { if (getFileName() == 'check.php') { let message = document.querySelector('.message p').innerHTML; @@ -57,6 +77,12 @@ function windowReload() { } } +/** + * Diese Funktion ändert die Zeit in der Anzeige des Countdowns und das neuladen der Seite am Ende + * @param {int} time Zeit des Countdowns + * @param {string} message Statusnachricht + * @returns {empty} + */ function updateMessage(time, message) { let newTime = time-1; message = message.replace(time, newTime);