OwlCyberSecurity - MANAGER
Edit File: admin.js
"use strict";function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);return"Object"===a&&t.constructor&&(a=t.constructor.name),"Map"===a||"Set"===a?Array.from(t):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=new Array(e);a<e;a++)i[a]=t[a];return i}function _iterableToArrayLimit(t,e){var a=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=a){var i,r,c,n,d=[],o=!0,s=!1;try{if(c=(a=a.call(t)).next,0===e){if(Object(a)!==a)return;o=!1}else for(;!(o=(i=c.call(a)).done)&&(d.push(i.value),d.length!==e);o=!0);}catch(t){s=!0,r=t}finally{try{if(!o&&null!=a.return&&(n=a.return(),Object(n)!==n))return}finally{if(s)throw r}}return d}}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}"object"===("undefined"==typeof ClSentry?"undefined":_typeof(ClSentry))&&(ClSentry.init({dsn:"https://"+clSmartAdviceConfig.sentry.key+"@cl.sentry.cloudlinux.com/"+clSmartAdviceConfig.sentry.projectId,environment:clSmartAdviceConfig.sentry.environment,release:clSmartAdviceConfig.sentry.release,tracesSampleRate:0,defaultIntegrations:!1}),ClSentry.setUser(clSmartAdviceConfig.sentry.user),ClSentry.setTags(clSmartAdviceConfig.sentry.tags)),window.clSmartAdvice={notice:{close:function(t){var e=jQuery(t).closest("[data-cl-smart-advice-notice]");if(e.length){var a={action:"cl_smart_advice_notice_close",notice_id:e.data("cl-smart-advice-notice")};jQuery.post(ajaxurl,a,function(){var a=jQuery(t).attr("href");void 0!==a&&!1!==a&&"#"!==a&&(window.location.href=a),e.fadeTo(100,0,function(){e.slideUp(100,function(){e.remove()})})})}},render:function(t){if(0!==t.length){var e=jQuery(".wrap");if(e.length){var a=e.first().find("h1,h2,h3");jQuery.each(t,function(t,e){var i=jQuery('[data-cl-smart-advice-notice="'+e.id+'"]');0===i.length?a.first().after(e.html):i.replaceWith(e.html)}),this.init()}}else jQuery("[data-cl-smart-advice-notice]").remove()},init:function(){jQuery("[data-cl-smart-advice-notice-close]").on("click",function(t){t.preventDefault(),clSmartAdvice.notice.close(this);var e=jQuery(this).data("cl-smart-advice-notice-close");"view"===e?clSmartAdvice.advice.reportNoticeEvent("notice_link_clicked"):"dismiss"===e&&clSmartAdvice.advice.reportNoticeEvent("notice_closed")})}},modal:{show:function(t){jQuery('[data-smart-advice-modal="'+t+'"]').addClass("cl-smart-advice__modal_show")},hide:function(t){jQuery('[data-smart-advice-modal="'+t+'"]').removeClass("cl-smart-advice__modal_show")},close:function(t,e){var a=jQuery(t).data("smart-advice-modal-close");(jQuery(e.target).is(t)||jQuery(t).data("smart-advice-modal-close")===a)&&this.hide(a)},send:function(t,e){var a=jQuery(t).data("smart-advice-modal-send");"rollback"===a?this.rollback.send(t,e):"agreement"===a&&this.agreement.send(t,e)},rollback:{type:"rollback",modal:jQuery('[data-smart-advice-modal="rollback"]'),show:function(t){this.modal.find('input[name="advice_id"]').val(t),clSmartAdvice.modal.show(this.type)},hide:function(){clSmartAdvice.modal.hide(this.type)},send:function(){var t={advice_id:this.modal.find('input[name="advice_id"]').val(),reason:this.modal.find('textarea[name="reason"]').val(),action:"cl_smart_advice_rollback"};clSmartAdvice.modal.hide(this.type),this.modal.find('textarea[name="reason"]').val(""),this.modal.find('input[name="advice_id"]').val(""),clSmartAdvice.advice.ui({id:t.advice_id,status:"pending"}),jQuery.post(ajaxurl,t,function(t){clSmartAdvice.advice.sync()})}},subscription:{type:"subscription",modal:jQuery('[data-smart-advice-modal="subscription"]'),advice_id:!1,url:!1,show:function(t,e){this.advice_id=t,this.url=e;var a=this.modal.find('[data-smart-advice-modal-subscription="note"]'),i=this.modal.find('[data-smart-advice-modal-subscription="link"]');if(e&&e.length){a.hide(),i.show();var r=jQuery("[data-smart-advice="+t+"]").data("upgrade-button-text");r&&r.length&&i.find("span").text(r)}else a.show(),i.hide();clSmartAdvice.modal.show(this.type)},hide:function(){clSmartAdvice.modal.hide(this.type)},gateway:function(){clSmartAdvice.subscription.gateway(this.advice_id,this.url)}},subscription_success:{type:"subscription-success",modal:jQuery('[data-smart-advice-modal="subscription-success"]'),show:function(){clSmartAdvice.modal.show(this.type)},hide:function(){clSmartAdvice.modal.hide(this.type)}},agreement:{type:"agreement",modal:jQuery('[data-smart-advice-modal="agreement"]'),show:function(t,e){var a=this.modal.find('[data-smart-advice-modal-body="'+this.type+'"]'),i=this.modal.find('[data-smart-advice-modal-footer="'+this.type+'"]');a.html("Loading..."),i.hide(),jQuery.post(ajaxurl,{type:e,action:"cl_smart_advice_agreement_text"},function(t){var e=t.length?JSON.parse(t):{text:""};e.text.length?(clSmartAdvice.modal.agreement.loaded=!0,a.html(e.text),i.removeAttr("style")):a.html("Error, please try again")}).fail(function(){a.html("Error, please try again")}),this.modal.find('input[name="advice_id"]').val(t),clSmartAdvice.modal.show(this.type)},hide:function(){clSmartAdvice.modal.hide(this.type)},send:function(){var t=this.modal.find('input[name="advice_id"]').val();clSmartAdvice.advice.apply(t,!0),this.modal.find('input[name="advice_id"]').val("")}}},advice:{wait:!1,timer:!1,apply:function(t,e){var a={advice_id:t,action:"cl_smart_advice_apply",agreement_accepted:!0===e?1:0};this.ui({id:t,status:"pending"}),jQuery.post(ajaxurl,a,function(t){var e=JSON.parse(t);clSmartAdvice.advice.sync(),!1!==e.agreement_type?clSmartAdvice.modal.agreement.show(e.advice_id,e.agreement_type):!1!==e.subscription_url&&clSmartAdvice.modal.subscription.show(e.advice_id,e.subscription_url)})},rollback:function(t,e){var a=jQuery(t).data("smart-advice-rollback");clSmartAdvice.modal.rollback.show(a)},sync:function(){!1===this.timer&&(this.statuses(),this.timer=setInterval(function(){clSmartAdvice.advice.statuses()},2e3))},statuses:function(){if(!1===this.wait){this.wait=!0;jQuery.post(ajaxurl,{action:"cl_smart_advice_sync_statuses"},function(t){clSmartAdvice.advice.wait=!1;var e=JSON.parse(t);clSmartAdvice.notice.render(e.notices),jQuery.each(e.advices,function(t,e){clSmartAdvice.advice.ui(e)}),!1!==clSmartAdvice.advice.timer&&!1===e.pending&&(clearInterval(clSmartAdvice.advice.timer),clSmartAdvice.advice.timer=!1)})}},ui:function(t){var e=jQuery("[data-smart-advice="+t.id+"]");if(e.length){e.attr("data-status",t.status),e.data("status",t.status);var a=e.find('[data-smart-advice="status"]');a.length&&a.html(t.status);var i=e.find('[data-smart-advice="spinner"]');if(i.length){var r=0;void 0!==t.spinner_percent&&(r=t.spinner_percent),i.attr("data-percent",r)}var c=e.find('[data-smart-advice="percent"]');if(c.length){var n=0;void 0!==t.stage_percent&&(n=t.stage_percent),c.html(n)}}},report:function(t,e){if(jQuery.each(t,function(e,a){void 0!==clSmartAdviceConfig.advices[a]&&!1===clSmartAdviceConfig.advices[a].is_analytics_available&&t.splice(e,1)}),0!=t.length){var a=jQuery.extend(clSmartAdviceConfig.sessionData,{advice_id:t.join(","),source:"wp_smartadvice",event:e});try{jQuery.ajax({url:clSmartAdviceConfig.analyticsApiUrl,type:"POST",data:JSON.stringify(a),contentType:"application/json; charset=utf-8",dataType:"json"}).error(function(t,e,i){clSmartAdvice.advice.handleApiCommsError(a,{message:i,responseCode:t.status,responseStatus:e,responseHeaders:t.getAllResponseHeaders()})})}catch(t){clSmartAdvice.advice.handleApiCommsError(a,{message:t.message})}}},handleApiCommsError:function(t,e){if("object"===("undefined"==typeof ClSentry?"undefined":_typeof(ClSentry))){var a=jQuery.extend({},e,{analyticsData:t});ClSentry.setExtras(a),ClSentry.captureMessage("Failed to send analytics data to microservice.")}},reportNoticeEvent:function(t){var e=jQuery('[data-cl-smart-advice-notice="NEW_ADVICES"]').data("cl-smart-advice-list");void 0!==e&&(e="number"!=typeof e?e.split(","):[e],clSmartAdvice.advice.report(e,t))},init:function(){Object.entries({widget:"wp_smartadvice_dashboard_widget_displayed",index:"advice_displayed"}).forEach(function(t){var e=_slicedToArray(t,2),a=e[0],i=e[1],r=jQuery('[data-smart-advice-page="'+a+'"] [data-smart-advice][data-status="review"],[data-smart-advice-page="'+a+'"] [data-smart-advice][data-status="outdated"]');if(r.length){var c=jQuery.map(r,function(t){return jQuery(t).data("smart-advice")});clSmartAdvice.advice.report(c,i)}}),clSmartAdvice.advice.reportNoticeEvent("notice_displayed"),jQuery('[data-smart-advice][data-status="pending"]').length&&clSmartAdvice.advice.sync(),jQuery("[data-smart-advice-apply]").on("click",function(t){t.preventDefault();var e=jQuery(this).data("smart-advice-apply");clSmartAdvice.advice.apply(e,!1)}),jQuery("[data-smart-advice-rollback]").on("click",function(t){t.preventDefault(),clSmartAdvice.advice.rollback(this,t)}),jQuery("[data-smart-advice-modal-close]").on("click",function(t){t.preventDefault(),clSmartAdvice.modal.close(this,t)}),jQuery("[data-smart-advice-modal-send]").on("click",function(t){t.preventDefault(),clSmartAdvice.modal.send(this,t)}),jQuery('[data-smart-advice-modal-subscription="link"]').on("click",function(t){t.preventDefault(),clSmartAdvice.modal.subscription.gateway(this,t)})}},subscription:{timer:!1,advice_id:"",window_object:!1,window_opened:!1,gateway:function(t,e){this.advice_id=t,this.window_opened||(clSmartAdvice.advice.report([t],"awp_purchase_button_clicked"),this.window_object=window.open(e,"","toolbar=0,status=0,width=1100,height=640"),this.window_opened=!0,this.timer=setInterval(function(){clSmartAdvice.subscription.window_object.closed&&(clSmartAdvice.subscription.window_opened=!1,clearInterval(clSmartAdvice.subscription.timer))},500))},listener:function(t){if("PAYMENT_SUCCESS"===t.data){var e=this.advice_id;clSmartAdvice.advice.ui({id:e,status:"pending"}),this.window_opened&&this.window_object.close(),clSmartAdvice.modal.subscription.hide(),clSmartAdvice.modal.subscription_success.show(),jQuery.post(ajaxurl,{action:"cl_smart_advice_payment_success",advice_id:e},function(){clSmartAdvice.advice.sync()})}}},init:function(){this.notice.init(),this.advice.init(),window.addEventListener("message",function(t){clSmartAdvice.subscription.listener(t)},!1)}},jQuery(document).ready(function(){clSmartAdvice.init()});