PluginProbe
Tagembed: Social Media Feeds and Customer Reviews Widget / 7.8
Tagembed: Social Media Feeds and Customer Reviews Widget v7.8
7.8 7.5 7.6 7.7 7.4 trunk 3.10 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 All 43 releases
tagembed-widget / assets / js / upgrade / tagembed.upgrade.script.js

tagembed.upgrade.script.js in Tagembed: Social Media Feeds and Customer Reviews Widget 7.8, at assets/js/upgrade/tagembed.upgrade.script.js

330 lines 19.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*--Start--Manage All Feacture Hide Show*/
2 function __tagembed__manageAllFeactureHideShow() {
3 let __tagembed__all_feacture_section = document.querySelector("#__tagembed__all_feacture_section");
4 let __tagembed__all_feacture_button = document.querySelector("#__tagembed__all_feacture_button");
5 if (__tagembed__all_feacture_section.style.display === "none") {
6 __tagembed__all_feacture_section.style.display = "block";
7 __tagembed__all_feacture_button.textContent = "Hide All Features";
8 } else {
9 __tagembed__all_feacture_section.style.display = "none";
10 __tagembed__all_feacture_button.textContent = "Show All Features";
11 }
12 }
13 /*--End--Manage All Feacture Hide Show*/
14 /*--Start--Manage All Feacture Hide Show*/
15 function __tagembed__manageSelectPlanPrice(timePeriod) {
16 let __tagembbed__monthely_price_button = document.querySelector("#__tagembbed__monthely_price_button");
17 let __tagembbed__yearly_price_button = document.querySelector("#__tagembbed__yearly_price_button");
18 if (timePeriod == "monthely") {
19 document.querySelectorAll('.__tagembed__yearly_plan').forEach(function (el) {
20 el.style.display = 'none';
21 });
22 document.querySelectorAll('.__tagembed__monthely_plan').forEach(function (el) {
23 el.style.display = 'block';
24 });
25 document.querySelectorAll('.__tagembed__selectbtn_yearly').forEach(function (el) {
26 el.style.display = 'none';
27 });
28 document.querySelectorAll('.__tagembed__selectbtn_monthely').forEach(function (el) {
29 el.style.display = 'block';
30 });
31 __tagembbed__monthely_price_button.classList.add("__tagembed__active");
32 __tagembbed__yearly_price_button.classList.remove("__tagembed__active");
33 } else if (timePeriod == "yearly") {
34 document.querySelectorAll('.__tagembed__yearly_plan').forEach(function (el) {
35 el.style.display = 'block';
36 });
37 document.querySelectorAll('.__tagembed__monthely_plan').forEach(function (el) {
38 el.style.display = 'none';
39 });
40 document.querySelectorAll('.__tagembed__selectbtn_yearly').forEach(function (el) {
41 el.style.display = 'block';
42 });
43 document.querySelectorAll('.__tagembed__selectbtn_monthely').forEach(function (el) {
44 el.style.display = 'none';
45 });
46 __tagembbed__yearly_price_button.classList.add("__tagembed__active");
47 __tagembbed__monthely_price_button.classList.remove("__tagembed__active");
48 }
49 }
50 /*--End--Manage All Feacture Hide Show*/
51 /*--Start-- Get User Accounts Details*/
52 window.addEventListener ? window.addEventListener("load", __tagembed__get_account_details, false) : window.attachEvent && window.attachEvent("onload", __tagembed__get_account_details);
53 function __tagembed__get_account_details() {
54 let __tagembed__all_feacture_section = document.querySelector("#__tagembed__all_feacture_section");
55 let allFeactureRemovableKeys = ['id', 'created', 'modified', 'webEmbed', 'status', 'collaborator', 'collaboratorStatus', 'themes', 'updatesIntervalCron', 'unit_cron', 'retainPost'];
56 let allFeactureIcons = ['apiLimit', 'name', 'retainPostCount', 'support', 'walls', 'feeds', 'linkedInFeedLimit', 'linkedInFeedLimit', 'twitterFeedLimit', 'viewCount']
57 let freeTrialPlanIds = ['1'];
58 let __tagembed__plan = document.querySelector("#__tagembed__plan");
59 let __tagembed__toast = new TagembedToast;
60 let formData = new FormData();
61 formData.append('action', 'tagembed_data');
62 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
63 formData.append('__tagembed__ajax_action', '__tagembed__get_account_details');
64 __tagembed__open_loader();
65 fetch(__tagembed__ajax_url, {
66 method: 'POST',
67 headers: {
68 'x-requested-with': 'XMLHttpRequest',
69 },
70 body: formData,
71 }).then(response => {
72 return response.json()
73 }).then(response => {
74 __tagembed__close_loader();
75 if (response.status == true) {
76
77 /*--Start-- Manage Upgrade Plan Section Hide | Show*/
78 let __tagembed__upgrade_plan_section = document.querySelector("#__tagembed__upgrade_plan_section");
79 let __tagembed__support_section = document.querySelector("#__tagembed__support_section");
80 if (response.data.upgradeSection && response.data.upgradeSection === "hide") {
81 if (__tagembed__upgrade_plan_section) {
82 __tagembed__upgrade_plan_section.style.display = "none";
83 }
84 if (__tagembed__support_section) {
85 __tagembed__support_section.style.display = "block";
86 }
87 return false;
88 }
89 /*--End-- Manage Upgrade Plan Section Hide | Show*/
90
91 /*--Start-- Manage All Feacture Section*/
92 let allFeactureHTML = "";
93 let i = 0;
94 for (let indexxxxx in response.data.Product) {
95 if (indexxxxx == "Plan") {
96 for (let indexxxxxx in response.data.Product[indexxxxx]) {
97 if (!freeTrialPlanIds.includes(response.data.Product[indexxxxx][indexxxxxx].Plan.id)) {
98 const selectedKeys = [
99 'name', 'walls', 'feeds', 'Networks', 'branding', 'api', 'support', 'apiLimit',
100 'customCss', 'manualModeration', 'automaticModeration', 'webAnalytic',
101 'customPost', 'customBanner', 'profanityFilter', 'cta', 'cdn', 'retainPostCount',
102 'linkedInFeedLimit', 'twitterFeedLimit', 'viewCount'
103 ];
104 if (i === 0) {
105 allFeactureHTML += '<tr>';
106
107 for (const key of selectedKeys) {
108 const planRuleData = response.data.Product[indexxxxx][indexxxxxx].PlanRule;
109 if (planRuleData.hasOwnProperty(key) && !allFeactureRemovableKeys.includes(key)) {
110 allFeactureHTML += `<th>${__tagembed__escapeText(key.replace(/([A-Z])/g, ' $1'))}</th>`;
111 }
112 }
113 allFeactureHTML += '<th>Networks</th></tr>';
114 }
115 i++;
116 allFeactureHTML += '<tr>';
117
118 for (const key of selectedKeys) {
119 const planRuleData = response.data.Product[indexxxxx][indexxxxxx].PlanRule;
120 if (planRuleData.hasOwnProperty(key) && !allFeactureRemovableKeys.includes(key)) {
121 if (allFeactureIcons.includes(key)) {
122 allFeactureHTML += `<td>${__tagembed__escapeText(planRuleData[key])}</td>`;
123 } else {
124 if (planRuleData[key] == "1") {
125 allFeactureHTML += `<td class="text-center mb-0"><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" class="img-fluid"></td>`;
126 } else {
127 allFeactureHTML += `<td class="text-center mb-0"><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" class="img-fluid"></td>`;
128 }
129 }
130 }
131 }
132 allFeactureHTML += '<td>';
133 for (let network of response.data.Product[indexxxxx][indexxxxxx].Planrulenetwork) {
134 allFeactureHTML += `<img style="height:14px; margin:2px;" src="${__tagembed__plugin_url_for_js}assets/images/network/${__tagembed__escapeAttr(network.network)}.png"/>`;
135 }
136 allFeactureHTML += '</td></tr>';
137 }
138 }
139 }
140 }
141 __tagembed__setSafeHtml(__tagembed__all_feacture_section, `<table> ${allFeactureHTML}</table>`);
142 /*--End-- Manage All Feacture Section*/
143 /*--Start-- Manage Plan Serction Section*/
144 let elemHTML = "";
145 for (let indexx in response.data.Product) {
146 if (indexx == "Plan") {
147 for (let indexxx in response.data.Product[indexx]) {
148 elemHTML = `${elemHTML}<div class="__tagembed__planbox ${(response.data.Product[indexx][indexxx].Plan.id == response.data.Product.ActivePlan.id) ? '__tagembed__activeplan' : ''}">`;
149 if (response.data.Product[indexx][indexxx].Plan.id == response.data.Product.ActivePlan.id)
150 elemHTML = `${elemHTML}<span class="__tagembed__currentplan">Current Plan</span>`;
151 elemHTML = `${elemHTML}<strong>${__tagembed__escapeText(response.data.Product[indexx][indexxx].Plan.name)}</strong>`;
152 let monthelyPrice = response.data.Product[indexx][indexxx].Plan.wordpessMonthlyPrice;
153 let yearlyPrice = response.data.Product[indexx][indexxx].Plan.wordpressYearlyPrice;
154 if (response.data.Product[indexx][indexxx].Plan.id == 67 || response.data.Product[indexx][indexxx].Plan.id == 53) {
155 elemHTML = `${elemHTML}<h2>Free</h2>`;
156 } else {
157 elemHTML = `${elemHTML}<h2 class="__tagembed__monthely_plan" style="display:none;">$${__tagembed__escapeText(monthelyPrice)}/Mo</h2>`;
158 elemHTML = `${elemHTML}<h2 class="__tagembed__yearly_plan">$${__tagembed__escapeText(yearlyPrice)}/Mo</h2>`;
159 }
160 elemHTML = `${elemHTML}<p>${__tagembed__escapeText(response.data.Product[indexx][indexxx].Plan.description)}</p>`;
161 elemHTML = `${elemHTML}<ul>`;
162 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.feeds)} ${response.data.Product[indexx][indexxx].Plan.id == 67 || response.data.Product[indexx][indexxx].Plan.id == 53 ? `Feed` : `Feeds`}</li>`;
163 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.viewCount)} Views/Month</li>`;
164 if (response.data.Product[indexx][indexxx].Plan.id != 67 && response.data.Product[indexx][indexxx].Plan.id != 53) {
165 if (response.data.Product[indexx][indexxx].PlanRule.linkedInFeedLimit != 0) {
166 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />LinkedIn Auto Update (Max ${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.linkedInFeedLimit)} Feeds)</li>`;
167 } else {
168 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />LinkedIn Manual</li>`;
169 }
170 } else {
171 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />LinkedIn Feed</li>`;
172 }
173 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.updatesIntervalCron)} ${(response.data.Product[indexx][indexxx].PlanRule.unit_cron == 3600) ? "Hours" : "Mins"} Update Time</li>`;
174 if (response.data.Product[indexx][indexxx].PlanRule.customCss == 0) {
175 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />No Custom CSS</li>`;
176 } else {
177 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />Custom CSS</li>`;
178 }
179 if (response.data.Product[indexx][indexxx].PlanRule.branding == 0) {
180 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />No Tagembed Branding</li>`;
181 } else {
182 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />Tagembed Branding</li>`;
183 }
184 elemHTML = `${elemHTML}</ul>`;
185 if (response.data.Product[indexx][indexxx].Plan.id != 1) {
186 if (response.data.Product[indexx][indexxx].Plan.id == response.data.Product.ActivePlan.id) {
187 if (response.data.Product[indexx][indexxx].Plan.id != 67 && response.data.Product[indexx][indexxx].Plan.id != 53) {
188 elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="cancel-subscription" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" class="__tagembed__selectbtn">Cancel Subscription</a>`;
189 }
190 } else {
191 if (response.data.Product[indexx][indexxx].Plan.id == 67 || response.data.Product[indexx][indexxx].Plan.id == 53) {
192 elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="lite-payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeMonthlyPriceCode)}" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`;
193 elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="lite-payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeYearlyPriceCode)}" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`;
194 } else {
195 elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeMonthlyPriceCode)}" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`;
196 elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeYearlyPriceCode)}" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`;
197 }
198 }
199 }
200 elemHTML = `${elemHTML}</div>`;
201 }
202 }
203 }
204 __tagembed__setSafeHtml(__tagembed__plan, elemHTML);
205 /* The plan buttons carry their values in data attributes and are wired up here,
206 so no event handler is written into the markup. */
207 __tagembed__plan.querySelectorAll("[data-tagembed-action]").forEach(function (__tagembed__planButton) {
208 __tagembed__planButton.addEventListener("click", function () {
209 let __tagembed__action = (this.getAttribute("data-tagembed-action") || "");
210 let __tagembed__planId = (this.getAttribute("data-tagembed-plan-id") || "");
211 let __tagembed__priceCode = (this.getAttribute("data-tagembed-price-code") || "");
212 if ("cancel-subscription" === __tagembed__action) __tagembed__cancel_subscription(__tagembed__planId);
213 else if ("lite-payment" === __tagembed__action) __tagembed__make_lite_plan_payment(__tagembed__planId, __tagembed__priceCode);
214 else if ("payment" === __tagembed__action) __tagembed__make_payment(__tagembed__planId, __tagembed__priceCode);
215 });
216 });
217 /*--End-- Manage Plan Serction Section*/
218
219 /*Manage Upgrade Plan Section Hide | Show */
220 if (__tagembed__upgrade_plan_section)
221 __tagembed__upgrade_plan_section.style.display = "block";
222
223 } else {
224 if (response.hasOwnProperty("message")) {
225 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
226 } else {
227 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
228 }
229 }
230 }).catch((error) => {
231 console.log(error);
232 __tagembed__close_loader();
233 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
234 });
235 }
236 /*--End-- Get User Accounts Details*/
237 /*--Start-- Manage Payment*/
238 function __tagembed__make_lite_plan_payment(planId, priceCode) {
239 __tagembed__confirmDialog({ title: 'Opting Free Forever LITE Plan', message: 'Your current plan will be canceled and changed to Lite Plan.', buttonText: 'Confirm', type: 'danger' }, function () {
240 __tagembed__make_payment(planId, priceCode);
241 });
242 }
243 function __tagembed__make_payment(planId, priceCode) {
244 let __tagembed__toast = new TagembedToast;
245 if (!planId) {
246 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
247 } else {
248 __tagembed__open_loader();
249 let formData = new FormData();
250 formData.append('action', 'tagembed_data');
251 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
252 formData.append('__tagembed__ajax_action', '__tagembed__make_payment');
253 formData.append('planId', planId);
254 formData.append('priceCode', priceCode);
255 fetch(__tagembed__ajax_url, {
256 method: 'POST',
257 headers: {
258 'x-requested-with': 'XMLHttpRequest',
259 },
260 body: formData,
261 }).then(response => {
262 return response.json()
263 }).then(response => {
264 if (response.status == true) {
265 window.open(response.data.redirectUrl + '?__tagembed__paymentData=' + response.data.__tagembed__paymentData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');
266 } else {
267 __tagembed__close_loader();
268 if (response.hasOwnProperty("message")) {
269 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
270 } else {
271 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
272 }
273 }
274 }).catch((error) => {
275 console.log(error);
276 __tagembed__close_loader();
277 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
278 });
279 }
280 }
281 /*--End-- Manage Payment*/
282 function __tagembed__cancel_subscription(planId) {
283 let __tagembed__toast = new TagembedToast;
284 if (!planId)
285 return __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
286 __tagembed__confirmDialog({ title: 'Are you sure!', message: 'Do you want to cancel subscription?', buttonText: 'Yes', type: 'danger' }, function () {
287 let formData = new FormData();
288 formData.append('planId', planId);
289 formData.append('action', 'tagembed_data');
290 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
291 formData.append('__tagembed__ajax_action', '__tagembed__cancel_subscription');
292 __tagembed__open_loader();
293 var __tagembed__toast = new TagembedToast;
294 fetch(__tagembed__ajax_url, {
295 method: 'POST',
296 headers: {
297 'x-requested-with': 'XMLHttpRequest',
298 },
299 body: formData,
300 }).then(response => {
301 return response.json()
302 }).then(response => {
303 __tagembed__close_loader();
304 if (response.status == true) {
305 if (response.data.hasOwnProperty("message")) {
306 __tagembed__toast.success({ message: response.data.message, position: '__tagembed__is-top-right' });
307 }
308 setTimeout(function () {
309 window.open('https://tagembed.com/subscription-cancelled/', '_blank');
310 }, 3000);
311 } else {
312 if (response.hasOwnProperty("message")) {
313 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
314 } else {
315 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
316 }
317 }
318 }).catch((error) => {
319 console.log(error);
320 __tagembed__close_loader();
321 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
322 });
323 });
324 }
325 /*--Start--Hide Account Upgrade Modal*/
326 function __tagembed__hide_upgrade_account_popup() {
327 let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup");
328 __tagembed__upgrade_account_popup.style.display = "none";
329 }
330 /*--End--Hide Account Upgrade Modal*/