").appendTo("body"); scrollbarWidth=scrollbarParent.children().innerWidth()-scrollbarParent.children().height(99).innerWidth(); if (userAgent.match(/(edge\/\d+|Edge\/\d+)/)) {scrollbarWidth=scrollbarWidth+4;} scrollbarParent.remove();} $("a[data-linkinject]").each(function() {$(this).attr("href",$(this).data("linkinject"));}); $("#interfacemenu").on("show.bs.collapse hide.bs.collapse", function(e) {e.preventDefault(); $(this).toggleClass("in");}); $("#interfacemenu .dropdown-menu").on("click", function(e) {if ($(e.target).closest("a, button, input").length===0) {e.stopPropagation();}}); $(".servicesselect>a").on("click", function(e) {e.preventDefault(); e.stopPropagation(); $(this).blur(); const $selected=$(this).parent(); $("#serviceslist>li.servicesselect").not($selected).removeClass("selected selectedsmall"); $selected.addClass("selected"); if ($(this).find(".fa-caret-right").first().css("display")==="none") {$selected.toggleClass("selectedsmall");} else {$selected.addClass("selectedsmall");} if ($selected.offset().top<$(window).scrollTop() || $selected.offset().top+$selected.outerHeight()>$(window).scrollTop()+$(window).height()) {$selected[0].scrollIntoView({behavior: "auto", block: "start"});}}); $(document).on("show.bs.modal", function() {$("#interfacemenu .dropdown.open").each(function() {$(this).find(".dropdown-toggle").dropdown("toggle");}); if ($("#interfacemenu").hasClass("in")) {$("#interfaceheader .navbar-toggle").click();}}); $(document).on("shown.bs.modal",function(){if (!isMobile) {$("body, #interfaceheader, .modal").css("margin-right",scrollbarWidth+"px"); if (!$("#proxyscroll").length) {$("
").appendTo("body");}} $("body").css({"overflow-x":"hidden","overflow-y":"hidden"});}); $(document).on("hidden.bs.modal",function(){if (!$(".modal").is(":visible")) {if (!isMobile) {$("body, #interfaceheader, .modal").css("margin-right","0"); $("#proxyscroll").remove();} $("body").css({"overflow-x":"visible","overflow-y":"scroll"});}}); if (isFF) {$("#interfaceheader .badge").css("padding-bottom","4px");} if (isMobile) {$("head").append("");} if (userAgent.match(/(iphone|ipad|ipod)/)) {$("head").append("");} $(".interfacematcheditor, .interfacematchtranslator, .interfacematchdesigner, .interfacematchwriter").click(function(e) {e.preventDefault(); const role=((e.currentTarget.className || "").match(/interfacematch(editor|translator|designer|writer)/) || [, "editor"] )[1], saved=(() => {try {return (localStorage.getItem("match"+role) || "").trim();} catch (err) {return "";}})(), $modal=$("#matchmodal"), $body=$modal.find(".modal-body").first(), $intro=$body.children("div:first-of-type"), $dialog=$body.children("div:last-of-type"); if (saved) {$intro.hide(); $dialog.html(saved).show();} else {$intro.show(); $dialog.hide().empty();} $modal.find("textarea").val(""); $modal.find(".matcheditor, .matchtranslator, .matchdesigner, .matchwriter").hide(); $modal.find(".match"+role).show(); $modal.modal({backdrop: "static", keyboard: false, show: true});}); $("#matchconfirmclear").click(function() {$("#matchconfirmmodal").modal({backdrop: "static", keyboard: false, show: true});}); $("#matchclear").click(function() {const $modal=$("#matchmodal"), $textarea=$modal.find("textarea:visible").first(), role=(($textarea.attr("class") || "").match(/match(editor|translator|designer|writer)/) || [, "editor"])[1], $body=$modal.find(".modal-body").first(), $intro=$body.children("div:first-of-type"), $dialog=$body.children("div:last-of-type"); try {localStorage.removeItem("match"+role);} catch (err) {} $dialog.empty(); $textarea.val("").focus(); if (!$intro.is(":visible")) {$intro.stop(true, true).fadeIn(200); $dialog.hide();} $("#matchconfirmmodal").modal("hide");}); $("#matchsubmit").click(function() {if ($("#matchhoneypot").val()==="") {const $modal=$("#matchmodal"), $textarea=$modal.find("textarea:visible").first(); if ($textarea.length) {const paragraphs=$textarea.val().replace(/&/g, "&").replace(//g, ">").replace(/\r\n?/g, "\n").replace(/[\x00-\x1F\x7F]/g, "").replace(/[\u200B-\u200D\uFEFF]/g, "").replace(/\n{2,}/g, "\n").trim().split(/\n+/).map(s => s.trim()).filter(Boolean), newDialog=paragraphs.length ? "" + paragraphs.join("
") + "
" : ""; if (newDialog!=="") {const $submit=$(this), $buttons=$modal.find("button"), $body=$modal.find(".modal-body").first(), $intro=$body.children("div:first-of-type"), introFade=$intro.is(":visible") ? $intro.stop(true, true).fadeOut(200).promise() : $.Deferred().resolve().promise(), $dialog=$body.children("div:last-of-type"), role=(($textarea.attr("class") || "").match(/match(editor|translator|designer|writer)/) || [, "editor"])[1]; $buttons.prop("disabled", true); $submit.addClass("matchloading").attr("aria-busy", "true"); introFade.done(function() {$textarea.val(""); $dialog.show().append(""); $body.scrollTop($body[0].scrollHeight); const shortDialog=truncateMatch($dialog), $ai=$(""); $.when($.ajax({url: "/processmatch", method: "POST", dataType: "text", timeout: 30000, data: {dialog: shortDialog, role: role, isvalidate: "true"}}), $.Deferred(function(d) {setTimeout(function() {d.resolve();}, 1000);}).promise()).then(function(ajaxTuple) {if (String(ajaxTuple[0] || "").trim()==="true") {return $.ajax({url: "/processmatch", method: "POST", dataType: "text", timeout: 30000, data: {dialog: shortDialog, role: role, isvalidate: "false"}});} else {return $.Deferred().resolve(ajaxTuple[0]).promise();}}).then(function(aiMessage) {aiMessage=String(aiMessage || "").trim(); if (!aiMessage) {return $.Deferred().reject().promise();} else {const $caret=$("█"), aiMessageArray=aiMessage.replace(//gi, "").replace(/<\/p>/gi, "\n\n").replace(/\r\n?/g, "\n").trim().split(/\n{2,}/).map(p => p.trim()).filter(Boolean); let t=0, lastDelay=0; $dialog.append($ai.append($caret)); $ai[0].scrollIntoView({block: "nearest"}); for (let pi=0; pi0) {t+=250;} const parts=aiMessageArray[pi].match(/[^.!?]+[.!?]*\s*/g) || [aiMessageArray[pi]]; for (let si=0; si {$ai.append($("").text(content).css("animation-delay", delay+"ms"));}, delay); lastDelay=delay; t+=90;} if (pi {$ai.append($("").css("animation-delay", delay+"ms"));}, delay); lastDelay=delay;}} setTimeout(() => {$ai.find(".matchchunk, .matchbr").each(function() {$(this).replaceWith($(this).text());}); $caret.remove(); try {localStorage.setItem("match"+role, truncateMatch($dialog));} catch (err) {} $buttons.prop("disabled", false); $submit.removeClass("matchloading").attr("aria-busy", "false");}, lastDelay+220);}}).fail(function() {const $error=$("Sorry—something went wrong. Please try again.
"); $dialog.append($ai.append($error)); $ai[0].scrollIntoView({block: "nearest"}); try {localStorage.setItem("match"+role, truncateMatch($dialog));} catch (err) {} $buttons.prop("disabled", false); $submit.removeClass("matchloading").attr("aria-busy", "false");});});} else {$textarea.focus();}}}}); $("#interfaceediting").click(function(e) {e.preventDefault(); $("#editingmodal").modal({backdrop:"static", keyboard:false, show:true});}); $(".interfacecontact").click(function(e) {e.preventDefault(); $("#contactmodal").modal({backdrop:"static", keyboard:false, show:true});}); $("#contactsubmit").click(function(){$("#contactform").submit();}); $(".results, .modalresults").each(function(){$(this).attr("src","about:blank");}); $(".modalresults").parents(".modal").on("hidden.bs.modal",function(){$(".modalresults",this).css({"height":"0","margin-bottom":"0"}).attr("src","about:blank");}); $(".modal").on("hidden.bs.modal",function(){$(".modal-footer",this).addClass("modalbtnhide");}); $(window).on("shown.bs.modal",function(){$(".modal:visible").each(function(){var shownModal=$(this), checkFooter=setInterval(function(){var shownFooter=shownModal.find(".modal-footer").first(); if (shownFooter.length) {clearInterval(checkFooter); modalButtons(shownFooter);}},0);});}); $("#browsemodal, #setupprojectmodal, #paymentmodal").on("hidden.bs.modal",function(){$(this).find(".modal-content").empty(); $(this).removeData();}); targetForm(""); modalScroll(""); modalPopover($("body")); $("a[data-toggle='popover']").on("shown.bs.popover",function(){modalPopover($(this).next());}); if (isMobile) {$(".modal-content").css("margin-bottom","30px"); $("#matchmodal textarea").css("font-size", "16px");} else {$(".modal-scroll").scroll(function(){$("[data-toggle=popover]").popover("hide");});} localDate(); $("#interfacesignin").click(function(e) {e.preventDefault(); signinModal("");}); $(".interfacejoin").click(function(e) {e.preventDefault(); $("#joinmodal").modal({backdrop:"static", keyboard:false, show:true});}); $(".signinretrieve").click(function(e) {e.preventDefault(); $(this).blur().toggleClass("signinretrieveactive");}); $("#signinsubmit").click(function(){$("#signinform").submit();}); $("#managersubmit").click(function(){$("#managertarget").val($("#signintarget").val()); $("#managerusername").val($("#signinusername").val()); $("#managerpassword1").val($("#signinpassword1").val()); $("#managerisremember").val($("#signinisremember").val()); $("#managerform").submit();}); if (typeof(Storage)!=="undefined") {var newBreadcrumbs=localStorage.getItem("breadcrumbpost95588en"), breadcrumbStart=$("#bodyfooter .breadcrumb li").first(), breadcrumbEnd=$("#bodyfooter .breadcrumb .active").first(), breadcrumbRemove=false; if (breadcrumbStart.length && breadcrumbEnd.length && newBreadcrumbs!=null && newBreadcrumbs!="") {$("#bodyfooter .breadcrumb li").each(function(){if ($(this).is(breadcrumbEnd)) {$(this).before(newBreadcrumbs); return false;} if (breadcrumbRemove) {$(this).remove();} if ($(this).is(breadcrumbStart)) {breadcrumbRemove=true;}});}} var subgenre=$("#body #comedy"); if (subgenre.length) {$(window).scrollTop(subgenre.offset().top-68);} setTimeout(function(){$(document).trigger("afterready");},1);}); $(document).bind("afterready",function(){$("html").css("opacity","1"); if ($("#bodyheader").length) {$("#bodyheader").css("opacity","1");}}); $(function(){$("[data-toggle=popover]").popover();}); $("body").on("click",function(e){$("[data-toggle=popover]").each(function(){if (!$(this).is(e.target) && $(this).has(e.target).length===0 && $(".popover").has(e.target).length===0) {$(this).popover("hide");}});}); $(window).resize(function(){$("[data-toggle=popover]").popover("hide");}); $(window).resize(function(){modalScroll(""); modalButtons($(".modal-footer:visible")); if ($.isFunction(window.froalaHeight)) {froalaHeight();} $(".results, .modalresults, .message").each(function(){if ($(this).contents().has("title").length && !($(this).hasClass("message") && $(this).prev().hasClass("msginitial"))) {iframeSize($(this));}});}); $(function(){$("[href^='#']").not("[href~='#']").click(function(e){e.preventDefault(); $(window).scrollTop($("[id*='"+$(this).attr("href").split("#")[1]+"']").offset().top-68);});});