X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=6ffa7ed359df29a24b8ee5133847ff3238d89f08;hb=233e75f9b59f1f3bed73422d5958d07bf659ad27;hp=b6987c369539217025dce8fba76fee93d07e0392;hpb=701e2dedb4d32876e6bfd0761edb4603889d8661;p=Sone.git
diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js
index b6987c3..6ffa7ed 100644
--- a/src/main/resources/static/javascript/sone.js
+++ b/src/main/resources/static/javascript/sone.js
@@ -17,7 +17,7 @@ jQuery.prototype.getJSON = function(url, data, successCallback, errorCallback) {
success: successCallback,
url: url
});
-}
+};
function isOnline() {
return $("#sone").hasClass("online");
@@ -456,7 +456,7 @@ function unlikePost(postId) {
function updatePostLikes(postId) {
$.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").toggleClass("hidden", data.likes == 0);
$("#sone .post#" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes);
$("#sone .post#" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones));
}
@@ -594,7 +594,7 @@ function unbookmarkPost(postId) {
function updateReplyLikes(replyId) {
$.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").toggleClass("hidden", data.likes == 0);
$("#sone .reply#" + replyId + " .status-line .likes span.like-count").text(data.likes);
$("#sone .reply#" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones));
}
@@ -769,7 +769,7 @@ function ajaxifyPost(postElement) {
});
/* add âcommentâ link. */
- addCommentLink(getPostId(postElement), getPostAuthor(postElement), postElement, $(postElement).find(".post-status-line .time"));
+ addCommentLink(getPostId(postElement), getPostAuthor(postElement), postElement, $(postElement).find(".post-status-line .permalink-author"));
/* process all replies. */
replyIds = [];
@@ -829,7 +829,7 @@ function ajaxifyReply(replyElement) {
});
});
})(replyElement);
- addCommentLink(getPostId(replyElement), getReplyAuthor(replyElement), replyElement, $(replyElement).find(".reply-status-line .time"));
+ addCommentLink(getPostId(replyElement), getReplyAuthor(replyElement), replyElement, $(replyElement).find(".reply-status-line .permalink-author"));
/* convert âshow sourceâ link into javascript function. */
$(replyElement).find(".show-reply-source").each(function() {
@@ -878,7 +878,7 @@ function ajaxifyNotification(notification) {
if (linkElement.is("[href^='viewPost']")) {
id = linkElement.attr("class").substr(5);
if (hasPost(id)) {
- linkElement.attr("href", "#post-" + id);
+ linkElement.attr("href", "#post-" + id).addClass("in-page-link");
}
}
});
@@ -923,8 +923,8 @@ function checkForRemovedSones(oldNotification, newNotification) {
if (getNotificationId(oldNotification) != "new-sone-notification") {
return;
}
- oldIds = getElementIds(oldNotification, ".sone-id");
- newIds = getElementIds(newNotification, ".sone-id");
+ oldIds = getElementIds(oldNotification, ".new-sone-id");
+ newIds = getElementIds(newNotification, ".new-sone-id");
$.each(oldIds, function(index, value) {
if ($.inArray(value, newIds) == -1) {
markSoneAsKnown(getSone(value), true);
@@ -978,7 +978,7 @@ function checkForRemovedReplies(oldNotification, newNotification) {
}
function getStatus() {
- $.getJSON("getStatus.ajax", {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) {
+ $.getJSON("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) {
if ((data != null) && data.success) {
/* process Sone information. */
$.each(data.sones, function(index, value) {
@@ -996,7 +996,7 @@ function getStatus() {
});
if (!foundNotification) {
if (notificationId == "new-sone-notification") {
- $(".sone-id", this).each(function(index, element) {
+ $(".new-sone-id", this).each(function(index, element) {
soneId = $(this).text();
markSoneAsKnown(getSone(soneId), true);
});
@@ -1048,7 +1048,7 @@ function getStatus() {
}, function(xmlHttpRequest, textStatus, error) {
/* something really bad happend, wait a minute. */
setTimeout(getStatus, 60000);
- })
+ });
}
/**
@@ -1081,7 +1081,7 @@ function loadNotifications(notificationIds) {
notification.slideDown();
setActivity();
}
- })
+ });
});
}
@@ -1115,6 +1115,22 @@ function isIndexPage() {
}
/**
+ * Returns the current page of the selected pagination. If no pagination can be
+ * found with the given selector, {@code 1} is returned.
+ *
+ * @param paginationSelector
+ * The pagination selector
+ * @returns The current page of the pagination
+ */
+function getPage(paginationSelector) {
+ pagination = $(paginationSelector);
+ if (pagination.length > 0) {
+ return $(".current-page", paginationSelector).text();
+ }
+ return 1;
+}
+
+/**
* Returns whether the current page is a âview Soneâ page.
*
* @returns {Boolean} true
if the current page is a âview Soneâ
@@ -1192,7 +1208,7 @@ function loadNewPost(postId, soneId, recipientId, time) {
if (hasPost(postId)) {
return;
}
- if (!isIndexPage()) {
+ if (!isIndexPage() || (getPage(".pagination-index") > 1)) {
if (!isViewPostPage() || (getShownPostId() != postId)) {
if (!isViewSonePage() || ((getShownSoneId() != soneId) && (getShownSoneId() != recipientId))) {
return;
@@ -1207,7 +1223,7 @@ function loadNewPost(postId, soneId, recipientId, time) {
if (hasPost(data.post.id)) {
return;
}
- if (!isIndexPage() && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) {
+ if ((!isIndexPage() || (getPage(".pagination-index") > 1)) && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) {
return;
}
var firstOlderPost = null;
@@ -1478,7 +1494,7 @@ function changeIcon(iconUrl) {
function createNotification(id, lastUpdatedTime, text, dismissable) {
notification = $("