From f0edeab05ebb38de63b97462dfd6b825a6636c17 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 13 Nov 2010 00:45:37 +0100 Subject: [PATCH] Add methods to post replies and get replies. --- src/main/resources/static/javascript/sone.js | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index bd372c1..361fc53 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -363,3 +363,41 @@ function updateReplyLikes(replyId) { } }); } + +/** + * Posts a reply and calls the given callback when the request finishes. + * + * @param postId + * The ID of the post the reply refers to + * @param text + * The text to post + * @param callbackFunction + * The callback function to call when the request finishes (takes 3 + * parameters: success, error, replyId) + */ +function postReply(postId, text, callbackFunction) { + $.getJSON("ajax/createReply.ajax", { "formPassword" : getFormPassword(), "post" : postId, "text": text }, function(data, textStatus) { + if (data.success) { + callbackFunction(true, null, data.reply); + } else { + callbackFunction(false, data.error); + } + }); +} + +/** + * Requests information about the reply with the given ID. + * + * @param replyId + * The ID of the reply + * @param callbackFunction + * A callback function (parameters soneId, soneName, replyTime, + * replyDisplayTime, text, html) + */ +function getReply(replyId, callbackFunction) { + $.getJSON("ajax/getReply.ajax", { "reply" : replyId }, function(data, textStatus) { + if (data.success) { + callbackFunction(data.soneId, data.soneName, data.time, data.displayTime, data.text, data.html); + } + }); +} -- 2.7.4