X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=accfabca8b86a30d59cad23a98ea9ff7b65feed3;hp=4f8ff2b130f71fb079dbb72ffad133d19fe9d9b2;hb=275ef92e9690ed28eaf97200493b1e4c04719f52;hpb=3fd7b8594c097f1448fe84f47f579fc9c85aaa25 diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 4f8ff2b..accfabc 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -67,30 +67,31 @@ function addCommentLink(postId, author, element, insertAfterThisElement) { if (($(element).find(".show-reply-form").length > 0) || (getPostElement(element).find(".create-reply").length == 0)) { return; } - commentElement = (function(postId, author) { + (function(postId, author, insertAfterThisElement) { separator = $(" · ").addClass("separator"); - var commentElement = $("
Comment
").addClass("show-reply-form").click(function() { - replyElement = $("#sone .post#" + postId + " .create-reply"); - replyElement.removeClass("hidden"); - replyElement.removeClass("light"); - (function(replyElement) { - replyElement.find("input.reply-input").blur(function() { - if ($(this).hasClass("default")) { - replyElement.addClass("light"); - } - }).focus(function() { - replyElement.removeClass("light"); - }); - })(replyElement); - textArea = replyElement.find("input.reply-input").focus().data("textarea"); - if (author != getCurrentSoneId()) { - textArea.val(textArea.val() + "@sone://" + author + " "); - } + getTranslation("WebInterface.Button.Comment", function(text) { + commentElement = $("
" + text + "
").addClass("show-reply-form").click(function() { + replyElement = $("#sone .post#post-" + postId + " .create-reply"); + replyElement.removeClass("hidden"); + replyElement.removeClass("light"); + (function(replyElement) { + replyElement.find("input.reply-input").blur(function() { + if ($(this).hasClass("default")) { + replyElement.addClass("light"); + } + }).focus(function() { + replyElement.removeClass("light"); + }); + })(replyElement); + textArea = replyElement.find("input.reply-input").focus().data("textarea"); + if (author != getCurrentSoneId()) { + textArea.val(textArea.val() + "@sone://" + author + " "); + } + }); + $(insertAfterThisElement).after(commentElement.clone(true)); + $(insertAfterThisElement).after(separator); }); - return commentElement; - })(postId, author); - $(insertAfterThisElement).after(commentElement.clone(true)); - $(insertAfterThisElement).after(separator); + })(postId, author, insertAfterThisElement); } var translations = {}; @@ -214,7 +215,7 @@ function enhanceDeletePostButton(button, postId, text) { return; } if (data.success) { - $("#sone .post#" + postId).slideUp(); + $("#sone .post#post-" + postId).slideUp(); } else if (data.error == "invalid-post-id") { /* pretend the post is already gone. */ getPost(postId).slideUp(); @@ -246,7 +247,7 @@ function enhanceDeleteReplyButton(button, replyId, text) { return; } if (data.success) { - $("#sone .reply#" + replyId).slideUp(); + $("#sone .reply#reply-" + replyId).slideUp(); } else if (data.error == "invalid-reply-id") { /* pretend the reply is already gone. */ getReply(replyId).slideUp(); @@ -291,7 +292,7 @@ function getSoneElement(element) { * @return The Sone ID */ function getMenuSone(element) { - return $(element).closest(".sone-menu").find(".sone-id").text(); + return $(element).closest(".sone-menu").find(".sone-menu-id").text(); } /** @@ -332,7 +333,7 @@ function getSoneId(element) { * @returns The element of the post */ function getPost(postId) { - return $("#sone .post#" + postId); + return $("#sone .post#post-" + postId); } function getPostElement(element) { @@ -340,7 +341,7 @@ function getPostElement(element) { } function getPostId(element) { - return getPostElement(element).attr("id"); + return getPostElement(element).attr("id").substr(5); } function getPostTime(element) { @@ -366,7 +367,7 @@ function getPostAuthor(element) { * @returns The element of the reply */ function getReply(replyId) { - return $("#sone .reply#" + replyId); + return $("#sone .reply#reply-" + replyId); } function getReplyElement(element) { @@ -374,7 +375,7 @@ function getReplyElement(element) { } function getReplyId(element) { - return getReplyElement(element).attr("id"); + return getReplyElement(element).attr("id").substr(6); } function getReplyTime(element) { @@ -441,8 +442,8 @@ function likePost(postId) { if ((data == null) || !data.success) { return; } - $("#sone .post#" + postId + " > .inner-part > .status-line .like").addClass("hidden"); - $("#sone .post#" + postId + " > .inner-part > .status-line .unlike").removeClass("hidden"); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .like").addClass("hidden"); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .unlike").removeClass("hidden"); updatePostLikes(postId); }, function(xmlHttpRequest, textStatus, error) { /* ignore error. */ @@ -454,8 +455,8 @@ function unlikePost(postId) { if ((data == null) || !data.success) { return; } - $("#sone .post#" + postId + " > .inner-part > .status-line .unlike").addClass("hidden"); - $("#sone .post#" + postId + " > .inner-part > .status-line .like").removeClass("hidden"); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .unlike").addClass("hidden"); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .like").removeClass("hidden"); updatePostLikes(postId); }, function(xmlHttpRequest, textStatus, error) { /* ignore error. */ @@ -465,9 +466,9 @@ function unlikePost(postId) { function updatePostLikes(postId) { ajaxGet("getLikes.ajax", { "type": "post", "post": postId }, function(data, textStatus) { if ((data != null) && data.success) { - $("#sone .post#" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0); - $("#sone .post#" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes); - $("#sone .post#" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones)); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes); + $("#sone .post#post-" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones)); } }, function(xmlHttpRequest, textStatus, error) { /* ignore error. */ @@ -479,8 +480,8 @@ function likeReply(replyId) { if ((data == null) || !data.success) { return; } - $("#sone .reply#" + replyId + " .status-line .like").addClass("hidden"); - $("#sone .reply#" + replyId + " .status-line .unlike").removeClass("hidden"); + $("#sone .reply#reply-" + replyId + " .status-line .like").addClass("hidden"); + $("#sone .reply#reply-" + replyId + " .status-line .unlike").removeClass("hidden"); updateReplyLikes(replyId); }, function(xmlHttpRequest, textStatus, error) { /* ignore error. */ @@ -492,8 +493,8 @@ function unlikeReply(replyId) { if ((data == null) || !data.success) { return; } - $("#sone .reply#" + replyId + " .status-line .unlike").addClass("hidden"); - $("#sone .reply#" + replyId + " .status-line .like").removeClass("hidden"); + $("#sone .reply#reply-" + replyId + " .status-line .unlike").addClass("hidden"); + $("#sone .reply#reply-" + replyId + " .status-line .like").removeClass("hidden"); updateReplyLikes(replyId); }, function(xmlHttpRequest, textStatus, error) { /* ignore error. */ @@ -603,9 +604,9 @@ function unbookmarkPost(postId) { function updateReplyLikes(replyId) { ajaxGet("getLikes.ajax", { "type": "reply", "reply": replyId }, function(data, textStatus) { if ((data != null) && data.success) { - $("#sone .reply#" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0); - $("#sone .reply#" + replyId + " .status-line .likes span.like-count").text(data.likes); - $("#sone .reply#" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones)); + $("#sone .reply#reply-" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0); + $("#sone .reply#reply-" + replyId + " .status-line .likes span.like-count").text(data.likes); + $("#sone .reply#reply-" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones)); } }, function(xmlHttpRequest, textStatus, error) { /* ignore error. */ @@ -713,10 +714,10 @@ function ajaxifyPost(postElement) { if (success) { $(inputField).val(""); loadNewReply(replyId, soneId, postId); - $("#sone .post#" + postId + " .create-reply").addClass("hidden"); - $("#sone .post#" + postId + " .create-reply .sender").hide(); - $("#sone .post#" + postId + " .create-reply .select-sender").show(); - $("#sone .post#" + postId + " .create-reply :input[name=sender]").val(getCurrentSoneId()); + $("#sone .post#post-" + postId + " .create-reply").addClass("hidden"); + $("#sone .post#post-" + postId + " .create-reply .sender").hide(); + $("#sone .post#post-" + postId + " .create-reply .select-sender").show(); + $("#sone .post#post-" + postId + " .create-reply :input[name=sender]").val(getCurrentSoneId()); } else { alert(error); } @@ -806,7 +807,16 @@ function ajaxifyPost(postElement) { $(".expand-post-text", getPostElement(this)).toggleClass("hidden"); $(".shrink-post-text", getPostElement(this)).toggleClass("hidden"); return false; - }) + }); + }); + + /* ajaxify author/post links */ + $(".post-status-line .permalink a", postElement).click(function() { + if (!$(".create-reply", postElement).hasClass("hidden")) { + textArea = $("input.reply-input", postElement).focus().data("textarea"); + $(textArea).replaceSelection($(this).attr("href")); + } + return false; }); /* add “comment” link. */ @@ -837,25 +847,37 @@ function ajaxifyPost(postElement) { }); /* mark everything as known on click. */ - $(postElement).click(function(event) { - if ($(event.target).hasClass("click-to-show")) { - return false; - } - markPostAsKnown(this); - }); + (function(postElement) { + $(postElement).click(function(event) { + if ($(event.target).hasClass("click-to-show")) { + return false; + } + markPostAsKnown(postElement, false); + }); + })(postElement); /* hide reply input field. */ $(postElement).find(".create-reply").addClass("hidden"); /* show Sone menu when hovering over the avatar. */ $(postElement).find(".post-avatar").mouseover(function() { - $(".sone-post-menu", postElement).mouseleave(function() { - $(this).fadeOut(); - }).fadeIn(); - return false; + if (typeof currentSoneMenuTimeoutHandler != undefined) { + clearTimeout(currentSoneMenuTimeoutHandler); + } + currentSoneMenuId = getPostId(this); + currentSoneMenuTimeoutHandler = setTimeout(function() { + $(".sone-menu:visible").fadeOut(); + $(".sone-post-menu", postElement).mouseleave(function() { + $(this).fadeOut(); + }).fadeIn(); + }, 1000); + }).mouseleave(function() { + if (currentSoneMenuId == getPostId(this)) { + clearTimeout(currentSoneMenuTimeoutHandler); + } }); (function(postElement) { - var soneId = $(".sone-id", postElement).text(); + var soneId = $(".sone-menu-id:first", postElement).text(); $(".sone-post-menu .follow", postElement).click(function() { var followElement = this; ajaxGet("followSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() { @@ -909,6 +931,16 @@ function ajaxifyReply(replyElement) { }); }); })(replyElement); + + /* ajaxify author links */ + $(".reply-status-line .permalink a", replyElement).click(function() { + if (!$(".create-reply", getPostElement(replyElement)).hasClass("hidden")) { + textArea = $("input.reply-input", getPostElement(replyElement)).focus().data("textarea"); + $(textArea).replaceSelection($(this).attr("href")); + } + return false; + }); + addCommentLink(getPostId(replyElement), getReplyAuthor(replyElement), replyElement, $(replyElement).find(".reply-status-line .permalink-author")); /* convert “show source” link into javascript function. */ @@ -968,13 +1000,23 @@ function ajaxifyReply(replyElement) { /* show Sone menu when hovering over the avatar. */ $(replyElement).find(".reply-avatar").mouseover(function() { - $(".sone-reply-menu", replyElement).mouseleave(function() { - $(this).fadeOut(); - }).fadeIn(); - return false; + if (typeof currentSoneMenuTimeoutHandler != undefined) { + clearTimeout(currentSoneMenuTimeoutHandler); + } + currentSoneMenuId = getPostId(this) + "-" + getReplyId(this); + currentSoneMenuTimeoutHandler = setTimeout(function() { + $(".sone-menu:visible").fadeOut(); + $(".sone-reply-menu", replyElement).mouseleave(function() { + $(this).fadeOut(); + }).fadeIn(); + }, 1000); + }).mouseleave(function() { + if (currentSoneMenuId == getPostId(this) + "-" + getReplyId(this)) { + clearTimeout(currentSoneMenuTimeoutHandler); + } }); (function(replyElement) { - var soneId = $(".sone-id", replyElement).text(); + var soneId = $(".sone-menu-id", replyElement).text(); $(".sone-menu .follow", replyElement).click(function() { var followElement = this; ajaxGet("followSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() { @@ -1023,7 +1065,7 @@ function ajaxifyNotification(notification) { } notification.find("form.mark-as-read button").click(function() { allIds = $(":input[name=id]", this.form).val().split(" "); - for (index = 0; index < allIds.length; index += 16) { + for (var 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}); } @@ -1049,6 +1091,24 @@ function ajaxifyNotification(notification) { } /** + * Returns the notification hash. This hash is used in {@link #getStatus()} to + * determine whether the notifications changed and need to be reloaded. + */ +function getNotificationHash() { + return $("#sone #notification-area #notification-hash").text(); +} + +/** + * Sets the notification hash. + * + * @param notificationHash + * The new notification hash + */ +function setNotificationHash(notificationHash) { + $("#sone #notification-area #notification-hash").text(notificationHash); +} + +/** * Retrieves element IDs from notification elements. * * @param notification @@ -1120,7 +1180,7 @@ function checkForRemovedPosts(oldNotification, newNotification) { * The new notification element */ function checkForRemovedReplies(oldNotification, newNotification) { - if (getNotificationId(oldNotification) != "new-replies-notification") { + if (getNotificationId(oldNotification) != "new-reply-notification") { return; } oldIds = getElementIds(oldNotification, ".reply-id"); @@ -1133,7 +1193,7 @@ function checkForRemovedReplies(oldNotification, newNotification) { } function getStatus() { - ajaxGet("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) { + ajaxGet("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : isKnownSonesPage() ? {"soneIds": getShownSoneIds() } : {}, function(data, textStatus) { if ((data != null) && data.success) { /* process Sone information. */ $.each(data.sones, function(index, value) { @@ -1143,6 +1203,33 @@ function getStatus() { if (!notLoggedIn) { showOfflineMarker(!online); } + if (data.notificationHash != getNotificationHash()) { + console.log("Old hash: ", getNotificationHash(), ", new hash: ", data.notificationHash); + requestNotifications(); + /* process new posts. */ + $.each(data.newPosts, function(index, value) { + loadNewPost(value.id, value.sone, value.recipient, value.time); + }); + /* process new replies. */ + $.each(data.newReplies, function(index, value) { + loadNewReply(value.id, value.sone, value.post, value.postSone); + }); + } + /* do it again in 5 seconds. */ + setTimeout(getStatus, 5000); + } else { + /* data.success was false, wait 30 seconds. */ + setTimeout(getStatus, 30000); + } + }, function() { + statusRequestQueued = false; + ajaxError(); + }); +} + +function requestNotifications() { + ajaxGet("getNotifications.ajax", {}, function(data, textStatus) { + if (data && data.success) { /* search for removed notifications. */ $("#sone #notification-area .notification").each(function() { notificationId = $(this).attr("id"); @@ -1154,17 +1241,17 @@ function getStatus() { } }); if (!foundNotification) { - if (notificationId == "new-sone-notification") { + if (notificationId == "new-sone-notification" && (data.options["ShowNotification/NewSones"] == true)) { $(".new-sone-id", this).each(function(index, element) { soneId = $(this).text(); markSoneAsKnown(getSone(soneId), true); }); - } else if (notificationId == "new-post-notification") { + } else if (notificationId == "new-post-notification" && (data.options["ShowNotification/NewPosts"] == true)) { $(".post-id", this).each(function(index, element) { postId = $(this).text(); markPostAsKnown(getPost(postId), true); }); - } else if (notificationId == "new-replies-notification") { + } else if (notificationId == "new-reply-notification" && (data.options["ShowNotification/NewReplies"] == true)) { $(".reply-id", this).each(function(index, element) { replyId = $(this).text(); markReplyAsKnown(getReply(replyId), true); @@ -1180,69 +1267,29 @@ function getStatus() { } }); /* process notifications. */ - notificationIds = []; $.each(data.notifications, function(index, value) { oldNotification = getNotification(value.id); - if ((oldNotification.length == 0) || (value.lastUpdatedTime > getNotificationLastUpdatedTime(oldNotification))) { - notificationIds.push(value.id); + notification = ajaxifyNotification(createNotification(value.id, value.lastUpdatedTime, value.text, value.dismissable)).hide(); + if (oldNotification.length != 0) { + if ((oldNotification.find(".short-text").length > 0) && (notification.find(".short-text").length > 0)) { + opened = oldNotification.is(":visible") && oldNotification.find(".short-text").hasClass("hidden"); + notification.find(".short-text").toggleClass("hidden", opened); + notification.find(".text").toggleClass("hidden", !opened); + } + checkForRemovedSones(oldNotification, notification); + checkForRemovedPosts(oldNotification, notification); + checkForRemovedReplies(oldNotification, notification); + oldNotification.replaceWith(notification.show()); + } else { + $("#sone #notification-area").append(notification); + if (value.id.substring(0, 5) != "local") { + notification.slideDown(); + setActivity(); + } } }); - if (notificationIds.length > 0) { - loadNotifications(notificationIds); - } - /* process new posts. */ - $.each(data.newPosts, function(index, value) { - loadNewPost(value.id, value.sone, value.recipient, value.time); - }); - /* process new replies. */ - $.each(data.newReplies, function(index, value) { - loadNewReply(value.id, value.sone, value.post, value.postSone); - }); - /* do it again in 5 seconds. */ - setTimeout(getStatus, 5000); - } else { - /* data.success was false, wait 30 seconds. */ - setTimeout(getStatus, 30000); + setNotificationHash(data.notificationHash); } - }, function() { - statusRequestQueued = false; - ajaxError(); - }); -} - -/** - * Requests multiple notifications from Sone and displays them. - * - * @param notificationIds - * Array of IDs of the notifications to load - */ -function loadNotifications(notificationIds) { - ajaxGet("getNotification.ajax", {"notifications": notificationIds.join(",")}, function(data, textStatus) { - if (!data || !data.success) { - // TODO - show error - return; - } - $.each(data.notifications, function(index, value) { - oldNotification = getNotification(value.id); - notification = ajaxifyNotification(createNotification(value.id, value.lastUpdatedTime, value.text, value.dismissable)).hide(); - if (oldNotification.length != 0) { - if ((oldNotification.find(".short-text").length > 0) && (notification.find(".short-text").length > 0)) { - opened = oldNotification.is(":visible") && oldNotification.find(".short-text").hasClass("hidden"); - notification.find(".short-text").toggleClass("hidden", opened); - notification.find(".text").toggleClass("hidden", !opened); - } - checkForRemovedSones(oldNotification, notification); - checkForRemovedPosts(oldNotification, notification); - checkForRemovedReplies(oldNotification, notification); - oldNotification.replaceWith(notification.show()); - } else { - $("#sone #notification-area").append(notification); - if (value.id.substring(0, 5) != "local") { - notification.slideDown(); - setActivity(); - } - } - }); }); } @@ -1308,7 +1355,21 @@ function isViewSonePage() { * @returns The ID of the currently shown Sone */ function getShownSoneId() { - return $("#sone .sone-id").text(); + return $("#sone .sone-id").first().text(); +} + +/** + * Returns the ID of all currently visible Sones. This is mainly used on the + * “Known Sones” page. + * + * @returns The ID of the currently shown Sones + */ +function getShownSoneIds() { + var soneIds = new Array(); + $("#sone #known-sones .sone .id").each(function() { + soneIds.push($(this).text()); + }); + return soneIds.join(","); } /** @@ -1350,7 +1411,7 @@ function isKnownSonesPage() { * exists on the page, false otherwise */ function hasPost(postId) { - return $(".post#" + postId).length > 0; + return $(".post#post-" + postId).length > 0; } /** @@ -1362,7 +1423,7 @@ function hasPost(postId) { * exists on the page, false otherwise */ function hasReply(replyId) { - return $("#sone .reply#" + replyId).length > 0; + return $("#sone .reply#reply-" + replyId).length > 0; } function loadNewPost(postId, soneId, recipientId, time) { @@ -1422,7 +1483,7 @@ function loadNewReply(replyId, soneId, postId, postSoneId) { if (hasReply(data.reply.id)) { return; } - $("#sone .post#" + data.reply.postId).each(function() { + $("#sone .post#post-" + data.reply.postId).each(function() { var firstNewerReply = null; $(this).find(".replies .reply").each(function() { if (getReplyTime(this) > data.reply.time) { @@ -1468,10 +1529,11 @@ function loadNewReply(replyId, soneId, postId, postSoneId) { * request */ function markSoneAsKnown(soneElement, skipRequest) { - if ($(soneElement).is(".new")) { + if ($(soneElement).hasClass("new")) { $(soneElement).removeClass("new"); if ((typeof skipRequest == "undefined") || !skipRequest) { ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "sone", "id": getSoneId(soneElement)}); + requestNotifications(); } } } @@ -1479,27 +1541,29 @@ function markSoneAsKnown(soneElement, skipRequest) { function markPostAsKnown(postElements, skipRequest) { $(postElements).each(function() { postElement = this; - if ($(postElement).hasClass("new") || ((typeof skipRequest != "undefined") && !skipRequest)) { + if ($(postElement).hasClass("new") || ((typeof skipRequest != "undefined"))) { (function(postElement) { $(postElement).removeClass("new"); if ((typeof skipRequest == "undefined") || !skipRequest) { ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "post", "id": getPostId(postElement)}); + requestNotifications(); } })(postElement); } $(".click-to-show", postElement).removeClass("new"); }); - markReplyAsKnown($(postElements).find(".reply")); + markReplyAsKnown($(postElements).find(".reply"), true); } function markReplyAsKnown(replyElements, skipRequest) { $(replyElements).each(function() { replyElement = this; - if ($(replyElement).hasClass("new") || ((typeof skipRequest != "undefined") && !skipRequest)) { + if ($(replyElement).hasClass("new") || ((typeof skipRequest != "undefined"))) { (function(replyElement) { $(replyElement).removeClass("new"); if ((typeof skipRequest == "undefined") || !skipRequest) { ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "reply", "id": getReplyId(replyElement)}); + requestNotifications(); } })(replyElement); } @@ -1807,8 +1871,22 @@ var online = true; var initiallyLoggedIn = $("#sone #loggedIn").text() == "true"; var notLoggedIn = !initiallyLoggedIn; +/** ID of the next-to-show Sone context menu. */ +var currentSoneMenuId; + +/** Timeout handler for the next-to-show Sone context menu. */ +var currentSoneMenuTimeoutHandler; + $(document).ready(function() { + /* rip out the status update textarea. */ + $("#sone .rip-out").each(function() { + var oldElement = $(this); + newElement = $(""); + newElement.attr("class", oldElement.attr("class")).attr("name", oldElement.attr("name")); + oldElement.before(newElement).remove(); + }); + /* this initializes the status update input field. */ getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) { registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false); @@ -1870,8 +1948,10 @@ $(document).ready(function() { getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) { getTranslation("WebInterface.Confirmation.DeleteReplyButton", function(text) { getTranslation("WebInterface.DefaultText.Reply", function(text) { - $("#sone .post").each(function() { - ajaxifyPost(this); + getTranslation("WebInterface.Button.Comment", function(text) { + $("#sone .post").each(function() { + ajaxifyPost(this); + }); }); }); }); @@ -1891,7 +1971,7 @@ $(document).ready(function() { allReplies = $(this).find(".reply"); if (allReplies.length > 2) { newHidden = false; - for (replyIndex = 0; !newHidden && (replyIndex < (allReplies.length - 2)); ++replyIndex) { + for (replyIndex = 0; replyIndex < (allReplies.length - 2); ++replyIndex) { $(allReplies[replyIndex]).addClass("hidden"); newHidden |= $(allReplies[replyIndex]).hasClass("new"); } @@ -1921,11 +2001,6 @@ $(document).ready(function() { ajaxifyNotification($(this)); }); - /* disable all permalinks. */ - $(".permalink").click(function() { - return false; - }); - /* activate status polling. */ setTimeout(getStatus, 5000);