From: David ‘Bombe’ Roden Date: Thu, 17 Feb 2011 10:26:01 +0000 (+0100) Subject: Add functions to bookmark and unbookmark posts. X-Git-Tag: 0.4.4^2~7^2~2 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=d3d8c053c8635e90452e620d98fd2e8c0f3ad89a;p=Sone.git Add functions to bookmark and unbookmark posts. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 60861b5..c5296ca 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) {