X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=db081970116230ea028cf02525cbce26fd4c5935;hb=0e692c966f8f3937b490949aa9d04b103a22b612;hp=8065b73d6da01d59fe1011c93eea5593a70822be;hpb=403bcebd8de71dcb793c3f15138bc2df6431ae06;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 8065b73..db08197 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -277,7 +277,7 @@ function getFormPassword() { */ function getSone(soneId) { return $("#sone .sone").filter(function(index) { - return $(".id").text() == soneId; + return $(".id", this).text() == soneId; }); } @@ -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() { @@ -1115,6 +1115,17 @@ function isIndexPage() { } /** + * Returns the current page of the selected pagination. + * + * @param paginationSelector + * The pagination selector + * @returns The current page of the pagination + */ +function getPage(paginationSelector) { + return $(".current-page", paginationSelector).text(); +} + +/** * Returns whether the current page is a “view Sone” page. * * @returns {Boolean} true if the current page is a “view Sone” @@ -1280,11 +1291,10 @@ function loadNewReply(replyId, soneId, postId, postSoneId) { * request */ function markSoneAsKnown(soneElement, skipRequest) { - if ($(".new", soneElement).length > 0) { - if ((typeof skipRequest != "undefined") && !skipRequest) { - $.getJSON("maskAsKnown.ajax", {"formPassword": getFormPassword(), "type": "sone", "id": getSoneId(soneElement)}, function(data, textStatus) { - $(soneElement).removeClass("new"); - }); + if ($(soneElement).is(".new")) { + $(soneElement).removeClass("new"); + if ((typeof skipRequest == "undefined") || !skipRequest) { + $.getJSON("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "sone", "id": getSoneId(soneElement)}); } } } @@ -1692,6 +1702,11 @@ $(document).ready(function() { ajaxifyNotification($(this)); }); + /* disable all permalinks. */ + $(".permalink").click(function() { + return false; + }); + /* activate status polling. */ setTimeout(getStatus, 5000);