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