OwlCyberSecurity - MANAGER
Edit File: admin-add-ons.js
(()=>{var e;(e=jQuery)(document).ready((function(){const n=e("#give-licenses-container"),a=e("#give-license-activator-wrap"),t=e("form",a),i=e('input[name="give_license_key"]',a),o=e('input[type="submit"]',t),d=e(".give-license-notices",a);d.on("click",e(".notice-dismiss",d),(function(e){d.empty().hide()})),t.on("submit",(function(){const a=i.val().trim(),t=e('input[name="give_license_activator_nonce"]',e(this)).val().trim();return d.empty(),a?(e.ajax({url:ajaxurl,method:"POST",data:{action:"give_get_license_info",license:a,_wpnonce:t},beforeSend:function(){o.val(o.attr("data-activating")),o.prop("disabled",!0),Give.fn.loader(n)},success:function(e){if(d.show(),i.val(""),!0!==e.success)e.data.hasOwnProperty("errorMsg")&&e.data.errorMsg?d.html(Give.notice.fn.getAdminNoticeHTML(e.data.errorMsg,"error")):d.html(Give.notice.fn.getAdminNoticeHTML(give_addon_var.notices.invalid_license,"error"));else if(e.data.hasOwnProperty("download")&&e.data.download){const a="string"==typeof e.data.download?give_addon_var.notices.download_file.replace("{link}",e.data.download):give_addon_var.notices.download_file.substring(0,give_addon_var.notices.download_file.indexOf(".")+1);d.html(Give.notice.fn.getAdminNoticeHTML(a,"success")),n.parent().parent().removeClass("give-hidden"),n.html(e.data.html)}else d.html(Give.notice.fn.getAdminNoticeHTML(give_addon_var.notices.invalid_license,"error"))}}).always((function(){Give.fn.loader(n,{show:!1}),o.val(o.attr("data-activate")),o.prop("disabled",!1)})),!1):(d.show(),d.html(Give.notice.fn.getAdminNoticeHTML(give_addon_var.notices.invalid_license,"error")),!1)})),n.on("click",".give-button__license-activate",(function(a){a.preventDefault();const t=e(this),i=t.parents(".give-addon-wrap"),o=e(".give-license-notice-container",i),d=t.prev('.give-license__key input[type="text"]').val().trim();o.empty().removeClass("give-addon-notice-shown").show(),d?e.ajax({url:ajaxurl,method:"POST",data:{action:"give_get_license_info",license:d,single:1,addon:t.attr("data-addon"),_wpnonce:e("#give_license_activator_nonce").val().trim()},beforeSend:function(){Give.fn.loader(i)},success:function(e){!0!==e.success?o.addClass("give-addon-notice-shown").prepend(Give.notice.fn.getAdminNoticeHTML(e.data.errorMsg,"error")):e.data.hasOwnProperty("is_all_access_pass")&&e.data.is_all_access_pass?n.html(e.data.html):i.replaceWith(e.data.html)}}).done((function(){Give.fn.loader(i,{show:!1})})):o.addClass("give-addon-notice-shown").prepend(Give.notice.fn.getAdminNoticeHTML(give_addon_var.notices.invalid_license,"error")),n.on("click",".notice-dismiss",(function(){o.slideUp(150,(function(){o.removeClass("give-addon-notice-shown")}))}))})),n.on("click",".give-license__deactivate",(function(a){a.preventDefault();const t=e(this);let i=t.parents(".give-addon-wrap"),o=e(".give-license-notice-container",i);const d=1<t.parents(".give-addon-inner").find(".give-addon-info-wrap").length,s=e(".give-addon-wrap").index(i);o.empty().removeClass("give-addon-notice-shown").show(),e.ajax({url:ajaxurl,method:"POST",data:{action:"give_deactivate_license",license:t.attr("data-license-key"),item_name:t.attr("data-item-name"),plugin_dirname:t.attr("data-plugin-dirname"),_wpnonce:t.attr("data-nonce")},beforeSend:function(){d?Give.fn.loader(n):Give.fn.loader(i)},success:function(a){!0===a.success?(d?n.html(a.data.html):i.replaceWith(a.data.html),i=e(".give-addon-wrap").get(s),o=e(".give-license-notice-container",i),o.addClass("give-addon-notice-shown").prepend(Give.notice.fn.getAdminNoticeHTML(a.data.msg,"success")),n.html().trim().length||n.parent().parent().addClass("give-hidden")):o.addClass("give-addon-notice-shown").prepend(Give.notice.fn.getAdminNoticeHTML(a.data.errorMsg,"error"))}}).done((function(){d?Give.fn.loader(n,{show:!1}):Give.fn.loader(i,{show:!1})})),n.on("click",".notice-dismiss",(function(){o.slideUp(150,(function(){o.removeClass("give-addon-notice-shown")}))}))})),n.on("click",".give-button__license-reactivate",(function(a){a.preventDefault();const t=e(this),i=t.attr("data-license").trim(),o=e(".give-addon-wrap").index(d);let d=t.parents(".give-addon-wrap"),s=e(".give-license-notice-container",d);s.empty().removeClass("give-addon-notice-shown").show(),i?e.ajax({url:ajaxurl,method:"POST",data:{action:"give_get_license_info",license:i,single:1,reactivate:1,addon:t.attr("data-addon"),_wpnonce:e("#give_license_activator_nonce").val().trim()},beforeSend:function(){Give.fn.loader(d)},success:function(a){!0!==a.success?(a.data.hasOwnProperty("html")&&a.data.html.length&&(a.data.hasOwnProperty("is_all_access_pass")&&a.data.is_all_access_pass?n.html(a.data.html):d.replaceWith(a.data.html)),d=e(".give-addon-wrap").get(o),s=e(".give-license-notice-container",d),s.addClass("give-addon-notice-shown").prepend(Give.notice.fn.getAdminNoticeHTML(a.data.errorMsg,"error"))):a.data.hasOwnProperty("is_all_access_pass")&&a.data.is_all_access_pass?n.html(a.data.html):d.replaceWith(a.data.html)}}).done((function(){Give.fn.loader(d,{show:!1})})):s.addClass("give-addon-notice-shown").prepend(Give.notice.fn.getAdminNoticeHTML(give_addon_var.notices.invalid_license,"error")),n.on("click",".notice-dismiss",(function(){s.slideUp(150,(function(){s.removeClass("give-addon-notice-shown")}))}))})),e("#give-button__refresh-licenses").on("click",(function(a){a.preventDefault();const t=e(this);e.ajax({url:ajaxurl,method:"POST",data:{action:"give_refresh_all_licenses",_wpnonce:t.attr("data-nonce")},beforeSend:function(){t.text(t.attr("data-activating")),Give.fn.loader(n)},success:function(a){!0===a.success&&(n.html(a.data.html),e("#give-last-refresh-notice").text(a.data.lastUpdateMsg)),a.success&&!a.data.refreshButton||t.prop("disabled",!0)}}).done((function(){Give.fn.loader(n,{show:!1}),t.text(t.attr("data-activate"))}))}))})),e(document).ready((function(){const n=e(".give-upload-addon-form-wrap"),a=e("form",n),t=e('input[type="file"]',a),i=e(".give-activate-addon-wrap",a),o=e("button",a),d=e(".give-addon-upload-notices",a),s=e("#give-licenses-container");function c(t){d.empty(),e.ajax({url:`${ajaxurl}?action=give_upload_addon&_wpnonce=${e('input[name="_give_upload_addon"]',a).val().trim()}`,method:"POST",data:t,contentType:!1,processData:!1,dataType:"json",beforeSend:function(){d.show(),Give.fn.loader(n,{loadingText:Give.fn.getGlobalVar("loader_translation").uploading})},success:function(e){let n;if(!0===e.success)return d.hide(),i.show(),o.attr("data-pluginPath",e.data.pluginPath),o.attr("data-pluginName",e.data.pluginName),o.attr("data-nonce",e.data.nonce),void s.html(e.data.licenseSectionHtml);n=e.data.hasOwnProperty("errorMsg")&&e.data.errorMsg?e.data.errorMsg:e.data.error,d.html(Give.notice.fn.getAdminNoticeHTML(n,"error"))}}).always((function(){Give.fn.loader(n,{show:!1})}))}n.on("drop",(function(n){n.stopPropagation(),n.preventDefault(),e(this).removeClass("give-dropzone-active");const a=n.originalEvent.dataTransfer.files,t=new FormData;t.append("file",a[0]),c(t)})),a.on("dragover",(function(n){e(this).addClass("give-dropzone-active")})).on("dragleave",(function(n){e(this).removeClass("give-dropzone-active")})),d.on("click",e(".notice-dismiss",d),(function(e){d.empty().hide(),a.removeClass("give-dropzone-active")})),t.on("change",(function(e){e.stopPropagation(),e.preventDefault();const n=new FormData,a=t[0].files[0];if(!a)return!1;n.append("file",a),c(n)})),o.on("click",(function(n){n.preventDefault(),d.empty(),e.ajax({url:ajaxurl,method:"POST",data:{action:"give_activate_addon",plugin:o.attr("data-pluginPath"),_wpnonce:o.attr("data-nonce")},beforeSend:function(){d.show(),o.text(o.attr("data-activating"))},success:function(e){if(!0===e.success){const n=give_addon_var.notices.addon_activated.replace("{pluginName}",o.attr("data-pluginName"));return d.show(),d.html(Give.notice.fn.getAdminNoticeHTML(n,"success")),void s.html(e.data.licenseSectionHtml)}e.data.hasOwnProperty("errorMsg")&&e.data.errorMsg?d.html(Give.notice.fn.getAdminNoticeHTML(e.data.errorMsg,"error")):Give.notice.fn.getAdminNoticeHTML(give_addon_var.notices.addon_activation_error,"error")}}).always((function(){o.text(o.attr("data-activate")),i.hide()}))}))}))})();