X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=be7deaa074a21800c90274564c5609039fca55e8;hb=63e85ddb7cebbb91f7be41640edb6104bd74650a;hp=f19b0d137629823bc735222398902228180d00a2;hpb=68f8e5e5c34fad6086af0c82d1dde64f67814297;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index f19b0d1..be7deaa 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -1,5 +1,9 @@ /* Sone JavaScript functions. */ +function isOnline() { + return $("#sone").hasClass("online"); +} + function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName, optional) { $(inputSelector).each(function() { textarea = $("").blur(function() { @@ -42,6 +46,9 @@ function registerInputTextareaSwap(inputSelector, defaultText, inputFieldName, o /* hide all the “create reply” forms until a link is clicked. */ function addCommentLinks() { + if (!isOnline()) { + return; + } $("#sone .post").each(function() { postId = $(this).attr("id"); commentElement = (function(postId) { @@ -238,7 +245,7 @@ function getFormPassword() { } function getSoneElement(element) { - return $(element).parent(".sone"); + return $(element).parents(".sone"); } /** @@ -279,6 +286,7 @@ function unlikePost(postId) { function updatePostLikes(postId) { $.getJSON("ajax/getPostLikes.ajax", { "post": postId }, function(data, textStatus) { 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); } });