From: David ‘Bombe’ Roden Date: Sat, 27 Nov 2010 08:30:24 +0000 (+0100) Subject: Move all AJAX handlers to the same directory as the HTML handlers. X-Git-Tag: 0.3.2-RC1~23 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8454806e48890675178c1b4b6cbe4bb9c42b68a3;p=Sone.git Move all AJAX handlers to the same directory as the HTML handlers. This should prevent seemingly strange errors that occured when the HTML session timed out but the AJAX session was still active, preventing you from posting anything because you were not logged in. --- diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java index 0d553cc..9b92249 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreatePostAjaxPage.java @@ -36,7 +36,7 @@ public class CreatePostAjaxPage extends JsonPage { * The Sone web interface */ public CreatePostAjaxPage(WebInterface webInterface) { - super("ajax/createPost.ajax", webInterface); + super("createPost.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java index 486fb75..0181ff2 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/CreateReplyAjaxPage.java @@ -37,7 +37,7 @@ public class CreateReplyAjaxPage extends JsonPage { * The Sone web interface */ public CreateReplyAjaxPage(WebInterface webInterface) { - super("ajax/createReply.ajax", webInterface); + super("createReply.ajax", webInterface); } // diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java index d2a7a39..479e71e 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeletePostAjaxPage.java @@ -36,7 +36,7 @@ public class DeletePostAjaxPage extends JsonPage { * The Sone web interface */ public DeletePostAjaxPage(WebInterface webInterface) { - super("ajax/deletePost.ajax", webInterface); + super("deletePost.ajax", webInterface); } // diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java index 6563a7c..7614de8 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DeleteReplyAjaxPage.java @@ -36,7 +36,7 @@ public class DeleteReplyAjaxPage extends JsonPage { * The Sone web interface */ public DeleteReplyAjaxPage(WebInterface webInterface) { - super("ajax/deleteReply.ajax", webInterface); + super("deleteReply.ajax", webInterface); } // diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java index 44171e3..283e924 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/DismissNotificationAjaxPage.java @@ -35,7 +35,7 @@ public class DismissNotificationAjaxPage extends JsonPage { * The Sone web interface */ public DismissNotificationAjaxPage(WebInterface webInterface) { - super("ajax/dismissNotification.ajax", webInterface); + super("dismissNotification.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java index 5cb03e1..1269b41 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/FollowSoneAjaxPage.java @@ -35,7 +35,7 @@ public class FollowSoneAjaxPage extends JsonPage { * The Sone web interface */ public FollowSoneAjaxPage(WebInterface webInterface) { - super("ajax/followSone.ajax", webInterface); + super("followSone.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java index 58b1265..a8b991d 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetLikesAjaxPage.java @@ -44,7 +44,7 @@ public class GetLikesAjaxPage extends JsonPage { * The Sone web interface */ public GetLikesAjaxPage(WebInterface webInterface) { - super("ajax/getLikes.ajax", webInterface); + super("getLikes.ajax", webInterface); } // diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java index 452fc5a..764c5bf 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java @@ -46,7 +46,7 @@ public class GetPostAjaxPage extends JsonPage { * The template to render for posts */ public GetPostAjaxPage(WebInterface webInterface, Template postTemplate) { - super("ajax/getPost.ajax", webInterface); + super("getPost.ajax", webInterface); this.postTemplate = postTemplate; } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java index 3c43593..77b3ada 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetReplyAjaxPage.java @@ -45,7 +45,7 @@ public class GetReplyAjaxPage extends JsonPage { * The template to render */ public GetReplyAjaxPage(WebInterface webInterface, Template replyTemplate) { - super("ajax/getReply.ajax", webInterface); + super("getReply.ajax", webInterface); this.replyTemplate = replyTemplate; } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java index 8b1612b..c556314 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetStatusAjaxPage.java @@ -52,7 +52,7 @@ public class GetStatusAjaxPage extends JsonPage { * The Sone web interface */ public GetStatusAjaxPage(WebInterface webInterface) { - super("ajax/getStatus.ajax", webInterface); + super("getStatus.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java index 014bc88..36327ca 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTranslationPage.java @@ -34,7 +34,7 @@ public class GetTranslationPage extends JsonPage { * The Sone web interface */ public GetTranslationPage(WebInterface webInterface) { - super("ajax/getTranslation.ajax", webInterface); + super("getTranslation.ajax", webInterface); } // diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java index 17438d4..efd1439 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/LikeAjaxPage.java @@ -36,7 +36,7 @@ public class LikeAjaxPage extends JsonPage { * The Sone web interface */ public LikeAjaxPage(WebInterface webInterface) { - super("ajax/like.ajax", webInterface); + super("like.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java index d1a21d3..6c4ece0 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/LockSoneAjaxPage.java @@ -36,7 +36,7 @@ public class LockSoneAjaxPage extends JsonPage { * The Sone web interface */ public LockSoneAjaxPage(WebInterface webInterface) { - super("ajax/lockSone.ajax", webInterface); + super("lockSone.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/MarkPostAsKnownPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/MarkPostAsKnownPage.java index b44d7f1..c2b0ca3 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MarkPostAsKnownPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MarkPostAsKnownPage.java @@ -35,7 +35,7 @@ public class MarkPostAsKnownPage extends JsonPage { * The Sone web interface */ public MarkPostAsKnownPage(WebInterface webInterface) { - super("ajax/markPostAsKnown.ajax", webInterface); + super("markPostAsKnown.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/MarkReplyAsKnownPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/MarkReplyAsKnownPage.java index 2406c7a..6a4f72b 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/MarkReplyAsKnownPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/MarkReplyAsKnownPage.java @@ -35,7 +35,7 @@ public class MarkReplyAsKnownPage extends JsonPage { * The Sone web interface */ public MarkReplyAsKnownPage(WebInterface webInterface) { - super("ajax/markReplyAsKnown.ajax", webInterface); + super("markReplyAsKnown.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java index 586ab55..c2379e8 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnfollowSoneAjaxPage.java @@ -35,7 +35,7 @@ public class UnfollowSoneAjaxPage extends JsonPage { * The Sone web interface */ public UnfollowSoneAjaxPage(WebInterface webInterface) { - super("ajax/unfollowSone.ajax", webInterface); + super("unfollowSone.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java index fb0445b..e5c933d 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlikeAjaxPage.java @@ -36,7 +36,7 @@ public class UnlikeAjaxPage extends JsonPage { * The Sone web interface */ public UnlikeAjaxPage(WebInterface webInterface) { - super("ajax/unlike.ajax", webInterface); + super("unlike.ajax", webInterface); } /** diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java index 5ea3aa9..02682b2 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/UnlockSoneAjaxPage.java @@ -36,7 +36,7 @@ public class UnlockSoneAjaxPage extends JsonPage { * The Sone web interface */ public UnlockSoneAjaxPage(WebInterface webInterface) { - super("ajax/unlockSone.ajax", webInterface); + super("unlockSone.ajax", webInterface); } /** diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index bded3ce..b7f323e 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -105,7 +105,7 @@ function getTranslation(key, callback) { callback(translations[key]); return; } - $.getJSON("ajax/getTranslation.ajax", {"key": key}, function(data, textStatus) { + $.getJSON("getTranslation.ajax", {"key": key}, function(data, textStatus) { if ((data != null) && data.success) { translations[key] = data.value; callback(data.value); @@ -201,7 +201,7 @@ function enhanceDeleteButton(button, text, deleteCallback) { */ function enhanceDeletePostButton(button, postId, text) { enhanceDeleteButton(button, text, function() { - $.getJSON("ajax/deletePost.ajax", { "post": postId, "formPassword": getFormPassword() }, function(data, textStatus) { + $.getJSON("deletePost.ajax", { "post": postId, "formPassword": getFormPassword() }, function(data, textStatus) { if (data == null) { return; } @@ -232,7 +232,7 @@ function enhanceDeletePostButton(button, postId, text) { */ function enhanceDeleteReplyButton(button, replyId, text) { enhanceDeleteButton(button, text, function() { - $.getJSON("ajax/deleteReply.ajax", { "reply": replyId, "formPassword": $("#sone #formPassword").text() }, function(data, textStatus) { + $.getJSON("deleteReply.ajax", { "reply": replyId, "formPassword": $("#sone #formPassword").text() }, function(data, textStatus) { if (data == null) { return; } @@ -314,7 +314,7 @@ function getReplyTime(element) { } function likePost(postId) { - $.getJSON("ajax/like.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function(data, textStatus) { + $.getJSON("like.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function(data, textStatus) { if ((data == null) || !data.success) { return; } @@ -327,7 +327,7 @@ function likePost(postId) { } function unlikePost(postId) { - $.getJSON("ajax/unlike.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function(data, textStatus) { + $.getJSON("unlike.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function(data, textStatus) { if ((data == null) || !data.success) { return; } @@ -340,7 +340,7 @@ function unlikePost(postId) { } function updatePostLikes(postId) { - $.getJSON("ajax/getLikes.ajax", { "type": "post", "post": postId }, function(data, textStatus) { + $.getJSON("getLikes.ajax", { "type": "post", "post": postId }, function(data, textStatus) { if ((data != null) && data.success) { $("#sone .post#" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0) $("#sone .post#" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes); @@ -352,7 +352,7 @@ function updatePostLikes(postId) { } function likeReply(replyId) { - $.getJSON("ajax/like.ajax", { "type": "reply", "reply" : replyId, "formPassword": getFormPassword() }, function(data, textStatus) { + $.getJSON("like.ajax", { "type": "reply", "reply" : replyId, "formPassword": getFormPassword() }, function(data, textStatus) { if ((data == null) || !data.success) { return; } @@ -365,7 +365,7 @@ function likeReply(replyId) { } function unlikeReply(replyId) { - $.getJSON("ajax/unlike.ajax", { "type": "reply", "reply" : replyId, "formPassword": getFormPassword() }, function(data, textStatus) { + $.getJSON("unlike.ajax", { "type": "reply", "reply" : replyId, "formPassword": getFormPassword() }, function(data, textStatus) { if ((data == null) || !data.success) { return; } @@ -378,7 +378,7 @@ function unlikeReply(replyId) { } function updateReplyLikes(replyId) { - $.getJSON("ajax/getLikes.ajax", { "type": "reply", "reply": replyId }, function(data, textStatus) { + $.getJSON("getLikes.ajax", { "type": "reply", "reply": replyId }, function(data, textStatus) { if ((data != null) && data.success) { $("#sone .reply#" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0) $("#sone .reply#" + replyId + " .status-line .likes span.like-count").text(data.likes); @@ -401,7 +401,7 @@ function updateReplyLikes(replyId) { * parameters: success, error, replyId) */ function postReply(postId, text, callbackFunction) { - $.getJSON("ajax/createReply.ajax", { "formPassword" : getFormPassword(), "post" : postId, "text": text }, function(data, textStatus) { + $.getJSON("createReply.ajax", { "formPassword" : getFormPassword(), "post" : postId, "text": text }, function(data, textStatus) { if (data == null) { /* TODO - show error */ return; @@ -426,7 +426,7 @@ function postReply(postId, text, callbackFunction) { * replyDisplayTime, text, html) */ function getReply(replyId, callbackFunction) { - $.getJSON("ajax/getReply.ajax", { "reply" : replyId }, function(data, textStatus) { + $.getJSON("getReply.ajax", { "reply" : replyId }, function(data, textStatus) { if ((data != null) && data.success) { callbackFunction(data.soneId, data.soneName, data.time, data.displayTime, data.text, data.html); } @@ -549,7 +549,7 @@ function ajaxifyNotification(notification) { return false; }); notification.find("form.dismiss button").click(function() { - $.getJSON("ajax/dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) { + $.getJSON("dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) { /* dismiss in case of error, too. */ notification.slideUp(); }, function(xmlHttpRequest, textStatus, error) { @@ -560,7 +560,7 @@ function ajaxifyNotification(notification) { } function getStatus() { - $.getJSON("ajax/getStatus.ajax", {}, function(data, textStatus) { + $.getJSON("getStatus.ajax", {}, function(data, textStatus) { if ((data != null) && data.success) { /* process Sone information. */ $.each(data.sones, function(index, value) { @@ -668,7 +668,7 @@ function loadNewPost(postId) { return; } loadedPosts[postId] = true; - $.getJSON("ajax/getPost.ajax", { "post" : postId }, function(data, textStatus) { + $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { if (!isIndexPage() && !(isViewSonePage() && (getSoneId() == data.post.sone))) { return; @@ -698,7 +698,7 @@ function loadNewReply(replyId) { return; } loadedReplies[replyId] = true; - $.getJSON("ajax/getReply.ajax", { "reply": replyId }, function(data, textStatus) { + $.getJSON("getReply.ajax", { "reply": replyId }, function(data, textStatus) { /* find post. */ if ((data != null) && data.success) { $("#sone .post#" + data.reply.postId).each(function() { @@ -732,7 +732,7 @@ function markPostAsKnown(postElements) { postElement = this; if ($(postElement).hasClass("new")) { (function(postElement) { - $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) { + $.getJSON("markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) { $(postElement).removeClass("new"); }); })(postElement); @@ -746,7 +746,7 @@ function markReplyAsKnown(replyElements) { replyElement = this; if ($(replyElement).hasClass("new")) { (function(replyElement) { - $.getJSON("ajax/markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function(data, textStatus) { + $.getJSON("markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function(data, textStatus) { $(replyElement).removeClass("new"); }); })(replyElement); @@ -805,7 +805,7 @@ $(document).ready(function() { registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false); $("#sone #update-status").submit(function() { text = $(this).find(":input:enabled").val(); - $.getJSON("ajax/createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) { + $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) { if ((data != null) && data.success) { loadNewPost(data.postId); } @@ -861,7 +861,7 @@ $(document).ready(function() { */ $("#sone .follow").submit(function() { var followElement = this; - $.getJSON("ajax/followSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() { + $.getJSON("followSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() { $(followElement).addClass("hidden"); $(followElement).parent().find(".unfollow").removeClass("hidden"); }); @@ -869,7 +869,7 @@ $(document).ready(function() { }); $("#sone .unfollow").submit(function() { var unfollowElement = this; - $.getJSON("ajax/unfollowSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() { + $.getJSON("unfollowSone.ajax", { "sone": getSoneId(this), "formPassword": getFormPassword() }, function() { $(unfollowElement).addClass("hidden"); $(unfollowElement).parent().find(".follow").removeClass("hidden"); }); @@ -877,7 +877,7 @@ $(document).ready(function() { }); $("#sone .lock").submit(function() { var lockElement = this; - $.getJSON("ajax/lockSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() { + $.getJSON("lockSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() { $(lockElement).addClass("hidden"); $(lockElement).parent().find(".unlock").removeClass("hidden"); }); @@ -885,7 +885,7 @@ $(document).ready(function() { }); $("#sone .unlock").submit(function() { var unlockElement = this; - $.getJSON("ajax/unlockSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() { + $.getJSON("unlockSone.ajax", { "sone" : getSoneId(this), "formPassword" : getFormPassword() }, function() { $(unlockElement).addClass("hidden"); $(unlockElement).parent().find(".lock").removeClass("hidden"); });