jsonReply.put("postSone", reply.getPost().getSone().getId());
jsonReplies.add(jsonReply);
}
- return createSuccessJsonObject().put("sones", jsonSones).put("notifications", jsonNotificationInformations).put("newPosts", jsonPosts).put("newReplies", jsonReplies);
+ return createSuccessJsonObject().put("loggedIn", currentSone != null).put("sones", jsonSones).put("notifications", jsonNotificationInformations).put("newPosts", jsonPosts).put("newReplies", jsonReplies);
}
/**
successCallback(data, textStatus);
}
}, "error": function(xmlHttpRequest, textStatus, errorThrown) {
+ if (xmlHttpRequest.status == 403) {
+ notLoggedIn = true;
+ }
if (typeof errorCallback != "undefined") {
errorCallback();
} else {
$.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");
*/
function ajaxError() {
online = false;
- toggleOfflineMarker(true);
+ showOfflineMarker(true);
if (!statusRequestQueued) {
setTimeout(getStatus, 5000);
statusRequestQueued = true;
*/
function ajaxSuccess() {
online = true;
- toggleOfflineMarker(false);
+ showOfflineMarker(!online || (initiallyLoggedIn && notLoggedIn));
}
/**
* {@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) {
var focus = true;
var online = true;
+var initiallyLoggedIn = $("#sone #loggedIn").text() == "true";
+var notLoggedIn = !initiallyLoggedIn;
$(document).ready(function() {