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