From: David ‘Bombe’ Roden Date: Thu, 4 Nov 2010 10:50:03 +0000 (+0100) Subject: Update the list of Sones that like a post or reply after liking/unliking. X-Git-Tag: 0.2-RC1~48 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ad54030fb89a0b74a7096e350c5428f884d28ffe;p=Sone.git Update the list of Sones that like a post or reply after liking/unliking. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 1d45493..695503c 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -250,6 +250,25 @@ function getSoneElement(element) { } /** + * Generates a list of Sones by concatening the names of the given sones with a + * new line character (“\n”). + * + * @param sones + * The sones to format + * @returns {String} The created string + */ +function generateSoneList(sones) { + var soneList = ""; + $.each(sones, function() { + if (soneList != "") { + soneList += "\n"; + } + soneList += this.name; + }); + return soneList; +} + +/** * Returns the ID of the Sone that this element belongs to. * * @param element @@ -297,6 +316,7 @@ function updatePostLikes(postId) { if (data.success) { $("#sone .post#" + postId + " > .status-line .likes").toggleClass("hidden", data.likes == 0) $("#sone .post#" + postId + " > .status-line .likes span.like-count").text(data.likes); + $("#sone .post#" + postId + " > .status-line .likes > span").attr("title", generateSoneList(data.sones)); } }); } @@ -322,6 +342,7 @@ function updateReplyLikes(replyId) { if (data.success) { $("#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)); } }); }