관리-도구
편집 파일: admin.min.js
function modal_submit_form(e,a,d,t=""){""===t||window[t](d)?document.getElementById(a).submit():e.preventDefault()}function advads_set_tab_hashes(){jQuery("#advads-tabs").find("a").each((function(){var e=jQuery(this).attr("id").replace("-tab",""),a=jQuery("#"+e).children(".advads-settings-tab-main-form");if(a.length){var d=a.attr("action").split("#")[0];a.attr("action",d+jQuery(this).attr("href"))}}))}function advads_scroll_to_element(e){var a=jQuery("#wpadminbar").height();jQuery("html, body").animate({scrollTop:jQuery(e).offset().top-a},1e3)}function advads_toggle(e){jQuery(e).slideToggle()}function advads_toggle_box(e,a){jQuery(e).is(":checked")?jQuery(a).slideDown():jQuery(a).slideUp()}function advads_toggle_box_enable(e,a){jQuery(e).is(":checked")?jQuery(a).find("input").removeAttr("disabled",""):jQuery(a).find("input").attr("disabled","disabled")}function advads_validate_new_form(e){return jQuery(".advads-form-type input:checked").length?(jQuery(".advads-form-type-error").hide(),""==jQuery(".advads-form-name").val()?(jQuery(".advads-form-name-error").show(),!1):(jQuery(".advads-form-name-error").hide(),!0)):(jQuery(".advads-form-type-error").show(),!1)}function advads_group_edit_submit(e){return jQuery(".advads-ad-group-form").filter(((a,d)=>!jQuery(d).parents(e).length)).remove(),!0}function advads_maybe_textarea_to_tinymce(e){var a=jQuery("#advads-ad-content-plain"),d=a.val(),t="advanced-ads-tinymce",n=jQuery("#"+t),s=jQuery("#advanced-ads-tinymce-wrapper");if("content"!==e)return n.prop("name",t),s.hide(),!1;if("object"==typeof tinyMCE&&null!==tinyMCE.get(t)){if(d){var o=window.wp;o&&o.editor&&o.editor.autop&&tinyMCE.get(t).getParam("wpautop",!0)&&(d=o.editor.autop(d)),tinyMCE.get(t).setContent(d)}a.remove(),n.prop("name",a.prop("name")),s.show()}else n.length&&(n.val(d),a.remove(),n.prop("name",a.prop("name")),s.show())}function advads_show_adsense_auto_ads_warning(){$msg=jQuery(".advads-auto-ad-in-ad-content").show(),$msg.on("click","button",(function(){$msg.hide(),jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"advads-adsense-enable-pla",nonce:advadsglobal.ajax_nonce}}).done((function(e){$msg.show().html(advadstxt.page_level_ads_enabled)})).fail((function(e,a){$msg.show()}))}))}function advads_ads_txt_find_issues(){var e=jQuery("#advads-ads-txt-notice-wrapper"),a=jQuery("#advads-ads-txt-notice-refresh"),d=jQuery(".advads-ads-txt-action");function t(a){d.toggle(!a),a&&e.html('<span class="spinner advads-spinner"></span>')}function n(a){e.html(a.notices),t(!1)}function s(a){e.html('<p class="advads-notice-inline advads-error">'+jQuery("#advads-ads-txt-notice-error").text().replace("%s",parseInt(a.status,10)),NaN),t(!1)}function o(e){t(!0),jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"advads-ads-txt",nonce:advadsglobal.ajax_nonce,type:e}}).done(n).fail(s)}e.length&&(e.find("ul").length||o("get_notices"),a.on("click",(function(){o("get_notices")})),jQuery(document).on("click","#advads-ads-txt-remove-real",(function(e){e.preventDefault();var a={data:{action:"advads-ads-txt",nonce:advadsglobal.ajax_nonce,type:"remove_real_file"},done:function(e){e.additional_content&&jQuery("#advads-ads-txt-additional-content").val(e.additional_content),n(e)},fail:s,before_send:function(){t(!0)}};advanced_ads_admin.filesystem.ajax(a)})),jQuery(document).on("click","#advads-ads-txt-create-real",(function(e){e.preventDefault();var a={data:{action:"advads-ads-txt",nonce:advadsglobal.ajax_nonce,type:"create_real_file"},done:n,fail:s,before_send:function(){t(!0)}};advanced_ads_admin.filesystem.ajax(a)})))}jQuery(document).ready((function(e){function a(e){e.each((function(){var e=jQuery(this);e.parents(".advads-ad-group-form").find(".advads-option:not(.static)").hide();var a=e.val();e.parents(".advads-ad-group-form").find(".advads-group-type-"+a).show()}))}function d(a=!0){var d=e("button.advads-license-activate, button.advads-license-deactivate");a?d.attr("disabled","disabled"):d.removeAttr("disabled")}function t(e){var a=e.replace(/^#top(#|%23)/,"").replace(/(#|%23)/,"").split("__");return{tab:a[0]||jQuery(".advads-tab").attr("id"),anchor:a[1]}}function n(e){if(jQuery("#advads-tabs").find("a").removeClass("nav-tab-active"),jQuery(".advads-tab").removeClass("active"),jQuery("#"+e.tab).addClass("active"),jQuery("#"+e.tab+"-tab").addClass("nav-tab-active"),e.anchor){var a=document.getElementById(e.anchor).getBoundingClientRect().top;window.scrollTo(0,a+window.scrollY-48)}}e(document).on("click","#switch-to-adsense-type",(function(a){a.preventDefault(),AdvancedAdsAdmin.AdImporter.adsenseCode=Advanced_Ads_Admin.get_ad_source_editor_text(),e("#advanced-ad-type-adsense").trigger("click"),e(this).closest("li").addClass("hidden")})),e(document).on("change","#advanced-ad-type input",(function(){!function(a){jQuery("#advanced-ad-type input").prop("disabled",!0),e("#advanced-ads-tinymce-wrapper").hide(),e("#advanced-ads-ad-parameters").html('<span class="spinner advads-ad-parameters-spinner advads-spinner"></span>'),e.ajax({type:"POST",url:ajaxurl,data:{action:"load_ad_parameters_metabox",ad_type:a,ad_id:e("#post_ID").val(),nonce:advadsglobal.ajax_nonce},success:function(d,t,n){d&&(e("#advanced-ads-ad-parameters").html(d).trigger("paramloaded"),advads_maybe_textarea_to_tinymce(a))},error:function(a,d,t){e("#advanced-ads-ad-parameters").html(t)}}).always((function(e,a,d){jQuery('#advanced-ad-type input[name^="advanced_ad"]').prop("disabled",!1)}))}(e(this).val())})),e("#advads-ad-injection-box .advads-ad-injection-button").on("click",(function(){var a=this.dataset.placementType,d=this.dataset.placementSlug,t={};if(a||d){if(a&&"post_content"===a){var n=prompt(advadstxt.after_paragraph_promt,1);null!==n&&(t.index=parseInt(n,10))}e("#advads-ad-injection-box .advads-loader").show(),e("#advads-ad-injection-box-placements").hide(),e("body").animate({scrollTop:e("#advads-ad-injection-box").offset().top-40},1,"linear"),e.ajax({type:"POST",url:ajaxurl,data:{action:"advads-ad-injection-content",placement_type:a,placement_slug:d,ad_id:e("#post_ID").val(),options:t,nonce:advadsglobal.ajax_nonce},success:function(a,d,t){a?(e("#advads-ad-injection-box *").hide(),e("#advads-ad-injection-message-placement-created .advads-placement-link").attr("href",e("#advads-ad-injection-message-placement-created a").attr("href")+a),e("#advads-ad-injection-message-placement-created, #advads-ad-injection-message-placement-created *").show()):e("#advads-ad-injection-box").html("an error occured")},error:function(a,d,t){e("#advads-ad-injection-box").html(t)}}).always((function(e,a,d){}))}})),e(".advads-buttonset").advads_buttonset(),e.fn.accordion&&e(".advads-accordion").accordion({active:!1,collapsible:!0}),e(".advads-ad-list-tooltip").advads_tooltip({content:function(){return jQuery(this).find(".advads-ad-list-tooltip-content").html()}}),e(".post-type-advanced_ads .wp-list-table thead th:last-of-type").append(e('<span class="dashicons dashicons-edit"></span>').on("click",(function(){e("#show-settings-link").trigger("click")}))),(()=>{let e="0",a="";const d=jQuery(".advads-placements-table tbody tr"),t=t=>{d.each(((d,t)=>{const n=jQuery(t),s=n.data("order");void 0!==s&&void 0!==s.type&&void 0!==s.name?n.toggle(!("0"!==e&&s.type!==e||""!==a&&-1===s.name.toLowerCase().indexOf(a.toLowerCase()))):n.show()}))};jQuery(".advads_filter_placement_type").on("change",(function(){e=jQuery(this).val(),t()})),jQuery(".advads_search_placement_name").on("keyup",(function(){a=this.value,t()}))})(),document.querySelectorAll('[name="advads[placement][type]"]').forEach((e=>{e.addEventListener("input",(e=>{jQuery('[name="advads[placement][item]"]').attr("disabled",!0),wp.ajax.post(window.advadstxt.placements_allowed_ads.action,{_ajax_nonce:window.advadstxt.placements_allowed_ads.nonce,placement_type:e.target.value}).done((e=>{jQuery('[name="advads[placement][item]"]').replaceWith(wp.template("advads-placement-ad-select")({items:Object.values(e.items)}))}))}))})),jQuery(".advads-delete-tag").each((function(){jQuery(this).on("click",(function(){if(!0===confirm(window.advadstxt.delete_placement_confirmation)){var e=jQuery(this).parents(".advanced-ads-placement-row");e.find(".advads-placements-item-delete").prop("checked",!0),e.data("touched",!0),jQuery("#advanced-ads-placements-form").submit()}}))})),jQuery(".advads-sort").on("click",(function(e){var a=jQuery(this),d=a.data("orderby"),t=jQuery(".advads-placements-table"),n=jQuery("> tbody > tr",t);jQuery("> thead th > a",t).each((function(){jQuery(this).removeClass("advads-placement-sorted")})),a.addClass("advads-placement-sorted"),n.sort((function(e,a){let t=jQuery(e).data("order"),n=jQuery(a).data("order");return"type"===d?t["words-between-repeats"]!==n["words-between-repeats"]?t["words-between-repeats"]?1:-1:t.order===n.order?t["post-content-index"]&&n["post-content-index"]&&t["post-content-index"]!==n["post-content-index"]?t["post-content-index"]<n["post-content-index"]?-1:1:t.name.localeCompare(n.name,void 0,{numeric:!0}):t.order-n.order:t.name.localeCompare(n.name,void 0,{numeric:!0})})),jQuery.each(n,(function(e,a){t.append(a)}));var s=window.location.pathname+window.location.search;-1!==s.indexOf("orderby=")?s=s.replace(/\borderby=[0-9a-zA-Z_@.#+-]{1,50}\b/,"orderby="+d):s+="&orderby="+d,window.history.replaceState({orderby:d},document.title,s),e.preventDefault()})),e("#advads-output-wrapper-id").on("keyup",(function(){var a=e(this).val();/^[a-z-0-9]*$/.test(a)?e(".advads-output-wrapper-id-error").addClass("hidden"):e(".advads-output-wrapper-id-error").removeClass("hidden")})),e(".advads-group-add-ad button").on("click",(function(){var a=e(this).closest(".advads-ad-group-form"),d=a.find(".advads-group-add-ad-list-ads option:selected"),t=a.find(".advads-group-add-ad-list-weights").last(),n=a.find(".advads-group-ads tbody");const s=d.val().match(/\d+/g);let o="";s&&(o=advancedAds.endpoints.editAd+s.pop()),d.length&&t.length&&!n.find('[name="'+d.val()+'"]').length&&n.append(e("<tr></tr>").append(e("<td></td>").html(`<a target="_blank" href="${o}">${d.text()}</a>`),e("<td></td>").append(t.clone().val(t.val()).prop("name",d.val())),'<td><button type="button" class="advads-remove-ad-from-group button">x</button></td>'))})),e("#advads-ad-group-list").on("click",".advads-remove-ad-from-group",(function(){var a=e(this).closest("tr");a.data("ad-id")&&e("#advads-ad-group-list form").append('<input type="hidden" name="advads-groups-removed-ads[]" value="'+a.data("ad-id")+'"><input type="hidden" name="advads-groups-removed-ads-gid[]" value="'+a.data("group-id")+'">'),a.remove()})),e(".advads-ad-group-type input").on("click",(function(){a(e(this))})),a(e(".advads-ad-group-type input:checked")),e(".advads-group-ads-list-show-more").on("click",(function(){e(this).hide().parent().siblings(".advads-ad-group-list-ads").children("div").show()})),e(".advads-settings-tab-main-form .advads-license-key").on("blur",(function(){var a=e(this).val();if(""!==a){var d=e(".advads-settings-tab-main-form .advads-license-key"),t=[];d.each((function(a,d){""===e(d).val()&&t.push(d)})),d.length===t.length+1&&e.each(t,(function(d,t){e(t).val(a)}))}})),e(".advads-license-activate").on("click",(function(){var a=e(this);if(this.dataset.addon){d(!0);var t={action:"advads-activate-license",addon:this.dataset.addon,pluginname:this.dataset.pluginname,optionslug:this.dataset.optionslug,license:e(this).parents("td").find(".advads-license-key").val(),security:e("#advads-licenses-ajax-referrer").val()};e('<span class="spinner advads-spinner"></span>').insertAfter(a),e.post(ajaxurl,t,(function(n){e("span.spinner").remove();var s=a.parents("td");if("1"===n){const e="advanced-ads-licenses["+t.addon+"]";r.setInitialValue(e,document.querySelector('[name="'+e+'"]')),s.find(".advads-license-activate-error").remove(),s.find(".advads-license-deactivate").show(),a.fadeOut(),s.find(".advads-license-activate-active").fadeIn(),s.find("input").prop("readonly","readonly"),d(!1)}else if("ex"===n){var o=s.find("input.advads-license-key"),i=s.find("a.advads-renewal-link");if(o&&i){var c=o.val(),l=i.prop("href");i.prop("href",l.replace("%LICENSE_KEY%",c))}s.find(".advads-license-activate-error").remove(),s.find(".advads-license-expired-error").show(),d(!1)}else s.find(".advads-license-activate-error").show().html(n),d(!1)}))}})),e(".advads-license-deactivate").on("click",(function(){var a=e(this);if(this.dataset.addon){d(!0);var t={action:"advads-deactivate-license",addon:this.dataset.addon,pluginname:this.dataset.pluginname,optionslug:this.dataset.optionslug,security:e("#advads-licenses-ajax-referrer").val()};e('<span class="spinner advads-spinner"></span>').insertAfter(a),e.post(ajaxurl,t,(function(t){e("span.spinner").remove(),"1"===t?(a.siblings(".advads-license-activate-error").hide(),a.siblings(".advads-license-activate-active").hide(),a.siblings(".advads-license-activate").show(),a.siblings("input").prop("readonly",!1),a.fadeOut(),d(!1)):"ex"===t?(a.siblings(".advads-license-activate-error").hide(),a.siblings(".advads-license-activate-active").hide(),a.siblings(".advads-license-expired-error").show(),a.siblings("input").prop("readonly",!1),a.fadeOut(),d(!1)):(console.log(t),a.siblings(".advads-license-activate-error").show().html(t),a.siblings(".advads-license-activate-active").hide(),d(!1))}))}})),jQuery(document).on("click",'a[href*="page=advanced-ads-settings"]:not(.nav-tab)',(function(){n(t(jQuery(this).attr("href").split("advanced-ads-settings")[1]))})),window.addEventListener("hashchange",(e=>{const a=t(new URL(e.newURL).hash);try{document.getElementById(a.tab+"-tab").dispatchEvent(new Event("click"))}catch(e){}})),n(t(window.location.hash)),advads_set_tab_hashes(),jQuery(".advads-tab-sub-menu").each((function(e,a){if("function"==typeof a.scrollIntoView){advads_settings_parent_tab=jQuery(a).parent(".advads-tab");var d=advads_settings_parent_tab.find("h2");d.length>1&&(advads_submenu_list=jQuery("<ul>"),d.each((function(e,a){var d="advads-tab-headline-"+advads_settings_parent_tab.attr("id")+e;jQuery(a).attr("id",d);var t=t=a.textContent||a.innerText;jQuery("<li><a onclick=\"document.getElementById('"+d+"').scrollIntoView()\">"+t+"</a></li>").appendTo(advads_submenu_list)})),advads_submenu_list.appendTo(a))}})),e("body:not(.post-type-advanced_ads ) #advads-show-filters").on("click",(function(){const a=e(this).find(".dashicons").hasClass("dashicons-arrow-up");e(".advads-toggle-with-filters-button").toggleClass("hidden",a),e("#advads-show-filters .dashicons").toggleClass("dashicons-filter",a),e("#advads-show-filters .dashicons").toggleClass("dashicons-arrow-up",!a)})),e('.post-type-advanced_ads .check-column input[type="checkbox"]').on("change",(function(){e(".post-type-advanced_ads .tablenav.bottom .bulkactions").toggleClass("fixed",0<e('.post-type-advanced_ads .check-column input[type="checkbox"]:checked').length)})),e("#advads-show-screen-options").on("click",(function(){e("#show-settings-link").trigger("click")})),e('<button type="button" class="button advads-button-secondary">'+advadstxt.close+"</button>").appendTo(e(".post-type-advanced_ads #adv-settings .submit")).on("click",(function(){e("#show-settings-link").trigger("click")}));var s=function(){var a=e(this).closest("tr.advanced-ads-placement-row");a&&a.data("touched",!0)};function o(a){"custom"===e(a).find("option:selected").val()?e(a).next(".advads-placements-content-custom-xpath").show():e(a).next(".advads-placements-content-custom-xpath").hide()}e("form#advanced-ads-placements-form input, #advanced-ads-placements-form select").on("change",s),e("form#advanced-ads-placements-form button").on("click",s),e("form#advanced-ads-placements-form .advads-modal").on("mouseover",s),e(document).on("advads-modal-canceled",(a=>{const d=e("#"+a.detail.modal_id).parents(".advanced-ads-placement-row");d.length&&d.data("touched",!1)})),e("form#advanced-ads-placements-form").on("submit",(function(){jQuery("form#advanced-ads-placements-form tr.advanced-ads-placement-row");jQuery("form#advanced-ads-placements-form tr.advanced-ads-placement-row").each((function(e,a){(a=jQuery(a)).data("touched")||a.find("input, select").each((function(e,a){(a=jQuery(a)).prop("disabled",!0)}))}))})),e(".advads-placements-content-tag").each((function(){o(this)})),e(".advads-placements-content-tag").on("change",(function(){o(this)})),e(".advads-form-type").advads_tooltip({content:function(){return jQuery(this).find(".advads-form-description").html()},parent:e=>{const a=e.parents(".advads-modal");return a.length?"#"+a[0].id:"body"}});const r=(()=>{let e,a,d=!1;if("advanced-ads_page_advanced-ads-placements"===window.advadstxt.admin_page&&(a=document.getElementById("advanced-ads-placements-form"),null!==a&&(e=new Advads_Termination(a))),"advanced_ads"===window.advadstxt.admin_page&&(a=document.getElementById("post"),null!==a&&(e=new Advads_Termination(a))),"advanced-ads_page_advanced-ads-settings"===window.advadstxt.admin_page&&(a=document.querySelector(".advads-tab.active > form"),null!==a&&(e=new Advads_Termination(a)),[...document.getElementsByClassName("nav-tab")].forEach((s=>{s.addEventListener("click",(s=>{if(!e.terminationNotice())return s.preventDefault(),e;n(t(new URL(s.target.href).hash)),a=document.querySelector(".advads-tab.active > form"),null!==a&&(e=new Advads_Termination(a),e.collectValues(),a.addEventListener("submit",(()=>{d=!0})))}))}))),void 0!==e){e.collectValues();const t=a=>{if(!d&&!e.terminationNotice())return a.preventDefault(),a.returnValue="string",e};window.addEventListener("beforeunload",t),a.addEventListener("submit",(()=>{d=!0}))}return e})();var i;e("body").on("click",".advads_image_upload",(function(a){a.preventDefault();var d=e(this);i||(i=wp.media.frames.file_frame=wp.media({id:"advads_type_image_wp_media",title:d.data("uploaderTitle"),button:{text:d.data("uploaderButtonText")},library:{type:"image"},multiple:!1})).on("select",(function(){i.state().get("selection").each((function(a,d){if(a=a.toJSON(),0===d){e("#advads-image-id").val(a.id),e('#advanced-ads-ad-parameters-size input[name="advanced_ad[width]"]').val(a.width),e('#advanced-ads-ad-parameters-size input[name="advanced_ad[height]"]').val(a.height);var t='<img width="'+a.width+'" height="'+a.height+'" title="'+a.title+'" alt="'+a.alt+'" src="'+a.url+'"/>';e("#advads-image-preview").html(t),e("#advads-image-edit-link").attr("href",a.editLink),e("#advads-image-edit-link").removeClass("hidden"),e("#advanced-ads-ad-parameters-size input[type=number]:first").trigger("change")}}))})),i.open()})),window.formfield="",e("#advanced-ads-use-adblocker").on("change",(function(){advads_toggle_box(this,"#advads-adblocker-wrapper")}));var c=e("#advads-adblocker-wrapper"),l=e("#advads-adblocker-rebuild");l.prop("disabled",!1),e(document).on("click","#advads-adblocker-rebuild",(function(a){a.preventDefault();var d=e("#advanced-ads-rebuild-assets-form");d.prev(".error").remove(),l.prop("disabled",!0).after('<span class="spinner advads-spinner"></span>');var t={data:{action:"advads-adblock-rebuild-assets",nonce:advadsglobal.ajax_nonce},done:function(a){c.html(a),l=e("#advads-adblocker-rebuild")},fail:function(e,a,t){d.before('<div class="error"><p>'+a+": "+t+"</p></div>"),l.prop("disabled",!1).next(".advads-spinner").remove()},on_modal_close:function(){l.prop("disabled",!1).next(".advads-spinner").remove()}};e('[name="advads_ab_assign_new_folder"]').is(":checked")&&(t.data.advads_ab_assign_new_folder=!0),advanced_ads_admin.filesystem.ajax(t)})),e("#advanced-ads-ad-parameters").on("change","#advanced-ads-ad-parameters-size input[type=number]",(function(){e("#advanced-ads-ad-parameters-size input[type=number]").filter((function(){return parseInt(this.value,10)>0})).length>=1?e("#advads-wrapper-add-sizes").prop("disabled",!1):e("#advads-wrapper-add-sizes").prop("disabled",!0).prop("checked",!1)})),e("#advanced-ads-ad-parameters").on("paramloaded",(function(){e("#advanced-ads-ad-parameters-size input[type=number]:first").trigger("change")})),e("#advanced-ads-ad-parameters-size input[type=number]:first").trigger("change"),e(".advads-hndlelinks").each((function(){e(this).appendTo(e(this).parents(".postbox").find("h2.hndle")),e(this).removeClass("hidden")})),e(".advads-video-link").on("click",(function(a){a.preventDefault();var d=e(a.target).closest(".postbox");d.removeClass("closed");var t=d.find(".advads-video-link-container");t.html(t.data("videolink"))})),jQuery(".advads_import_type").on("change",(function(){"xml_content"===this.value?(jQuery("#advads_xml_file").hide(),jQuery("#advads_xml_content").show()):(jQuery("#advads_xml_file").show(),jQuery("#advads_xml_content").hide())}));var u=jQuery("textarea[name=advanced_ad\\[content\\]]").text()||"";(-1!==u.indexOf("enable_page_level_ads")||/script[^>]+(?:data-ad-client=|adsbygoogle\.js\?client=)/.test(u))&&advads_show_adsense_auto_ads_warning(),advads_ads_txt_find_issues(),jQuery(".advanced-ads-adsense-dashboard").each((function(e,a){Advanced_Ads_Adsense_Report_Helper&&Advanced_Ads_Adsense_Report_Helper.init(a)}))})),window.advanced_ads_admin=window.advanced_ads_admin||{},advanced_ads_admin.filesystem={_locked_job:!1,_requestForCredentialsModalToggle:function(){this.$filesystemModal.toggle(),jQuery("body").toggleClass("modal-open")},_init:function(){this._init=function(){};var e=this;e.$filesystemModal=jQuery("#advanced-ads-rfc-dialog"),e.$filesystemModal.on("submit","form",(function(a){a.preventDefault(),e.ajax(e._locked_job,!0),e._requestForCredentialsModalToggle()})),e.$filesystemModal.on("click",'[data-js-action="close"]',(function(){jQuery.isPlainObject(e._locked_job)&&e._locked_job.on_modal_close&&e._locked_job.on_modal_close(),e._locked_job=!1,e._requestForCredentialsModalToggle()}))},ajax:function(e,a){if(this._init(),!a&&this.$filesystemModal.length>0)return this._requestForCredentialsModalToggle(),this.$filesystemModal.find("input:enabled:first").focus(),void(this._locked_job=e);var d={method:"POST",url:window.ajaxurl,data:{username:jQuery("#username").val(),password:jQuery("#password").val(),hostname:jQuery("#hostname").val(),connection_type:jQuery('input[name="connection_type"]:checked').val(),public_key:jQuery("#public_key").val(),private_key:jQuery("#private_key").val(),_fs_nonce:jQuery("#_fs_nonce").val()}};e.before_send&&e.before_send(),d.data=jQuery.extend(d.data,e.data);var t=jQuery.ajax(d);e.done&&t.done(e.done),e.fail&&t.fail(e.fail)}},window.Advanced_Ads_Admin=window.Advanced_Ads_Admin||{init_ad_source_editor:function(){},get_ad_source_editor_text:function(){let e="";if(Advanced_Ads_Admin.editor&&Advanced_Ads_Admin.editor.codemirror)e=Advanced_Ads_Admin.editor.codemirror.getValue();else{const a=jQuery("#advads-ad-content-plain");a&&(e=a.val())}return e},set_ad_source_editor_text:function(e){Advanced_Ads_Admin.editor&&Advanced_Ads_Admin.editor.codemirror?Advanced_Ads_Admin.editor.codemirror.setValue(e):jQuery("#advads-ad-content-plain").val(e)},check_ad_source:function(){const e=Advanced_Ads_Admin.get_ad_source_editor_text(),a=jQuery("#advads-parameters-php-warning"),d=jQuery("#advads-allow-php-warning");a.hide(),d.hide();const t=document.getElementById("advads-ad-content-plain");t.value=e,t.dispatchEvent(new Event("input")),jQuery("#advads-parameters-php").prop("checked")&&(/<\?(?:php|=)/.test(e)?d.show():a.show()),jQuery("#advads-parameters-shortcodes").prop("checked")&&!/\[[^\]]+\]/.test(e)?jQuery("#advads-parameters-shortcodes-warning").show():jQuery("#advads-parameters-shortcodes-warning").hide()},reassign_ad:function(e){let a=jQuery("#post_author_override");a.length||(a=jQuery("#post_author")),a.val(e).queue((()=>{jQuery("#post").submit()}))},toggle_placements_visibility:function(e,a){var d=jQuery(e).next(".advads-placements-advanced-options");if(void 0!==a?!a:d.is(":visible"))d.hide(),jQuery("#advads-last-edited-placement").val("");else{var t=jQuery(e).parents(".advads-placements-table-options").find(".advads-placement-slug").val();d.show(),jQuery("#advads-last-edited-placement").val(t);var n=jQuery(e).closest("tr.advanced-ads-placement-row");n&&n.data("touched",!0)}},get_cookie:function(e){var a,d,t,n=document.cookie.split(";");for(a=0;a<n.length;a++)if(d=n[a].substr(0,n[a].indexOf("=")),t=n[a].substr(n[a].indexOf("=")+1),(d=d.replace(/^\s+|\s+$/g,""))===e)return unescape(t)},set_cookie:function(e,a,d,t,n,s){var o=null==d?null:24*d*60*60;this.set_cookie_sec(e,a,o,t,n,s)},set_cookie_sec:function(e,a,d,t,n,s){var o=new Date;o.setSeconds(o.getSeconds()+parseInt(d)),document.cookie=e+"="+escape(a)+(null==d?"":"; expires="+o.toUTCString())+(null==t?"; path=/":"; path="+t)+(null==n?"":"; domain="+n)+(null==s?"":"; secure")}},window.AdvancedAdsAdmin||(window.AdvancedAdsAdmin={}),window.AdvancedAdsAdmin.AdImporter||(window.AdvancedAdsAdmin.AdImporter={highlightSelectedRowInExternalAdsList:function(e){void 0===e&&(e=AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle);const a=jQuery("#mapi-table-wrap tbody");jQuery("#mapi-toggle-idle");(e?jQuery("#mapi-table-wrap tbody tr[data-active=1]").length:jQuery("#mapi-table-wrap tbody tr").length)>8?jQuery("#mapi-table-wrap").addClass("overflow"):jQuery("#mapi-table-wrap").removeClass("overflow");const d=AdvancedAdsAdmin.AdImporter.getSelectedRow();a.find("tr").removeClass("selected error"),d&&d.show();const t=a.find("tr:visible");return t.filter(":odd").css("background-color","#FFFFFF"),t.filter(":even").css("background-color","#F9F9F9"),d&&(d.css("background-color",""),d.addClass("selected"),this.scrollToSelectedRow(d)),d||!1},scrollToSelectedRow(e){const a=jQuery("#mapi-table-wrap"),d=a.height(),t=a.scrollTop();if(!e)return void a.animate({scrollTop:0},200);let n=e.position().top,s=+n+e.height();(n<t||s>t||n>t+d)&&(s>a.children("table").height()-d&&(n=s),n<d&&(n=0),a.animate({scrollTop:n},200))},getSelectedRow(){const e=AdvancedAdsAdmin.AdImporter.adNetwork.getSelectedId(),a=jQuery("#mapi-table-wrap tbody");if(e){const d=a.find('tr[data-slotid="'+e+'"]');if(d.length)return d}return null},openExternalAdsList:function(){const e=AdvancedAdsAdmin.AdImporter.adNetwork;if(e.openSelector(),jQuery(".mapi-insert-code").css("display","inline"),jQuery(".mapi-open-selector").css("display","none"),jQuery(".mapi-close-selector-link").css("display","inline"),jQuery(".advads-adsense-code").css("display","none"),jQuery("#remote-ad-unsupported-ad-type").css("display","none"),AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList(e.hideIdle),e.getCustomInputs().css("display","none"),jQuery("#mapi-wrap").css("display","block"),!e.fetchedExternalAds){e.fetchedExternalAds=!0;0==jQuery("#mapi-table-wrap tbody tr[data-slotid]").length&&AdvancedAdsAdmin.AdImporter.refreshAds()}jQuery("#wpwrap").trigger("advads-mapi-adlist-opened")},onChangedAdType:function(){AdvancedAdsAdmin.AdImporter.adNetwork&&(AdvancedAdsAdmin.AdImporter.adNetwork.onBlur(),AdvancedAdsAdmin.AdImporter.adNetwork=null)},setup:function(e){AdvancedAdsAdmin.AdImporter.adNetwork=e,e.onSelected(),AdvancedAdsAdmin.AdImporter.isSetup?AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList():(AdvancedAdsAdmin.AdImporter.isSetup=!0,jQuery(document).on("click",".prevent-default",(function(e){e.preventDefault()})),jQuery(document).on("click",".mapi-insert-code",(function(e){e.preventDefault(),jQuery("#remote-ad-unsupported-ad-type").css("display","none"),jQuery(".advads-adsense-code").show(),jQuery(".mapi-open-selector").css("display","inline"),jQuery(".mapi-close-selector-link").css("display","inline"),jQuery(".mapi-insert-code").css("display","none"),jQuery("#mapi-wrap").css("display","none"),AdvancedAdsAdmin.AdImporter.adNetwork.getCustomInputs().css("display","none")})),jQuery(document).on("click",".mapi-open-selector a",(function(){AdvancedAdsAdmin.AdImporter.openExternalAdsList()})),jQuery(document).on("click","#mapi-close-selector,.mapi-close-selector-link",(function(){jQuery("#remote-ad-unsupported-ad-type").css("display","none"),AdvancedAdsAdmin.AdImporter.manualSetup()})),jQuery(document).on("click",".mapiaction",(function(e){switch(jQuery(this).attr("data-mapiaction")){case"updateList":AdvancedAdsAdmin.AdImporter.refreshAds();break;case"getCode":if(jQuery(this).hasClass("disabled"))break;var a=jQuery(this).attr("data-slotid");AdvancedAdsAdmin.AdImporter.adNetwork.selectAdFromList(a);break;case"updateCode":a=jQuery(this).attr("data-slotid");AdvancedAdsAdmin.AdImporter.adNetwork.updateAdFromList(a);break;case"toggleidle":if(void 0===AdvancedAdsAdmin.AdImporter.adNetwork.getMapiAction||"function"!=typeof AdvancedAdsAdmin.AdImporter.adNetwork.getMapiAction("toggleidle")){AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle=!AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle,AdvancedAdsAdmin.AdImporter.toggleIdleAds(AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle);const e=jQuery("#mapi-notice-inactive");e.length&&e.toggle(AdvancedAdsAdmin.AdImporter.adNetwork.hideIdle);break}AdvancedAdsAdmin.AdImporter.adNetwork.getMapiAction("toggleidle")(e,this)}})),AdvancedAdsAdmin.AdImporter.adNetwork.onDomReady())},manualSetup(){jQuery(".mapi-open-selector,.advads-adsense-show-code").css("display","inline"),jQuery(".mapi-insert-code").css("display","inline"),jQuery(".mapi-close-selector-link").css("display","none"),jQuery("#mapi-wrap").css("display","none"),AdvancedAdsAdmin.AdImporter.adNetwork.getCustomInputs().css("display","block"),"in-feed"!==jQuery("#unit-type").val()&&jQuery(".advads-adsense-layout-key").css("display","none").next("div").css("display","none"),AdvancedAdsAdmin.AdImporter.adNetwork.onManualSetup()},setRemoteErrorMessage(e){e?jQuery("#remote-ad-code-msg").html(e):jQuery("#remote-ad-code-msg").empty()},closeAdSelector:function(){setTimeout((function(){jQuery("#mapi-wrap").animate({height:0},360,(function(){jQuery(".mapi-open-selector,.advads-adsense-show-code").css("display","inline"),jQuery(".mapi-close-selector-link").css("display","none"),jQuery("#mapi-wrap").css({display:"none",height:"auto"});AdvancedAdsAdmin.AdImporter.adNetwork.getCustomInputs().css("display","block")}))}),80)},unitIsNotSupported:function(e){jQuery("#remote-ad-unsupported-ad-type").css("display","block"),AdsenseMAPI.unsupportedUnits[e]=1,jQuery("#unit-code").val(""),jQuery("#unit-type").val("normal"),jQuery("#ad-layout-key").val(""),jQuery('tr[data-slotid^="ca-"]').removeClass("selected error");var a=jQuery('tr[data-slotid="'+e+'"]');a.addClass("selected error").css("background-color",""),this.scrollToSelectedRow(a)},unitIsSupported:function(e){if(jQuery("#remote-ad-unsupported-ad-type").css("display","none"),void 0!==AdsenseMAPI.unsupportedUnits[e]&&delete AdsenseMAPI.unsupportedUnits[e],jQuery('i[data-mapiaction="getCode"][data-slotid="'+e+'"]').removeClass("disabled"),jQuery('tr[data-slotid="'+e+'"] .unittype a').length){var a=jQuery('tr[data-slotid="'+e+'"] .unittype'),d=jQuery('tr[data-slotid="'+e+'"] .unittype a').attr("data-type");a.text(d)}if(jQuery('tr[data-slotid="'+e+'"] .unitsize a').length){a=jQuery('tr[data-slotid="'+e+'"] .unitsize'),d=jQuery('tr[data-slotid="'+e+'"] .unitsize a').attr("data-size");a.text(d)}},emptyMapiSelector:function(e){const a='<div class="advads-notice-inline advads-error"><p>'+e+"</p></div>";jQuery("#mapi-loading-overlay").css("display","none"),jQuery("#mapi-wrap").html(jQuery(a))},refreshAds:function(){const e=AdvancedAdsAdmin.AdImporter.adNetwork;jQuery("#mapi-loading-overlay").css("display","block"),jQuery.ajax({type:"post",url:ajaxurl,data:e.getRefreshAdsParameters(),success:function(e,a,d){void 0!==e.html?(jQuery("#mapi-wrap").replaceWith(jQuery(e.html)),AdvancedAdsAdmin.AdImporter.openExternalAdsList()):void 0!==e.msg&&AdvancedAdsAdmin.AdImporter.emptyMapiSelector(e.msg),void 0!==e.raw&&console.log(e.raw),jQuery("#mapi-loading-overlay").css("display","none")},error:function(e,a,d){jQuery("#mapi-loading-overlay").css("display","none")}})},toggleIdleAds:function(e){void 0===e&&(e=!0),AdvancedAdsAdmin.AdImporter.highlightSelectedRowInExternalAdsList(e)}});class AdvancedAdsAdNetwork{constructor(e){this.id=e,this.units=[],this.vars=window[e+"AdvancedAdsJS"],this.hideIdle=!0,this.fetchedExternalAds=!1}onSelected(){console.error("Please override onSelected.")}onBlur(){console.error("Please override onBlur.")}openSelector(){console.error("Please override openSelector.")}getSelectedId(){console.error("Please override getSelectedId.")}selectAdFromList(e){console.error("Please override selectAdFromList.")}updateAdFromList(e){console.error("Please override updateAdFromList.")}getRefreshAdsParameters(){console.error("Please override getRefreshAdsParameters.")}getCustomInputs(){console.error("Please override getCustomInputs.")}onDomReady(){console.error("Please override onDomReady.")}onManualSetup(){}}class AdvancedAdsExternalAdUnit{}function Advads_Termination(e){function a(){this.addedNodes=[],this.removedNodes=[]}let d=new a,t=new a;const n=["active_post_lock"];this.observers={list:[],push:e=>{this.observers.list.push(e)},disconnect:()=>{this.observers.list.forEach((e=>{e.disconnect()})),this.observers.list=[]}},this.setInitialValue=(e,a)=>{a&&a.value&&(d[e]=a.value)};const s=function(a,d){if("checkbox"===d.type){const n=e.querySelectorAll('[name="'+d.name+'"]');return n.length>1?(a[(t=n)[0].name]=[],t.forEach((e=>{e.checked&&a[e.name].push(e.value)})),a):(a[d.name]=d.checked,a)}var t;return"radio"!==d.type||d.checked?(a[d.name]=d.value,a):a},o=new MutationObserver((e=>{for(const a of e){for(const e of a.removedNodes){const a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;a.nextNode();)if("INPUT"===a.currentNode.tagName||"SELECT"===a.currentNode.tagName){const e=t.addedNodes.indexOf(a.currentNode.name);e>-1?t.addedNodes.splice(e,1):t.removedNodes.push(a.currentNode.name)}}for(const e of a.addedNodes){if(e.nodeType===Node.TEXT_NODE)continue;const a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;a.nextNode();)if("INPUT"===a.currentNode.tagName||"SELECT"===a.currentNode.tagName){if(""===a.currentNode.name)continue;t.addedNodes.push(a.currentNode.name)}}}}));o.observe(e,{childList:!0,subtree:!0}),this.observers.push(o),this.hasChanged=(e,a)=>{for(const d in a)if(!e.hasOwnProperty(d)||e[d].toString()!==a[d].toString())return!0;return!1},this.terminationNotice=(a=!1)=>{if(!this.hasChanged(d,t))return!0;if(window.confirm(window.advadstxt.confirmation)){if(t.addedNodes.length||t.removedNodes.length)return a&&window.location.reload(),!0;for(const a in t){const t=e.querySelector('[name="'+a+'"]');if(null!==t)if("checkbox"===t.type)t.checked=d[a];else if("radio"===t.type){let n=null!==d[a]&&void 0!==d[a]?d[a]:t.value;e.querySelector('[name="'+a+'"][value="'+n+'"]').checked=!0}else t.value=d[a]}return!0}return!1},this.collectValues=()=>{const a="DIALOG"===e.tagName;e.querySelectorAll("input, select, textarea").forEach((o=>{if(o.name.length&&!n.includes(o.id)&&!n.includes(o.name)&&(a||!o.closest("dialog"))){if(d=s(d,o),"hidden"===o.type){const a=new MutationObserver((function(e,a){e.forEach((e=>{"value"===e.attributeName&&e.target.dispatchEvent(new Event("input"))}))}));a.observe(e,{attributes:!0,subtree:!0}),this.observers.push(a)}o.addEventListener("input",(e=>{t=s(t,o)}))}}))}}jQuery(document).ready((function(){jQuery(document).on("click",".advads-tr-remove",(function(){jQuery(this).closest("tr").remove()}))})),void 0===jQuery.escapeSelector&&(jQuery.escapeSelector=function(e){return e.replace(/([$%&()*+,./:;<=>?@\[\\\]^{|}~])/g,"\\$1")});const modal=e=>{let a,d;const t=()=>window.location.hash.replace("#",""),n=()=>{e.showModal(),e.dispatchEvent(new CustomEvent("advads-modal-opened")),a=new Advads_Termination(e),d&&a.collectValues()},s=()=>{t()===e.id&&n()};if(s(),window.addEventListener("hashchange",(()=>{s(),"close"===t()&&(d&&!a.terminationNotice(!0)||e.close())})),document.querySelectorAll('a[href$="#'+e.id+'"]').forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),n()}))})),e.addEventListener("cancel",(t=>{t.preventDefault(),d?a.terminationNotice(!0)&&(e.close(),a.observers.disconnect(),document.dispatchEvent(new CustomEvent("advads-modal-canceled",{detail:{modal_id:e.id}}))):e.close()})),e.addEventListener("close",(a=>{t()===e.id&&(window.location.hash="")})),d=e.querySelector("form"),null===d)try{d=e.querySelector("button.advads-modal-close-action").form}catch(e){}d&&(e.querySelectorAll("input").forEach((e=>{e.addEventListener("keydown",(e=>{"Enter"===e.key&&(d.reportValidity()?d.submit():e.preventDefault())}))})),d.addEventListener("submit",(()=>{window.location.hash=""}))),e.querySelectorAll(".advads-modal-close, .advads-modal-close-background").forEach((a=>{a.addEventListener("click",(a=>{a.preventDefault(),e.dispatchEvent(new Event("cancel"))}))}));try{e.querySelector("a.advads-modal-close-action").addEventListener("click",(a=>{a.preventDefault(),e.close()}))}catch(e){}};window.addEventListener("DOMContentLoaded",(()=>{try{if("function"!=typeof document.querySelector(".advads-modal[id^=modal-]").showModal)return}catch(e){return}[...document.getElementsByClassName("advads-modal")].forEach(modal)}));