From 693da3f2d937022bca8377d95e57df8ea8ee10f9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 27 Nov 2010 01:04:35 +0100 Subject: [PATCH] =?utf8?q?Add=20function=20to=20detect=20if=20the=20curren?= =?utf8?q?t=20page=20is=20a=20=E2=80=9Cview=20post=E2=80=9D=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/javascript/sone.js | 20 ++++++++++++++++++++ src/main/resources/templates/viewPost.html | 3 +++ 2 files changed, 23 insertions(+) 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> -- 2.7.4