PluginProbe
Tagembed: Social Media Feeds and Customer Reviews Widget / 4.6
Tagembed: Social Media Feeds and Customer Reviews Widget v4.6
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 4.6, at assets/js/upgrade/tagembed.upgrade.script.js

277 lines 19.1 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.innerHTML = "Hide All Features";
8 } else {
9 __tagembed__all_feacture_section.style.display = "none";
10 __tagembed__all_feacture_button.innerHTML = "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', 'unitCron', 'retainPost'];
56 let allFeactureIcons = ['apiLimit', 'name', 'retainPostCount', 'support', 'walls', 'feeds', 'linkedinFeed', 'linkedinFeed', 'twitterFeed', 'viewCount']
57 let suitePlanIds = ['55', '56'];
58 let freeTrialPlanIds = ['43', '48', '49'];
59 let __tagembed__plan = document.querySelector("#__tagembed__plan");
60 let __tagembed__toast = new TagembedToast;
61 let formData = new FormData();
62 formData.append('action', 'data');
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 /*--Start-- Manage All Feacture Section*/
77 let allFeactureHTML = "";
78 let i = 0;
79 for (let indexxxx in response.data) {
80 for (let indexxxxx in response.data[indexxxx].Product) {
81 if (indexxxxx == "Plan") {
82 for (let indexxxxxx in response.data[indexxxx].Product[indexxxxx]) {
83 if (!freeTrialPlanIds.includes(response.data[indexxxx].Product[indexxxxx][indexxxxxx].Plan.id) && !suitePlanIds.includes(response.data[indexxxx].Product[indexxxxx][indexxxxxx].Plan.id)) {
84 if (i == 0) {
85 allFeactureHTML = `${allFeactureHTML}<tr>`;
86 for (const [key, value] of Object.entries(response.data[indexxxx].Product[indexxxxx][indexxxxxx].PlanRule)) {
87 if (!allFeactureRemovableKeys.includes(key)) {
88 allFeactureHTML = `${allFeactureHTML}<th>${ key.replace(/([A-Z])/g, ' $1')}</th>`;
89 }
90 }
91 allFeactureHTML = `${allFeactureHTML}<th>Networks</th></tr>`;
92 }
93 i++;
94 allFeactureHTML = `${allFeactureHTML}<tr>`;
95 for (const [key, value] of Object.entries(response.data[indexxxx].Product[indexxxxx][indexxxxxx].PlanRule)) {
96 if (!allFeactureRemovableKeys.includes(key)) {
97 if (allFeactureIcons.includes(key)) {
98 allFeactureHTML = `${allFeactureHTML}<td>${value}</td>`;
99 } else {
100 if (value == "1") {
101 allFeactureHTML = `${allFeactureHTML}<td class="text-center mb-0"><img src="https://cdn.tagembed.com/app/img/plan-subscription/plan-ok.svg" alt="access" class="img-fluid"></td>`;
102 } else {
103 allFeactureHTML = `${allFeactureHTML}<td class="text-center mb-0"><img src="https://cdn.tagembed.com/app/img/plan-subscription/plan-cross.svg" alt="no-access" class="img-fluid"></td>`;
104 }
105 }
106 }
107 }
108 allFeactureHTML = `${allFeactureHTML}<td>`;
109 for (let indexxxxxxx in response.data[indexxxx].Product[indexxxxx][indexxxxxx].Planrulenetwork) {
110 allFeactureHTML = `${allFeactureHTML}<img style="height:14px; margin:2px;" src="https://cdn.tagembed.com/common/images/network/network/${response.data[indexxxx].Product[indexxxxx][indexxxxxx].Planrulenetwork[indexxxxxxx].network}.png"/>`;
111 }
112 allFeactureHTML = `${allFeactureHTML}</td></tr>`;
113 }
114 }
115 }
116 }
117 }
118 __tagembed__all_feacture_section.innerHTML = `<table> ${allFeactureHTML}</table>`;
119 /*--End-- Manage All Feacture Section*/
120 /*--Start-- Manage Plan Serction Section*/
121 let elemHTML = "";
122 for (let index in response.data) {
123 for (let indexx in response.data[index].Product) {
124 if (indexx == "Plan") {
125 for (let indexxx in response.data[index].Product[indexx]) {
126 elemHTML = `${elemHTML}<div class="__tagembed__planbox ${(response.data[index].Product[indexx][indexxx].Plan.id == response.data[index].Product.Subscription.planId) ? '__tagembed__activeplan' : ''}">`;
127 if (response.data[index].Product[indexx][indexxx].Plan.id == response.data[index].Product.Subscription.planId)
128 elemHTML = `${elemHTML}<span class="__tagembed__currentplan">Current Plan</span>`;
129 elemHTML = `${elemHTML}<strong>${response.data[index].Product[indexx][indexxx].Plan.name}</strong>`;
130 let monthelyPrice = response.data[index].Product[indexx][indexxx].Plan.wordpessMonthlyPrice;
131 let yearlyPrice = response.data[index].Product[indexx][indexxx].Plan.wordpressYearlyPrice;
132 if (response.data[index].Product[indexx][indexxx].Plan.id == 28) {
133 elemHTML = `${elemHTML}<h2>Free</h2>`;
134 } else {
135 elemHTML = `${elemHTML}<h2 class="__tagembed__monthely_plan" style="display:none;">$${monthelyPrice}/Mo</h2>`;
136 elemHTML = `${elemHTML}<h2 class="__tagembed__yearly_plan">$${yearlyPrice}/Mo</h2>`;
137 }
138 elemHTML = `${elemHTML}<p>${response.data[index].Product[indexx][indexxx].Plan.description}</p>`;
139 elemHTML = `${elemHTML}<ul>`;
140 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${response.data[index].Product[indexx][indexxx].PlanRule.feeds} ${response.data[index].Product[indexx][indexxx].Plan.id == 28 ? `Feed` : `Feeds`}</li>`;
141 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${response.data[index].Product[indexx][indexxx].PlanRule.viewCount} Views/Month</li>`;
142 if (response.data[index].Product[indexx][indexxx].Plan.id != 28) {
143 if (response.data[index].Product[indexx][indexxx].PlanRule.linkedinFeed != 0) {
144 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />LinkedIn Auto Update (Max 2 Feeds)</li>`;
145 } else {
146 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />LinkedIn Manual</li>`;
147 }
148 } else {
149 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />LinkedIn Feed</li>`;
150 }
151 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${response.data[index].Product[indexx][indexxx].PlanRule.updatesIntervalCron} ${(response.data[index].Product[indexx][indexxx].PlanRule.unitCron == 3600) ? "Hours" : "Mins"} Update Time</li>`;
152 if (response.data[index].Product[indexx][indexxx].PlanRule.customCss == 0) {
153 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />No Custom CSS</li>`;
154 } else {
155 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />Custom CSS</li>`;
156 }
157 if (response.data[index].Product[indexx][indexxx].PlanRule.branding == 0) {
158 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />No Tagembed Branding</li>`;
159 } else {
160 elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />Tagembed Branding</li>`;
161 }
162 elemHTML = `${elemHTML}</ul>`;
163 if (response.data[index].Product[indexx][indexxx].Plan.id != 43) {
164 if (response.data[index].Product[indexx][indexxx].Plan.id == response.data[index].Product.Subscription.planId) {
165 if (response.data[index].Product[indexx][indexxx].Plan.id != 28) {
166 elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__cancel_subscription('${response.data[index].Product[indexx][indexxx].Plan.id}');" class="__tagembed__selectbtn">Cancel Subscription</a>`;
167 }
168 } else {
169 if (response.data[index].Product[indexx][indexxx].Plan.id == 28) {
170 elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__make_lite_plan_payment('${response.data[index].Product[indexx][indexxx].Plan.id}','${response.data[index].Product[indexx][indexxx].Plan.wordpressStripeMonthlyPriceCode}');" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`;
171 elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__make_lite_plan_payment('${response.data[index].Product[indexx][indexxx].Plan.id}','${response.data[index].Product[indexx][indexxx].Plan.wordpressStripeYearlyPriceCode}');" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`;
172 } else {
173 elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__make_payment('${response.data[index].Product[indexx][indexxx].Plan.id}','${response.data[index].Product[indexx][indexxx].Plan.wordpressStripeMonthlyPriceCode}');" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`;
174 elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__make_payment('${response.data[index].Product[indexx][indexxx].Plan.id}','${response.data[index].Product[indexx][indexxx].Plan.wordpressStripeYearlyPriceCode}');" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`;
175 }
176 }
177 }
178 elemHTML = `${elemHTML}</div>`;
179 }
180 }
181 }
182 }
183 __tagembed__plan.innerHTML = elemHTML;
184 /*--End-- Manage Plan Serction Section*/
185 } else {
186 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
187 }
188 }).catch((error) => {
189 console.log(error);
190 __tagembed__close_loader();
191 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
192 });
193 }
194 /*--End-- Get User Accounts Details*/
195 /*--Start-- Manage Payment*/
196 function __tagembed__make_lite_plan_payment(planId, priceCode) {
197 confirmDialog({title: 'Opting Free Forever LITE Plan', message: 'Your current plan will be canceled and changed to Lite Plan.', buttonText: 'Confirm', type: 'danger'}, function () {
198 __tagembed__make_payment(planId, priceCode);
199 });
200 }
201 function __tagembed__make_payment(planId, priceCode) {
202 let __tagembed__toast = new TagembedToast;
203 if (!planId || !priceCode) {
204 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
205 } else {
206 __tagembed__open_loader();
207 let formData = new FormData();
208 formData.append('action', 'data');
209 formData.append('__tagembed__ajax_action', '__tagembed__make_payment');
210 formData.append('planId', planId);
211 formData.append('priceCode', priceCode);
212 fetch(__tagembed__ajax_url, {
213 method: 'POST',
214 headers: {
215 'x-requested-with': 'XMLHttpRequest',
216 },
217 body: formData,
218 }).then(response => {
219 return response.json()
220 }).then(response => {
221 if (response.status == true) {
222 window.open(response.data.redirectUrl + '?__tagembed__paymentData=' + response.data.__tagembed__paymentData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');
223 } else {
224 __tagembed__close_loader();
225 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
226 }
227 }).catch((error) => {
228 console.log(error);
229 __tagembed__close_loader();
230 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
231 });
232 }
233 }
234 /*--End-- Manage Payment*/
235 function __tagembed__cancel_subscription(planId) {
236 let __tagembed__toast = new TagembedToast;
237 if (!planId)
238 return __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
239 confirmDialog({title: 'Are you sure!', message: 'Do you want to cancel subscription?', buttonText: 'Yes', type: 'danger'}, function () {
240 let formData = new FormData();
241 formData.append('planId', planId);
242 formData.append('action', 'data');
243 formData.append('__tagembed__ajax_action', '__tagembed__cancel_subscription');
244 __tagembed__open_loader();
245 var __tagembed__toast = new TagembedToast;
246 fetch(__tagembed__ajax_url, {
247 method: 'POST',
248 headers: {
249 'x-requested-with': 'XMLHttpRequest', },
250 body: formData,
251 }).then(response => {
252 return response.json()
253 }).then(response => {
254 __tagembed__close_loader();
255 if (response.status == true) {
256 if (response.data.hasOwnProperty("message")) {
257 __tagembed__toast.success({message: response.data.message, position: '__tagembed__is-top-right'});
258 }
259 setTimeout(function () {
260 window.open('https://tagembed.com/subscription-cancelled/', '_blank');
261 }, 3000);
262 } else {
263 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
264 }
265 }).catch((error) => {
266 console.log(error);
267 __tagembed__close_loader();
268 __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'});
269 });
270 });
271 }
272 /*--Start--Hide Account Upgrade Modal*/
273 function __tagembed__hide_upgrade_account_popup() {
274 let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup");
275 __tagembed__upgrade_account_popup.style.display = "none";
276 }
277 /*--End--Hide Account Upgrade Modal*/