Add functions to detect a “view Sone” page and the ID of the shown Sone.
[Sone.git] / src / main / resources / static / javascript / sone.js
index 59135af..cb16e64 100644 (file)
@@ -620,6 +620,26 @@ function isIndexPage() {
        return getPageId() == "index";
 }
 
+/**
+ * Returns whether the current page is a “view Sone” page.
+ *
+ * @returns {Boolean} <code>true</code> if the current page is a “view Sone”
+ *          page, <code>false</code> otherwise
+ */
+function isViewSonePage() {
+       return getPageId() == "view-sone";
+}
+
+/**
+ * Returns the ID of the currently shown Sone. This will only return a sensible
+ * value if isViewSonePage() returns <code>true</code>.
+ *
+ * @returns The ID of the currently shown Sone
+ */
+function getSoneId() {
+       return $("#sone .sone-id").text();
+}
+
 var loadedPosts = {};
 var loadedReplies = {};