X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=6e7184e4c7ea4cc195592e24e2a90cb7f49c448a;hp=0cc6480b944121cabd86bf281abda8f7b755a091;hb=8e4b0c79cea9367a42ecef1f2b610f675eb92a74;hpb=9d50dcb65cec8d10306fbdb0d73826f33af2afb9 diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 0cc6480..6e7184e 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -759,8 +759,27 @@ function ajaxifyPost(postElement) { /* convert “show source” link into javascript function. */ $(postElement).find(".show-source").each(function() { $("a", this).click(function() { + post = getPostElement(this); + rawPostText = $(".post-text.raw-text", post); + rawPostText.toggleClass("hidden"); + if (rawPostText.hasClass("hidden")) { + $(".post-text.short-text", post).removeClass("hidden"); + $(".post-text.text", post).addClass("hidden"); + $(".expand-post-text", post).removeClass("hidden"); + } else { + $(".post-text.short-text", post).addClass("hidden"); + $(".post-text.text", post).addClass("hidden"); + $(".expand-post-text", post).addClass("hidden"); + } + return false; + }); + }); + + /* convert “show more” link into javascript function. */ + $(postElement).find(".expand-post-text").each(function() { + $(this).click(function() { $(".post-text.text", getPostElement(this)).toggleClass("hidden"); - $(".post-text.raw-text", getPostElement(this)).toggleClass("hidden"); + $(".post-text.short-text", getPostElement(this)).toggleClass("hidden"); return false; }); }); @@ -831,8 +850,27 @@ function ajaxifyReply(replyElement) { /* convert “show source” link into javascript function. */ $(replyElement).find(".show-reply-source").each(function() { $("a", this).click(function() { + reply = getReplyElement(this); + rawReplyText = $(".reply-text.raw-text", reply); + rawReplyText.toggleClass("hidden"); + if (rawReplyText.hasClass("hidden")) { + $(".reply-text.short-text", reply).removeClass("hidden"); + $(".reply-text.text", reply).addClass("hidden"); + $(".expand-reply-text", reply).removeClass("hidden"); + } else { + $(".reply-text.short-text", reply).addClass("hidden"); + $(".reply-text.text", reply).addClass("hidden"); + $(".expand-reply-text", reply).addClass("hidden"); + } + return false; + }); + }); + + /* convert “show more” link into javascript function. */ + $(replyElement).find(".expand-reply-text").each(function() { + $(this).click(function() { $(".reply-text.text", getReplyElement(this)).toggleClass("hidden"); - $(".reply-text.raw-text", getReplyElement(this)).toggleClass("hidden"); + $(".reply-text.short-text", getReplyElement(this)).toggleClass("hidden"); return false; }); }); @@ -868,7 +906,11 @@ function ajaxifyNotification(notification) { notification.find(".text").addClass("hidden"); } notification.find("form.mark-as-read button").click(function() { - ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": $(":input[name=type]", this.form).val(), "id": $(":input[name=id]", this.form).val()}); + allIds = $(":input[name=id]", this.form).val().split(" "); + for (index = 0; index < allIds.length; index += 16) { + ids = allIds.slice(index, index + 16).join(" "); + ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": $(":input[name=type]", this.form).val(), "id": ids}); + } }); notification.find("a[class^='link-']").each(function() { linkElement = $(this); @@ -1079,8 +1121,10 @@ function loadNotifications(notificationIds) { oldNotification.replaceWith(notification.show()); } else { $("#sone #notification-area").append(notification); - notification.slideDown(); - setActivity(); + if (value.id.substring(0, 5) != "local") { + notification.slideDown(); + setActivity(); + } } }); }); @@ -1237,11 +1281,6 @@ function loadNewPost(postId, soneId, recipientId, time) { newPost = $(data.post.html).addClass("hidden"); if ($(".post-author-local", newPost).text() == "true") { newPost.removeClass("new"); - (function(newPost) { - setTimeout(function() { - markPostAsKnown(newPost, false); - }, 5000); - })(newPost); } if (firstOlderPost != null) { newPost.insertBefore(firstOlderPost);