$(this).data("textarea", textarea).after(textarea);
(function(inputField, textarea) {
inputField.focus(function() {
- $(this).hide().attr("disabled", "disabled");
+ $(this).hide().prop("disabled", "disabled");
/* no, show(), “display: block” is not what I need. */
- textarea.attr("style", "display: inline").focus();
+ textarea.prop("style", "display: inline").focus();
});
if (inputField.val() == "") {
inputField.addClass("default");
inputField.val(defaultText);
} else {
- inputField.hide().attr("disabled", "disabled");
+ inputField.hide().prop("disabled", "disabled");
textarea.show();
}
$(inputField.get(0).form).submit(function() {
- inputField.attr("disabled", "disabled");
+ inputField.prop("disabled", "disabled");
if (!optional && (textarea.val() == "")) {
inputField.removeAttr("disabled").focus();
return false;
* The date and time of the last update (formatted for display)
*/
function updateSoneStatus(soneId, name, status, modified, locked, lastUpdated, lastUpdatedText) {
- var updateSone = sone.find(".sone." + filterSoneId(soneId));
+ var updateSone = sone.find(".sone." + filterSoneId(soneId));
updateSone.toggleClass("unknown", status == "unknown").
toggleClass("idle", status == "idle").
toggleClass("inserting", status == "inserting").
updateSone.find(".lock").toggleClass("hidden", locked);
updateSone.find(".unlock").toggleClass("hidden", !locked);
if (lastUpdated != null) {
- updateSone.find(".last-update span.time").attr("title", lastUpdated).text(lastUpdatedText);
+ updateSone.find(".last-update span.time").prop("title", lastUpdated).text(lastUpdatedText);
} else {
getTranslation("View.Sone.Text.UnknownDate", function(unknown) {
updateSone.find(".last-update span.time").text(unknown);
}
function getPostId(element) {
- return getPostElement(element).attr("id").substr(5);
+ return getPostElement(element).prop("id").substr(5);
}
function getPostTime(element) {
}
function getReplyId(element) {
- return getReplyElement(element).attr("id").substr(6);
+ return getReplyElement(element).prop("id").substr(6);
}
function getReplyTime(element) {
* @returns The ID of the notification
*/
function getNotificationId(notificationElement) {
- return $(notificationElement).attr("id");
+ return $(notificationElement).prop("id");
}
/**
* @returns The last update time of the notification
*/
function getNotificationLastUpdatedTime(notificationElement) {
- return $(notificationElement).attr("lastUpdatedTime");
+ return $(notificationElement).prop("lastUpdatedTime");
}
function likePost(postId) {
if ((data != null) && data.success) {
sone.find(".post#post-" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0);
sone.find(".post#post-" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes);
- sone.find(".post#post-" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones));
+ sone.find(".post#post-" + postId + " > .inner-part > .status-line .likes > span").prop("title", generateSoneList(data.sones));
}
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
if ((data != null) && data.success) {
sone.find(".reply#reply-" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0);
sone.find(".reply#reply-" + replyId + " .status-line .likes span.like-count").text(data.likes);
- sone.find(".reply#reply-" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones));
+ sone.find(".reply#reply-" + replyId + " .status-line .likes > span").prop("title", generateSoneList(data.sones));
}
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
});
$(postElement).find(".create-reply button:submit").click(function() {
var button = $(this);
- button.attr("disabled", "disabled");
+ button.prop("disabled", "disabled");
var sender = $(this.form).find(":input[name=sender]").val();
var inputField = $(this.form).find(":input[name=text]:enabled").get(0);
var postId = getPostId(this);
sone.find(".post#post-" + postId + " .create-reply .sender").hide();
sone.find(".post#post-" + postId + " .create-reply .select-sender").show();
sone.find(".post#post-" + postId + " .create-reply :input[name=sender]").val(getCurrentSoneId());
+ updateReplyTimes(replyId);
} else {
alert(error);
}
$(".post-status-line .permalink a", postElement).click(function() {
if (!$(".create-reply", postElement).hasClass("hidden")) {
var textArea = $(":input.reply-input", postElement).focus().data("textarea");
- $(textArea).replaceSelection($(this).attr("href"));
+ $(textArea).replaceSelection($(this).prop("href"));
}
return false;
});
$(".reply-status-line .permalink a", replyElement).click(function() {
if (!$(".create-reply", getPostElement(replyElement)).hasClass("hidden")) {
var textArea = $(":input.reply-input", getPostElement(replyElement)).focus().data("textarea");
- $(textArea).replaceSelection($(this).attr("href"));
+ $(textArea).replaceSelection($(this).prop("href"));
}
return false;
});
notification.find("a[class^='link-']").each(function() {
var linkElement = $(this);
if (linkElement.is("[href^='viewPost']")) {
- var id = linkElement.attr("class").substr(5);
+ var id = linkElement.prop("class").substr(5);
if (hasPost(id)) {
- linkElement.attr("href", "#post-" + id).addClass("in-page-link");
+ linkElement.prop("href", "#post-" + id).addClass("in-page-link");
}
}
});
notification.find("form.dismiss button").click(function() {
- ajaxGet("dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) {
+ ajaxGet("dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.prop("id") }, function(data, textStatus) {
/* dismiss in case of error, too. */
notification.slideUp();
}, function(xmlHttpRequest, textStatus, error) {
}
function getStatus() {
- ajaxGet("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : isKnownSonesPage() ? {"soneIds": getShownSoneIds() } : {}, function(data, textStatus) {
+ var parameters = isViewSonePage() ? {"soneIds": getShownSoneId() } : isKnownSonesPage() ? {"soneIds": getShownSoneIds() } : {};
+ $.extend(parameters, {
+ "elements": JSON.stringify($(".linked-element.not-loaded").map(function () {
+ return $(this).prop("title");
+ }).toArray())
+ });
+ ajaxGet("getStatus.ajax", parameters, function(data, textStatus) {
if ((data != null) && data.success) {
/* process Sone information. */
$.each(data.sones, function(index, value) {
loadNewReply(value.id, value.sone, value.post, value.postSone);
});
}
+ if (data.linkedElements) {
+ loadLinkedElements(data.linkedElements)
+ }
/* do it again in 5 seconds. */
setTimeout(getStatus, 5000);
} else {
if (data && data.success) {
/* search for removed notifications. */
sone.find("#notification-area .notification").each(function() {
- var notificationId = $(this).attr("id");
+ var notificationId = $(this).prop("id");
var foundNotification = false;
$.each(data.notifications, function(index, value) {
if (value.id == notificationId) {
});
}
+function loadLinkedElements(links) {
+ var failedElements = links.filter(function(element) {
+ return element.failed;
+ });
+ if (failedElements.length > 0) {
+ failedElements.forEach(function(element) {
+ getLinkedElements(element.link).each(function() {
+ $(this).remove()
+ });
+ });
+ }
+ var loadedElements = links.filter(function(element) {
+ return !element.loading && !element.failed;
+ });
+ if (loadedElements.length > 0) {
+ ajaxGet("getLinkedElement.ajax", {
+ "elements": JSON.stringify(loadedElements.map(function(element) {
+ return element.link;
+ }))
+ }, function (data, textStatus) {
+ if ((data != null) && (data.success)) {
+ data.linkedElements.forEach(function (linkedElement) {
+ getLinkedElements(linkedElement.link).each(function() {
+ $(this).replaceWith(linkedElement.html);
+ });
+ });
+ }
+ });
+ }
+}
+
+function getLinkedElements(link) {
+ return $(".linked-element[title='" + link + "']")
+}
+
/**
* Marks the given Sone as known if it is still new.
*
if (!getPost(postId).is(":visible")) {
return;
}
- getPost(postId).find(".post-status-line > .time a").html(timeText).attr("title", tooltip);
+ getPost(postId).find(".post-status-line > .time a").html(timeText).prop("title", tooltip);
(function(postId, refreshTime) {
setTimeout(function() {
updatePostTimes(postId);
* Comma-separated post IDs
*/
function updatePostTimes(postIds) {
- ajaxGet("getTimes.ajax", { "posts" : postIds }, function(data, textStatus) {
- if ((data != null) && data.success) {
- $.each(data.postTimes, function(index, value) {
- updatePostTime(index, value.timeText, value.refreshTime, value.tooltip);
- });
- }
- });
+ if (postIds != "") {
+ ajaxGet("getTimes.ajax", {"posts": postIds}, function (data, textStatus) {
+ if ((data != null) && data.success) {
+ $.each(data.postTimes, function (index, value) {
+ updatePostTime(index, value.timeText, value.refreshTime, value.tooltip);
+ });
+ }
+ });
+ }
}
/**
* The tooltip to show
*/
function updateReplyTime(replyId, timeText, refreshTime, tooltip) {
- getReply(replyId).find(".reply-status-line > .time").html(timeText).attr("title", tooltip);
+ getReply(replyId).find(".reply-status-line > .time").html(timeText).prop("title", tooltip);
(function(replyId, refreshTime) {
setTimeout(function() {
updateReplyTimes(replyId);
* Comma-separated post IDs
*/
function updateReplyTimes(replyIds) {
- ajaxGet("getTimes.ajax", { "replies" : replyIds }, function(data, textStatus) {
- if ((data != null) && data.success) {
- $.each(data.replyTimes, function(index, value) {
- updateReplyTime(index, value.timeText, value.refreshTime, value.tooltip);
- });
- }
- });
+ if (replyIds != "") {
+ ajaxGet("getTimes.ajax", {"replies": replyIds}, function (data, textStatus) {
+ if ((data != null) && data.success) {
+ $.each(data.replyTimes, function (index, value) {
+ updateReplyTime(index, value.timeText, value.refreshTime, value.tooltip);
+ });
+ }
+ });
+ }
}
function resetActivity() {
*/
function changeIcon(iconUrl) {
$("link[rel=icon]").remove();
- $("head").append($("<link>").attr("rel", "icon").attr("type", "image/png").attr("href", iconUrl));
+ $("head").append($("<link>").prop("rel", "icon").prop("type", "image/png").prop("href", iconUrl));
$("iframe[id=icon-update]")[0].src += "";
}
* user
*/
function createNotification(id, lastUpdatedTime, text, dismissable) {
- var notification = $("<div></div>").addClass("notification").attr("id", id).attr("lastUpdatedTime", lastUpdatedTime);
+ var notification = $("<div></div>").addClass("notification").prop("id", id).prop("lastUpdatedTime", lastUpdatedTime);
if (dismissable) {
var dismissForm = sone.find("#notification-area #notification-dismiss-template").clone().removeClass("hidden").removeAttr("id");
dismissForm.find("input[name=notification]").val(id);
sone.find(".rip-out").each(function() {
var oldElement = $(this);
var newElement = $("<input type='text'/>");
- newElement.attr("class", oldElement.attr("class")).attr("name", oldElement.attr("name"));
+ newElement.prop("class", oldElement.prop("class")).prop("name", oldElement.prop("name"));
oldElement.before(newElement).remove();
});
});
sone.find("#update-status").submit(function() {
var button = $("button:submit", this);
- button.attr("disabled", "disabled");
+ button.prop("disabled", "disabled");
if ($(this).find(":input.default:enabled").length > 0) {
return false;
}
getTranslation("WebInterface.Confirmation.DeletePostButton", function() {
getTranslation("WebInterface.Confirmation.DeleteReplyButton", function() {
getTranslation("WebInterface.DefaultText.Reply", function() {
- getTranslation("WebInterface.Button.Comment", function () {
- sone.find(".post").each(function() {
+ getTranslation("WebInterface.Button.Comment", function () {
+ sone.find(".post").each(function() {
ajaxifyPost(this);
});
});