| @@ -1,7 +1,45 @@ | ||
| 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'); | |
| 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*/ | |
| 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(); | |
| 4 | 42 | var __tagembed__window_pupup_timer = setInterval(function () { |
| 5 | 43 | if (__tagmebed__window_popup.closed) { |
| 6 | 44 | location.reload(); |
| 7 | 45 | clearInterval(__tagembed__window_pupup_timer); |
| @@ -6,522 +44,489 @@ | ||
| 6 | 44 | location.reload(); |
| 7 | 45 | clearInterval(__tagembed__window_pupup_timer); |
| 8 | 46 | } |
| 9 | 47 | }, 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 | 48 | }*/ |
| 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 | - }); | |
| 49 | +function __tagmebed__openWindowPopup(url, windowName = "Tagembed") { | |
| 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); | |
| 56 | 57 | } |
| 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"; | |
| 58 | +function __tagmebed__closeWindowPopup() { | |
| 59 | + if (__tagmebed__window_popup) | |
| 60 | + __tagmebed__window_popup.close(); | |
| 60 | 61 | } |
| 61 | -/*--End-- Manage Hide And Show plugin Upgrade Message*/ | |
| 62 | +/*--End-- Create And Manage Window Popup*/ | |
| 63 | + | |
| 64 | +/*--Start--Hide/Show Loader During Page Readay State*/ | |
| 65 | +document.onreadystatechange = function () { | |
| 66 | + if (document.readyState !== "complete") { | |
| 67 | + __tagembed__open_loader(); | |
| 68 | + } else { | |
| 69 | + __tagembed__close_loader(); | |
| 70 | + } | |
| 71 | +}; | |
| 72 | +/*--End--Hide/Show Loader During Page Readay State*/ | |
| 73 | + | |
| 62 | 74 | /*--Start-- Manage Response Message*/ |
| 63 | 75 | window.addEventListener ? window.addEventListener("load", __tagembed__message, false) : window.attachEvent && window.attachEvent("onload", __tagembed__message); |
| 64 | 76 | 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 | - } | |
| 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 | + } | |
| 116 | 174 | } |
| 117 | 175 | /*--End-- Manage Response Message*/ |
| 118 | 176 | /*--Start--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 119 | 177 | 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; | |
| 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; | |
| 125 | 183 | } |
| 126 | 184 | /*--End--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 127 | 185 | /*--Start-- Logout*/ |
| 128 | 186 | var __tagembed__logout = document.querySelector("#__tagembed__logout"); |
| 129 | 187 | 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 | - }); | |
| 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 | + }); | |
| 159 | 222 | } |
| 160 | 223 | /*--End-- Logout*/ |
| 224 | + | |
| 161 | 225 | /*--Start--Manage Tagembed Menue*/ |
| 162 | 226 | 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 | - }); | |
| 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 | + }); | |
| 189 | 261 | } |
| 190 | 262 | /*--End--Manage Tagembed Menue*/ |
| 191 | 263 | /*--Start-- Get Already Exist Auth*/ |
| 192 | 264 | 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 | - }); | |
| 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 | + }); | |
| 211 | 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 | +} | |
| 212 | 309 | /*--End-- Get Already Exist Auth*/ |
| 213 | 310 | /*--Start-- Manage Active Widget*/ |
| 214 | 311 | var __tagembed__widgets = document.querySelector("#__tagembed__widgets"); |
| 215 | 312 | 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 | - }); | |
| 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 | + }); | |
| 233 | 330 | } |
| 234 | 331 | 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 | - }); | |
| 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 | + }); | |
| 271 | 372 | } |
| 272 | 373 | /*--End-- Manage Active Widget*/ |
| 273 | 374 | /*--Start--Create Widget*/ |
| 274 | 375 | var __tagembed__widget_create_form = document.querySelector("#__tagembed__widget_create_form"); |
| 275 | 376 | 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 | - }); | |
| 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 | + }); | |
| 330 | 433 | } |
| 331 | 434 | /*--End--Create Widget*/ |
| 332 | 435 | /*--Start--Manage Menue Hide Show In Mobile*/ |
| 333 | 436 | 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 | - } | |
| 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 | + } | |
| 343 | 446 | } |
| 344 | 447 | /*--Start--Manage Menue Hide Show In Mobile*/ |
| 345 | 448 | /*--Start--Manage Toggel On Press Space Button*/ |
| 346 | 449 | function __tagembed__manageToggelOnPressSpace() { |
| 347 | - let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog"); | |
| 348 | - if (tagembedConfirmDialog) | |
| 349 | - return true; | |
| 350 | - return false; | |
| 450 | + let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog"); | |
| 451 | + if (tagembedConfirmDialog) | |
| 452 | + return true; | |
| 453 | + return false; | |
| 351 | 454 | } |
| 352 | 455 | /*--End--Manage Toggel On Press Space Button*/ |
| 353 | 456 | /*--Start-- Add And Update Connected Account*/ |
| 354 | 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) { |
| 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 => { | |
| 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); | |
| 376 | 484 | |
| 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 | - }); | |
| 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 | + } | |
| 388 | 499 | } |
| 389 | -} | |
| 390 | 500 | /*--End-- Add And Update Connected Account*/ |
| 391 | 501 | /*--Start-- Manage Short Code*/ |
| 392 | 502 | window.addEventListener ? window.addEventListener("load", __tagembed__manageShotrCode, false) : window.attachEvent && window.attachEvent("onload", __tagembed__manageShotrCode); |
| 393 | 503 | 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 | - } | |
| 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 | + } | |
| 401 | 511 | } |
| 402 | 512 | /*--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'}); | |
| 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' }); | |
| 417 | 530 | } |
| 418 | 531 | /*--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 | 532 | |