vendor
7 years ago
admin.js
2 years ago
ads.js
2 years ago
documents-viewer-script.js
3 years ago
front.js
2 years ago
index.html
7 years ago
initplyr.js
2 years ago
pdfobject.min.js
3 years ago
plyr.polyfilled.js
3 years ago
preview.js
3 years ago
settings.js
6 years ago
vimeo-player.js
2 years ago
ytiframeapi.js
2 years ago
admin.js
242 lines
| 1 | /** |
| 2 | * @package EmbedPress |
| 3 | * @author EmbedPress <help@embedpress.com> |
| 4 | * @copyright Copyright (C) 2018 EmbedPress. All rights reserved. |
| 5 | * @license GPLv2 or later |
| 6 | * @since 1.7.0 |
| 7 | */ |
| 8 | (function ($) { |
| 9 | 'use strict'; |
| 10 | |
| 11 | var __ = wp.i18n.__; |
| 12 | var addQueryArgs = wp.url.addQueryArgs; |
| 13 | $(document).on('click', '.embedpress-plugin-notice-dismissible.is-dismissible', function () { |
| 14 | var data = { |
| 15 | action: 'embedpress_notice_dismiss', |
| 16 | security: EMBEDPRESS_ADMIN_PARAMS.nonce, |
| 17 | }; |
| 18 | |
| 19 | $.post(EMBEDPRESS_ADMIN_PARAMS.ajaxurl, data, function () { |
| 20 | |
| 21 | }); |
| 22 | }); |
| 23 | |
| 24 | $(document).on('click', '.embedpress-license-activation-btn', function (e) { |
| 25 | e.preventDefault(); |
| 26 | let $this = $(this); |
| 27 | |
| 28 | const licensesKey = $('#embedpress-pro-license-key').val(); |
| 29 | |
| 30 | if (licensesKey) { |
| 31 | $this.attr('disabled', 'disabled'); |
| 32 | $this.html(__('Sending Request.....', 'embedpress')); |
| 33 | } |
| 34 | |
| 35 | $.ajax({ |
| 36 | type: 'POST', |
| 37 | url: ajaxurl, |
| 38 | data: { |
| 39 | // Your data to be sent in the request body |
| 40 | action: 'embedpress/license/activate', |
| 41 | _nonce: wpdeveloperLicenseManagerConfig.nonce, // |
| 42 | license_key: licensesKey, |
| 43 | }, |
| 44 | success: function (response) { |
| 45 | // Handle the successful response here |
| 46 | if (!response.success) { |
| 47 | $this.html(__('Active License', 'embedpress')); |
| 48 | $this.removeAttr('disabled'); |
| 49 | $('.embedpress-toast__message.toast__message--error p').text(response?.data?.message); |
| 50 | $('.toast__message--error').addClass('show-toast'); |
| 51 | |
| 52 | setTimeout(() => { |
| 53 | $('.toast__message--error').removeClass('show-toast'); |
| 54 | }, 2000); |
| 55 | |
| 56 | } |
| 57 | else if (response.data.license === 'valid') { |
| 58 | activationMessage(); |
| 59 | } |
| 60 | else if (response.data.license === 'required_otp') { |
| 61 | $this.html(__('Verification Required', 'embedpress')); |
| 62 | $('#valid-license-key-message').removeClass('hidden'); |
| 63 | $('#email-placeholder').text(response.data.customer_email); |
| 64 | $('#embedpress-pro-license-key').attr('disabled', 'disabled'); |
| 65 | |
| 66 | $('.embedpress-toast__message.toast__message--success p').text('Verification Code Sent successfully'); |
| 67 | $('.toast__message--success').addClass('show-toast'); |
| 68 | |
| 69 | setTimeout(() => { |
| 70 | $('.toast__message--success').removeClass('show-toast'); |
| 71 | }, 2000); |
| 72 | |
| 73 | $('#otp-varify-form').removeClass('hidden'); |
| 74 | } |
| 75 | }, |
| 76 | error: function (xhr, status, error) { |
| 77 | // Handle errors here |
| 78 | console.error('Error:', status, error); |
| 79 | } |
| 80 | }); |
| 81 | |
| 82 | }); |
| 83 | |
| 84 | $(document).on('click', '.embedpress-verification-activation-btn', function (e) { |
| 85 | e.preventDefault(); |
| 86 | let $this = $(this); |
| 87 | |
| 88 | const licensesKey = $('#embedpress-pro-license-key').val(); |
| 89 | const otpCode = $('#embedpress-pro-verification-key').val(); |
| 90 | |
| 91 | $('#invalid-verification-key-message').addClass('hidden'); |
| 92 | |
| 93 | if (licensesKey) { |
| 94 | $this.attr('disabled', 'disabled'); |
| 95 | $this.html(__('Verifying.....', 'embedpress')); |
| 96 | } |
| 97 | // var ajaxUrl = 'embedpress/license/activate'; // Replace with the actual URL |
| 98 | |
| 99 | $.ajax({ |
| 100 | type: 'POST', |
| 101 | url: ajaxurl, |
| 102 | data: { |
| 103 | // Your data to be sent in the request body |
| 104 | action: 'embedpress/license/submit-otp', |
| 105 | _nonce: wpdeveloperLicenseManagerConfig.nonce, // |
| 106 | license: licensesKey, |
| 107 | otp: otpCode, |
| 108 | }, |
| 109 | success: function (response) { |
| 110 | // Handle the successful response here |
| 111 | console.log('Success:', response); |
| 112 | if (!response.success) { |
| 113 | $this.html('Verify'); |
| 114 | $this.removeAttr('disabled'); |
| 115 | $('.embedpress-toast__message.toast__message--error p').text(response?.data?.message); |
| 116 | $('.toast__message--error').addClass('show-toast'); |
| 117 | setTimeout(() => { |
| 118 | $('.toast__message--error').removeClass('show-toast'); |
| 119 | }, 2000); |
| 120 | |
| 121 | } |
| 122 | else { |
| 123 | $this.html(__('Verified', 'embedpress')); |
| 124 | activationMessage(); |
| 125 | } |
| 126 | }, |
| 127 | error: function (xhr, status, error) { |
| 128 | // Handle errors here |
| 129 | console.error('Error:', status, error); |
| 130 | } |
| 131 | }); |
| 132 | |
| 133 | }); |
| 134 | $(document).on('click', '#resend-license-verification-key', function (e) { |
| 135 | e.preventDefault(); |
| 136 | let $this = $(this); |
| 137 | |
| 138 | |
| 139 | const licensesKey = $('#embedpress-pro-license-key').val(); |
| 140 | $('#resend-license-verification-key').text(__('Resending', 'embedpress')); |
| 141 | |
| 142 | $.ajax({ |
| 143 | type: 'POST', |
| 144 | url: ajaxurl, |
| 145 | data: { |
| 146 | // Your data to be sent in the request body |
| 147 | action: 'embedpress/license/resend-otp', |
| 148 | _nonce: wpdeveloperLicenseManagerConfig.nonce, // |
| 149 | license: licensesKey, |
| 150 | }, |
| 151 | success: function (response) { |
| 152 | // Handle the successful response here |
| 153 | console.log('Success:', response); |
| 154 | if (!response.success) { |
| 155 | $('.embedpress-toast__message.toast__message--error p').text(response?.data?.message); |
| 156 | $('.toast__message--error').addClass('show-toast'); |
| 157 | |
| 158 | setTimeout(() => { |
| 159 | $('.toast__message--error').removeClass('show-toast'); |
| 160 | }, 2000); |
| 161 | |
| 162 | } |
| 163 | else { |
| 164 | $('.embedpress-toast__message.toast__message--success p').text('Verification Code Resent Successfully.'); |
| 165 | $('.toast__message--success').addClass('show-toast'); |
| 166 | |
| 167 | setTimeout(() => { |
| 168 | $('.toast__message--success').removeClass('show-toast'); |
| 169 | }, 2000); |
| 170 | } |
| 171 | |
| 172 | $('#resend-license-verification-key').text(__('Resend', 'embedpress')); |
| 173 | |
| 174 | }, |
| 175 | error: function (xhr, status, error) { |
| 176 | // Handle errors here |
| 177 | console.error('Error:', status, error); |
| 178 | } |
| 179 | }); |
| 180 | |
| 181 | }); |
| 182 | |
| 183 | $(document).on('click', '.embedpress-license-deactivation-btn', function (e) { |
| 184 | e.preventDefault(); |
| 185 | let $this = $(this); |
| 186 | |
| 187 | const licensesKey = $('#embedpress-pro-license-key').val(); |
| 188 | const otpCode = $('#embedpress-pro-verification-key').val(); |
| 189 | |
| 190 | console.log(licensesKey); |
| 191 | |
| 192 | if (licensesKey) { |
| 193 | $this.attr('disabled', 'disabled'); |
| 194 | $this.html(__('Deactivating.....', 'embedpress')); |
| 195 | } |
| 196 | // var ajaxUrl = 'embedpress/license/activate'; // Replace with the actual URL |
| 197 | |
| 198 | $.ajax({ |
| 199 | type: 'POST', |
| 200 | url: ajaxurl, |
| 201 | data: { |
| 202 | // Your data to be sent in the request body |
| 203 | action: 'embedpress/license/deactivate', |
| 204 | _nonce: wpdeveloperLicenseManagerConfig.nonce, // |
| 205 | }, |
| 206 | success: function (response) { |
| 207 | // Handle the successful response here |
| 208 | console.log('Success:', response); |
| 209 | if (response.success) { |
| 210 | deactivationMessage(); |
| 211 | } |
| 212 | }, |
| 213 | error: function (xhr, status, error) { |
| 214 | // Handle errors here |
| 215 | console.error('Error:', status, error); |
| 216 | } |
| 217 | }); |
| 218 | |
| 219 | }); |
| 220 | |
| 221 | function activationMessage() { |
| 222 | var currentUrl = window.location.href; |
| 223 | var newUrl = addQueryArgs(currentUrl, { |
| 224 | success: true, |
| 225 | message: __('License has been activated', 'embedpress') |
| 226 | }); |
| 227 | window.location.href = newUrl; |
| 228 | } |
| 229 | function deactivationMessage() { |
| 230 | var currentUrl = window.location.href; |
| 231 | var newUrl = addQueryArgs(currentUrl, { |
| 232 | success: true, |
| 233 | message: __('License has been deactivated', 'embedpress') |
| 234 | }); |
| 235 | |
| 236 | window.location.href = newUrl; |
| 237 | } |
| 238 | |
| 239 | |
| 240 | |
| 241 | })(jQuery); |
| 242 |