X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=c9d51c4f3cf76f8219a7b335bac08edb8d794bfa;hp=e07a08b982ebd4e30b0b396a72dc9eeaaa085319;hb=701569d76dbf1916125d5cf81fb2b65c6976d6d7;hpb=c60c3423fc6653c7f2f220b4ee409037367132bc diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index e07a08b..c9d51c4 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -8,6 +8,9 @@ function ajaxGet(url, data, successCallback, errorCallback) { successCallback(data, textStatus); } }, "error": function(xmlHttpRequest, textStatus, errorThrown) { + if (xmlHttpRequest.status == 403) { + notLoggedIn = true; + } if (typeof errorCallback != "undefined") { errorCallback(); } else { @@ -976,6 +979,10 @@ function getStatus() { $.each(data.sones, function(index, value) { updateSoneStatus(value.id, value.name, value.status, value.modified, value.locked, value.lastUpdatedUnknown ? null : value.lastUpdated, value.lastUpdatedText); }); + notLoggedIn = !data.loggedIn; + if (!notLoggedIn) { + showOfflineMarker(!online); + } /* search for removed notifications. */ $("#sone #notification-area .notification").each(function() { notificationId = $(this).attr("id"); @@ -1586,7 +1593,7 @@ var statusRequestQueued = true; */ function ajaxError() { online = false; - toggleOfflineMarker(true); + showOfflineMarker(true); if (!statusRequestQueued) { setTimeout(getStatus, 5000); statusRequestQueued = true; @@ -1598,7 +1605,7 @@ function ajaxError() { */ function ajaxSuccess() { online = true; - toggleOfflineMarker(false); + showOfflineMarker(!online || (initiallyLoggedIn && notLoggedIn)); } /** @@ -1608,7 +1615,7 @@ function ajaxSuccess() { * {@code true} to display the offline marker, {@code false} to hide * it */ -function toggleOfflineMarker(visible) { +function showOfflineMarker(visible) { /* jQuery documentation says toggle() works the other way around?! */ $("#sone #offline-marker").toggle(visible); if (visible) { @@ -1624,6 +1631,8 @@ function toggleOfflineMarker(visible) { var focus = true; var online = true; +var initiallyLoggedIn = $("#sone #loggedIn").text() == "true"; +var notLoggedIn = !initiallyLoggedIn; $(document).ready(function() {