| 1 |
/*--Start-- Create And Manage Window Popup*/ |
| 2 |
/*function __tagmebed__openWindowPopup(url, windowName) { |
| 3 |
__tagmebed__window_popup = window.open(url, windowName, 'height=600,width=600,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes'); |
| 4 |
var __tagembed__window_pupup_timer = setInterval(function () { |
| 5 |
if (__tagmebed__window_popup.closed) { |
| 6 |
location.reload(); |
| 7 |
clearInterval(__tagembed__window_pupup_timer); |
| 8 |
} |
| 9 |
}, 250); |
| 10 |
} |
| 11 |
window.addEventListener ? window.addEventListener("load", __tagmebed__closeWindowPopup, false) : window.attachEvent && window.attachEvent("onload", __tagmebed__closeWindowPopup); |
| 12 |
function __tagmebed__closeWindowPopup() { |
| 13 |
if (__tagmebed__window_popup) |
| 14 |
__tagmebed__window_popup.close(); |
| 15 |
}*/ |
| 16 |
/*--End-- Create And Manage Window Popup*/ |
| 17 |
/*--Start-- Manage Hide And Show plugin Upgrade Message*/ |
| 18 |
window.addEventListener ? window.addEventListener("load", __tagembed__plugin_version, false) : window.attachEvent && window.attachEvent("onload", __tagembed__plugin_version); |
| 19 |
function __tagembed__plugin_version() { |
| 20 |
let __tagembed__toast = new TagembedToast; |
| 21 |
let formData = new FormData(); |
| 22 |
formData.append('action', 'data'); |
| 23 |
formData.append('__tagembed__ajax_action', '__tagembed__plugin_version'); |
| 24 |
fetch(__tagembed__ajax_url, { |
| 25 |
method: 'POST', |
| 26 |
headers: { |
| 27 |
'x-requested-with': 'XMLHttpRequest', |
| 28 |
}, |
| 29 |
body: formData, |
| 30 |
}).then(response => { |
| 31 |
return response.json() |
| 32 |
}).then(response => { |
| 33 |
if (response.status == true) { |
| 34 |
if (response.data.installedPluginVersion != response.data.livePluginVersion) { |
| 35 |
let elemHTML = `<div class="__tagembed__popupwrap __tagembed__popup_md">`; |
| 36 |
elemHTML = `${elemHTML}<button onclick="__tagembed__hide_plugin_upgrade_message();" type="button" class="__tagembed__closebtn"></button>`; |
| 37 |
elemHTML = `${elemHTML}<div class="__tagembed__popupinn">`; |
| 38 |
elemHTML = `${elemHTML}<div class="__tagembed__header"><h2>Upgrade Plugin</h2></div>`; |
| 39 |
elemHTML = `${elemHTML}<hr class="__tagembed__horizontaborder">`; |
| 40 |
elemHTML = `${elemHTML}<div class="__tagembed__formwbody">`; |
| 41 |
elemHTML = `${elemHTML}<div class="__tagembed__formwrow">`; |
| 42 |
elemHTML = `${elemHTML}<p><strong> Tagembed : </strong> There is a new version of Tagembed Widget available. <strong> ${response.data.livePluginVersion} </strong> is a recommended Update For Performance Improvements. </p>`; |
| 43 |
elemHTML = `${elemHTML}</div></div>`; |
| 44 |
elemHTML = `${elemHTML}<div class = "__tagembed__btnwrap text-center">`; |
| 45 |
elemHTML = `${elemHTML}<a href="${response.data.pluginUpgradeURL}" class="__tagembed__okaybtn">Upgrade</a>`; |
| 46 |
elemHTML = `${elemHTML}</div></div></div>`; |
| 47 |
document.getElementById("__tagembed__plugin_upgrade_message").innerHTML = elemHTML; |
| 48 |
} |
| 49 |
} else { |
| 50 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 51 |
} |
| 52 |
}).catch((error) => { |
| 53 |
console.log(error); |
| 54 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 55 |
}); |
| 56 |
} |
| 57 |
function __tagembed__hide_plugin_upgrade_message() { |
| 58 |
let __tagembed__plugin_upgrade_message = document.querySelector("#__tagembed__plugin_upgrade_message") |
| 59 |
__tagembed__plugin_upgrade_message.style.display = "none"; |
| 60 |
} |
| 61 |
/*--End-- Manage Hide And Show plugin Upgrade Message*/ |
| 62 |
/*--Start-- Manage Response Message*/ |
| 63 |
window.addEventListener ? window.addEventListener("load", __tagembed__message, false) : window.attachEvent && window.attachEvent("onload", __tagembed__message); |
| 64 |
function __tagembed__message() { |
| 65 |
let __tagembed__toast = new TagembedToast; |
| 66 |
/*--Start-- Manage Redirect Url Error*/ |
| 67 |
let urlSearchParams = new URLSearchParams(window.location.search); |
| 68 |
let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); |
| 69 |
/*--Start-- Manage Show Messaage According Time*/ |
| 70 |
let getTime = new Date(); |
| 71 |
getTime = getTime.getTime(); /*milliseconds*/ |
| 72 |
getTime = Math.floor(getTime / 1000); /*seconds*/ |
| 73 |
if (__tagembed__message.hasOwnProperty("status")) { |
| 74 |
if (__tagembed__message.status < getTime) |
| 75 |
return; |
| 76 |
} |
| 77 |
/*--End-- Manage Show Messaage According Time*/ |
| 78 |
if (__tagembed__message.hasOwnProperty("__tagembed__message")) { |
| 79 |
if (__tagembed__message.hasOwnProperty("success")) { |
| 80 |
__tagembed__toast.success({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); |
| 81 |
} else if (__tagembed__message.hasOwnProperty("info")) { |
| 82 |
__tagembed__toast.info({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); |
| 83 |
} else if (__tagembed__message.hasOwnProperty("warning")) { |
| 84 |
__tagembed__toast.warning({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); |
| 85 |
} else { |
| 86 |
__tagembed__toast.danger({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); |
| 87 |
} |
| 88 |
/*--Start--Show Popup On Plan Upgrade Time*/ |
| 89 |
if (__tagembed__message.hasOwnProperty("planname") && __tagembed__message.hasOwnProperty("amount") && __tagembed__message.hasOwnProperty("refrenceid")) { |
| 90 |
let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup"); |
| 91 |
let elemHTML = `<div class="__tagembed__popupwrap __tagembed__popup_md">`; |
| 92 |
elemHTML = `${elemHTML}<button id="__tagembed__upgrade_account_popup_close_btn" onclick="__tagembed__hide_upgrade_account_popup();" type="button" class="__tagembed__closebtn"></button>`; |
| 93 |
elemHTML = `${elemHTML}<div class="__tagembed__popupinn">`; |
| 94 |
elemHTML = `${elemHTML}<div class="__tagembed__formwbody">`; |
| 95 |
elemHTML = `${elemHTML}<div class="__tagembed__thankyou">`; |
| 96 |
elemHTML = `${elemHTML}<img src="${TAGEMBED_PLUGIN_URL_JS}assets/images/check-green.png" alt="check">`; |
| 97 |
elemHTML = `${elemHTML}<h2>Congratulations! <span>Your account has been upgraded</span></h2>`; |
| 98 |
elemHTML = `${elemHTML}<div class="__tagembed__plandetail">`; |
| 99 |
elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; |
| 100 |
elemHTML = `${elemHTML}<p>Amount</p>`; |
| 101 |
elemHTML = `${elemHTML}<span>$${__tagembed__message.amount}</span>`; |
| 102 |
elemHTML = `${elemHTML}</div>`; |
| 103 |
elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; |
| 104 |
elemHTML = `${elemHTML}<p>Payment ID</p>`; |
| 105 |
elemHTML = `${elemHTML}<span>${__tagembed__message.refrenceid}</span>`; |
| 106 |
elemHTML = `${elemHTML}</div>`; |
| 107 |
elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; |
| 108 |
elemHTML = `${elemHTML}<p>Plan Name</p>`; |
| 109 |
elemHTML = `${elemHTML}<span>${__tagembed__message.planname}</span>`; |
| 110 |
elemHTML = `${elemHTML}</div></div></div></div></div></div>`; |
| 111 |
__tagembed__upgrade_account_popup.innerHTML = elemHTML; |
| 112 |
__tagembed__upgrade_account_popup.style.display = "block"; |
| 113 |
} |
| 114 |
/*--End--Show Popup On Plan Upgrade Time*/ |
| 115 |
} |
| 116 |
} |
| 117 |
/*--End-- Manage Response Message*/ |
| 118 |
/*--Start--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 119 |
function __tagembed__manageApiCall() { |
| 120 |
let urlSearchParams = new URLSearchParams(window.location.search); |
| 121 |
let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); |
| 122 |
if (__tagembed__message.hasOwnProperty("__tagembed__message")) |
| 123 |
return true |
| 124 |
return false; |
| 125 |
} |
| 126 |
/*--End--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 127 |
/*--Start-- Logout*/ |
| 128 |
var __tagembed__logout = document.querySelector("#__tagembed__logout"); |
| 129 |
if (__tagembed__logout) { |
| 130 |
__tagembed__logout.addEventListener('click', function (event) { |
| 131 |
confirmDialog({title: 'Yes, sign out', message: 'Are you sure! do you want to sign out?', buttonText: 'Sign Out', type: 'warning'}, function () { |
| 132 |
let formData = new FormData(); |
| 133 |
formData.append('action', 'data'); |
| 134 |
formData.append('__tagembed__ajax_action', '__tagembed__logout'); |
| 135 |
__tagembed__open_loader(); |
| 136 |
let __tagembed__toast = new TagembedToast; |
| 137 |
fetch(__tagembed__ajax_url, { |
| 138 |
method: 'POST', |
| 139 |
headers: { |
| 140 |
'x-requested-with': 'XMLHttpRequest', |
| 141 |
}, |
| 142 |
body: formData, |
| 143 |
}).then(response => { |
| 144 |
return response.json() |
| 145 |
}).then(response => { |
| 146 |
__tagembed__close_loader(); |
| 147 |
if (response.status == true) { |
| 148 |
window.location.replace(response.data.redirectUrl); |
| 149 |
} else { |
| 150 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 151 |
} |
| 152 |
}).catch((error) => { |
| 153 |
console.log(error); |
| 154 |
__tagembed__close_loader(); |
| 155 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 156 |
}); |
| 157 |
}); |
| 158 |
}); |
| 159 |
} |
| 160 |
/*--End-- Logout*/ |
| 161 |
/*--Start--Manage Tagembed Menue*/ |
| 162 |
function __tagembed__menus(__tagembed__menu_id, __tagembed__widgetId = null) { |
| 163 |
if (__tagembed__widgetId) |
| 164 |
__tagembed__manageActiveWidget(__tagembed__widgetId); |
| 165 |
let __tagembed__toast = new TagembedToast; |
| 166 |
let formData = new FormData(); |
| 167 |
formData.append('action', 'data'); |
| 168 |
formData.append('menueId', __tagembed__menu_id); |
| 169 |
formData.append('__tagembed__ajax_action', '__tagembed__menue'); |
| 170 |
fetch(__tagembed__ajax_url, { |
| 171 |
method: 'POST', |
| 172 |
headers: { |
| 173 |
'x-requested-with': 'XMLHttpRequest', |
| 174 |
}, |
| 175 |
body: formData, |
| 176 |
}).then(response => { |
| 177 |
return response.json() |
| 178 |
}).then(response => { |
| 179 |
if (response.status == true) { |
| 180 |
return window.location.replace(response.data.redirectUrl); |
| 181 |
} else { |
| 182 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 183 |
} |
| 184 |
}).catch((error) => { |
| 185 |
console.log(error); |
| 186 |
__tagembed__close_loader(); |
| 187 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 188 |
}); |
| 189 |
} |
| 190 |
/*--End--Manage Tagembed Menue*/ |
| 191 |
/*--Start-- Get Already Exist Auth*/ |
| 192 |
function __tagembed__get_already_exist_auth(__tagembed__network_id) { |
| 193 |
if (!__tagembed__network_id) |
| 194 |
return; |
| 195 |
let formData = new FormData(); |
| 196 |
formData.append('networkId', __tagembed__network_id); |
| 197 |
formData.append('action', 'data'); |
| 198 |
formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth'); |
| 199 |
fetch(__tagembed__ajax_url, { |
| 200 |
method: 'POST', |
| 201 |
headers: { |
| 202 |
'x-requested-with': 'XMLHttpRequest', |
| 203 |
}, |
| 204 |
body: formData, |
| 205 |
}).then(response => { |
| 206 |
return response.json() |
| 207 |
}).then(response => { |
| 208 |
if (response.status == true) |
| 209 |
__tagembed__network_already_exist_auth = response.data; |
| 210 |
}); |
| 211 |
} |
| 212 |
/*--End-- Get Already Exist Auth*/ |
| 213 |
/*--Start-- Manage Active Widget*/ |
| 214 |
var __tagembed__widgets = document.querySelector("#__tagembed__widgets"); |
| 215 |
if (__tagembed__widgets) { |
| 216 |
__tagembed__widgets.addEventListener("change", function (event) { |
| 217 |
if (typeof __tagembed__get_theme !== 'undefined') |
| 218 |
__tagembed__get_theme(); /*Manage Widget Theme According Widget*/ |
| 219 |
if (typeof __tagembed__changeIfrmSrc !== 'undefined') |
| 220 |
__tagembed__changeIfrmSrc(); /*Manage Widget Display Preview According Widget*/ |
| 221 |
if (typeof __tagembed__manageShotrCode !== 'undefined') |
| 222 |
__tagembed__manageShotrCode(); /*Manage Short Code According Widget*/ |
| 223 |
if (typeof __tagembed__manageEmbedCode !== 'undefined') |
| 224 |
__tagembed__manageEmbedCode(); /*Manage Embed Code According Widget*/ |
| 225 |
if (typeof __tagembed__getFeed !== 'undefined') |
| 226 |
__tagembed__getFeed(); /*Get Feed According Widget*/ |
| 227 |
if (typeof __tagembed__call_common_filter_function !== 'undefined')/*Call Common Post Filter Function */ |
| 228 |
__tagembed__call_common_filter_function(); |
| 229 |
__tagembed__manageActiveWidget(); /*Manage Active Widget*/ |
| 230 |
if (typeof __tagembed__getCustomizationOption !== 'undefined')/*Call Get Customization Options*/ |
| 231 |
__tagembed__getCustomizationOption(); |
| 232 |
}); |
| 233 |
} |
| 234 |
function __tagembed__manageActiveWidget(__tagembed__widgetId = null) { |
| 235 |
if (!__tagembed__widgetId) { |
| 236 |
__tagembed__widgetId = document.querySelector("#__tagembed__widgets").selectedOptions[0]; |
| 237 |
__tagembed__widgetId = __tagembed__widgetId.value.split('#')[0]; |
| 238 |
} |
| 239 |
let __tagembed__toast = new TagembedToast; |
| 240 |
let formData = new FormData(); |
| 241 |
formData.append('action', 'data'); |
| 242 |
formData.append('__tagembed__ajax_action', '__tagembed__manage_active_widget'); |
| 243 |
formData.append('widgetId', __tagembed__widgetId); |
| 244 |
if (__tagembed__loader_status) |
| 245 |
__tagembed__open_loader(); |
| 246 |
fetch(__tagembed__ajax_url, { |
| 247 |
method: 'POST', |
| 248 |
headers: { |
| 249 |
'x-requested-with': 'XMLHttpRequest', |
| 250 |
}, |
| 251 |
body: formData, |
| 252 |
}).then(response => { |
| 253 |
return response.json() |
| 254 |
}).then(response => { |
| 255 |
|
| 256 |
if (__tagembed__loader_status) |
| 257 |
__tagembed__close_loader(); |
| 258 |
if (response.status == true) { |
| 259 |
/*--Start--Reload Page For Manage Active Class On Widget Page*/ |
| 260 |
if (document.querySelector("#__tagembed__widgetbox0")) |
| 261 |
location.reload(); |
| 262 |
/*--End--Reload Page For Manage Active Class On Widget Page*/ |
| 263 |
} else { |
| 264 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 265 |
} |
| 266 |
}).catch((error) => { |
| 267 |
console.log(error); |
| 268 |
__tagembed__close_loader(); |
| 269 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 270 |
}); |
| 271 |
} |
| 272 |
/*--End-- Manage Active Widget*/ |
| 273 |
/*--Start--Create Widget*/ |
| 274 |
var __tagembed__widget_create_form = document.querySelector("#__tagembed__widget_create_form"); |
| 275 |
if (__tagembed__widget_create_form) { |
| 276 |
__tagembed__widget_create_form.addEventListener("click", function (event) { |
| 277 |
__tagembed__dialog_form({popupSize: '__tagembed__popup_md', title: 'Create Widget', |
| 278 |
form: {method: 'post', buttonText: 'Create'}, |
| 279 |
inputs: [{label: 'Widget Name', type: 'text', name: 'name', placeholder: 'Enter your widget name e.g. mywidget'}, {label: 'Profanity Filter', type: 'checkbox', name: 'profanity'}], |
| 280 |
action: function (event, formData) { |
| 281 |
let __tagembed__name_error = document.querySelector("#__tagembed__name_error"); |
| 282 |
__tagembed__name_error.style.display = 'none'; |
| 283 |
if (!formData.get('name')) { |
| 284 |
__tagembed__name_error.style.display = 'block'; |
| 285 |
__tagembed__name_error.textContent = "Widget name is required"; |
| 286 |
return; |
| 287 |
} |
| 288 |
__tagembed__open_loader(); |
| 289 |
let __tagembed__toast = new TagembedToast; |
| 290 |
formData.append('action', 'data'); |
| 291 |
formData.append('__tagembed__ajax_action', '__tagembed__create_widget'); |
| 292 |
fetch(__tagembed__ajax_url, { |
| 293 |
method: 'POST', |
| 294 |
headers: { |
| 295 |
'x-requested-with': 'XMLHttpRequest', |
| 296 |
}, |
| 297 |
body: formData, |
| 298 |
}).then(response => { |
| 299 |
return response.json(); |
| 300 |
}).then(response => { |
| 301 |
__tagembed__close_loader(); |
| 302 |
if (response.status == true) { |
| 303 |
document.querySelector('#__tagembed__dialog_form_id_').remove(); |
| 304 |
if (response.data.hasOwnProperty("message")) { |
| 305 |
__tagembed__toast.success({message: response.data.message, position: '__tagembed__is-top-right'}); |
| 306 |
} |
| 307 |
window.location.replace(response.data.redirectUrl); |
| 308 |
} else { |
| 309 |
if (response.hasOwnProperty("data") && Object.keys(response.data).length > 0) { |
| 310 |
if (response.data.hasOwnProperty("name")) { |
| 311 |
__tagembed__name_error.style.display = 'block'; |
| 312 |
__tagembed__name_error.textContent = response.data.name; |
| 313 |
} |
| 314 |
} else { |
| 315 |
if (response.hasOwnProperty("message")) { |
| 316 |
__tagembed__toast.danger({message: response.message, position: '__tagembed__is-top-right'}); |
| 317 |
} else { |
| 318 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 319 |
} |
| 320 |
} |
| 321 |
} |
| 322 |
}).catch((error) => { |
| 323 |
console.log(error); |
| 324 |
__tagembed__close_loader(); |
| 325 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 326 |
}); |
| 327 |
} |
| 328 |
}); |
| 329 |
}); |
| 330 |
} |
| 331 |
/*--End--Create Widget*/ |
| 332 |
/*--Start--Manage Menue Hide Show In Mobile*/ |
| 333 |
function __tagembed__manageMenueHideShowInMobile() { |
| 334 |
let __tagembed__menulist = document.querySelector("#__tagembed__menulist"); |
| 335 |
let __tagembed__burger = document.querySelector("#__tagembed__burger"); |
| 336 |
if (__tagembed__menulist.style.display === "none") { |
| 337 |
__tagembed__menulist.style.display = "block"; |
| 338 |
__tagembed__burger.classList.add("__tagembed__addclose"); |
| 339 |
} else { |
| 340 |
__tagembed__menulist.style.display = "none"; |
| 341 |
__tagembed__burger.classList.remove("__tagembed__addclose"); |
| 342 |
} |
| 343 |
} |
| 344 |
/*--Start--Manage Menue Hide Show In Mobile*/ |
| 345 |
/*--Start--Manage Toggel On Press Space Button*/ |
| 346 |
function __tagembed__manageToggelOnPressSpace() { |
| 347 |
let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog"); |
| 348 |
if (tagembedConfirmDialog) |
| 349 |
return true; |
| 350 |
return false; |
| 351 |
} |
| 352 |
/*--End--Manage Toggel On Press Space Button*/ |
| 353 |
/*--Start-- Add And Update Connected Account*/ |
| 354 |
function __tageembed__addUpdateAndRefreshAccount(__tagembed__networkId, __tagembed__type, __tagembed__connected_account_id = null, __tagembed__feed_id = null, __tagembed__feed_filter_id = null, __tagembed__other_data = null) { |
| 355 |
if (__tagembed__networkId) { |
| 356 |
let __tagembed__toast = new TagembedToast; |
| 357 |
let formData = new FormData(); |
| 358 |
formData.append('action', 'data'); |
| 359 |
formData.append('__tagembed__ajax_action', '__tagembed__add_or_update_account'); |
| 360 |
formData.append('type', __tagembed__type); |
| 361 |
formData.append('connectedAccountId', __tagembed__connected_account_id); |
| 362 |
formData.append('feedId', __tagembed__feed_id); |
| 363 |
formData.append('networkId', __tagembed__networkId); |
| 364 |
formData.append('filterId', __tagembed__feed_filter_id); |
| 365 |
formData.append('otherData', __tagembed__other_data); |
| 366 |
__tagembed__open_loader(); |
| 367 |
fetch(__tagembed__ajax_url, { |
| 368 |
method: 'POST', |
| 369 |
headers: { |
| 370 |
'x-requested-with': 'XMLHttpRequest', |
| 371 |
}, |
| 372 |
body: formData, |
| 373 |
}).then(response => { |
| 374 |
return response.json() |
| 375 |
}).then(response => { |
| 376 |
|
| 377 |
if (response.status == true) { |
| 378 |
window.open(response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self'); |
| 379 |
} else { |
| 380 |
__tagembed__close_loader(); |
| 381 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 382 |
} |
| 383 |
}).catch((error) => { |
| 384 |
console.log(error); |
| 385 |
__tagembed__close_loader(); |
| 386 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 387 |
}); |
| 388 |
} |
| 389 |
} |
| 390 |
/*--End-- Add And Update Connected Account*/ |
| 391 |
/*--Start-- Manage Short Code*/ |
| 392 |
window.addEventListener ? window.addEventListener("load", __tagembed__manageShotrCode, false) : window.attachEvent && window.attachEvent("onload", __tagembed__manageShotrCode); |
| 393 |
function __tagembed__manageShotrCode() { |
| 394 |
let widgetData = document.querySelector("#__tagembed__widgets"); |
| 395 |
if (widgetData) { |
| 396 |
let __tagembed__widgetId = widgetData.selectedOptions[0].value.split('#')[0]; |
| 397 |
let __tagembed__shortCode = document.querySelector("#__tagembed__shortCode"); |
| 398 |
if (__tagembed__shortCode) |
| 399 |
__tagembed__shortCode.innerHTML = `[tagembed widgetid ${__tagembed__widgetId}]`; |
| 400 |
} |
| 401 |
} |
| 402 |
/*--Start--Copy Short Code*/ |
| 403 |
function __tagembed__copyCodeEmbed(__tagembed__codeType, __tagembed__copyEmbedId) { |
| 404 |
let __tagembed__toast = new TagembedToast; |
| 405 |
let __tagembed__copyEmbedCode = ""; |
| 406 |
console.log(__tagembed__copyEmbedId); |
| 407 |
switch (__tagembed__codeType) { |
| 408 |
case "shortCode": |
| 409 |
__tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).innerHTML; |
| 410 |
break; |
| 411 |
case "embedCode": |
| 412 |
__tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).value; |
| 413 |
break; |
| 414 |
} |
| 415 |
navigator.clipboard.writeText(__tagembed__copyEmbedCode); |
| 416 |
__tagembed__toast.success({message: 'copied', position: '__tagembed__is-top-right'}); |
| 417 |
} |
| 418 |
/*--End--Copy Short Code*/ |
| 419 |
/*--End-- Manage Short Code*/ |
| 420 |
/*--Start--Manage Connection Share Link Popup*/ |
| 421 |
function __tagembed__manageShareLinkPopup() { |
| 422 |
let __tagembed__share_link_popup = document.querySelector("#__tagembed__share_link_popup"); |
| 423 |
if (__tagembed__share_link_popup.style.display === "none") { |
| 424 |
__tagembed__share_link_popup.style.display = "block"; |
| 425 |
} else { |
| 426 |
__tagembed__share_link_popup.style.display = "none"; |
| 427 |
} |
| 428 |
} |
| 429 |
function __tagembed__manageShareLinkPopup() { |
| 430 |
let __tagembed__share_link_popup = document.querySelector("#__tagembed__share_link_popup"); |
| 431 |
__tagembed__share_link_popup.style.display = 'none'; |
| 432 |
let __tagembed__toast = new TagembedToast; |
| 433 |
let formData = new FormData(); |
| 434 |
formData.append('action', 'data'); |
| 435 |
formData.append('__tagembed__ajax_action', '__tagembed__get_en_user_id'); |
| 436 |
__tagembed__open_loader(); |
| 437 |
fetch(__tagembed__ajax_url, { |
| 438 |
method: 'POST', |
| 439 |
headers: { |
| 440 |
'x-requested-with': 'XMLHttpRequest', |
| 441 |
}, |
| 442 |
body: formData, |
| 443 |
}).then(response => { |
| 444 |
return response.json() |
| 445 |
}).then(response => { |
| 446 |
__tagembed__close_loader(); |
| 447 |
if (response.status == true) { |
| 448 |
__tagembed__share_link_popup.style.display = 'block'; |
| 449 |
document.getElementById("__tagembed__share_link_input").value = response.data.shareLink; |
| 450 |
} else { |
| 451 |
__tagembed__share_link_popup.style.display = 'none'; |
| 452 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 453 |
} |
| 454 |
}).catch((error) => { |
| 455 |
console.log(error); |
| 456 |
__tagembed__close_loader(); |
| 457 |
__tagembed__share_link_popup.style.display = 'none'; |
| 458 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 459 |
}); |
| 460 |
} |
| 461 |
function __tagembed__shareLink() { |
| 462 |
let __tagembed__toast = new TagembedToast; |
| 463 |
let __tagembed__share_link_popup = document.querySelector("#__tagembed__share_link_popup"); |
| 464 |
let __tagembed__en_user_id = document.querySelector("#__tagembed__share_link_input"); |
| 465 |
let __tagembed__email_ids = document.querySelector("#__tagembed__email_ids"); |
| 466 |
if (!__tagembed__en_user_id || !__tagembed__email_ids) |
| 467 |
return __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 468 |
__tagembed__en_user_id = __tagembed__en_user_id.value.split("/").pop(); |
| 469 |
__tagembed__email_ids = __tagembed__email_ids.value; |
| 470 |
if (!__tagembed__en_user_id) |
| 471 |
return __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 472 |
if (!__tagembed__email_ids) |
| 473 |
return __tagembed__toast.danger({message: "Enter Email Id", position: '__tagembed__is-top-right'}); |
| 474 |
let formData = new FormData(); |
| 475 |
formData.append('action', 'data'); |
| 476 |
formData.append('emailIds', __tagembed__email_ids); |
| 477 |
formData.append('enUserId', __tagembed__en_user_id); |
| 478 |
formData.append('__tagembed__ajax_action', '__tagembed__share_link'); |
| 479 |
__tagembed__open_loader(); |
| 480 |
fetch(__tagembed__ajax_url, { |
| 481 |
method: 'POST', |
| 482 |
headers: { |
| 483 |
'x-requested-with': 'XMLHttpRequest', |
| 484 |
}, |
| 485 |
body: formData, |
| 486 |
}).then(response => { |
| 487 |
return response.json() |
| 488 |
}).then(response => { |
| 489 |
__tagembed__close_loader(); |
| 490 |
if (response.status == true) { |
| 491 |
__tagembed__email_ids.value = ""; |
| 492 |
__tagembed__share_link_popup.style.display = 'none'; |
| 493 |
__tagembed__toast.success({message: 'Successfully shared', position: '__tagembed__is-top-right'}); |
| 494 |
} else { |
| 495 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 496 |
} |
| 497 |
}).catch((error) => { |
| 498 |
console.log(error); |
| 499 |
__tagembed__close_loader(); |
| 500 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 501 |
}); |
| 502 |
} |
| 503 |
/*--End--Manage Connection Share Link Popup*/ |
| 504 |
/*--Start--Manage Connection Share Link Popup Hide Show On Close Btn*/ |
| 505 |
var __tagembed__share_link_popup_close_btn = document.querySelector("#__tagembed__share_link_popup_close_btn"); |
| 506 |
if (__tagembed__share_link_popup_close_btn) { |
| 507 |
__tagembed__share_link_popup_close_btn.addEventListener('click', function () { |
| 508 |
document.querySelector("#__tagembed__share_link_popup").style.display = "none"; |
| 509 |
}); |
| 510 |
} |
| 511 |
/*--End--Manage Connection Share Link Popup Hide Show On Close Btn*/ |
| 512 |
/*--Start--Copy Share Link Code*/ |
| 513 |
function __tagembed__copyToShareLink() { |
| 514 |
__tagembed__share_link_input |
| 515 |
let __tagembed__toast = new TagembedToast; |
| 516 |
let text = document.getElementById("__tagembed__share_link_input").value; |
| 517 |
navigator.clipboard.writeText(text); |
| 518 |
__tagembed__toast.success({message: 'copied', position: '__tagembed__is-top-right'}); |
| 519 |
} |
| 520 |
/*--End--Copy Share Link Code*/ |
| 521 |
|
| 522 |
/*--Start --Open Crisp Chat On Click*/ |
| 523 |
function __tagembed__openCrispChat() { |
| 524 |
$crisp.push(['do', 'chat:open']); |
| 525 |
} |
| 526 |
/*--End --Open Crisp Chat On Click*/ |
| 527 |
|
| 528 |
|