X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=b6b125761894660ed26c5ad76076834559ec42ca;hb=33f333b35a73d3d4a4e79f41e9dd7b342db87b1a;hp=60861b5e7344660331c18fc1b0d11182723fa2cf;hpb=43f0b7c9feffceff7aabed2d24c1131e24fb8262;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 60861b5..b6b1257 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -486,6 +486,38 @@ function updateTrustControls(soneId, trustValue) { }); } +/** + * Bookmarks the post with the given ID. + * + * @param postId + * The ID of the post to bookmark + */ +function bookmarkPost(postId) { + (function(postId) { + $.getJSON("bookmark.ajax", {"formPassword": getFormPassword(), "type": "post", "post": postId}, function(data, textStatus) { + if ((data != null) && data.success) { + getPost(postId).find(".bookmark").toggleClass("hidden", true); + getPost(postId).find(".unbookmark").toggleClass("hidden", false); + } + }); + })(postId); +} + +/** + * Unbookmarks the post with the given ID. + * + * @param postId + * The ID of the post to unbookmark + */ +function unbookmarkPost(postId) { + $.getJSON("unbookmark.ajax", {"formPassword": getFormPassword(), "type": "post", "post": postId}, function(data, textStatus) { + if ((data != null) && data.success) { + getPost(postId).find(".bookmark").toggleClass("hidden", false); + getPost(postId).find(".unbookmark").toggleClass("hidden", true); + } + }); +} + function updateReplyLikes(replyId) { $.getJSON("getLikes.ajax", { "type": "reply", "reply": replyId }, function(data, textStatus) { if ((data != null) && data.success) { @@ -660,6 +692,25 @@ function ajaxifyPost(postElement) { return false; }); + /* convert bookmark/unbookmark buttons to javascript functions. */ + $(postElement).find(".bookmark").submit(function() { + bookmarkPost(getPostId(this)); + return false; + }); + $(postElement).find(".unbookmark").submit(function() { + unbookmarkPost(getPostId(this)); + return false; + }); + + /* convert “show source” link into javascript function. */ + $(postElement).find(".show-source").each(function() { + $("a", this).click(function() { + $(".post-text.text", getPostElement(this)).toggleClass("hidden"); + $(".post-text.raw-text", getPostElement(this)).toggleClass("hidden"); + return false; + }); + }); + /* add “comment” link. */ addCommentLink(getPostId(postElement), postElement, $(postElement).find(".post-status-line .time")); @@ -720,6 +771,15 @@ function ajaxifyReply(replyElement) { })(replyElement); addCommentLink(getPostId(replyElement), replyElement, $(replyElement).find(".reply-status-line .time")); + /* convert “show source” link into javascript function. */ + $(replyElement).find(".show-reply-source").each(function() { + $("a", this).click(function() { + $(".reply-text.text", getReplyElement(this)).toggleClass("hidden"); + $(".reply-text.raw-text", getReplyElement(this)).toggleClass("hidden"); + return false; + }); + }); + /* convert trust control buttons to javascript functions. */ $(replyElement).find(".reply-trust").submit(function() { trustSone(getReplyAuthor(this)); @@ -1282,6 +1342,13 @@ $(document).ready(function() { }); }); + /* ajaxify album creation input field. */ + getTranslation("WebInterface.DefaultText.Reply", function(text) { + $("#create-album input[type=text]").each(function() { + registerInputTextareaSwap(this, text, "name", false, true); + }); + }); + /* Ajaxifies all posts. */ /* calling getTranslation here will cache the necessary values. */ getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) {