From: David ‘Bombe’ Roden Date: Sat, 27 Nov 2010 00:04:35 +0000 (+0100) Subject: Add function to detect if the current page is a “view post” page. X-Git-Tag: 0.3.2-RC1~25 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=693da3f2d937022bca8377d95e57df8ea8ee10f9 Add function to detect if the current page is a “view post” page. --- diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 7482138..fa2b1cf 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -640,6 +640,26 @@ function getSoneId() { return $("#sone .sone-id").text(); } +/** + * Returns whether the current page is a “view post” page. + * + * @returns {Boolean} true if the current page is a “view post” + * page, false otherwise + */ +function isViewPostPage() { + return getPageId() == "view-post"; +} + +/** + * Returns the ID of the currently shown post. This will only return a sensible + * value if isViewPostPage() returns true. + * + * @returns The ID of the currently shown post + */ +function getPostId() { + return $("#sone .post-id").text(); +} + var loadedPosts = {}; var loadedReplies = {}; diff --git a/src/main/resources/templates/viewPost.html b/src/main/resources/templates/viewPost.html index 867971c..3de8ebc 100644 --- a/src/main/resources/templates/viewPost.html +++ b/src/main/resources/templates/viewPost.html @@ -1,5 +1,8 @@ <%include include/head.html> + + +

<%= Page.ViewPost.Page.Title|l10n|insert needle="{sone}" key=post.sone.niceName|html>

<%include include/viewPost.html>