| 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 |
/*if (__tagembed__manageApiCall()) |
| 55 |
return;*/ |
| 56 |
let __tagembed__plan = document.querySelector("#__tagembed__plan"); |
| 57 |
let __tagembed__toast = new TagembedToast; |
| 58 |
let formData = new FormData(); |
| 59 |
formData.append('action', 'data'); |
| 60 |
formData.append('__tagembed__ajax_action', '__tagembed__get_account_details'); |
| 61 |
__tagembed__open_loader(); |
| 62 |
fetch(__tagembed__ajax_url, { |
| 63 |
method: 'POST', |
| 64 |
headers: { |
| 65 |
'x-requested-with': 'XMLHttpRequest', |
| 66 |
}, |
| 67 |
body: formData, |
| 68 |
}).then(response => { |
| 69 |
return response.json() |
| 70 |
}).then(response => { |
| 71 |
__tagembed__close_loader(); |
| 72 |
if (response.status == true) { |
| 73 |
let elemHTML = ""; |
| 74 |
for (let index in response.data) { |
| 75 |
for (let indexx in response.data[index].Product) { |
| 76 |
if (indexx == "Plan") { |
| 77 |
for (let indexxx in response.data[index].Product[indexx]) { |
| 78 |
elemHTML = `${elemHTML}<div class="__tagembed__planbox ${(response.data[index].Product[indexx][indexxx].Plan.id == response.data[index].Product.Subscription.planId) ? '__tagembed__activeplan' : ''}">`; |
| 79 |
if (response.data[index].Product[indexx][indexxx].Plan.id == response.data[index].Product.Subscription.planId) |
| 80 |
elemHTML = `${elemHTML}<span class="__tagembed__currentplan">Current Plan</span>`; |
| 81 |
elemHTML = `${elemHTML}<strong>${response.data[index].Product[indexx][indexxx].Plan.name}</strong>`; |
| 82 |
/*Manage Plan Price*/ |
| 83 |
let monthelyPrice = ""; |
| 84 |
let yearlyPrice = ""; |
| 85 |
switch (response.data[index].Product[indexx][indexxx].Plan.id) { |
| 86 |
case "1": |
| 87 |
yearlyPrice = "0"; |
| 88 |
monthelyPrice = "0"; |
| 89 |
break; |
| 90 |
case "28": |
| 91 |
yearlyPrice = "1"; |
| 92 |
monthelyPrice = "1"; |
| 93 |
break; |
| 94 |
case "42": |
| 95 |
yearlyPrice = "9"; |
| 96 |
monthelyPrice = "11"; |
| 97 |
break; |
| 98 |
case "29": |
| 99 |
yearlyPrice = "19"; |
| 100 |
monthelyPrice = "24"; |
| 101 |
break; |
| 102 |
case "13": |
| 103 |
yearlyPrice = "39"; |
| 104 |
monthelyPrice = "49"; |
| 105 |
break; |
| 106 |
} |
| 107 |
if (response.data[index].Product[indexx][indexxx].Plan.id == 28) { |
| 108 |
elemHTML = `${elemHTML}<h2>Free</h2>`; |
| 109 |
} else { |
| 110 |
elemHTML = `${elemHTML}<h2 class="__tagembed__monthely_plan" style="display:none;">$${monthelyPrice}/Mo</h2>`; |
| 111 |
elemHTML = `${elemHTML}<h2 class="__tagembed__yearly_plan">$${yearlyPrice}/Mo</h2>`; |
| 112 |
} |
| 113 |
elemHTML = `${elemHTML}<p>${response.data[index].Product[indexx][indexxx].Plan.description}</p>`; |
| 114 |
elemHTML = `${elemHTML}<ul>`; |
| 115 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_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>`; |
| 116 |
let totalViews = ""; |
| 117 |
switch (response.data[index].Product[indexx][indexxx].Plan.id) { |
| 118 |
case "1": |
| 119 |
case "13": |
| 120 |
totalViews = "Unlimited"; |
| 121 |
break; |
| 122 |
case "28": |
| 123 |
totalViews = "2,000"; |
| 124 |
break; |
| 125 |
case "42": |
| 126 |
totalViews = "10,000"; |
| 127 |
break; |
| 128 |
case "29": |
| 129 |
totalViews = "100,000"; |
| 130 |
break; |
| 131 |
} |
| 132 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-ok.svg" alt="access" />${totalViews} Views/Month</li>`; |
| 133 |
|
| 134 |
let linkedinViews = ""; |
| 135 |
switch (response.data[index].Product[indexx][indexxx].Plan.id) { |
| 136 |
case "13": |
| 137 |
linkedinViews = "LinkedIn Auto Update (Max 2 Feeds)"; |
| 138 |
break; |
| 139 |
case "28": |
| 140 |
linkedinViews = "LinkedIn Feed"; |
| 141 |
break; |
| 142 |
case "1": |
| 143 |
case "42": |
| 144 |
case "29": |
| 145 |
linkedinViews = "LinkedIn Manual"; |
| 146 |
break; |
| 147 |
} |
| 148 |
if (response.data[index].Product[indexx][indexxx].Plan.id != 28) { |
| 149 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-ok.svg" alt="access" />${linkedinViews}</li>`; |
| 150 |
} else { |
| 151 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-cross.svg" alt="no-access" />${linkedinViews}</li>`; |
| 152 |
} |
| 153 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-ok.svg" alt="access" />${response.data[index].Product[indexx][indexxx].PlanRule.updatesIntervalCron} ${(response.data[index].Product[indexx][indexxx].PlanRule.unit == 3600) ? "Hours" : "Mins"} Update Time</li>`; |
| 154 |
if (response.data[index].Product[indexx][indexxx].PlanRule.customCss == 0) { |
| 155 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-cross.svg" alt="no-access" />No Custom CSS</li>`; |
| 156 |
} else { |
| 157 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-ok.svg" alt="access" />Custom CSS</li>`; |
| 158 |
} |
| 159 |
if (response.data[index].Product[indexx][indexxx].PlanRule.branding == 0) { |
| 160 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-cross.svg" alt="no-access" />No Tagembed Branding</li>`; |
| 161 |
} else { |
| 162 |
elemHTML = `${elemHTML}<li><img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/plan-ok.svg" alt="access" />Tagembed Branding</li>`; |
| 163 |
} |
| 164 |
elemHTML = `${elemHTML}</ul>`; |
| 165 |
|
| 166 |
if (response.data[index].Product[indexx][indexxx].Plan.id != 1) { |
| 167 |
if (response.data[index].Product[indexx][indexxx].Plan.id == response.data[index].Product.Subscription.planId) { |
| 168 |
if (response.data[index].Product[indexx][indexxx].Plan.id != 28) { |
| 169 |
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>`; |
| 170 |
} |
| 171 |
} else { |
| 172 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__make_payment('${response.data[index].Product[indexx][indexxx].Plan.id}','${monthelyPrice}');" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`; |
| 173 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" onclick="__tagembed__make_payment('${response.data[index].Product[indexx][indexxx].Plan.id}','${yearlyPrice}');" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`; |
| 174 |
} |
| 175 |
} |
| 176 |
elemHTML = `${elemHTML}</div>`; |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
} |
| 181 |
} |
| 182 |
__tagembed__plan.innerHTML = elemHTML; |
| 183 |
} else { |
| 184 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 185 |
} |
| 186 |
}).catch((error) => { |
| 187 |
console.log(error); |
| 188 |
__tagembed__close_loader(); |
| 189 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 190 |
}); |
| 191 |
} |
| 192 |
/*--End-- Get User Accounts Details*/ |
| 193 |
/*--Start-- Manage Payment*/ |
| 194 |
function __tagembed__make_payment(plan, price) { |
| 195 |
let __tagembed__toast = new TagembedToast; |
| 196 |
if (!plan || !price) { |
| 197 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 198 |
} else { |
| 199 |
__tagembed__open_loader(); |
| 200 |
let formData = new FormData(); |
| 201 |
formData.append('action', 'data'); |
| 202 |
formData.append('__tagembed__ajax_action', '__tagembed__make_payment'); |
| 203 |
formData.append('plan', plan); |
| 204 |
formData.append('price', price); |
| 205 |
fetch(__tagembed__ajax_url, { |
| 206 |
method: 'POST', |
| 207 |
headers: { |
| 208 |
'x-requested-with': 'XMLHttpRequest', |
| 209 |
}, |
| 210 |
body: formData, |
| 211 |
}).then(response => { |
| 212 |
return response.json() |
| 213 |
}).then(response => { |
| 214 |
if (response.status == true) { |
| 215 |
window.open(response.data.redirectUrl + '?__tagembed__paymentData=' + response.data.__tagembed__paymentData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self'); |
| 216 |
} else { |
| 217 |
__tagembed__close_loader(); |
| 218 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 219 |
} |
| 220 |
}).catch((error) => { |
| 221 |
console.log(error); |
| 222 |
__tagembed__close_loader(); |
| 223 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 224 |
}); |
| 225 |
|
| 226 |
} |
| 227 |
} |
| 228 |
/*--End-- Manage Payment*/ |
| 229 |
function __tagembed__cancel_subscription(plan) { |
| 230 |
let __tagembed__toast = new TagembedToast; |
| 231 |
if (!plan) |
| 232 |
return __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 233 |
confirmDialog({title: 'Are you sure!', message: 'Do you want to cancel subscription?', buttonText: 'Yes', type: 'danger'}, function () { |
| 234 |
let formData = new FormData(); |
| 235 |
formData.append('plan', plan); |
| 236 |
formData.append('action', 'data'); |
| 237 |
formData.append('__tagembed__ajax_action', '__tagembed__cancel_subscription'); |
| 238 |
__tagembed__open_loader(); |
| 239 |
var __tagembed__toast = new TagembedToast; |
| 240 |
fetch(__tagembed__ajax_url, { |
| 241 |
method: 'POST', |
| 242 |
headers: { |
| 243 |
'x-requested-with': 'XMLHttpRequest', }, |
| 244 |
body: formData, |
| 245 |
}).then(response => { |
| 246 |
return response.json() |
| 247 |
}).then(response => { |
| 248 |
__tagembed__close_loader(); |
| 249 |
if (response.status == true) { |
| 250 |
if (response.data.hasOwnProperty("message")) { |
| 251 |
__tagembed__toast.success({message: response.data.message, position: '__tagembed__is-top-right'}); |
| 252 |
} |
| 253 |
setTimeout(function () { |
| 254 |
window.open('https://tagembed.com/subscription-cancelled/', '_blank'); |
| 255 |
}, 3000); |
| 256 |
} else { |
| 257 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 258 |
} |
| 259 |
}).catch((error) => { |
| 260 |
console.log(error); |
| 261 |
__tagembed__close_loader(); |
| 262 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 263 |
}); |
| 264 |
}); |
| 265 |
} |
| 266 |
/*--Start--Hide Account Upgrade Modal*/ |
| 267 |
function __tagembed__hide_upgrade_account_popup() { |
| 268 |
let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup"); |
| 269 |
__tagembed__upgrade_account_popup.style.display = "none"; |
| 270 |
} |
| 271 |
/*--End--Hide Account Upgrade Modal*/ |