| @@ -1,451 +1,532 @@ | ||
| 1 | +/*--Start--Validation : Accept An Identifier Only When It Is Digits Only*/ | |
| 2 | +/* Validation, as described in the WordPress security handbook : test the value against a | |
| 3 | + known pattern and treat anything else as invalid. */ | |
| 4 | +function __tagembed__isValidId(value) { | |
| 5 | + return /^\d+$/.test(String(value === undefined || value === null ? "" : value).trim()); | |
| 6 | +} | |
| 7 | +function __tagembed__validId(value) { | |
| 8 | + return __tagembed__isValidId(value) ? String(value).trim() : ""; | |
| 9 | +} | |
| 10 | +/*--End--Validation*/ | |
| 11 | +/*--Start--Escaping : WordPress Core @wordpress/escape-html Package*/ | |
| 12 | +/* wp.escapeHtml is shipped by WordPress core (script handle wp-escape-html). | |
| 13 | + escapeHTML() is for text between tags, escapeAttribute() is for a double quoted attribute. */ | |
| 14 | +function __tagembed__escapeText(value) { | |
| 15 | + let __tagembed__stringValue = String(value === undefined || value === null ? "" : value); | |
| 16 | + return window.wp.escapeHtml.escapeHTML(__tagembed__stringValue); | |
| 17 | +} | |
| 18 | +function __tagembed__escapeAttr(value) { | |
| 19 | + let __tagembed__stringValue = String(value === undefined || value === null ? "" : value); | |
| 20 | + return window.wp.escapeHtml.escapeAttribute(__tagembed__stringValue); | |
| 21 | +} | |
| 22 | +/*--End--Escaping*/ | |
| 23 | +/*--Start--Sanitization : DOMPurify, Applied To Every Markup String Before It Reaches The DOM*/ | |
| 24 | +/* Our own DOMPurify instance is captured as soon as this file loads, so a copy loaded | |
| 25 | + later by another plugin can never replace the one this plugin uses. */ | |
| 26 | +var __tagembed__purifier = window.__tagembed__DOMPurify || window.DOMPurify; | |
| 27 | +function __tagembed__setSafeHtml(element, html) { | |
| 28 | + if (!element) return; | |
| 29 | + var __tagembed__sanitizer = __tagembed__purifier || window.__tagembed__DOMPurify || window.DOMPurify; | |
| 30 | + if (!__tagembed__sanitizer || typeof __tagembed__sanitizer.sanitize !== "function") { | |
| 31 | + /* Without the sanitizer nothing is rendered, so unsanitized markup can never reach the page. */ | |
| 32 | + element.textContent = ""; | |
| 33 | + return; | |
| 34 | + } | |
| 35 | + element.innerHTML = __tagembed__sanitizer.sanitize(String(html === undefined || html === null ? "" : html), { USE_PROFILES: { html: true } }); | |
| 36 | +} | |
| 37 | +/*--End--Sanitization*/ | |
| 1 | 38 | /*--Start-- Manage Window Popup In New Tab*/ |
| 39 | +/*function __tagmebed__openWindowPopup(url, windowName = "Tagembed") { | |
| 40 | + __tagmebed__window_popup = window.open(url, '_blank'); | |
| 41 | + __tagmebed__window_popup.focus(); | |
| 42 | + var __tagembed__window_pupup_timer = setInterval(function () { | |
| 43 | + if (__tagmebed__window_popup.closed) { | |
| 44 | + location.reload(); | |
| 45 | + clearInterval(__tagembed__window_pupup_timer); | |
| 46 | + } | |
| 47 | + }, 250); | |
| 48 | + }*/ | |
| 2 | 49 | function __tagmebed__openWindowPopup(url, windowName = "Tagembed") { |
| 3 | - __tagmebed__window_popup = window.open(url, '_blank'); | |
| 4 | - __tagmebed__window_popup.focus(); | |
| 5 | - var __tagembed__window_pupup_timer = setInterval(function () { | |
| 6 | - if (__tagmebed__window_popup.closed) { | |
| 7 | - location.reload(); | |
| 8 | - clearInterval(__tagembed__window_pupup_timer); | |
| 9 | - } | |
| 10 | - }, 250); | |
| 50 | + __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'); | |
| 51 | + var __tagembed__window_pupup_timer = setInterval(function () { | |
| 52 | + if (__tagmebed__window_popup.closed) { | |
| 53 | + location.reload(); | |
| 54 | + clearInterval(__tagembed__window_pupup_timer); | |
| 55 | + } | |
| 56 | + }, 250); | |
| 11 | 57 | } |
| 12 | 58 | function __tagmebed__closeWindowPopup() { |
| 13 | - if (__tagmebed__window_popup) | |
| 14 | - __tagmebed__window_popup.close(); | |
| 59 | + if (__tagmebed__window_popup) | |
| 60 | + __tagmebed__window_popup.close(); | |
| 15 | 61 | } |
| 16 | 62 | /*--End-- Create And Manage Window Popup*/ |
| 17 | 63 | |
| 18 | 64 | /*--Start--Hide/Show Loader During Page Readay State*/ |
| 19 | 65 | document.onreadystatechange = function () { |
| 20 | - if (document.readyState !== "complete") { | |
| 21 | - __tagembed__open_loader(); | |
| 22 | - } else { | |
| 23 | - __tagembed__close_loader(); | |
| 24 | - } | |
| 66 | + if (document.readyState !== "complete") { | |
| 67 | + __tagembed__open_loader(); | |
| 68 | + } else { | |
| 69 | + __tagembed__close_loader(); | |
| 70 | + } | |
| 25 | 71 | }; |
| 26 | 72 | /*--End--Hide/Show Loader During Page Readay State*/ |
| 27 | -/*--Start-- Manage Hide And Show plugin Upgrade Message*/ | |
| 28 | -window.addEventListener ? window.addEventListener("load", __tagembed__plugin_version, false) : window.attachEvent && window.attachEvent("onload", __tagembed__plugin_version); | |
| 29 | -function __tagembed__plugin_version() { | |
| 30 | - let __tagembed__toast = new TagembedToast; | |
| 31 | - let formData = new FormData(); | |
| 32 | - formData.append('action', 'data'); | |
| 33 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 34 | - formData.append('__tagembed__ajax_action', '__tagembed__plugin_version'); | |
| 35 | - fetch(__tagembed__ajax_url, { | |
| 36 | - method: 'POST', | |
| 37 | - headers: { | |
| 38 | - 'x-requested-with': 'XMLHttpRequest', | |
| 39 | - }, | |
| 40 | - body: formData, | |
| 41 | - }).then(response => { | |
| 42 | - return response.json() | |
| 43 | - }).then(response => { | |
| 44 | - if (response.status == true) { | |
| 45 | - if (response.data.installedPluginVersion != response.data.livePluginVersion) { | |
| 46 | - let elemHTML = `<div class="__tagembed__popupwrap __tagembed__popup_md">`; | |
| 47 | - elemHTML = `${elemHTML}<button onclick="__tagembed__hide_plugin_upgrade_message();" type="button" class="__tagembed__closebtn"></button>`; | |
| 48 | - elemHTML = `${elemHTML}<div class="__tagembed__popupinn">`; | |
| 49 | - elemHTML = `${elemHTML}<div class="__tagembed__header"><h2>Update Plugin For Free</h2></div>`; | |
| 50 | - elemHTML = `${elemHTML}<hr class="__tagembed__horizontaborder">`; | |
| 51 | - elemHTML = `${elemHTML}<div class="__tagembed__formwbody">`; | |
| 52 | - elemHTML = `${elemHTML}<div class="__tagembed__formwrow">`; | |
| 53 | - elemHTML = `${elemHTML}<p><strong> Note : </strong> There is a new version of Tagembed Widget available. <strong> ${response.data.livePluginVersion} </strong> is a recommended Update For Performance Improvements. </p>`; | |
| 54 | - elemHTML = `${elemHTML}</div></div>`; | |
| 55 | - elemHTML = `${elemHTML}<div class = "__tagembed__btnwrap text-center">`; | |
| 56 | - elemHTML = `${elemHTML}<a style="background: #d63638;" href="${response.data.pluginUpgradeURL}" class="__tagembed__okaybtn">Update Plugin</a>`; | |
| 57 | - elemHTML = `${elemHTML}</div></div></div>`; | |
| 58 | - document.getElementById("__tagembed__plugin_upgrade_message").innerHTML = elemHTML; | |
| 59 | - } | |
| 60 | - } else { | |
| 61 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 62 | - } | |
| 63 | - }).catch((error) => { | |
| 64 | - console.log(error); | |
| 65 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 66 | - }); | |
| 67 | -} | |
| 68 | -function __tagembed__hide_plugin_upgrade_message() { | |
| 69 | - let __tagembed__plugin_upgrade_message = document.querySelector("#__tagembed__plugin_upgrade_message") | |
| 70 | - __tagembed__plugin_upgrade_message.style.display = "none"; | |
| 71 | -} | |
| 72 | -/*--End-- Manage Hide And Show plugin Upgrade Message*/ | |
| 73 | + | |
| 73 | 74 | /*--Start-- Manage Response Message*/ |
| 74 | 75 | window.addEventListener ? window.addEventListener("load", __tagembed__message, false) : window.attachEvent && window.attachEvent("onload", __tagembed__message); |
| 75 | 76 | function __tagembed__message() { |
| 76 | - let __tagembed__toast = new TagembedToast; | |
| 77 | - /*--Start-- Manage Redirect Url Error*/ | |
| 78 | - let urlSearchParams = new URLSearchParams(window.location.search); | |
| 79 | - let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); | |
| 80 | - /*--Start-- Manage Show Messaage According Time*/ | |
| 81 | - let getTime = new Date(); | |
| 82 | - getTime = getTime.getTime(); /*milliseconds*/ | |
| 83 | - getTime = Math.floor(getTime / 1000); /*seconds*/ | |
| 84 | - if (__tagembed__message.hasOwnProperty("status")) { | |
| 85 | - if (__tagembed__message.status < getTime) | |
| 86 | - return; | |
| 87 | - } | |
| 88 | - /*--End-- Manage Show Messaage According Time*/ | |
| 89 | - if (__tagembed__message.hasOwnProperty("__tagembed__message")) { | |
| 90 | - if (__tagembed__message.hasOwnProperty("success")) { | |
| 91 | - __tagembed__toast.success({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); | |
| 92 | - } else if (__tagembed__message.hasOwnProperty("info")) { | |
| 93 | - __tagembed__toast.info({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); | |
| 94 | - } else if (__tagembed__message.hasOwnProperty("warning")) { | |
| 95 | - __tagembed__toast.warning({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); | |
| 96 | - } else { | |
| 97 | - __tagembed__toast.danger({message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right'}); | |
| 98 | - } | |
| 99 | - /*--Start--Show Popup On Plan Upgrade Time*/ | |
| 100 | - if (__tagembed__message.hasOwnProperty("planName") && __tagembed__message.hasOwnProperty("amount") && __tagembed__message.hasOwnProperty("paymentId")) { | |
| 101 | - let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup"); | |
| 102 | - let elemHTML = `<div class="__tagembed__popupwrap __tagembed__popup_md">`; | |
| 103 | - elemHTML = `${elemHTML}<button id="__tagembed__upgrade_account_popup_close_btn" onclick="__tagembed__hide_upgrade_account_popup();" type="button" class="__tagembed__closebtn"></button>`; | |
| 104 | - elemHTML = `${elemHTML}<div class="__tagembed__popupinn">`; | |
| 105 | - elemHTML = `${elemHTML}<div class="__tagembed__formwbody">`; | |
| 106 | - elemHTML = `${elemHTML}<div class="__tagembed__thankyou">`; | |
| 107 | - elemHTML = `${elemHTML}<img src="${__tagembed__plugin_url_for_js}assets/images/check-green.png" alt="check">`; | |
| 108 | - elemHTML = `${elemHTML}<h2>Congratulations! <span>Your account has been upgraded</span></h2>`; | |
| 109 | - elemHTML = `${elemHTML}<div class="__tagembed__plandetail">`; | |
| 110 | - elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; | |
| 111 | - elemHTML = `${elemHTML}<p>Amount</p>`; | |
| 112 | - elemHTML = `${elemHTML}<span>$${__tagembed__message.amount}</span>`; | |
| 113 | - elemHTML = `${elemHTML}</div>`; | |
| 114 | - elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; | |
| 115 | - elemHTML = `${elemHTML}<p>Payment Id</p>`; | |
| 116 | - elemHTML = `${elemHTML}<span>${__tagembed__message.paymentId}</span>`; | |
| 117 | - elemHTML = `${elemHTML}</div>`; | |
| 118 | - elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; | |
| 119 | - elemHTML = `${elemHTML}<p>Product</p>`; | |
| 120 | - elemHTML = `${elemHTML}<span>${__tagembed__message.productName}</span>`; | |
| 121 | - elemHTML = `${elemHTML}</div>`; | |
| 122 | - elemHTML = `${elemHTML}<div class="__tagembed__planbox">`; | |
| 123 | - elemHTML = `${elemHTML}<p>Plan</p>`; | |
| 124 | - elemHTML = `${elemHTML}<span>${__tagembed__message.planName}</span>`; | |
| 125 | - elemHTML = `${elemHTML}</div></div></div></div></div></div>`; | |
| 126 | - __tagembed__upgrade_account_popup.innerHTML = elemHTML; | |
| 127 | - __tagembed__upgrade_account_popup.style.display = "block"; | |
| 128 | - } | |
| 129 | - /*--End--Show Popup On Plan Upgrade Time*/ | |
| 130 | - } | |
| 77 | + let __tagembed__toast = new TagembedToast; | |
| 78 | + /*--Start-- Manage Redirect Url Error*/ | |
| 79 | + let urlSearchParams = new URLSearchParams(window.location.search); | |
| 80 | + let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); | |
| 81 | + /*--Start-- Manage Show Messaage According Time*/ | |
| 82 | + let getTime = new Date(); | |
| 83 | + getTime = getTime.getTime(); /*milliseconds*/ | |
| 84 | + getTime = Math.floor(getTime / 1000); /*seconds*/ | |
| 85 | + if (__tagembed__message.hasOwnProperty("status")) { | |
| 86 | + if (__tagembed__message.status < getTime) | |
| 87 | + return; | |
| 88 | + } | |
| 89 | + /*--End-- Manage Show Messaage According Time*/ | |
| 90 | + if (__tagembed__message.hasOwnProperty("__tagembed__message")) { | |
| 91 | + if (__tagembed__message.hasOwnProperty("success")) { | |
| 92 | + __tagembed__toast.success({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); | |
| 93 | + } else if (__tagembed__message.hasOwnProperty("info")) { | |
| 94 | + __tagembed__toast.info({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); | |
| 95 | + } else if (__tagembed__message.hasOwnProperty("warning")) { | |
| 96 | + __tagembed__toast.warning({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); | |
| 97 | + } else { | |
| 98 | + __tagembed__toast.danger({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); | |
| 99 | + } | |
| 100 | + /*--Start--Show Popup On Plan Upgrade Time*/ | |
| 101 | + /* Every query string value is read through one trimmed lookup, so a key that arrives with | |
| 102 | + no value at all (&paymentId) counts as absent instead of printing a blank box. */ | |
| 103 | + let __tagembed__queryValue = function (key) { | |
| 104 | + let __tagembed__raw = __tagembed__message[key]; | |
| 105 | + return String(__tagembed__raw === undefined || __tagembed__raw === null ? "" : __tagembed__raw).trim(); | |
| 106 | + }; | |
| 107 | + let __tagembed__planName = __tagembed__queryValue("planName"); | |
| 108 | + if (__tagembed__planName) { | |
| 109 | + let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup"); | |
| 110 | + /* The popup markup only exists on the upgrade screen, so nothing is built when it is absent. */ | |
| 111 | + if (!__tagembed__upgrade_account_popup) return; | |
| 112 | + /* Built with DOM methods. The query string values are inserted as text | |
| 113 | + nodes only, so no markup can be produced from them. */ | |
| 114 | + let __tagembed__makeElement = function (tag, className) { | |
| 115 | + let __tagembed__element = document.createElement(tag); | |
| 116 | + if (className) __tagembed__element.className = className; | |
| 117 | + return __tagembed__element; | |
| 118 | + }; | |
| 119 | + let __tagembed__makePlanBox = function (label, value) { | |
| 120 | + let __tagembed__box = __tagembed__makeElement("div", "__tagembed__planbox"); | |
| 121 | + let __tagembed__label = document.createElement("p"); | |
| 122 | + __tagembed__label.textContent = label; | |
| 123 | + let __tagembed__value = document.createElement("span"); | |
| 124 | + __tagembed__value.textContent = (value === undefined || value === null) ? "" : String(value); | |
| 125 | + __tagembed__box.appendChild(__tagembed__label); | |
| 126 | + __tagembed__box.appendChild(__tagembed__value); | |
| 127 | + return __tagembed__box; | |
| 128 | + }; | |
| 129 | + let __tagembed__wrap = __tagembed__makeElement("div", "__tagembed__popupwrap __tagembed__popup_md"); | |
| 130 | + let __tagembed__closeBtn = __tagembed__makeElement("button", "__tagembed__closebtn"); | |
| 131 | + __tagembed__closeBtn.setAttribute("id", "__tagembed__upgrade_account_popup_close_btn"); | |
| 132 | + __tagembed__closeBtn.setAttribute("type", "button"); | |
| 133 | + __tagembed__closeBtn.addEventListener("click", __tagembed__hide_upgrade_account_popup); | |
| 134 | + let __tagembed__inn = __tagembed__makeElement("div", "__tagembed__popupinn"); | |
| 135 | + let __tagembed__body = __tagembed__makeElement("div", "__tagembed__formwbody"); | |
| 136 | + let __tagembed__thankyou = __tagembed__makeElement("div", "__tagembed__thankyou"); | |
| 137 | + let __tagembed__checkImg = document.createElement("img"); | |
| 138 | + __tagembed__checkImg.setAttribute("src", __tagembed__plugin_url_for_js + "assets/images/check-green.png"); | |
| 139 | + __tagembed__checkImg.setAttribute("alt", "check"); | |
| 140 | + let __tagembed__heading = document.createElement("h2"); | |
| 141 | + __tagembed__heading.appendChild(document.createTextNode("Congratulations! ")); | |
| 142 | + let __tagembed__headingSpan = document.createElement("span"); | |
| 143 | + /* The popup repeats the message that came back in the query string, so an upgrade and a | |
| 144 | + downgrade each read correctly instead of both claiming an upgrade. */ | |
| 145 | + __tagembed__headingSpan.textContent = __tagembed__message.__tagembed__message.replace(/-/g, ' '); | |
| 146 | + __tagembed__heading.appendChild(__tagembed__headingSpan); | |
| 147 | + let __tagembed__detail = __tagembed__makeElement("div", "__tagembed__plandetail"); | |
| 148 | + /* A free plan costs nothing, so a missing or zero amount is left out rather than shown as $0. */ | |
| 149 | + let __tagembed__amount = __tagembed__queryValue("amount"); | |
| 150 | + let __tagembed__amountValue = Number(__tagembed__amount); | |
| 151 | + if (__tagembed__amount && !(isFinite(__tagembed__amountValue) && 0 === __tagembed__amountValue)) | |
| 152 | + __tagembed__detail.appendChild(__tagembed__makePlanBox("Amount", "$" + __tagembed__amount)); | |
| 153 | + /* A downgrade carries no payment, so the payment id is shown only when one actually arrived. */ | |
| 154 | + let __tagembed__paymentId = __tagembed__queryValue("paymentId"); | |
| 155 | + if (__tagembed__paymentId) | |
| 156 | + __tagembed__detail.appendChild(__tagembed__makePlanBox("Payment Id", __tagembed__paymentId)); | |
| 157 | + /* The free plan is the fallback every downgrade lands on, so naming it adds nothing. */ | |
| 158 | + if ("free" !== __tagembed__planName.toLowerCase()) | |
| 159 | + __tagembed__detail.appendChild(__tagembed__makePlanBox("Plan", __tagembed__planName)); | |
| 160 | + __tagembed__thankyou.appendChild(__tagembed__checkImg); | |
| 161 | + __tagembed__thankyou.appendChild(__tagembed__heading); | |
| 162 | + /* A free downgrade leaves out every detail, so the empty row is not added at all. */ | |
| 163 | + if (__tagembed__detail.hasChildNodes()) | |
| 164 | + __tagembed__thankyou.appendChild(__tagembed__detail); | |
| 165 | + __tagembed__body.appendChild(__tagembed__thankyou); | |
| 166 | + __tagembed__inn.appendChild(__tagembed__body); | |
| 167 | + __tagembed__wrap.appendChild(__tagembed__closeBtn); | |
| 168 | + __tagembed__wrap.appendChild(__tagembed__inn); | |
| 169 | + __tagembed__upgrade_account_popup.replaceChildren(__tagembed__wrap); | |
| 170 | + __tagembed__upgrade_account_popup.style.display = "block"; | |
| 171 | + } | |
| 172 | + /*--End--Show Popup On Plan Upgrade Time*/ | |
| 173 | + } | |
| 131 | 174 | } |
| 132 | 175 | /*--End-- Manage Response Message*/ |
| 133 | 176 | /*--Start--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 134 | 177 | function __tagembed__manageApiCall() { |
| 135 | - let urlSearchParams = new URLSearchParams(window.location.search); | |
| 136 | - let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); | |
| 137 | - if (__tagembed__message.hasOwnProperty("__tagembed__message")) | |
| 138 | - return true | |
| 139 | - return false; | |
| 178 | + let urlSearchParams = new URLSearchParams(window.location.search); | |
| 179 | + let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); | |
| 180 | + if (__tagembed__message.hasOwnProperty("__tagembed__message")) | |
| 181 | + return true | |
| 182 | + return false; | |
| 140 | 183 | } |
| 141 | 184 | /*--End--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 142 | 185 | /*--Start-- Logout*/ |
| 143 | 186 | var __tagembed__logout = document.querySelector("#__tagembed__logout"); |
| 144 | 187 | if (__tagembed__logout) { |
| 145 | - __tagembed__logout.addEventListener('click', function (event) { | |
| 146 | - confirmDialog({title: 'Yes, sign out', message: 'Are you sure! do you want to sign out?', buttonText: 'Sign Out', type: 'warning'}, function () { | |
| 147 | - let formData = new FormData(); | |
| 148 | - formData.append('action', 'data'); | |
| 149 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 150 | - formData.append('__tagembed__ajax_action', '__tagembed__logout'); | |
| 151 | - __tagembed__open_loader(); | |
| 152 | - let __tagembed__toast = new TagembedToast; | |
| 153 | - fetch(__tagembed__ajax_url, { | |
| 154 | - method: 'POST', | |
| 155 | - headers: { | |
| 156 | - 'x-requested-with': 'XMLHttpRequest', | |
| 157 | - }, | |
| 158 | - body: formData, | |
| 159 | - }).then(response => { | |
| 160 | - return response.json() | |
| 161 | - }).then(response => { | |
| 162 | - __tagembed__close_loader(); | |
| 163 | - if (response.status == true) { | |
| 164 | - window.location.replace(response.data.redirectUrl); | |
| 165 | - } else { | |
| 166 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 167 | - } | |
| 168 | - }).catch((error) => { | |
| 169 | - console.log(error); | |
| 170 | - __tagembed__close_loader(); | |
| 171 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 172 | - }); | |
| 173 | - }); | |
| 174 | - }); | |
| 188 | + __tagembed__logout.addEventListener('click', function (event) { | |
| 189 | + __tagembed__confirmDialog({ title: 'Yes, sign out', message: 'Are you sure! do you want to sign out?', buttonText: 'Sign Out', type: 'warning' }, function () { | |
| 190 | + let formData = new FormData(); | |
| 191 | + formData.append('action', 'tagembed_data'); | |
| 192 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 193 | + formData.append('__tagembed__ajax_action', '__tagembed__logout'); | |
| 194 | + __tagembed__open_loader(); | |
| 195 | + let __tagembed__toast = new TagembedToast; | |
| 196 | + fetch(__tagembed__ajax_url, { | |
| 197 | + method: 'POST', | |
| 198 | + headers: { | |
| 199 | + 'x-requested-with': 'XMLHttpRequest', | |
| 200 | + }, | |
| 201 | + body: formData, | |
| 202 | + }).then(response => { | |
| 203 | + return response.json() | |
| 204 | + }).then(response => { | |
| 205 | + __tagembed__close_loader(); | |
| 206 | + if (response.status == true) { | |
| 207 | + window.location.replace(response.data.redirectUrl); | |
| 208 | + } else { | |
| 209 | + if (response.hasOwnProperty("message")) { | |
| 210 | + __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); | |
| 211 | + } else { | |
| 212 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 213 | + } | |
| 214 | + } | |
| 215 | + }).catch((error) => { | |
| 216 | + console.log(error); | |
| 217 | + __tagembed__close_loader(); | |
| 218 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 219 | + }); | |
| 220 | + }); | |
| 221 | + }); | |
| 175 | 222 | } |
| 176 | 223 | /*--End-- Logout*/ |
| 177 | 224 | |
| 178 | 225 | /*--Start--Manage Tagembed Menue*/ |
| 179 | 226 | function __tagembed__menus(__tagembed__menu_id, __tagembed__widgetId = null) { |
| 180 | - if (__tagembed__widgetId) | |
| 181 | - __tagembed__manageActiveWidget(__tagembed__widgetId); | |
| 182 | - __tagembed__open_loader(); | |
| 183 | - let __tagembed__toast = new TagembedToast; | |
| 184 | - let formData = new FormData(); | |
| 185 | - formData.append('action', 'data'); | |
| 186 | - formData.append('menueId', __tagembed__menu_id); | |
| 187 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 188 | - formData.append('__tagembed__ajax_action', '__tagembed__menue'); | |
| 189 | - fetch(__tagembed__ajax_url, { | |
| 190 | - method: 'POST', | |
| 191 | - headers: { | |
| 192 | - 'x-requested-with': 'XMLHttpRequest', | |
| 193 | - }, | |
| 194 | - body: formData, | |
| 195 | - }).then(response => { | |
| 196 | - return response.json() | |
| 197 | - }).then(response => { | |
| 198 | - if (response.status == true) { | |
| 199 | - return window.location.replace(response.data.redirectUrl); | |
| 200 | - /*return window.location.href = response.data.redirectUrl;*/ | |
| 201 | - } else { | |
| 202 | - __tagembed__close_loader(); | |
| 203 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 204 | - } | |
| 205 | - }).catch((error) => { | |
| 206 | - console.log(error); | |
| 207 | - __tagembed__close_loader(); | |
| 208 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 209 | - }); | |
| 227 | + if (__tagembed__widgetId) | |
| 228 | + __tagembed__manageActiveWidget(__tagembed__widgetId); | |
| 229 | + __tagembed__open_loader(); | |
| 230 | + let __tagembed__toast = new TagembedToast; | |
| 231 | + let formData = new FormData(); | |
| 232 | + formData.append('action', 'tagembed_data'); | |
| 233 | + formData.append('menueId', __tagembed__menu_id); | |
| 234 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 235 | + formData.append('__tagembed__ajax_action', '__tagembed__menue'); | |
| 236 | + fetch(__tagembed__ajax_url, { | |
| 237 | + method: 'POST', | |
| 238 | + headers: { | |
| 239 | + 'x-requested-with': 'XMLHttpRequest', | |
| 240 | + }, | |
| 241 | + body: formData, | |
| 242 | + }).then(response => { | |
| 243 | + return response.json() | |
| 244 | + }).then(response => { | |
| 245 | + if (response.status == true) { | |
| 246 | + return window.location.replace(response.data.redirectUrl); | |
| 247 | + /*return window.location.href = response.data.redirectUrl;*/ | |
| 248 | + } else { | |
| 249 | + __tagembed__close_loader(); | |
| 250 | + if (response.hasOwnProperty("message")) { | |
| 251 | + __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); | |
| 252 | + } else { | |
| 253 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 254 | + } | |
| 255 | + } | |
| 256 | + }).catch((error) => { | |
| 257 | + console.log(error); | |
| 258 | + __tagembed__close_loader(); | |
| 259 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 260 | + }); | |
| 210 | 261 | } |
| 211 | 262 | /*--End--Manage Tagembed Menue*/ |
| 212 | 263 | /*--Start-- Get Already Exist Auth*/ |
| 213 | 264 | function __tagembed__get_already_exist_auth(__tagembed__network_id) { |
| 214 | - if (!__tagembed__network_id) | |
| 215 | - return; | |
| 216 | - let formData = new FormData(); | |
| 217 | - formData.append('networkId', __tagembed__network_id); | |
| 218 | - formData.append('action', 'data'); | |
| 219 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 220 | - formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth'); | |
| 221 | - fetch(__tagembed__ajax_url, { | |
| 222 | - method: 'POST', | |
| 223 | - headers: { | |
| 224 | - 'x-requested-with': 'XMLHttpRequest', | |
| 225 | - }, | |
| 226 | - body: formData, | |
| 227 | - }).then(response => { | |
| 228 | - return response.json() | |
| 229 | - }).then(response => { | |
| 230 | - if (response.status == true) | |
| 231 | - __tagembed__network_already_exist_auth = response.data; | |
| 232 | - }); | |
| 265 | + if (!__tagembed__network_id) | |
| 266 | + return; | |
| 267 | + let formData = new FormData(); | |
| 268 | + formData.append('networkId', __tagembed__network_id); | |
| 269 | + formData.append('action', 'tagembed_data'); | |
| 270 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 271 | + formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth'); | |
| 272 | + fetch(__tagembed__ajax_url, { | |
| 273 | + method: 'POST', | |
| 274 | + headers: { | |
| 275 | + 'x-requested-with': 'XMLHttpRequest', | |
| 276 | + }, | |
| 277 | + body: formData, | |
| 278 | + }).then(response => { | |
| 279 | + return response.json() | |
| 280 | + }).then(response => { | |
| 281 | + if (response.status == true) | |
| 282 | + __tagembed__network_already_exist_auth = response.data; | |
| 283 | + }); | |
| 233 | 284 | } |
| 285 | +/*Note : This Use For Merge Instagram 2/18*/ | |
| 286 | +function __tagembed__get_already_exist_auth_new(__tagembed__network_id, __tagembed__feed_data) { | |
| 287 | + if (!__tagembed__network_id) | |
| 288 | + return; | |
| 289 | + __tagembed__open_loader(); | |
| 290 | + let formData = new FormData(); | |
| 291 | + formData.append('networkId', __tagembed__network_id); | |
| 292 | + formData.append('action', 'tagembed_data'); | |
| 293 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 294 | + formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth'); | |
| 295 | + fetch(__tagembed__ajax_url, { | |
| 296 | + method: 'POST', | |
| 297 | + headers: { 'x-requested-with': 'XMLHttpRequest', }, | |
| 298 | + body: formData, | |
| 299 | + }).then(response => { | |
| 300 | + return response.json() | |
| 301 | + }).then(response => { | |
| 302 | + if (response.status == true) { | |
| 303 | + __tagembed__network_already_exist_auth = response.data; | |
| 304 | + __tagembed__createInstagramBusinessFeed(__tagembed__feed_data); | |
| 305 | + __tagembed__close_loader(); | |
| 306 | + } | |
| 307 | + }); | |
| 308 | +} | |
| 234 | 309 | /*--End-- Get Already Exist Auth*/ |
| 235 | 310 | /*--Start-- Manage Active Widget*/ |
| 236 | 311 | var __tagembed__widgets = document.querySelector("#__tagembed__widgets"); |
| 237 | 312 | if (__tagembed__widgets) { |
| 238 | - __tagembed__widgets.addEventListener("change", function (event) { | |
| 239 | - if (typeof __tagembed__get_theme !== 'undefined') | |
| 240 | - __tagembed__get_theme(); /*Manage Widget Theme According Widget*/ | |
| 241 | - if (typeof __tagembed__changeIfrmSrc !== 'undefined') | |
| 242 | - __tagembed__changeIfrmSrc(); /*Manage Widget Display Preview According Widget*/ | |
| 243 | - if (typeof __tagembed__manageShotrCode !== 'undefined') | |
| 244 | - __tagembed__manageShotrCode(); /*Manage Short Code According Widget*/ | |
| 245 | - if (typeof __tagembed__manageEmbedCode !== 'undefined') | |
| 246 | - __tagembed__manageEmbedCode(); /*Manage Embed Code According Widget*/ | |
| 247 | - if (typeof __tagembed__getFeed !== 'undefined') | |
| 248 | - __tagembed__getFeed(); /*Get Feed According Widget*/ | |
| 249 | - if (typeof __tagembed__changeFilterIfrmSrc !== 'undefined') | |
| 250 | - __tagembed__changeFilterIfrmSrc(); /*Mange Filter Section According Widget*/ | |
| 251 | - __tagembed__manageActiveWidget(); /*Manage Active Widget*/ | |
| 252 | - if (typeof __tagembed__getCustomizationOption !== 'undefined')/*Call Get Customization Options*/ | |
| 253 | - __tagembed__getCustomizationOption(); | |
| 254 | - }); | |
| 313 | + __tagembed__widgets.addEventListener("change", function (event) { | |
| 314 | + if (typeof __tagembed__get_theme !== 'undefined') | |
| 315 | + __tagembed__get_theme(); /*Manage Widget Theme According Widget*/ | |
| 316 | + if (typeof __tagembed__changeIfrmSrc !== 'undefined') | |
| 317 | + __tagembed__changeIfrmSrc(); /*Manage Widget Display Preview According Widget*/ | |
| 318 | + if (typeof __tagembed__manageShotrCode !== 'undefined') | |
| 319 | + __tagembed__manageShotrCode(); /*Manage Short Code According Widget*/ | |
| 320 | + if (typeof __tagembed__manageEmbedCode !== 'undefined') | |
| 321 | + __tagembed__manageEmbedCode(); /*Manage Embed Code According Widget*/ | |
| 322 | + if (typeof __tagembed__getFeed !== 'undefined') | |
| 323 | + __tagembed__getFeed(); /*Get Feed According Widget*/ | |
| 324 | + if (typeof __tagembed__changeFilterIfrmSrc !== 'undefined') | |
| 325 | + __tagembed__changeFilterIfrmSrc(); /*Mange Filter Section According Widget*/ | |
| 326 | + __tagembed__manageActiveWidget(); /*Manage Active Widget*/ | |
| 327 | + if (typeof __tagembed__getCustomizationOption !== 'undefined')/*Call Get Customization Options*/ | |
| 328 | + __tagembed__getCustomizationOption(); | |
| 329 | + }); | |
| 255 | 330 | } |
| 256 | 331 | function __tagembed__manageActiveWidget(__tagembed__widgetId = null) { |
| 257 | - if (!__tagembed__widgetId) { | |
| 258 | - __tagembed__widgetId = document.querySelector("#__tagembed__widgets").selectedOptions[0]; | |
| 259 | - __tagembed__widgetId = __tagembed__widgetId.value.split('#')[0]; | |
| 260 | - } | |
| 261 | - let __tagembed__toast = new TagembedToast; | |
| 262 | - let formData = new FormData(); | |
| 263 | - formData.append('action', 'data'); | |
| 264 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 265 | - formData.append('__tagembed__ajax_action', '__tagembed__manage_active_widget'); | |
| 266 | - formData.append('widgetId', __tagembed__widgetId); | |
| 267 | - if (__tagembed__loader_status) | |
| 268 | - __tagembed__open_loader(); | |
| 269 | - fetch(__tagembed__ajax_url, { | |
| 270 | - method: 'POST', | |
| 271 | - headers: { | |
| 272 | - 'x-requested-with': 'XMLHttpRequest', | |
| 273 | - }, | |
| 274 | - body: formData, | |
| 275 | - }).then(response => { | |
| 276 | - return response.json() | |
| 277 | - }).then(response => { | |
| 278 | - | |
| 279 | - if (__tagembed__loader_status) | |
| 280 | - __tagembed__close_loader(); | |
| 281 | - if (response.status == true) { | |
| 282 | - /*--Start--Reload Page For Manage Active Class On Widget Page*/ | |
| 283 | - if (document.querySelector("#__tagembed__widgetbox0")) | |
| 284 | - location.reload(); | |
| 285 | - /*--End--Reload Page For Manage Active Class On Widget Page*/ | |
| 286 | - } else { | |
| 287 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 288 | - } | |
| 289 | - }).catch((error) => { | |
| 290 | - console.log(error); | |
| 291 | - __tagembed__close_loader(); | |
| 292 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 293 | - }); | |
| 332 | + if (!__tagembed__widgetId) { | |
| 333 | + __tagembed__widgetId = document.querySelector("#__tagembed__widgets").selectedOptions[0]; | |
| 334 | + __tagembed__widgetId = __tagembed__widgetId.value.split('#')[0]; | |
| 335 | + } | |
| 336 | + let __tagembed__toast = new TagembedToast; | |
| 337 | + let formData = new FormData(); | |
| 338 | + formData.append('action', 'tagembed_data'); | |
| 339 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 340 | + formData.append('__tagembed__ajax_action', '__tagembed__manage_active_widget'); | |
| 341 | + formData.append('widgetId', __tagembed__widgetId); | |
| 342 | + if (__tagembed__loader_status) | |
| 343 | + __tagembed__open_loader(); | |
| 344 | + fetch(__tagembed__ajax_url, { | |
| 345 | + method: 'POST', | |
| 346 | + headers: { | |
| 347 | + 'x-requested-with': 'XMLHttpRequest', | |
| 348 | + }, | |
| 349 | + body: formData, | |
| 350 | + }).then(response => { | |
| 351 | + return response.json() | |
| 352 | + }).then(response => { | |
| 353 | + if (__tagembed__loader_status) | |
| 354 | + __tagembed__close_loader(); | |
| 355 | + if (response.status == true) { | |
| 356 | + /*--Start--Reload Page For Manage Active Class On Widget Page*/ | |
| 357 | + if (document.querySelector("#__tagembed__widgetbox0")) | |
| 358 | + location.reload(); | |
| 359 | + /*--End--Reload Page For Manage Active Class On Widget Page*/ | |
| 360 | + } else { | |
| 361 | + if (response.hasOwnProperty("message")) { | |
| 362 | + __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); | |
| 363 | + } else { | |
| 364 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 365 | + } | |
| 366 | + } | |
| 367 | + }).catch((error) => { | |
| 368 | + console.log(error); | |
| 369 | + __tagembed__close_loader(); | |
| 370 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 371 | + }); | |
| 294 | 372 | } |
| 295 | 373 | /*--End-- Manage Active Widget*/ |
| 296 | 374 | /*--Start--Create Widget*/ |
| 297 | 375 | var __tagembed__widget_create_form = document.querySelector("#__tagembed__widget_create_form"); |
| 298 | 376 | if (__tagembed__widget_create_form) { |
| 299 | - __tagembed__widget_create_form.addEventListener("click", function (event) { | |
| 300 | - __tagembed__dialog_form({popupSize: '__tagembed__popup_md', title: 'Create Widget', | |
| 301 | - form: {method: 'post', buttonText: 'Create'}, | |
| 302 | - inputs: [{label: 'Widget Name', type: 'text', name: 'name', placeholder: 'Enter your widget name e.g. mywidget'}, {label: 'Profanity Filter', type: 'checkbox', name: 'profanity'}], | |
| 303 | - action: function (event, formData) { | |
| 304 | - let __tagembed__name_error = document.querySelector("#__tagembed__name_error"); | |
| 305 | - __tagembed__name_error.style.display = 'none'; | |
| 306 | - if (!formData.get('name')) { | |
| 307 | - __tagembed__name_error.style.display = 'block'; | |
| 308 | - __tagembed__name_error.textContent = "Widget name is required"; | |
| 309 | - return; | |
| 310 | - } | |
| 311 | - __tagembed__open_loader(); | |
| 312 | - let __tagembed__toast = new TagembedToast; | |
| 313 | - formData.append('action', 'data'); | |
| 314 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 315 | - formData.append('__tagembed__ajax_action', '__tagembed__create_widget'); | |
| 316 | - fetch(__tagembed__ajax_url, { | |
| 317 | - method: 'POST', | |
| 318 | - headers: { | |
| 319 | - 'x-requested-with': 'XMLHttpRequest', | |
| 320 | - }, | |
| 321 | - body: formData, | |
| 322 | - }).then(response => { | |
| 323 | - return response.json(); | |
| 324 | - }).then(response => { | |
| 325 | - __tagembed__close_loader(); | |
| 326 | - if (response.status == true) { | |
| 327 | - document.querySelector('#__tagembed__dialog_form_id_').remove(); | |
| 328 | - if (response.data.hasOwnProperty("message")) { | |
| 329 | - __tagembed__toast.success({message: response.data.message, position: '__tagembed__is-top-right'}); | |
| 330 | - } | |
| 331 | - window.location.replace(response.data.redirectUrl); | |
| 332 | - } else { | |
| 333 | - if (response.hasOwnProperty("data") && Object.keys(response.data).length > 0) { | |
| 334 | - if (response.data.hasOwnProperty("name")) { | |
| 335 | - __tagembed__name_error.style.display = 'block'; | |
| 336 | - __tagembed__name_error.textContent = response.data.name; | |
| 337 | - } | |
| 338 | - } else { | |
| 339 | - if (response.hasOwnProperty("message")) { | |
| 340 | - __tagembed__toast.danger({message: response.message, position: '__tagembed__is-top-right'}); | |
| 341 | - } else { | |
| 342 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 343 | - } | |
| 344 | - } | |
| 345 | - } | |
| 346 | - }).catch((error) => { | |
| 347 | - console.log(error); | |
| 348 | - __tagembed__close_loader(); | |
| 349 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 350 | - }); | |
| 351 | - } | |
| 352 | - }); | |
| 353 | - }); | |
| 377 | + __tagembed__widget_create_form.addEventListener("click", function (event) { | |
| 378 | + __tagembed__dialog_form({ | |
| 379 | + popupSize: '__tagembed__popup_md', title: 'Create Widget', | |
| 380 | + form: { method: 'post', buttonText: 'Create' }, | |
| 381 | + inputs: [{ label: 'Widget Name', type: 'text', name: 'name', placeholder: 'Enter your widget name e.g. mywidget' }, { label: 'Profanity Filter', type: 'checkbox', name: 'profanity' }], | |
| 382 | + action: function (event, formData) { | |
| 383 | + let __tagembed__name_error = document.querySelector("#__tagembed__name_error"); | |
| 384 | + __tagembed__name_error.style.display = 'none'; | |
| 385 | + if (!formData.get('name')) { | |
| 386 | + __tagembed__name_error.style.display = 'block'; | |
| 387 | + __tagembed__name_error.textContent = "Widget name is required"; | |
| 388 | + return; | |
| 389 | + } | |
| 390 | + __tagembed__open_loader(); | |
| 391 | + let __tagembed__toast = new TagembedToast; | |
| 392 | + formData.append('action', 'tagembed_data'); | |
| 393 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 394 | + formData.append('__tagembed__ajax_action', '__tagembed__create_widget'); | |
| 395 | + fetch(__tagembed__ajax_url, { | |
| 396 | + method: 'POST', | |
| 397 | + headers: { | |
| 398 | + 'x-requested-with': 'XMLHttpRequest', | |
| 399 | + }, | |
| 400 | + body: formData, | |
| 401 | + }).then(response => { | |
| 402 | + return response.json(); | |
| 403 | + }).then(response => { | |
| 404 | + __tagembed__close_loader(); | |
| 405 | + if (response.status == true) { | |
| 406 | + document.querySelector('#__tagembed__dialog_form_id_').remove(); | |
| 407 | + if (response.data.hasOwnProperty("message")) { | |
| 408 | + __tagembed__toast.success({ message: response.data.message, position: '__tagembed__is-top-right' }); | |
| 409 | + } | |
| 410 | + window.location.replace(response.data.redirectUrl); | |
| 411 | + } else { | |
| 412 | + if (response.hasOwnProperty("data") && Object.keys(response.data).length > 0) { | |
| 413 | + if (response.data.hasOwnProperty("name")) { | |
| 414 | + __tagembed__name_error.style.display = 'block'; | |
| 415 | + __tagembed__name_error.textContent = response.data.name; | |
| 416 | + } | |
| 417 | + } else { | |
| 418 | + if (response.hasOwnProperty("message")) { | |
| 419 | + __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); | |
| 420 | + } else { | |
| 421 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 422 | + } | |
| 423 | + } | |
| 424 | + } | |
| 425 | + }).catch((error) => { | |
| 426 | + console.log(error); | |
| 427 | + __tagembed__close_loader(); | |
| 428 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 429 | + }); | |
| 430 | + } | |
| 431 | + }); | |
| 432 | + }); | |
| 354 | 433 | } |
| 355 | 434 | /*--End--Create Widget*/ |
| 356 | 435 | /*--Start--Manage Menue Hide Show In Mobile*/ |
| 357 | 436 | function __tagembed__manageMenueHideShowInMobile() { |
| 358 | - let __tagembed__menulist = document.querySelector("#__tagembed__menulist"); | |
| 359 | - let __tagembed__burger = document.querySelector("#__tagembed__burger"); | |
| 360 | - if (__tagembed__menulist.style.display === "none") { | |
| 361 | - __tagembed__menulist.style.display = "block"; | |
| 362 | - __tagembed__burger.classList.add("__tagembed__addclose"); | |
| 363 | - } else { | |
| 364 | - __tagembed__menulist.style.display = "none"; | |
| 365 | - __tagembed__burger.classList.remove("__tagembed__addclose"); | |
| 366 | - } | |
| 437 | + let __tagembed__menulist = document.querySelector("#__tagembed__menulist"); | |
| 438 | + let __tagembed__burger = document.querySelector("#__tagembed__burger"); | |
| 439 | + if (__tagembed__menulist.style.display === "none") { | |
| 440 | + __tagembed__menulist.style.display = "block"; | |
| 441 | + __tagembed__burger.classList.add("__tagembed__addclose"); | |
| 442 | + } else { | |
| 443 | + __tagembed__menulist.style.display = "none"; | |
| 444 | + __tagembed__burger.classList.remove("__tagembed__addclose"); | |
| 445 | + } | |
| 367 | 446 | } |
| 368 | 447 | /*--Start--Manage Menue Hide Show In Mobile*/ |
| 369 | 448 | /*--Start--Manage Toggel On Press Space Button*/ |
| 370 | 449 | function __tagembed__manageToggelOnPressSpace() { |
| 371 | - let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog"); | |
| 372 | - if (tagembedConfirmDialog) | |
| 373 | - return true; | |
| 374 | - return false; | |
| 450 | + let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog"); | |
| 451 | + if (tagembedConfirmDialog) | |
| 452 | + return true; | |
| 453 | + return false; | |
| 375 | 454 | } |
| 376 | 455 | /*--End--Manage Toggel On Press Space Button*/ |
| 377 | 456 | /*--Start-- Add And Update Connected Account*/ |
| 378 | 457 | 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) { |
| 379 | - if (__tagembed__networkId) { | |
| 380 | - let __tagembed__toast = new TagembedToast; | |
| 381 | - let formData = new FormData(); | |
| 382 | - formData.append('action', 'data'); | |
| 383 | - formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 384 | - formData.append('__tagembed__ajax_action', '__tagembed__add_or_update_account'); | |
| 385 | - formData.append('type', __tagembed__type); | |
| 386 | - formData.append('connectedAccountId', __tagembed__connected_account_id); | |
| 387 | - formData.append('feedId', __tagembed__feed_id); | |
| 388 | - formData.append('networkId', __tagembed__networkId); | |
| 389 | - formData.append('filterId', __tagembed__feed_filter_id); | |
| 390 | - formData.append('otherData', __tagembed__other_data); | |
| 391 | - __tagembed__open_loader(); | |
| 392 | - fetch(__tagembed__ajax_url, { | |
| 393 | - method: 'POST', | |
| 394 | - headers: { | |
| 395 | - 'x-requested-with': 'XMLHttpRequest', | |
| 396 | - }, | |
| 397 | - body: formData, | |
| 398 | - }).then(response => { | |
| 399 | - return response.json() | |
| 400 | - }).then(response => { | |
| 401 | - if (response.status == true) { | |
| 402 | - /*window.open(response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');*/ | |
| 403 | - let __tagembed__Url = response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl; | |
| 404 | - __tagmebed__openWindowPopup(__tagembed__Url); | |
| 458 | + if (__tagembed__networkId) { | |
| 459 | + let __tagembed__toast = new TagembedToast; | |
| 460 | + let formData = new FormData(); | |
| 461 | + formData.append('action', 'tagembed_data'); | |
| 462 | + formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); | |
| 463 | + formData.append('__tagembed__ajax_action', '__tagembed__add_or_update_account'); | |
| 464 | + formData.append('type', __tagembed__type); | |
| 465 | + formData.append('connectedAccountId', __tagembed__connected_account_id); | |
| 466 | + formData.append('feedId', __tagembed__feed_id); | |
| 467 | + formData.append('networkId', __tagembed__networkId); | |
| 468 | + formData.append('filterId', __tagembed__feed_filter_id); | |
| 469 | + formData.append('otherData', __tagembed__other_data); | |
| 470 | + __tagembed__open_loader(); | |
| 471 | + fetch(__tagembed__ajax_url, { | |
| 472 | + method: 'POST', | |
| 473 | + headers: { | |
| 474 | + 'x-requested-with': 'XMLHttpRequest', | |
| 475 | + }, | |
| 476 | + body: formData, | |
| 477 | + }).then(response => { | |
| 478 | + return response.json() | |
| 479 | + }).then(response => { | |
| 480 | + if (response.status == true) { | |
| 481 | + /*window.open(response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');*/ | |
| 482 | + let __tagembed__Url = response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl; | |
| 483 | + __tagmebed__openWindowPopup(__tagembed__Url); | |
| 405 | 484 | |
| 406 | - } else { | |
| 407 | - __tagembed__close_loader(); | |
| 408 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 409 | - } | |
| 410 | - }).catch((error) => { | |
| 411 | - console.log(error); | |
| 412 | - __tagembed__close_loader(); | |
| 413 | - __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); | |
| 414 | - }); | |
| 485 | + } else { | |
| 486 | + __tagembed__close_loader(); | |
| 487 | + if (response.hasOwnProperty("message")) { | |
| 488 | + __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); | |
| 489 | + } else { | |
| 490 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 491 | + } | |
| 492 | + } | |
| 493 | + }).catch((error) => { | |
| 494 | + console.log(error); | |
| 495 | + __tagembed__close_loader(); | |
| 496 | + __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); | |
| 497 | + }); | |
| 498 | + } | |
| 415 | 499 | } |
| 416 | -} | |
| 417 | 500 | /*--End-- Add And Update Connected Account*/ |
| 418 | 501 | /*--Start-- Manage Short Code*/ |
| 419 | 502 | window.addEventListener ? window.addEventListener("load", __tagembed__manageShotrCode, false) : window.attachEvent && window.attachEvent("onload", __tagembed__manageShotrCode); |
| 420 | 503 | function __tagembed__manageShotrCode() { |
| 421 | - let widgetData = document.querySelector("#__tagembed__widgets"); | |
| 422 | - if (widgetData) { | |
| 423 | - let __tagembed__widgetId = widgetData.selectedOptions[0].value.split('#')[0]; | |
| 424 | - let __tagembed__shortCode = document.querySelector("#__tagembed__shortCode"); | |
| 425 | - if (__tagembed__shortCode) | |
| 426 | - __tagembed__shortCode.innerHTML = `[tagembed widgetid ${__tagembed__widgetId}]`; | |
| 427 | - } | |
| 504 | + let widgetData = document.querySelector("#__tagembed__widgets"); | |
| 505 | + if (widgetData) { | |
| 506 | + let __tagembed__widgetId = widgetData.selectedOptions[0].value.split('#')[0]; | |
| 507 | + let __tagembed__shortCode = document.querySelector("#__tagembed__shortCode"); | |
| 508 | + if (__tagembed__shortCode) | |
| 509 | + __tagembed__shortCode.textContent = `[tagembed widgetid ${__tagembed__widgetId}]`; | |
| 510 | + } | |
| 428 | 511 | } |
| 429 | 512 | /*--Start--Copy Short Code*/ |
| 430 | -function __tagembed__copyCodeEmbed(__tagembed__codeType, __tagembed__copyEmbedId) { | |
| 431 | - let __tagembed__toast = new TagembedToast; | |
| 432 | - let __tagembed__copyEmbedCode = ""; | |
| 433 | - console.log(__tagembed__copyEmbedId); | |
| 434 | - switch (__tagembed__codeType) { | |
| 435 | - case "shortCode": | |
| 436 | - __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).innerHTML; | |
| 437 | - break; | |
| 438 | - case "embedCode": | |
| 439 | - __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).value; | |
| 440 | - break; | |
| 441 | - } | |
| 442 | - navigator.clipboard.writeText(__tagembed__copyEmbedCode); | |
| 443 | - __tagembed__toast.success({message: 'copied', position: '__tagembed__is-top-right'}); | |
| 513 | +async function __tagembed__copyCodeEmbed(__tagembed__codeType, __tagembed__copyEmbedId) { | |
| 514 | + | |
| 515 | + let ___tagembed__shouldStop = await __tagembed__upgradePlan(); | |
| 516 | + if (___tagembed__shouldStop) return; | |
| 517 | + | |
| 518 | + let __tagembed__toast = new TagembedToast; | |
| 519 | + let __tagembed__copyEmbedCode = ""; | |
| 520 | + switch (__tagembed__codeType) { | |
| 521 | + case "shortCode": | |
| 522 | + __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).textContent; | |
| 523 | + break; | |
| 524 | + case "embedCode": | |
| 525 | + __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).value; | |
| 526 | + break; | |
| 527 | + } | |
| 528 | + navigator.clipboard.writeText(__tagembed__copyEmbedCode); | |
| 529 | + __tagembed__toast.success({ message: 'copied', position: '__tagembed__is-top-right' }); | |
| 444 | 530 | } |
| 445 | 531 | /*--End--Copy Short Code*/ |
| 446 | -/*--Start --Open Crisp Chat On Click*/ | |
| 447 | -function __tagembed__openCrispChat() { | |
| 448 | - $crisp.push(['do', 'chat:open']); | |
| 449 | -} | |
| 450 | -/*--End --Open Crisp Chat On Click*/ | |
| 451 | 532 | |