Kommentare in main.js
Habe die Kommentare und Beschreibungen der Parameter in Main.js hinzugefügt
This commit is contained in:
parent
9d730633ad
commit
6b141395bf
1 changed files with 28 additions and 2 deletions
|
@ -17,6 +17,10 @@
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', init);
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiale Methode, die alles startet
|
||||||
|
*/
|
||||||
function init() {
|
function init() {
|
||||||
//forceHttps();
|
//forceHttps();
|
||||||
actrivateMessage();
|
actrivateMessage();
|
||||||
|
@ -24,16 +28,26 @@ function init() {
|
||||||
windowReload();
|
windowReload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode stellt das Protokoll fals nötig auf https:// um
|
||||||
|
*/
|
||||||
function forceHttps() {
|
function forceHttps() {
|
||||||
if (location.protocol != 'https:') {
|
if (location.protocol != 'https:') {
|
||||||
location.href = 'https://' + location.hostname + location.pathname;
|
location.href = 'https://' + location.hostname + location.pathname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode lässt die Status-/Fehlermeldung(en) erscheinen
|
||||||
|
*/
|
||||||
function actrivateMessage() {
|
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() {
|
function getFileName() {
|
||||||
let pathname = location.pathname;
|
let pathname = location.pathname;
|
||||||
let fileNameRegEx = /[a-z]+\.[a-z]+/i;
|
let fileNameRegEx = /[a-z]+\.[a-z]+/i;
|
||||||
|
@ -41,12 +55,18 @@ function getFileName() {
|
||||||
return (fileName === null)?'index.php':fileName[0];
|
return (fileName === null)?'index.php':fileName[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode lässt die Status-/Fehlermeldung(en) verschwinden
|
||||||
|
*/
|
||||||
function hideMessage() {
|
function hideMessage() {
|
||||||
if (getFileName() != 'check.php') {
|
if (getFileName() != 'check.php') {
|
||||||
document.querySelectorAll('.modal').forEach((modal) => { modal.style.display = 'none' });
|
document.querySelectorAll('.modal').forEach((modal) => { modal.style.display = 'none' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Methode startet auf der Seite check.php den Countdown
|
||||||
|
*/
|
||||||
function windowReload() {
|
function windowReload() {
|
||||||
if (getFileName() == 'check.php') {
|
if (getFileName() == 'check.php') {
|
||||||
let message = document.querySelector('.message p').innerHTML;
|
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) {
|
function updateMessage(time, message) {
|
||||||
let newTime = time-1;
|
let newTime = time-1;
|
||||||
message = message.replace(time, newTime);
|
message = message.replace(time, newTime);
|
||||||
|
|
Loading…
Reference in a new issue