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