X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=bc7d7ead3295f36e53f207ee185dbb186a7931c5;hb=241820c52127d0069e259288d8ddb3382e2891e2;hp=60a38487778a55a91a8eff0d962386b9091cb73b;hpb=b18d79c7c4478b3c474448e45da7fca4fb38c3f9;p=Sone.git
diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js
index 60a3848..bc7d7ea 100644
--- a/src/main/resources/static/javascript/sone.js
+++ b/src/main/resources/static/javascript/sone.js
@@ -256,7 +256,7 @@ function getFormPassword() {
}
function getSoneElement(element) {
- return $(element).parents(".sone");
+ return $(element).closest(".sone");
}
/**
@@ -560,7 +560,7 @@ function ajaxifyNotification(notification) {
}
function getStatus() {
- $.getJSON("getStatus.ajax", {}, function(data, textStatus) {
+ $.getJSON("getStatus.ajax", {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) {
if ((data != null) && data.success) {
/* process Sone information. */
$.each(data.sones, function(index, value) {
@@ -660,6 +660,16 @@ function getShownPostId() {
return $("#sone .post-id").text();
}
+/**
+ * Returns whether the current page is the âknown Sonesâ page.
+ *
+ * @returns {Boolean} true
if the current page is the âknown
+ * Sonesâ page, false
otherwise
+ */
+function isKnownSonesPage() {
+ return getPageId() == "known-sones";
+}
+
var loadedPosts = {};
var loadedReplies = {};
@@ -815,6 +825,21 @@ $(document).ready(function() {
});
});
+ /* ajaxify input field on âview Soneâ page. */
+ getTranslation("WebInterface.DefaultText.Message", function(defaultText) {
+ registerInputTextareaSwap("#sone #post-message input[name=text]", defaultText, "text", false, false);
+ $("#sone #post-message").submit(function() {
+ text = $(this).find(":input:enabled").val();
+ $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "text": text }, function(data, textStatus) {
+ if ((data != null) && data.success) {
+ loadNewPost(data.postId);
+ }
+ });
+ $(this).find(":input:enabled").val("").blur();
+ return false;
+ });
+ });
+
/* Ajaxifies all posts. */
/* calling getTranslation here will cache the necessary values. */
getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) {