diff --git a/inc/admin-templates/field-templates/checkbox.php b/inc/admin-templates/field-templates/checkbox.php deleted file mode 100644 index 62aaf9576..000000000 --- a/inc/admin-templates/field-templates/checkbox.php +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - settings[ $data['parent'] ] ? ' disabled="disabled"' : ''; ?> - - - -/> - - - - - - - - - - -
- diff --git a/inc/admin-templates/field-templates/hidden.php b/inc/admin-templates/field-templates/hidden.php deleted file mode 100644 index 8c6f4c1c8..000000000 --- a/inc/admin-templates/field-templates/hidden.php +++ /dev/null @@ -1,11 +0,0 @@ - - -/> diff --git a/inc/admin-templates/field-templates/number.php b/inc/admin-templates/field-templates/number.php deleted file mode 100644 index 7b39030ce..000000000 --- a/inc/admin-templates/field-templates/number.php +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - -settings[ $data['parent'] ] ? ' disabled="disabled"' : '') - . ' value="' . $data['value'] . '" ' - . ' min="' . $data['min'] . '" ' - . ' max="' . $data['max'] . '" ' - . ($data['required'] ? ' required="required"' : '') - . '>'; - -?> - - - - - - - - diff --git a/inc/admin-templates/field-templates/radio.php b/inc/admin-templates/field-templates/radio.php deleted file mode 100644 index b42d98504..000000000 --- a/inc/admin-templates/field-templates/radio.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - -' . $text . ''; - return; -} - -foreach ($data['options'] as $option) { - echo '' - . '' - . ''; - echo ' '; -} - -?> diff --git a/inc/admin-templates/field-templates/select.php b/inc/admin-templates/field-templates/select.php deleted file mode 100644 index 8a4f86ae5..000000000 --- a/inc/admin-templates/field-templates/select.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - -'; - -foreach ($data['options'] as $option) { - echo ''; -} -echo ''; -?> - - - - - - - - diff --git a/inc/admin-templates/field-templates/text.php b/inc/admin-templates/field-templates/text.php deleted file mode 100644 index 18f100574..000000000 --- a/inc/admin-templates/field-templates/text.php +++ /dev/null @@ -1,38 +0,0 @@ - - - - -data['moderate'] ? ' disabled="disabled"' : '') - . ($data['class'] ? ' class="' . $data['class'] . '"' : '') - . ($data['required'] ? ' required="required"' : '') - . 'value="' . ($data['value'] ?: $affiliate_short_code) . '" ' - . $readonly - . ($data['disabled'] || ($data['parent'] && ! $data['parent_value']) ? ' disabled="disabled"' : '') - . (! $data['children'] ? '' : ' children="' . implode(",", $data['children']) . '"') - . (! $data['children'] ? '' : ' onchange="spbcSettingsDependencies(\'' . implode(",", $data['children']) . '\')"') - . ' />'; -?> - - - - - - - - - - - - diff --git a/inc/admin-templates/field-templates/textarea.php b/inc/admin-templates/field-templates/textarea.php deleted file mode 100644 index 804d99907..000000000 --- a/inc/admin-templates/field-templates/textarea.php +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - -"+e.desc+"
"),jQuery(document).on("click",c)}},s)}function spbcStartShowHide(){jQuery(".spbcShortText").off("mouseover").on("mouseover",function(){jQuery(this).next().show()}).off("mouseout").on("mouseout",function(){jQuery(this).next().hide()}),jQuery(".spbcFullText").off("mouseout").on("mouseout",function(){jQuery(this).hide()}).off("mouseover").on("mouseover",function(){jQuery(this).show()})}function spbcScannerReloadScanInfo(){jQuery(".spbc_hint__last_scan_title").text(spbcScaner.look_below_for_scan_res);spbcSendAJAXRequest({action:"spbc_scanner__last_scan_info"},{callback:e=>{document.getElementById("spbc_scanner__last_scan_info").innerText=e.data}})}function spbcBannerCheck(){let c=setInterval(function(){spbcSendAJAXRequest({action:"spbc_settings__check_renew_banner"},{callback:function(e,t,s,n){e.close_renew_banner&&(jQuery("#spbc_renew_notice").length&&jQuery("#spbc_renew_notice").hide("slow"),jQuery("#spbc_trial_notice").length&&jQuery("#spbc_trial_notice").hide("slow"),clearInterval(c))}})},6e4)}function spbcToggleClass(t,s){for(let e=0;e"+e.data+"
",jQuery(c).insertAfter(jQuery(a)))}})}}),jQuery(document).on("click","#spbc_settings_templates_export_button",function(){jQuery("#spbc-ajax-result").remove();var t=jQuery("option:selected",jQuery("#spbc_settings_templates_export")),s=jQuery("#spbc_settings_templates_export_name");if(s.css("border-color","inherit"),void 0===t.data("id"))console.log('Attribute "data-id" not set for the option.');else{let e;if("new_template"===t.data("id")){var n=s.val();if(""===n)return void s.css("border-color","red");e={template_name:n}}else e={template_id:t.data("id")};let a=this;spbcSendAJAXRequest({action:"spbc_settings_templates_export",data:e},{timeout:25e3,button:a,spinner:jQuery("#spbc_settings_templates_export_button .spbc_preloader_button"),callback:function(e,t,s,n){let c;e.success?(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)),jQuery("#spbc_settings_templates_export_button .spbc_success").show(300),setTimeout(function(){jQuery("#spbc_settings_templates_export_button .spbc_success").hide(300)},2e3),document.addEventListener("spbcModalClosed",function(e){document.location.reload()}),setTimeout(function(){spbcModal.close()},2e3)):(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)))}})}}),jQuery(document).on("click","#spbc_settings_templates_reset_button",function(){let a=this;spbcSendAJAXRequest({action:"spbc_settings_templates_reset"},{timeout:25e3,button:a,spinner:jQuery("#spbc_settings_templates_reset_button .spbc_preloader_button"),callback:function(e,t,s,n){let c;e.success?(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)),jQuery("#spbc_settings_templates_reset_button .spbc_success").show(300),setTimeout(function(){jQuery("#spbc_settings_templates_reset_button .spbc_success").hide(300)},2e3),document.addEventListener("spbcModalClosed",function(e){document.location.reload()}),setTimeout(function(){spbcModal.close()},2e3)):(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)))}})}),jQuery(document).on("change","#spbc_settings_templates_export",function(){"new_template"===jQuery("option:selected",this).data("id")?jQuery(this).parent().parent().find("#spbc_settings_templates_export_name").show():jQuery(this).parent().parent().find("#spbc_settings_templates_export_name").hide()}),jQuery(document).on("click","#spbc-change-account-email",function(e){e.preventDefault();var e=jQuery(this),t=jQuery("#spbc-account-email"),s=t.text();spbcToggleClass(e,"active"),e.hasClass("active")?(e.text(e.data("save-text")),t.attr("contenteditable","true"),t.focus(),t.on("keydown",function(e){"Enter"===e.code&&e.preventDefault()}),t.on("input",function(e){"insertParagraph"===e.inputType&&e.preventDefault()})):(spbcSendAJAXRequest({action:"spbc_update_account_email",accountEmail:s},{timeout:5e3,callback:function(e,t,s,n){void 0!==e.success&&"ok"===e.success&&void 0!==e.manuallyLink&&jQuery("#spbc-key-manually-link").attr("href",e.manuallyLink),void 0!==e.error&&jQuery("#spbc-account-email").css("border-color","red")},errorOutput:function(e){spbcModal.loaded=e,spbcModal.open()}}),t.attr("contenteditable","false"),e.text(e.data("default-text")))}),jQuery(document).on("click",".spbct_notice-dismiss",function(e){var t=this.parentElement.classList;let s=t[t.length-1];document.querySelectorAll("."+s).forEach(e=>{e.parentElement.setAttribute("style","display:none;"),spbcSetCookie(s,1,2592e3)})}),jQuery(document).off("click",".spbc_long_description__show"),jQuery(document).on("click",".spbc_long_description__show",function(){self=jQuery(this),spbcHandleLongDescription(self,self.attr("data-setting")||self.attr("setting"))}),jQuery(document).off("click",".spbc_long_recommendation__show"),jQuery(document).on("click",".spbc_long_recommendation__show",function(){spbcSettingsShowRecommendation(self=jQuery(this),self.attr("data-setting")||self.attr("setting"))}),document.referrer&&-1!==document.referrer.indexOf("page=spbc")||sessionStorage.removeItem("spbc_trial_renew_fullpage_dismissed"),sessionStorage.getItem("spbc_trial_renew_fullpage_dismissed")&&(jQuery(".spbc-trial-renew-fullpage").hide(),jQuery("#spbct-page--react").show()),jQuery("body").on("click",".spbc-trial-renew-fullpage .notice-dismiss",function(e){e.preventDefault(),sessionStorage.setItem("spbc_trial_renew_fullpage_dismissed","1"),jQuery(".spbc-trial-renew-fullpage").hide(),jQuery("#spbct-page--react").show()}),jQuery(document).off("click","#spbc_debug__run_pass_check_btn").on("click","#spbc_debug__run_pass_check_btn",function(){let t=jQuery(this),s=jQuery("#spbc_debug__pass_check_status");t.prop("disabled",!0),s.css("color","").text("Resetting records and running check, please wait..."),jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"spbc_debug_users_pass_check_run",security:spbcSettings.ajax_nonce},success:function(e){t.prop("disabled",!1),e.success?s.css("color","green").html("✓ Done! Total: "+e.data.total+", Checked: "+e.data.checked+", Leaked: "+e.data.leaked+" — You can now test the login form in incognito."):s.css("color","red").text("Error: "+(e.data||"unknown error"))},error:function(e){t.prop("disabled",!1),s.css("color","red").text("Request failed: "+e.status+" "+e.statusText)}})})}); +function spbcSwitchTab(e,t){var s=e.classList[1].replace("spbc_tab_nav-",""),n=new URLSearchParams(window.location.search),c=(n.set("spbc_tab",s),window.location.hash),c=window.location.pathname+"?"+n.toString()+c;if(history.replaceState(null,"",c),"backups"!==n.get("spbc_tab")&&jQuery(".spbc_tab_nav-backups").hide(),jQuery(".spbc_tab_nav").removeClass("spbc_tab_nav--active"),jQuery(".spbc_tab").removeClass("spbc_tab--active"),jQuery(e).addClass("spbc_tab_nav--active"),jQuery(".spbc_tab-"+s).addClass("spbc_tab--active"),jQuery(e).data("loaded")){if(t&&t.action)switch(t.action){case"highlight":spbcHighlightElement(t.target,t.times);break;case"click":setTimeout(function(){jQuery("#"+t.additional.target).click()},500)}}else{c={action:"spbc_settings__draw_elements",tab_name:s,security:spbcSettings.ajax_nonce};t={callback:spbcDrawSettingsCallback,notJson:!0,additional:t||null},spbcSendAJAXRequest(c,t,e)}}function spbcDrawSettingsCallback(e,t,s,n){jQuery(n).data("loaded",!0),jQuery(".spbc_tab-"+t.tab_name).replaceWith(e);n=jQuery(".spbc_tab-"+t.tab_name);if(n.addClass("spbc_tab--active"),jQuery(document).off("click",".spbc_long_recommendation__show"),jQuery(document).on("click",".spbc_long_recommendation__show",function(){spbcSettingsShowRecommendation(self=jQuery(this),self.attr("data-setting")||self.attr("setting"))}),s.additional)switch(s.additional.action){case"highlight":spbcHighlightElement(s.additional.target,s.additional.times);break;case"click":setTimeout(function(){jQuery("#"+s.additional.target).click()},500)}jQuery(n).on("click",".spbc_hint-send_"+t.tab_name,function(){jQuery(".spbc_hint-send_"+t.tab_name).hide(),spbcSendAJAXRequest({action:"spbc_send_"+t.tab_name,tab_name:t.tab_name},{callback:spbcSendLogsCallback})}),window.location.hash&&null!==(e=document.getElementById(window.location.hash.substring(1)))&&e.scrollIntoView(),"function"==typeof spbcHighlightCriticalFilesNotice&&spbcHighlightCriticalFilesNotice(!1),spbcSaveSettingsButtonMobileLayout(),window.addEventListener("resize",e=>{spbcSaveSettingsButtonMobileLayout()})}function spbcSaveSettingsButtonMobileLayout(){var e=document.querySelector('div[name="spbc_settings--save_button_custom"]');e&&(900"+e.desc+"
"),jQuery(document).on("click",c)}},s)}function spbcStartShowHide(){jQuery(".spbcShortText").off("mouseover").on("mouseover",function(){jQuery(this).next().show()}).off("mouseout").on("mouseout",function(){jQuery(this).next().hide()}),jQuery(".spbcFullText").off("mouseout").on("mouseout",function(){jQuery(this).hide()}).off("mouseover").on("mouseover",function(){jQuery(this).show()})}function spbcScannerReloadScanInfo(){jQuery(".spbc_hint__last_scan_title").text(spbcScaner.look_below_for_scan_res);spbcSendAJAXRequest({action:"spbc_scanner__last_scan_info"},{callback:e=>{document.getElementById("spbc_scanner__last_scan_info").innerText=e.data}})}function spbcBannerCheck(){let c=setInterval(function(){spbcSendAJAXRequest({action:"spbc_settings__check_renew_banner"},{callback:function(e,t,s,n){e.close_renew_banner&&(jQuery("#spbc_renew_notice").length&&jQuery("#spbc_renew_notice").hide("slow"),jQuery("#spbc_trial_notice").length&&jQuery("#spbc_trial_notice").hide("slow"),clearInterval(c))}})},6e4)}function spbcCreateSupportUser(e){e.preventDefault();e=spbcSettings.support_user_creation_msg_array;spbcModal.open(),spbcModal.confirm(e.confirm_header,e.confirm_text,"",spbcCreateUserCallback)}function spbcCreateUserCallback(){spbcSendAJAXRequest({action:"spbc_create_support_user"},{timeout:5e3,callback:function(s,e,t,n){var c=spbcSettings.support_user_creation_msg_array;let a=c.default_error;if("object"==typeof s&&s.hasOwnProperty("success")&&s.hasOwnProperty("user_created")&&s.hasOwnProperty("mail_sent")&&s.hasOwnProperty("cron_updated")&&s.hasOwnProperty("user_data")&&s.hasOwnProperty("result_code")&&"object"==typeof s.user_data&&s.user_data.hasOwnProperty("username")&&s.user_data.hasOwnProperty("email")&&s.user_data.hasOwnProperty("password")&&s.success){if(s.user_created){let e="",t="";var o=c.cron_updated;return e=s.mail_sent?c.mail_sent_success:c.mail_sent_error,t=0===s.result_code?c.user_updated:c.user_created,jQuery("#spbc_stats_user_creation_username").text(s.user_data.username),jQuery("#spbc_stats_user_creation_email").text(s.user_data.email),jQuery("#spbc_stats_user_creation_password").text(s.user_data.password),jQuery("#spbc_stats_user_creation_mail_sent").text(e),jQuery("#spbc_stats_user_creation_title").text(t),jQuery("#spbc_stats_user_creation_cron_updated").text(o),void jQuery(".spbc_stats_user_creation_result").css("display","block")}-2===s.result_code?a=c.invalid_permission:-1===s.result_code?a=c.unknown_creation_error:-4===s.result_code?a=c.on_cooldown:-5===s.result_code&&(a=c.email_is_busy)}spbcModal.loaded=a,spbcModal.open()},errorOutput:function(e){spbcModal.loaded=e,spbcModal.open()}})}String.prototype.printf=function(){let e=this;for(var t in arguments){var s=e.substring(0,e.indexOf("%s",0)),n=e.substring(e.indexOf("%s",0)+2,e.length);e=s+arguments[t]+n}return e},jQuery(document).ready(function(){(jQuery("#spbc_renew_notice").length||jQuery("#spbc_trial_notice").length)&&spbcBannerCheck(),spbcSettings.key_changed&&jQuery("#spbc_button__sync").click(),jQuery(document).on("click","#spbc_settings_templates_import_button",function(){jQuery("#spbc-ajax-result").remove();var e=jQuery("option:selected",jQuery("#spbc_settings_templates_import"));if(jQuery("#spbc_settings_templates_import_name").css("border-color","inherit"),void 0===e.data("id"))console.log('Attribute "data-id" not set for the option.');else{e={template_id:e.data("id"),template_name:e.data("name"),settings:e.data("settings")};let a=this;spbcSendAJAXRequest({action:"spbc_settings_templates_import",data:e},{timeout:25e3,button:a,spinner:jQuery("#spbc_settings_templates_import_button .spbc_preloader_button"),callback:function(e,t,s,n){let c;e.success?(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)),jQuery("#spbc_settings_templates_import_button .spbc_success").show(300),setTimeout(function(){jQuery("#spbc_settings_templates_import_button .spbc_success").hide(300)},2e3),document.addEventListener("spbcModalClosed",function(e){document.location.reload()}),setTimeout(function(){spbcModal.close()},2e3)):(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)))}})}}),jQuery(document).on("click","#spbc_settings_templates_export_button",function(){jQuery("#spbc-ajax-result").remove();var t=jQuery("option:selected",jQuery("#spbc_settings_templates_export")),s=jQuery("#spbc_settings_templates_export_name");if(s.css("border-color","inherit"),void 0===t.data("id"))console.log('Attribute "data-id" not set for the option.');else{let e;if("new_template"===t.data("id")){var n=s.val();if(""===n)return void s.css("border-color","red");e={template_name:n}}else e={template_id:t.data("id")};let a=this;spbcSendAJAXRequest({action:"spbc_settings_templates_export",data:e},{timeout:25e3,button:a,spinner:jQuery("#spbc_settings_templates_export_button .spbc_preloader_button"),callback:function(e,t,s,n){let c;e.success?(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)),jQuery("#spbc_settings_templates_export_button .spbc_success").show(300),setTimeout(function(){jQuery("#spbc_settings_templates_export_button .spbc_success").hide(300)},2e3),document.addEventListener("spbcModalClosed",function(e){document.location.reload()}),setTimeout(function(){spbcModal.close()},2e3)):(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)))}})}}),jQuery(document).on("click","#spbc_settings_templates_reset_button",function(){let a=this;spbcSendAJAXRequest({action:"spbc_settings_templates_reset"},{timeout:25e3,button:a,spinner:jQuery("#spbc_settings_templates_reset_button .spbc_preloader_button"),callback:function(e,t,s,n){let c;e.success?(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)),jQuery("#spbc_settings_templates_reset_button .spbc_success").show(300),setTimeout(function(){jQuery("#spbc_settings_templates_reset_button .spbc_success").hide(300)},2e3),document.addEventListener("spbcModalClosed",function(e){document.location.reload()}),setTimeout(function(){spbcModal.close()},2e3)):(c=""+e.data+"
",jQuery(c).insertAfter(jQuery(a)))}})}),jQuery(document).on("change","#spbc_settings_templates_export",function(){"new_template"===jQuery("option:selected",this).data("id")?jQuery(this).parent().parent().find("#spbc_settings_templates_export_name").show():jQuery(this).parent().parent().find("#spbc_settings_templates_export_name").hide()}),jQuery(document).on("click",".spbct_notice-dismiss",function(e){var t=this.parentElement.classList;let s=t[t.length-1];document.querySelectorAll("."+s).forEach(e=>{e.parentElement.setAttribute("style","display:none;"),spbcSetCookie(s,1,2592e3)})}),jQuery(document).off("click",".spbc_long_description__show"),jQuery(document).on("click",".spbc_long_description__show",function(){self=jQuery(this),spbcHandleLongDescription(self,self.attr("data-setting")||self.attr("setting"))}),jQuery(document).off("click",".spbc_long_recommendation__show"),jQuery(document).on("click",".spbc_long_recommendation__show",function(){spbcSettingsShowRecommendation(self=jQuery(this),self.attr("data-setting")||self.attr("setting"))}),document.referrer&&-1!==document.referrer.indexOf("page=spbc")||sessionStorage.removeItem("spbc_trial_renew_fullpage_dismissed"),sessionStorage.getItem("spbc_trial_renew_fullpage_dismissed")&&(jQuery(".spbc-trial-renew-fullpage").hide(),jQuery("#spbct-page--react").show()),jQuery("body").on("click",".spbc-trial-renew-fullpage .notice-dismiss",function(e){e.preventDefault(),sessionStorage.setItem("spbc_trial_renew_fullpage_dismissed","1"),jQuery(".spbc-trial-renew-fullpage").hide(),jQuery("#spbct-page--react").show()}),jQuery(document).off("click","#spbc_debug__run_pass_check_btn").on("click","#spbc_debug__run_pass_check_btn",function(){let t=jQuery(this),s=jQuery("#spbc_debug__pass_check_status");t.prop("disabled",!0),s.css("color","").text("Resetting records and running check, please wait..."),jQuery.ajax({type:"POST",url:ajaxurl,data:{action:"spbc_debug_users_pass_check_run",security:spbcSettings.ajax_nonce},success:function(e){t.prop("disabled",!1),e.success?s.css("color","green").html("✓ Done! Total: "+e.data.total+", Checked: "+e.data.checked+", Leaked: "+e.data.leaked+" — You can now test the login form in incognito."):s.css("color","red").text("Error: "+(e.data||"unknown error"))},error:function(e){t.prop("disabled",!1),s.css("color","red").text("Request failed: "+e.status+" "+e.statusText)}})})}); //# sourceMappingURL=spbc-settings.min.js.map diff --git a/js/spbc-settings.min.js.map b/js/spbc-settings.min.js.map index bb24bc3a9..1c0a4d027 100644 --- a/js/spbc-settings.min.js.map +++ b/js/spbc-settings.min.js.map @@ -1 +1 @@ -{"version":3,"file":"spbc-settings.min.js","sources":["spbc-settings.js"],"sourcesContent":["// Printf for JS\nString.prototype.printf = function() { // eslint-disable-line no-extend-native\n let formatted = this;\n /* eslint-disable guard-for-in */\n for ( let arg in arguments ) { // eslint-disable-line prefer-rest-params\n let beforeFormatted = formatted.substring(0, formatted.indexOf('%s', 0));\n let afterFormatted = formatted.substring(formatted.indexOf('%s', 0)+2, formatted.length);\n formatted = beforeFormatted + arguments[arg] + afterFormatted; // eslint-disable-line prefer-rest-params\n }\n return formatted;\n};\n\n/**\n * Switching tabs\n *\n * @param {object} tab\n * @param {object} params\n */\nfunction spbcSwitchTab(tab, params) {\n let tabName = tab.classList[1].replace('spbc_tab_nav-', '');\n\n // update url\n let searchParams = new URLSearchParams(window.location.search);\n searchParams.set('spbc_tab', tabName);\n let hashParam = window.location.hash;\n let newRelativePathQuery = window.location.pathname + '?' + searchParams.toString() + hashParam;\n\n history.replaceState(null, '', newRelativePathQuery);\n\n // Hiding a tab 'Backups' if exist\n if (searchParams.get('spbc_tab') !== 'backups') {\n jQuery('.spbc_tab_nav-backups').hide();\n }\n\n // update active tab\n jQuery('.spbc_tab_nav').removeClass('spbc_tab_nav--active');\n jQuery('.spbc_tab').removeClass('spbc_tab--active');\n jQuery(tab).addClass('spbc_tab_nav--active');\n jQuery('.spbc_tab-' + tabName).addClass('spbc_tab--active');\n\n if (!jQuery(tab).data('loaded')) {\n let data = {\n action: 'spbc_settings__draw_elements',\n tab_name: tabName,\n security: spbcSettings.ajax_nonce,\n };\n params = {\n callback: spbcDrawSettingsCallback,\n notJson: true,\n additional: params || null,\n };\n spbcSendAJAXRequest( data, params, tab );\n } else if (params && params.action) {\n switch (params.action) {\n case 'highlight':\n spbcHighlightElement(params.target, params.times);\n break;\n case 'click':\n setTimeout(function() {\n jQuery('#'+params.additional.target).click();\n }, 500);\n break;\n }\n }\n}\n\n/**\n * Draws settings\n *\n * @param {*} result\n * @param {*} data\n * @param {*} params\n * @param {*} obj\n */\nfunction spbcDrawSettingsCallback(result, data, params, obj) {\n jQuery(obj).data('loaded', true);\n jQuery('.spbc_tab-'+data.tab_name).replaceWith(result);\n let tab = jQuery('.spbc_tab-'+data.tab_name);\n tab.addClass('spbc_tab--active');\n\n jQuery(document).off( 'click', '.spbc_long_recommendation__show');\n jQuery(document).on('click', '.spbc_long_recommendation__show', function() {\n self = jQuery(this);\n spbcSettingsShowRecommendation(self, self.attr('data-setting') || self.attr('setting'));\n });\n\n if (params.additional) {\n switch (params.additional.action) {\n case 'highlight':\n spbcHighlightElement(params.additional.target, params.additional.times);\n break;\n case 'click':\n setTimeout(function() {\n jQuery('#'+params.additional.target).click();\n }, 500);\n break;\n }\n }\n\n jQuery(tab).on('click', '.spbc_hint-send_'+data.tab_name, function() {\n jQuery('.spbc_hint-send_'+data.tab_name).hide();\n spbcSendAJAXRequest(\n {action: 'spbc_send_'+data.tab_name, tab_name: data.tab_name},\n {callback: spbcSendLogsCallback},\n );\n });\n\n // scroll to anchor\n if (window.location.hash) {\n let scrollToTag = document.getElementById(window.location.hash.substring(1));\n if (scrollToTag !== null) {\n scrollToTag.scrollIntoView();\n }\n }\n\n if (typeof spbcHighlightCriticalFilesNotice === 'function') {\n spbcHighlightCriticalFilesNotice(false);\n }\n\n spbcSaveSettingsButtonMobileLayout();\n window.addEventListener('resize', (event) => {\n spbcSaveSettingsButtonMobileLayout();\n });\n}\n\n/**\n * A chunk to hide the custom element \"submit button\" on large screen or make sticky on mobile\n */\nfunction spbcSaveSettingsButtonMobileLayout() {\n const selector = document.querySelector('div[name=\"spbc_settings--save_button_custom\"]');\n if (selector) {\n if (window.innerWidth > 900) {\n selector.style.display = 'none';\n } else {\n selector.style.display = 'flex';\n }\n }\n}\n\n/**\n * Sends logs\n *\n * @param {*} result\n * @param {*} data\n * @param {*} params\n * @param {*} obj\n */\nfunction spbcSendLogsCallback(result, data, params, obj) {\n jQuery('.spbc_tab_nav-'+data.tab_name).data('loaded', false);\n spbcSwitchTab(document.getElementsByClassName('spbc_tab_nav-'+data.tab_name)[0]);\n}\n\n/**\n * Disables/enables settings by ID\n *\n * @param {array} settingsIDs\n * @param {number} enable\n */\nfunction spbcSettingsDependenciesbyId(settingsIDs, enable) { // eslint-disable-line no-unused-vars\n if (typeof settingsIDs === 'string') {\n tmp = [];\n tmp.push(settingsIDs);\n settingsIDs = tmp;\n }\n\n enable = typeof enable === 'undefined' ? null : +enable;\n\n settingsIDs.forEach(function(settingID, i, arr) {\n let elem = document.getElementById('spbc_setting_'+settingID);\n let doDisable = function() {\n elem.setAttribute('disabled', 'disabled');\n };\n let doEnable = function() {\n elem.removeAttribute('disabled');\n };\n\n if (enable !== null) {\n // Set\n enable === 1 ? doEnable() : doDisable();\n } else {\n // Switch\n elem.getAttribute('disabled') === null ? doDisable() : doEnable();\n }\n });\n}\n\n/**\n * Recursive in case children found!\n *\n * Settings dependencies\n *\n * @param {array} settingNames\n * @param {number} enable\n */\nfunction spbcSettingsDependencies(settingNames, enable) { // eslint-disable-line no-unused-vars\n // Cast settingNames to array\n const eventTarget = window.event && window.event.target ? window.event.target : null;\n const isRadio = eventTarget && eventTarget.type === 'radio';\n const radioEnabled = isRadio && eventTarget.value == '1';\n const targetEnableFlag = eventTarget ?\n ((isRadio && !radioEnabled) || +eventTarget.checked) :\n null;\n const doEnableFlag = typeof enable === 'undefined' ? targetEnableFlag : +enable;\n\n settingNames = typeof settingNames === 'string' ? settingNames.split(',') : settingNames;\n\n settingNames.forEach(function(settingName, i, arr) {\n let elements = document.getElementsByName('spbc_settings['+settingName+']');\n if (elements.length === 0) {\n // multiple selector case\n elements = document.getElementsByName('spbc_settings['+settingName+'][]');\n }\n\n elements\n .forEach(function( elem, i, arr ) {\n let doDisable = function() {\n elem.setAttribute('disabled', 'disabled');\n };\n let doEnable = function() {\n elem.removeAttribute('disabled');\n };\n if (doEnableFlag !== null) {\n // Set\n doEnableFlag === 1 ? doEnable() : doDisable();\n } else {\n // Switch\n elem.getAttribute('disabled') === null ? doDisable() : doEnable();\n }\n\n let children = elem.getAttribute('data-children');\n if ( children !== null ) {\n spbcSettingsDependencies(children, doEnableFlag && elem.checked);\n }\n });\n });\n}\n\n/**\n * Shows recommendation\n *\n * @param {object} label\n * @param {string} settingId\n */\nfunction spbcSettingsShowRecommendation(label, settingId) {\n let removeRecommendationFunc = function(e) {\n if (\n typeof e === 'undefined' ||\n (\n jQuery(e.target).parent('.spbc_long_desc').length == 0 ||\n jQuery(e.target).hasClass('spbc_long_desc__cancel')\n ) && !jQuery(e.target).hasClass('spbc_long_recommendation__show')\n ) {\n jQuery('.spbc_long_desc').remove();\n jQuery(document).off('click', removeRecommendationFunc);\n }\n };\n\n removeRecommendationFunc();\n\n label.after('');\n let obj = jQuery('#spbc_long_desc__'+settingId);\n obj.append('')\n .append('')\n .css({\n top: label.position().top + 25,\n left: label.position().left + 5,\n });\n\n\n spbcSendAJAXRequest(\n {action: 'spbc_settings__get_recommendation', setting_id: settingId},\n {\n spinner: obj.children('img'),\n callback: function(result, data, params, obj) {\n obj.empty()\n .append('')\n .append('')\n .append(''+result.desc+'
');\n\n jQuery(document).on('click', removeRecommendationFunc);\n },\n },\n obj,\n );\n}\n\n/**\n * Shows/hides full text\n */\nfunction spbcStartShowHide() { // eslint-disable-line no-unused-vars\n jQuery('.spbcShortText')\n .off('mouseover' )\n .on('mouseover', function() {\n jQuery(this).next().show();\n })\n .off('mouseout' )\n .on('mouseout', function() {\n jQuery(this).next().hide();\n });\n jQuery('.spbcFullText')\n .off('mouseout' )\n .on('mouseout', function() {\n jQuery(this).hide();\n })\n .off('mouseover' )\n .on('mouseover', function() {\n jQuery(this).show();\n });\n}\n\n/**\n * Reloads last scan info\n */\nfunction spbcScannerReloadScanInfo() { // eslint-disable-line no-unused-vars\n jQuery('.spbc_hint__last_scan_title').text(spbcScaner.look_below_for_scan_res);\n const data = {\n action: 'spbc_scanner__last_scan_info',\n };\n const params = {\n callback: (result) => {\n document.getElementById('spbc_scanner__last_scan_info').innerText = result.data;\n },\n };\n spbcSendAJAXRequest(data, params);\n}\n\n/**\n * Checking current account status for renew notice\n */\nfunction spbcBannerCheck() {\n let bannerChecker = setInterval( function() {\n spbcSendAJAXRequest(\n {action: 'spbc_settings__check_renew_banner'},\n {\n callback: function(result, data, params, obj) {\n if (result.close_renew_banner) {\n if (jQuery('#spbc_renew_notice').length) {\n jQuery('#spbc_renew_notice').hide('slow');\n }\n if (jQuery('#spbc_trial_notice').length) {\n jQuery('#spbc_trial_notice').hide('slow');\n }\n clearInterval(bannerChecker);\n }\n },\n },\n );\n }, 60000);\n}\n\njQuery(document).ready(function() {\n if (jQuery('#spbc_renew_notice').length || jQuery('#spbc_trial_notice').length) {\n spbcBannerCheck();\n }\n\n // Sync button migrated to react\n\n if ( spbcSettings.key_changed ) {\n jQuery('#spbc_button__sync').click();\n }\n\n // Get Key Auto button migrated to Signup Wizard\n\n // Import settings\n jQuery( document ).on('click', '#spbc_settings_templates_import_button', function() {\n jQuery('#spbc-ajax-result').remove();\n let optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_import'));\n let templateNameInput = jQuery('#spbc_settings_templates_import_name');\n templateNameInput.css('border-color', 'inherit');\n if ( typeof optionSelected.data('id') === 'undefined' ) {\n console.log( 'Attribute \"data-id\" not set for the option.' );\n return;\n }\n let data = {\n 'template_id': optionSelected.data('id'),\n 'template_name': optionSelected.data('name'),\n 'settings': optionSelected.data('settings'),\n };\n let button = this;\n spbcSendAJAXRequest(\n {action: 'spbc_settings_templates_import', data: data},\n {\n timeout: 25000,\n button: button,\n spinner: jQuery('#spbc_settings_templates_import_button .spbc_preloader_button' ),\n callback: function(result, data, params, obj) {\n let selector;\n if (result.success) {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n jQuery('#spbc_settings_templates_import_button .spbc_success').show(300);\n setTimeout(function() {\n jQuery('#spbc_settings_templates_import_button .spbc_success').hide(300);\n }, 2000);\n document.addEventListener('spbcModalClosed', function( e ) {\n document.location.reload();\n });\n setTimeout(function() {\n spbcModal.close();\n }, 2000);\n } else {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n }\n },\n },\n );\n });\n\n // Export settings\n jQuery( document ).on('click', '#spbc_settings_templates_export_button', function() {\n jQuery('#spbc-ajax-result').remove();\n let optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_export'));\n let templateNameInput = jQuery('#spbc_settings_templates_export_name');\n templateNameInput.css('border-color', 'inherit');\n if ( typeof optionSelected.data('id') === 'undefined' ) {\n console.log( 'Attribute \"data-id\" not set for the option.' );\n return;\n }\n let data;\n if ( optionSelected.data('id') === 'new_template' ) {\n let templateName = templateNameInput.val();\n if ( templateName === '' ) {\n templateNameInput.css('border-color', 'red');\n return;\n }\n data = {\n 'template_name': templateName,\n };\n } else {\n data = {\n 'template_id': optionSelected.data('id'),\n };\n }\n let button = this;\n spbcSendAJAXRequest(\n {action: 'spbc_settings_templates_export', data: data},\n {\n timeout: 25000,\n button: button,\n spinner: jQuery('#spbc_settings_templates_export_button .spbc_preloader_button' ),\n callback: function(result, data, params, obj) {\n let selector;\n if (result.success) {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n jQuery('#spbc_settings_templates_export_button .spbc_success').show(300);\n setTimeout(function() {\n jQuery('#spbc_settings_templates_export_button .spbc_success').hide(300);\n }, 2000);\n document.addEventListener('spbcModalClosed', function( e ) {\n document.location.reload();\n });\n setTimeout(function() {\n spbcModal.close();\n }, 2000);\n } else {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n }\n },\n },\n );\n });\n\n // Reset settings\n jQuery( document ).on('click', '#spbc_settings_templates_reset_button', function() {\n let button = this;\n spbcSendAJAXRequest(\n {action: 'spbc_settings_templates_reset'},\n {\n timeout: 25000,\n button: button,\n spinner: jQuery('#spbc_settings_templates_reset_button .spbc_preloader_button' ),\n callback: function(result, data, params, obj) {\n let selector;\n if (result.success) {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n jQuery('#spbc_settings_templates_reset_button .spbc_success').show(300);\n setTimeout(function() {\n jQuery('#spbc_settings_templates_reset_button .spbc_success').hide(300);\n }, 2000);\n document.addEventListener('spbcModalClosed', function( e ) {\n document.location.reload();\n });\n setTimeout(function() {\n spbcModal.close();\n }, 2000);\n } else {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n }\n },\n },\n );\n });\n\n jQuery(document).on('change', '#spbc_settings_templates_export', function() {\n let optionSelected = jQuery('option:selected', this);\n if ( optionSelected.data('id') === 'new_template' ) {\n jQuery(this).parent().parent().find('#spbc_settings_templates_export_name').show();\n } else {\n jQuery(this).parent().parent().find('#spbc_settings_templates_export_name').hide();\n }\n });\n\n //* TAB_CONTROL\n // migrated to react\n //* / REFRESH TAB IF ctrl+F5 END\n\n /**\n * Change cleantalk account email\n */\n jQuery(document).on('click', '#spbc-change-account-email', function(e) {\n e.preventDefault();\n\n let $this = jQuery(this);\n let accountEmailField = jQuery('#spbc-account-email');\n let accountEmail = accountEmailField.text();\n\n spbcToggleClass($this, 'active');\n\n if ($this.hasClass('active')) {\n $this.text($this.data('save-text'));\n accountEmailField.attr('contenteditable', 'true');\n accountEmailField.focus();\n accountEmailField.on('keydown', function(e) {\n if (e.code === 'Enter') {\n e.preventDefault();\n }\n });\n accountEmailField.on('input', function(e) {\n if (e.inputType === 'insertParagraph') {\n e.preventDefault();\n }\n });\n } else {\n spbcSendAJAXRequest(\n {\n action: 'spbc_update_account_email',\n accountEmail: accountEmail,\n },\n {\n timeout: 5000,\n callback: function(result, data, params, obj) {\n if (result.success !== undefined && result.success === 'ok') {\n if (result.manuallyLink !== undefined) {\n jQuery('#spbc-key-manually-link').attr('href', result.manuallyLink);\n }\n }\n\n if (result.error !== undefined) {\n jQuery('#spbc-account-email').css('border-color', 'red');\n }\n },\n errorOutput: function(msg) {\n spbcModal.loaded = msg;\n spbcModal.open();\n },\n },\n );\n\n accountEmailField.attr('contenteditable', 'false');\n $this.text($this.data('default-text'));\n }\n });\n\n // Only handle legacy banners, not React Components\n // @ToDo remove the outdated way to close notice after transferring all tabs to components.\n jQuery(document).on('click', '.spbct_notice-dismiss', function(e) {\n let classListNotice = this.parentElement.classList;\n let classNoticeForClose = classListNotice[classListNotice.length - 1];\n\n document.querySelectorAll('.' + classNoticeForClose).forEach((element) => {\n element.parentElement.setAttribute('style', 'display:none;');\n spbcSetCookie(classNoticeForClose, 1, 86400 * 30);\n });\n });\n\n // @ToDo need to be refactored - this is the code dublication\n jQuery(document).off( 'click', '.spbc_long_description__show');\n jQuery(document).on('click', '.spbc_long_description__show', function() {\n self = jQuery(this);\n spbcHandleLongDescription(self, self.attr('data-setting') || self.attr('setting'));\n });\n\n // @ToDo need to be refactored - this is the code dublication\n jQuery(document).off( 'click', '.spbc_long_recommendation__show');\n jQuery(document).on('click', '.spbc_long_recommendation__show', function() {\n self = jQuery(this);\n spbcSettingsShowRecommendation(self, self.attr('data-setting') || self.attr('setting'));\n });\n\n // Reset dismiss flag if user came from outside plugin settings\n if (!document.referrer || document.referrer.indexOf('page=spbc') === -1) {\n sessionStorage.removeItem('spbc_trial_renew_fullpage_dismissed');\n }\n\n // Hide fullpage trial banner if it was already dismissed in this browser session\n if (sessionStorage.getItem('spbc_trial_renew_fullpage_dismissed')) {\n jQuery('.spbc-trial-renew-fullpage').hide();\n jQuery('#spbct-page--react').show();\n }\n\n jQuery('body').on('click', '.spbc-trial-renew-fullpage .notice-dismiss', function(e) {\n e.preventDefault();\n sessionStorage.setItem('spbc_trial_renew_fullpage_dismissed', '1');\n jQuery('.spbc-trial-renew-fullpage').hide();\n jQuery('#spbct-page--react').show();\n });\n\n jQuery(document)\n .off('click', '#spbc_debug__run_pass_check_btn')\n .on('click', '#spbc_debug__run_pass_check_btn', function() {\n let $btn = jQuery(this);\n let $st = jQuery('#spbc_debug__pass_check_status');\n $btn.prop('disabled', true);\n $st.css('color', '').text('Resetting records and running check, please wait...');\n jQuery.ajax({\n type: 'POST',\n url: ajaxurl,\n data: {\n action: 'spbc_debug_users_pass_check_run',\n security: spbcSettings.ajax_nonce,\n },\n success: function(response) {\n $btn.prop('disabled', false);\n if (response.success) {\n $st.css('color', 'green').html(\n '✓ Done! Total: ' + response.data.total +\n ', Checked: ' + response.data.checked +\n ', Leaked: ' + response.data.leaked +\n ' — You can now test the login form in incognito.',\n );\n } else {\n $st.css('color', 'red').text('Error: ' + (response.data || 'unknown error'));\n }\n },\n error: function(xhr) {\n $btn.prop('disabled', false);\n $st.css('color', 'red').text('Request failed: ' + xhr.status + ' ' + xhr.statusText);\n },\n });\n });\n});\n\n/**\n * Toggle class for DOM elements\n * @param {Array} arr\n * @param {string} className\n * @return {void}\n */\nfunction spbcToggleClass(arr, className) {\n for (let i=0; i'+result.desc+'
');\n\n jQuery(document).on('click', removeRecommendationFunc);\n },\n },\n obj,\n );\n}\n\n/**\n * Shows/hides full text\n */\nfunction spbcStartShowHide() { // eslint-disable-line no-unused-vars\n jQuery('.spbcShortText')\n .off('mouseover' )\n .on('mouseover', function() {\n jQuery(this).next().show();\n })\n .off('mouseout' )\n .on('mouseout', function() {\n jQuery(this).next().hide();\n });\n jQuery('.spbcFullText')\n .off('mouseout' )\n .on('mouseout', function() {\n jQuery(this).hide();\n })\n .off('mouseover' )\n .on('mouseover', function() {\n jQuery(this).show();\n });\n}\n\n/**\n * Reloads last scan info\n */\nfunction spbcScannerReloadScanInfo() { // eslint-disable-line no-unused-vars\n jQuery('.spbc_hint__last_scan_title').text(spbcScaner.look_below_for_scan_res);\n const data = {\n action: 'spbc_scanner__last_scan_info',\n };\n const params = {\n callback: (result) => {\n document.getElementById('spbc_scanner__last_scan_info').innerText = result.data;\n },\n };\n spbcSendAJAXRequest(data, params);\n}\n\n/**\n * Checking current account status for renew notice\n */\nfunction spbcBannerCheck() {\n let bannerChecker = setInterval( function() {\n spbcSendAJAXRequest(\n {action: 'spbc_settings__check_renew_banner'},\n {\n callback: function(result, data, params, obj) {\n if (result.close_renew_banner) {\n if (jQuery('#spbc_renew_notice').length) {\n jQuery('#spbc_renew_notice').hide('slow');\n }\n if (jQuery('#spbc_trial_notice').length) {\n jQuery('#spbc_trial_notice').hide('slow');\n }\n clearInterval(bannerChecker);\n }\n },\n },\n );\n }, 60000);\n}\n\njQuery(document).ready(function() {\n if (jQuery('#spbc_renew_notice').length || jQuery('#spbc_trial_notice').length) {\n spbcBannerCheck();\n }\n\n // Sync button migrated to react\n\n if ( spbcSettings.key_changed ) {\n jQuery('#spbc_button__sync').click();\n }\n\n // Get Key Auto button migrated to Signup Wizard\n\n // Import settings\n jQuery( document ).on('click', '#spbc_settings_templates_import_button', function() {\n jQuery('#spbc-ajax-result').remove();\n let optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_import'));\n let templateNameInput = jQuery('#spbc_settings_templates_import_name');\n templateNameInput.css('border-color', 'inherit');\n if ( typeof optionSelected.data('id') === 'undefined' ) {\n console.log( 'Attribute \"data-id\" not set for the option.' );\n return;\n }\n let data = {\n 'template_id': optionSelected.data('id'),\n 'template_name': optionSelected.data('name'),\n 'settings': optionSelected.data('settings'),\n };\n let button = this;\n spbcSendAJAXRequest(\n {action: 'spbc_settings_templates_import', data: data},\n {\n timeout: 25000,\n button: button,\n spinner: jQuery('#spbc_settings_templates_import_button .spbc_preloader_button' ),\n callback: function(result, data, params, obj) {\n let selector;\n if (result.success) {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n jQuery('#spbc_settings_templates_import_button .spbc_success').show(300);\n setTimeout(function() {\n jQuery('#spbc_settings_templates_import_button .spbc_success').hide(300);\n }, 2000);\n document.addEventListener('spbcModalClosed', function( e ) {\n document.location.reload();\n });\n setTimeout(function() {\n spbcModal.close();\n }, 2000);\n } else {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n }\n },\n },\n );\n });\n\n // Export settings\n jQuery( document ).on('click', '#spbc_settings_templates_export_button', function() {\n jQuery('#spbc-ajax-result').remove();\n let optionSelected = jQuery('option:selected', jQuery('#spbc_settings_templates_export'));\n let templateNameInput = jQuery('#spbc_settings_templates_export_name');\n templateNameInput.css('border-color', 'inherit');\n if ( typeof optionSelected.data('id') === 'undefined' ) {\n console.log( 'Attribute \"data-id\" not set for the option.' );\n return;\n }\n let data;\n if ( optionSelected.data('id') === 'new_template' ) {\n let templateName = templateNameInput.val();\n if ( templateName === '' ) {\n templateNameInput.css('border-color', 'red');\n return;\n }\n data = {\n 'template_name': templateName,\n };\n } else {\n data = {\n 'template_id': optionSelected.data('id'),\n };\n }\n let button = this;\n spbcSendAJAXRequest(\n {action: 'spbc_settings_templates_export', data: data},\n {\n timeout: 25000,\n button: button,\n spinner: jQuery('#spbc_settings_templates_export_button .spbc_preloader_button' ),\n callback: function(result, data, params, obj) {\n let selector;\n if (result.success) {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n jQuery('#spbc_settings_templates_export_button .spbc_success').show(300);\n setTimeout(function() {\n jQuery('#spbc_settings_templates_export_button .spbc_success').hide(300);\n }, 2000);\n document.addEventListener('spbcModalClosed', function( e ) {\n document.location.reload();\n });\n setTimeout(function() {\n spbcModal.close();\n }, 2000);\n } else {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n }\n },\n },\n );\n });\n\n // Reset settings\n jQuery( document ).on('click', '#spbc_settings_templates_reset_button', function() {\n let button = this;\n spbcSendAJAXRequest(\n {action: 'spbc_settings_templates_reset'},\n {\n timeout: 25000,\n button: button,\n spinner: jQuery('#spbc_settings_templates_reset_button .spbc_preloader_button' ),\n callback: function(result, data, params, obj) {\n let selector;\n if (result.success) {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n jQuery('#spbc_settings_templates_reset_button .spbc_success').show(300);\n setTimeout(function() {\n jQuery('#spbc_settings_templates_reset_button .spbc_success').hide(300);\n }, 2000);\n document.addEventListener('spbcModalClosed', function( e ) {\n document.location.reload();\n });\n setTimeout(function() {\n spbcModal.close();\n }, 2000);\n } else {\n selector = '' + result.data + '
';\n jQuery( selector ).insertAfter( jQuery(button) );\n }\n },\n },\n );\n });\n\n jQuery(document).on('change', '#spbc_settings_templates_export', function() {\n let optionSelected = jQuery('option:selected', this);\n if ( optionSelected.data('id') === 'new_template' ) {\n jQuery(this).parent().parent().find('#spbc_settings_templates_export_name').show();\n } else {\n jQuery(this).parent().parent().find('#spbc_settings_templates_export_name').hide();\n }\n });\n\n // Only handle legacy banners, not React Components\n // @ToDo remove the outdated way to close notice after transferring all tabs to components.\n jQuery(document).on('click', '.spbct_notice-dismiss', function(e) {\n let classListNotice = this.parentElement.classList;\n let classNoticeForClose = classListNotice[classListNotice.length - 1];\n\n document.querySelectorAll('.' + classNoticeForClose).forEach((element) => {\n element.parentElement.setAttribute('style', 'display:none;');\n spbcSetCookie(classNoticeForClose, 1, 86400 * 30);\n });\n });\n\n // @ToDo need to be refactored - this is the code dublication\n jQuery(document).off( 'click', '.spbc_long_description__show');\n jQuery(document).on('click', '.spbc_long_description__show', function() {\n self = jQuery(this);\n spbcHandleLongDescription(self, self.attr('data-setting') || self.attr('setting'));\n });\n\n // @ToDo need to be refactored - this is the code dublication\n jQuery(document).off( 'click', '.spbc_long_recommendation__show');\n jQuery(document).on('click', '.spbc_long_recommendation__show', function() {\n self = jQuery(this);\n spbcSettingsShowRecommendation(self, self.attr('data-setting') || self.attr('setting'));\n });\n\n // Reset dismiss flag if user came from outside plugin settings\n if (!document.referrer || document.referrer.indexOf('page=spbc') === -1) {\n sessionStorage.removeItem('spbc_trial_renew_fullpage_dismissed');\n }\n\n // Hide fullpage trial banner if it was already dismissed in this browser session\n if (sessionStorage.getItem('spbc_trial_renew_fullpage_dismissed')) {\n jQuery('.spbc-trial-renew-fullpage').hide();\n jQuery('#spbct-page--react').show();\n }\n\n jQuery('body').on('click', '.spbc-trial-renew-fullpage .notice-dismiss', function(e) {\n e.preventDefault();\n sessionStorage.setItem('spbc_trial_renew_fullpage_dismissed', '1');\n jQuery('.spbc-trial-renew-fullpage').hide();\n jQuery('#spbct-page--react').show();\n });\n\n jQuery(document)\n .off('click', '#spbc_debug__run_pass_check_btn')\n .on('click', '#spbc_debug__run_pass_check_btn', function() {\n let $btn = jQuery(this);\n let $st = jQuery('#spbc_debug__pass_check_status');\n $btn.prop('disabled', true);\n $st.css('color', '').text('Resetting records and running check, please wait...');\n jQuery.ajax({\n type: 'POST',\n url: ajaxurl,\n data: {\n action: 'spbc_debug_users_pass_check_run',\n security: spbcSettings.ajax_nonce,\n },\n success: function(response) {\n $btn.prop('disabled', false);\n if (response.success) {\n $st.css('color', 'green').html(\n '✓ Done! Total: ' + response.data.total +\n ', Checked: ' + response.data.checked +\n ', Leaked: ' + response.data.leaked +\n ' — You can now test the login form in incognito.',\n );\n } else {\n $st.css('color', 'red').text('Error: ' + (response.data || 'unknown error'));\n }\n },\n error: function(xhr) {\n $btn.prop('disabled', false);\n $st.css('color', 'red').text('Request failed: ' + xhr.status + ' ' + xhr.statusText);\n },\n });\n });\n});\n\n/**\n * Action to confirm creating support user.\n * @param {event} e\n * @return {void}\n */\nfunction spbcCreateSupportUser(e) { // eslint-disable-line no-unused-vars\n e.preventDefault();\n let localTextArray = spbcSettings.support_user_creation_msg_array;\n spbcModal.open();\n spbcModal.confirm(\n localTextArray.confirm_header,\n localTextArray.confirm_text,\n '',\n spbcCreateUserCallback,\n );\n}\n\n/**\n * Support user creation callback.\n * @return {void}\n */\nfunction spbcCreateUserCallback() {\n spbcSendAJAXRequest(\n {\n action: 'spbc_create_support_user',\n },\n {\n timeout: 5000,\n callback: function(result, data, params, obj) {\n let localTextArray = spbcSettings.support_user_creation_msg_array;\n let popupMsg = localTextArray.default_error;\n const responseValid = (\n typeof result === 'object' &&\n result.hasOwnProperty('success') &&\n result.hasOwnProperty('user_created') &&\n result.hasOwnProperty('mail_sent') &&\n result.hasOwnProperty('cron_updated') &&\n result.hasOwnProperty('user_data') &&\n result.hasOwnProperty('result_code') &&\n typeof result.user_data === 'object' &&\n result.user_data.hasOwnProperty('username') &&\n result.user_data.hasOwnProperty('email') &&\n result.user_data.hasOwnProperty('password')\n );\n if (responseValid && result.success) {\n if (result.user_created) {\n let mailSentMsg = '';\n let successCreationMsg = '';\n let cronUpdatedMsg = localTextArray.cron_updated;\n\n if (result.mail_sent) {\n mailSentMsg = localTextArray.mail_sent_success;\n } else {\n mailSentMsg = localTextArray.mail_sent_error;\n }\n\n if (result.result_code === 0) {\n successCreationMsg = localTextArray.user_updated;\n } else {\n successCreationMsg = localTextArray.user_created;\n }\n\n jQuery('#spbc_stats_user_creation_username').text(result.user_data.username);\n jQuery('#spbc_stats_user_creation_email').text(result.user_data.email);\n jQuery('#spbc_stats_user_creation_password').text(result.user_data.password);\n jQuery('#spbc_stats_user_creation_mail_sent').text(mailSentMsg);\n jQuery('#spbc_stats_user_creation_title').text(successCreationMsg);\n jQuery('#spbc_stats_user_creation_cron_updated').text(cronUpdatedMsg);\n jQuery('.spbc_stats_user_creation_result').css('display', 'block');\n return;\n } else {\n if (result.result_code === -2) {\n popupMsg = localTextArray.invalid_permission;\n } else if (result.result_code === -1) {\n popupMsg = localTextArray.unknown_creation_error;\n } else if (result.result_code === -4) {\n popupMsg = localTextArray.on_cooldown;\n } else if (result.result_code === -5) {\n popupMsg = localTextArray.email_is_busy;\n }\n }\n }\n spbcModal.loaded = popupMsg;\n spbcModal.open();\n },\n errorOutput: function(msg) {\n spbcModal.loaded = msg;\n spbcModal.open();\n },\n },\n );\n}\n"],"names":["spbcSwitchTab","tab","params","let","tabName","classList","replace","searchParams","URLSearchParams","window","location","search","hashParam","set","hash","newRelativePathQuery","pathname","toString","history","replaceState","get","jQuery","hide","removeClass","addClass","data","action","spbcHighlightElement","target","times","setTimeout","additional","click","tab_name","security","spbcSettings","ajax_nonce","callback","spbcDrawSettingsCallback","notJson","spbcSendAJAXRequest","result","obj","replaceWith","document","off","on","spbcSettingsShowRecommendation","self","this","attr","spbcSendLogsCallback","scrollToTag","getElementById","substring","scrollIntoView","spbcHighlightCriticalFilesNotice","spbcSaveSettingsButtonMobileLayout","addEventListener","selector","querySelector","innerWidth","style","display","getElementsByClassName","spbcSettingsDependenciesbyId","settingsIDs","enable","tmp","push","forEach","settingID","i","arr","elem","doDisable","setAttribute","doEnable","removeAttribute","getAttribute","spbcSettingsDependencies","settingNames","eventTarget","event","isRadio","type","radioEnabled","value","targetEnableFlag","checked","doEnableFlag","split","settingName","elements","getElementsByName","length","children","label","settingId","removeRecommendationFunc","e","parent","hasClass","remove","after","append","css","top","position","left","setting_id","spinner","empty","title","desc","spbcStartShowHide","next","show","spbcScannerReloadScanInfo","text","spbcScaner","look_below_for_scan_res","innerText","spbcBannerCheck","bannerChecker","setInterval","close_renew_banner","clearInterval","spbcCreateSupportUser","preventDefault","localTextArray","support_user_creation_msg_array","spbcModal","open","confirm","confirm_header","confirm_text","spbcCreateUserCallback","timeout","popupMsg","default_error","hasOwnProperty","user_data","success","user_created","mailSentMsg","successCreationMsg","cronUpdatedMsg","cron_updated","mail_sent","mail_sent_success","mail_sent_error","result_code","user_updated","username","email","password","invalid_permission","unknown_creation_error","on_cooldown","email_is_busy","loaded","errorOutput","msg","String","prototype","printf","formatted","arg","arguments","beforeFormatted","indexOf","afterFormatted","ready","key_changed","optionSelected","console","log","template_id","template_name","settings","button","insertAfter","reload","close","templateNameInput","templateName","val","find","classListNotice","parentElement","classNoticeForClose","querySelectorAll","element","spbcSetCookie","spbcHandleLongDescription","referrer","sessionStorage","removeItem","getItem","setItem","$btn","$st","prop","ajax","url","ajaxurl","response","html","total","leaked","error","xhr","status","statusText"],"mappings":"AAkBA,SAASA,cAAcC,EAAKC,GACxBC,IAAIC,EAAUH,EAAII,UAAU,GAAGC,QAAQ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db14c2c..5ec0bd062 100644 --- a/js/spbc-timeline-widget.min.js +++ b/js/spbc-timeline-widget.min.js @@ -1,4 +1,4 @@ -class SpbcTimelineWidget{static markerRadius=4;static hoursRangeMax=24;static axisStepsCount=6;static userActionsUpstep=24;static legendCircleX=-120;static legendTextX=-105;static userLegendMaxRows=2;static userLegendRowHeight=18;static userLegendItemGap=15;static userLegendAxisOffset=60;constructor(){this.now=new Date,this.currentTimestamp=Math.floor(this.now.getTime()/1e3),this.eventsData=null,this.timelineMarkersData=[],this.timelineKnownEventsData=[],this.timelineEventTooltip=null,this.timelineStartTimestamp=this.currentTimestamp-3600*SpbcTimelineWidget.hoursRangeMax,this.usersCount=0,this.summaryEventsCount=0,this.userLegendExpanded=!1,this.selectedUserValue="most_active__action"}render(){var e;"undefined"!=typeof spbcTimelineWidgetData&&(this.timelineEventTooltip=document.getElementById("spbc-timeline-tooltip"),this.eventsData=spbcTimelineWidgetData.users_actions,spbcTimelineWidgetData.current_timestamp_local&&(this.currentTimestamp=Number(spbcTimelineWidgetData.current_timestamp_local)),this.timelineStartTimestamp=Number(spbcTimelineWidgetData.first_event_timestamp),this.timelineKnownEventsData=spbcTimelineWidgetData.known_events_data,this.timelineMarkersData=this.generateMarkersData(spbcTimelineWidgetData.found_types),(e=document.querySelector(".spbc_tab_section--active"))&&"spbc_tab-security_log"===e.id&&this.initTimeline(),window.addEventListener("spbctTabLoaded",e=>{"security_log"===e.detail.tab&&this.initTimeline()}),jQuery("#spbc-timeline-tab").on("click",e=>{e.hasOwnProperty("originalEvent")&&("1"!==localStorage.getItem("spbc_timeline_closed")?localStorage.setItem("spbc_timeline_closed","1"):localStorage.setItem("spbc_timeline_closed","0"))}),window.addEventListener("resize",()=>{this.selectedUserValue&&(this.userLegendExpanded=!1,"most_active__action"===this.selectedUserValue?this.drawUserTimelineMostActive():this.drawUserTimeline(this.selectedUserValue))}))}initTimeline(){let i=document.getElementById("spbc-timeline-user-select-wrapper");var e=document.getElementById("spbc-timeline-user-select-trigger");let s=document.getElementById("spbc-timeline-user-select-dropdown"),n=document.getElementById("spbc-timeline-user-select-value");var t,r,a,l=[];for(t in this.usersCount=0,this.summaryEventsCount=0,this.eventsData)this.eventsData.hasOwnProperty(t)&&(r=this.eventsData[t],0<(a=(Array.isArray(r)?r:r.events||[]).filter(e=>e.time>=this.timelineStartTimestamp&&e.time<=this.currentTimestamp)).length)&&(this.usersCount++,this.summaryEventsCount+=a.length,l.push({user:t,role:r.role||"unknown",eventsCount:a.length}));s.innerHTML="";let c=(e,t)=>{var i=document.createElement("div");return i.className="spbc-timeline-select-option",i.dataset.value=t,i.textContent=e,i};var o=c("Most Active Users","most_active__action"),o=(o.classList.add("selected"),s.appendChild(o),l.forEach(e=>{var t=e.user+` (${e.role}) (${e.eventsCount} events)`;s.appendChild(c(t,e.user))}),e.addEventListener("click",e=>{e.stopPropagation(),i.classList.toggle("open")}),document.addEventListener("click",e=>{i.contains(e.target)||i.classList.remove("open")}),s.addEventListener("click",e=>{var t,e=e.target.closest(".spbc-timeline-select-option");e&&(t=e.dataset.value,this.selectedUserValue=t,this.userLegendExpanded=!1,n.textContent=e.textContent,s.querySelectorAll(".spbc-timeline-select-option").forEach(e=>{e.classList.remove("selected")}),e.classList.add("selected"),i.classList.remove("open"),"most_active__action"===t?(this.drawUserTimelineMostActive(),(e=new URL(window.location)).searchParams.delete("users"),window.history.pushState({},"",e)):(this.drawUserTimeline(t),(e=new URL(window.location)).searchParams.set("users",t),window.history.pushState({},"",e)),updateSecurityLogTable())}),0{var t=(e.time-this.timelineStartTimestamp)/s*d,i=m+this.timelineMarkersData[e.event].upstep;u.appendChild(this.createEventElement(e,t,i,n))})}}measureTextWidth(e,t,i="spbc-timeline-legend-text"){var s=document.createElementNS("http://www.w3.org/2000/svg","text"),i=(s.setAttribute("class",i),s.textContent=t,s.style.visibility="hidden",e.appendChild(s),s.getComputedTextLength());return e.removeChild(s),i}calculateUserLegendRowsCount(t,i,s,n=null){var r=SpbcTimelineWidget.userLegendItemGap,a=SpbcTimelineWidget.markerRadius,l=this.measureTextWidth(t,"and 99 more")+r;let c=0,o=0;for(let e=0;e