Initial commit
This commit is contained in:
117
alt/script.js
Normal file
117
alt/script.js
Normal file
@@ -0,0 +1,117 @@
|
||||
function pageload(view, meta) { // Funktion zum Laden des Inhalts
|
||||
|
||||
secondaryNavigation("close"); // Schließe das Stecker-Menü
|
||||
page = window.location.hash.substr(1); // Hole die aufzurufende Seite über den URL-Hash (#xy)
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "pagecontent/" + page + ".php?view=" + view + "&meta=" + meta, // Pfad der zu ladenden Seite aufbauen
|
||||
success: function(result){ // Abfrage erfolgreich
|
||||
$("#content").html(result);
|
||||
$("div.navigation>div").removeClass("active"); // Alle Buttons inaktiv
|
||||
$("#" + page).addClass("active"); // Button mit Klasse "page" wird aktiv geschaltet (im Menü)
|
||||
}});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function checkConnection(last) { // Verbindunsstatus überwachen // Last ist der letzte gemessene Netzwerkzustand
|
||||
$.ajax({
|
||||
url: "actions/connection-test.php?a=" + Date.now(), // verändere idr URL leicht, damit der Server nicht cached
|
||||
timeout: 5000, // maximale Wartezeit sind 5 Sekunden; alles darüber wird als zu unzuverlässig angesehen
|
||||
error: function(jqXHR, textStatus, errorThrown) { // Wenn ein Fehler bei der Anfrage auftritt (z.B. Netzwerkprobleme)
|
||||
|
||||
$(".navigation-footer").html('<div class="connection-indicator false"></div>Keine Verbindung<img class="infrago-logo" src="/vendor/DB_InfraGo_logo_red_black_100px_rgb.svg" width="100%" />');
|
||||
console.error("Fehler bei der Anfrage:", textStatus, errorThrown);
|
||||
|
||||
if (last != 1) { // letzter Zustand war "online" // Vermeiden von ständigen Nachrichten
|
||||
message("Keine Verbindung"); // Werfe eine Nachricht
|
||||
}
|
||||
|
||||
setTimeout(function() { // nächste Prüfung in 5 Sekunden
|
||||
checkConnection(1); // der Status offline wird mit übertragen
|
||||
}, 5000);
|
||||
},
|
||||
success: function(data) { // Verbindung iO
|
||||
setTimeout(function() { // nächste Prüfung in 5 Sekunden
|
||||
checkConnection();
|
||||
}, 5000);
|
||||
|
||||
if (data == 'true') { // der Rückgabewert ist true, alles IO
|
||||
$(".navigation-footer").html('<div class="connection-indicator true"></div>Verbunden<img class="infrago-logo" src="/vendor/DB_InfraGo_logo_red_black_100px_rgb.svg" width="100%" />');
|
||||
if (last == 1) { // war der letzte Status noch "offline", wird der Nutzer benachrichtigt
|
||||
message("Verbindung wiederhergestellt!");
|
||||
}
|
||||
} else { // außergewöhnlicher Fehler, aber möglich
|
||||
message("Keine Verbindung"); // Verbindung dennoch unbrauchbar, wenn keine Daten geladen werden
|
||||
$(".navigation-footer").html('<div class="connection-indicator false"></div>Keine Verbindung<img class="infrago-logo" src="/vendor/DB_InfraGo_logo_red_black_100px_rgb.svg" width="100%" />');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function secondaryNavigation(animation, content) {
|
||||
|
||||
|
||||
|
||||
|
||||
if (animation == "open") {
|
||||
|
||||
|
||||
$.get("pagecontent/plug-select.php", {
|
||||
|
||||
|
||||
},
|
||||
function(data, status) {
|
||||
if (status == "success") {
|
||||
if (data != 'false') {
|
||||
$("#navigation-secondary").css("left", "250px");
|
||||
$(".navigation-header").attr("onclick", "secondaryNavigation('close','plug-select')");
|
||||
setTimeout(function() {
|
||||
$("#navigation-secondary").html(data);
|
||||
console.log(data);
|
||||
}, 200);
|
||||
} else {
|
||||
window.location.href = "#";
|
||||
|
||||
alert("Die Inhalte konnten nicht abgerufen werden. Vergewissern Sie sich, dass Sie mit dem WLAN-Netzwerk verbunden sind und laden Sie bei Bedarf die Seite neu.");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
$("#navigation-secondary").css("left", "-250px");
|
||||
$(".navigation-header").attr("onclick", "secondaryNavigation('open','plug-select')");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function message(content) {
|
||||
$("#message-box").html(content);
|
||||
$("#message-box").css("display", "block");
|
||||
setTimeout(function() {
|
||||
$("#message-box").css("transform", "translateY(0)");
|
||||
}, 50);
|
||||
setTimeout(function() {
|
||||
setTimeout(function() {
|
||||
$("#message-box").css("display", "none");
|
||||
}, 500);
|
||||
$("#message-box").css("transform", "translateY(calc(100% + 5px))");
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$(window).bind('beforeunload', function() {
|
||||
$("#warning").css("display", "block");
|
||||
return 'Are you sure you want to leave?';
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user