// Functions for WS push. function initPush() { OmniFaces.Push.open("page"); } function handlePush(data) { var functionReference = window[data.functionName]; if (functionReference) { (function wait() { if (!kizitos.inProgress()) { // inProgress() returns true if there's currently an ajax request running. functionReference(data.functionData); } else { setTimeout(wait, 250); // If that's the case, recheck after 250ms until it's finished, else push updates may miss hits due to ajax updates. } })(); } else { throw new Error("Function " + data.functionName + " does not exist."); } } function closePush() { OmniFaces.Push.close("page"); } function updateLink(data) { var $link = $("#link_" + data.id); if (!$link.length) { return; } $link.attr("title", data.title); $link.find(".text").text(data.text); if (data.icon) { $link.find("[class^='favicon-']").attr("class", "favicon").css("background-image", "url(/favicon/link/" + data.icon + "?" + new Date().getTime() + ")"); } var $block = $link.closest(".block"); var order = $block.find("ol").data("order"); if (order == "a") { // Alphabetic; in case link title has been changed. sortBlock($block, order); } updateBrokenStatus($link, data.broken); highlight($link); } function updateLinkTitleSuggestions(data) { if (!data.suggestions) { return; } var $link = $("#link_" + data.id); if (!$link.length) { return; } var $suggestions = $("Title suggestions:").insertAfter($link); for (var i = 0; i < data.suggestions.length; i++) { var suggestion = data.suggestions[i]; $suggestions.append($("").attr("title", "Change title to " + suggestion)); } $suggestions.append(""); } function updateSuggestedLink(data) { var $suggestedLink = $("#suggestedLink_" + data.id); if (!$suggestedLink.length) { return; } $suggestedLink.attr("title", data.title); $suggestedLink.find(".text").text(data.text); if (data.icon) { $suggestedLink.find("img").attr("src", "/favicon/link/" + data.icon + "?" + new Date().getTime()); } updateBrokenStatus($suggestedLink, data.broken); highlight($suggestedLink); } function updateProfileBlogLink(data) { var $blogLink = $("#profile-blog"); if (!$blogLink.length) { return; } $blogLink.find(".text").text(data.text); highlight($blogLink); } /* Private ---------------------------------------------------------------------------------------------------------- */ function updateBrokenStatus($link, broken) { var $li = $link.closest("li"); if ($li.hasClass("broken")) { if (!broken) { $li.removeClass("broken").find(".link-menu.broken").remove(); } } else if (broken) { $li.addClass("broken").find(".menu").prepend(""); } }