PluginProbe
Tagembed: Social Media Feeds and Customer Reviews Widget / 7.6
Tagembed: Social Media Feeds and Customer Reviews Widget v7.6
7.8 7.5 7.6 7.7 7.4 trunk 3.10 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 All 43 releases
tagembed-widget / assets / js / tagembed.common.js

tagembed.common.js in Tagembed: Social Media Feeds and Customer Reviews Widget 7.6, at assets/js/tagembed.common.js

511 lines 23.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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();
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 }*/
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);
57 }
58 function __tagmebed__closeWindowPopup() {
59 if (__tagmebed__window_popup)
60 __tagmebed__window_popup.close();
61 }
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
74 /*--Start-- Manage Response Message*/
75 window.addEventListener ? window.addEventListener("load", __tagembed__message, false) : window.attachEvent && window.attachEvent("onload", __tagembed__message);
76 function __tagembed__message() {
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 if (__tagembed__message.hasOwnProperty("planName") && __tagembed__message.hasOwnProperty("amount") && __tagembed__message.hasOwnProperty("paymentId")) {
102 let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup");
103 /* Built with DOM methods. The three query string values are inserted as text
104 nodes only, so no markup can be produced from them. */
105 let __tagembed__makeElement = function (tag, className) {
106 let __tagembed__element = document.createElement(tag);
107 if (className) __tagembed__element.className = className;
108 return __tagembed__element;
109 };
110 let __tagembed__makePlanBox = function (label, value) {
111 let __tagembed__box = __tagembed__makeElement("div", "__tagembed__planbox");
112 let __tagembed__label = document.createElement("p");
113 __tagembed__label.textContent = label;
114 let __tagembed__value = document.createElement("span");
115 __tagembed__value.textContent = (value === undefined || value === null) ? "" : String(value);
116 __tagembed__box.appendChild(__tagembed__label);
117 __tagembed__box.appendChild(__tagembed__value);
118 return __tagembed__box;
119 };
120 let __tagembed__wrap = __tagembed__makeElement("div", "__tagembed__popupwrap __tagembed__popup_md");
121 let __tagembed__closeBtn = __tagembed__makeElement("button", "__tagembed__closebtn");
122 __tagembed__closeBtn.setAttribute("id", "__tagembed__upgrade_account_popup_close_btn");
123 __tagembed__closeBtn.setAttribute("type", "button");
124 __tagembed__closeBtn.addEventListener("click", __tagembed__hide_upgrade_account_popup);
125 let __tagembed__inn = __tagembed__makeElement("div", "__tagembed__popupinn");
126 let __tagembed__body = __tagembed__makeElement("div", "__tagembed__formwbody");
127 let __tagembed__thankyou = __tagembed__makeElement("div", "__tagembed__thankyou");
128 let __tagembed__checkImg = document.createElement("img");
129 __tagembed__checkImg.setAttribute("src", __tagembed__plugin_url_for_js + "assets/images/check-green.png");
130 __tagembed__checkImg.setAttribute("alt", "check");
131 let __tagembed__heading = document.createElement("h2");
132 __tagembed__heading.appendChild(document.createTextNode("Congratulations! "));
133 let __tagembed__headingSpan = document.createElement("span");
134 __tagembed__headingSpan.textContent = "Your account has been upgraded";
135 __tagembed__heading.appendChild(__tagembed__headingSpan);
136 let __tagembed__detail = __tagembed__makeElement("div", "__tagembed__plandetail");
137 __tagembed__detail.appendChild(__tagembed__makePlanBox("Amount", "$" + __tagembed__message.amount));
138 __tagembed__detail.appendChild(__tagembed__makePlanBox("Payment Id", __tagembed__message.paymentId));
139 __tagembed__detail.appendChild(__tagembed__makePlanBox("Plan", __tagembed__message.planName));
140 __tagembed__thankyou.appendChild(__tagembed__checkImg);
141 __tagembed__thankyou.appendChild(__tagembed__heading);
142 __tagembed__thankyou.appendChild(__tagembed__detail);
143 __tagembed__body.appendChild(__tagembed__thankyou);
144 __tagembed__inn.appendChild(__tagembed__body);
145 __tagembed__wrap.appendChild(__tagembed__closeBtn);
146 __tagembed__wrap.appendChild(__tagembed__inn);
147 __tagembed__upgrade_account_popup.replaceChildren(__tagembed__wrap);
148 __tagembed__upgrade_account_popup.style.display = "block";
149 }
150 /*--End--Show Popup On Plan Upgrade Time*/
151 }
152 }
153 /*--End-- Manage Response Message*/
154 /*--Start--Manage Windiow Onload Function When Response Message Exist In Query String*/
155 function __tagembed__manageApiCall() {
156 let urlSearchParams = new URLSearchParams(window.location.search);
157 let __tagembed__message = Object.fromEntries(urlSearchParams.entries());
158 if (__tagembed__message.hasOwnProperty("__tagembed__message"))
159 return true
160 return false;
161 }
162 /*--End--Manage Windiow Onload Function When Response Message Exist In Query String*/
163 /*--Start-- Logout*/
164 var __tagembed__logout = document.querySelector("#__tagembed__logout");
165 if (__tagembed__logout) {
166 __tagembed__logout.addEventListener('click', function (event) {
167 __tagembed__confirmDialog({ title: 'Yes, sign out', message: 'Are you sure! do you want to sign out?', buttonText: 'Sign Out', type: 'warning' }, function () {
168 let formData = new FormData();
169 formData.append('action', 'tagembed_data');
170 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
171 formData.append('__tagembed__ajax_action', '__tagembed__logout');
172 __tagembed__open_loader();
173 let __tagembed__toast = new TagembedToast;
174 fetch(__tagembed__ajax_url, {
175 method: 'POST',
176 headers: {
177 'x-requested-with': 'XMLHttpRequest',
178 },
179 body: formData,
180 }).then(response => {
181 return response.json()
182 }).then(response => {
183 __tagembed__close_loader();
184 if (response.status == true) {
185 window.location.replace(response.data.redirectUrl);
186 } else {
187 if (response.hasOwnProperty("message")) {
188 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
189 } else {
190 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
191 }
192 }
193 }).catch((error) => {
194 console.log(error);
195 __tagembed__close_loader();
196 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
197 });
198 });
199 });
200 }
201 /*--End-- Logout*/
202
203 /*--Start--Manage Tagembed Menue*/
204 function __tagembed__menus(__tagembed__menu_id, __tagembed__widgetId = null) {
205 if (__tagembed__widgetId)
206 __tagembed__manageActiveWidget(__tagembed__widgetId);
207 __tagembed__open_loader();
208 let __tagembed__toast = new TagembedToast;
209 let formData = new FormData();
210 formData.append('action', 'tagembed_data');
211 formData.append('menueId', __tagembed__menu_id);
212 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
213 formData.append('__tagembed__ajax_action', '__tagembed__menue');
214 fetch(__tagembed__ajax_url, {
215 method: 'POST',
216 headers: {
217 'x-requested-with': 'XMLHttpRequest',
218 },
219 body: formData,
220 }).then(response => {
221 return response.json()
222 }).then(response => {
223 if (response.status == true) {
224 return window.location.replace(response.data.redirectUrl);
225 /*return window.location.href = response.data.redirectUrl;*/
226 } else {
227 __tagembed__close_loader();
228 if (response.hasOwnProperty("message")) {
229 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
230 } else {
231 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
232 }
233 }
234 }).catch((error) => {
235 console.log(error);
236 __tagembed__close_loader();
237 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
238 });
239 }
240 /*--End--Manage Tagembed Menue*/
241 /*--Start-- Get Already Exist Auth*/
242 function __tagembed__get_already_exist_auth(__tagembed__network_id) {
243 if (!__tagembed__network_id)
244 return;
245 let formData = new FormData();
246 formData.append('networkId', __tagembed__network_id);
247 formData.append('action', 'tagembed_data');
248 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
249 formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth');
250 fetch(__tagembed__ajax_url, {
251 method: 'POST',
252 headers: {
253 'x-requested-with': 'XMLHttpRequest',
254 },
255 body: formData,
256 }).then(response => {
257 return response.json()
258 }).then(response => {
259 if (response.status == true)
260 __tagembed__network_already_exist_auth = response.data;
261 });
262 }
263 /*Note : This Use For Merge Instagram 2/18*/
264 function __tagembed__get_already_exist_auth_new(__tagembed__network_id, __tagembed__feed_data) {
265 if (!__tagembed__network_id)
266 return;
267 __tagembed__open_loader();
268 let formData = new FormData();
269 formData.append('networkId', __tagembed__network_id);
270 formData.append('action', 'tagembed_data');
271 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
272 formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth');
273 fetch(__tagembed__ajax_url, {
274 method: 'POST',
275 headers: { 'x-requested-with': 'XMLHttpRequest', },
276 body: formData,
277 }).then(response => {
278 return response.json()
279 }).then(response => {
280 if (response.status == true) {
281 __tagembed__network_already_exist_auth = response.data;
282 __tagembed__createInstagramBusinessFeed(__tagembed__feed_data);
283 __tagembed__close_loader();
284 }
285 });
286 }
287 /*--End-- Get Already Exist Auth*/
288 /*--Start-- Manage Active Widget*/
289 var __tagembed__widgets = document.querySelector("#__tagembed__widgets");
290 if (__tagembed__widgets) {
291 __tagembed__widgets.addEventListener("change", function (event) {
292 if (typeof __tagembed__get_theme !== 'undefined')
293 __tagembed__get_theme(); /*Manage Widget Theme According Widget*/
294 if (typeof __tagembed__changeIfrmSrc !== 'undefined')
295 __tagembed__changeIfrmSrc(); /*Manage Widget Display Preview According Widget*/
296 if (typeof __tagembed__manageShotrCode !== 'undefined')
297 __tagembed__manageShotrCode(); /*Manage Short Code According Widget*/
298 if (typeof __tagembed__manageEmbedCode !== 'undefined')
299 __tagembed__manageEmbedCode(); /*Manage Embed Code According Widget*/
300 if (typeof __tagembed__getFeed !== 'undefined')
301 __tagembed__getFeed(); /*Get Feed According Widget*/
302 if (typeof __tagembed__changeFilterIfrmSrc !== 'undefined')
303 __tagembed__changeFilterIfrmSrc(); /*Mange Filter Section According Widget*/
304 __tagembed__manageActiveWidget(); /*Manage Active Widget*/
305 if (typeof __tagembed__getCustomizationOption !== 'undefined')/*Call Get Customization Options*/
306 __tagembed__getCustomizationOption();
307 });
308 }
309 function __tagembed__manageActiveWidget(__tagembed__widgetId = null) {
310 if (!__tagembed__widgetId) {
311 __tagembed__widgetId = document.querySelector("#__tagembed__widgets").selectedOptions[0];
312 __tagembed__widgetId = __tagembed__widgetId.value.split('#')[0];
313 }
314 let __tagembed__toast = new TagembedToast;
315 let formData = new FormData();
316 formData.append('action', 'tagembed_data');
317 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
318 formData.append('__tagembed__ajax_action', '__tagembed__manage_active_widget');
319 formData.append('widgetId', __tagembed__widgetId);
320 if (__tagembed__loader_status)
321 __tagembed__open_loader();
322 fetch(__tagembed__ajax_url, {
323 method: 'POST',
324 headers: {
325 'x-requested-with': 'XMLHttpRequest',
326 },
327 body: formData,
328 }).then(response => {
329 return response.json()
330 }).then(response => {
331 if (__tagembed__loader_status)
332 __tagembed__close_loader();
333 if (response.status == true) {
334 /*--Start--Reload Page For Manage Active Class On Widget Page*/
335 if (document.querySelector("#__tagembed__widgetbox0"))
336 location.reload();
337 /*--End--Reload Page For Manage Active Class On Widget Page*/
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 }).catch((error) => {
346 console.log(error);
347 __tagembed__close_loader();
348 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
349 });
350 }
351 /*--End-- Manage Active Widget*/
352 /*--Start--Create Widget*/
353 var __tagembed__widget_create_form = document.querySelector("#__tagembed__widget_create_form");
354 if (__tagembed__widget_create_form) {
355 __tagembed__widget_create_form.addEventListener("click", function (event) {
356 __tagembed__dialog_form({
357 popupSize: '__tagembed__popup_md', title: 'Create Widget',
358 form: { method: 'post', buttonText: 'Create' },
359 inputs: [{ label: 'Widget Name', type: 'text', name: 'name', placeholder: 'Enter your widget name e.g. mywidget' }, { label: 'Profanity Filter', type: 'checkbox', name: 'profanity' }],
360 action: function (event, formData) {
361 let __tagembed__name_error = document.querySelector("#__tagembed__name_error");
362 __tagembed__name_error.style.display = 'none';
363 if (!formData.get('name')) {
364 __tagembed__name_error.style.display = 'block';
365 __tagembed__name_error.textContent = "Widget name is required";
366 return;
367 }
368 __tagembed__open_loader();
369 let __tagembed__toast = new TagembedToast;
370 formData.append('action', 'tagembed_data');
371 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
372 formData.append('__tagembed__ajax_action', '__tagembed__create_widget');
373 fetch(__tagembed__ajax_url, {
374 method: 'POST',
375 headers: {
376 'x-requested-with': 'XMLHttpRequest',
377 },
378 body: formData,
379 }).then(response => {
380 return response.json();
381 }).then(response => {
382 __tagembed__close_loader();
383 if (response.status == true) {
384 document.querySelector('#__tagembed__dialog_form_id_').remove();
385 if (response.data.hasOwnProperty("message")) {
386 __tagembed__toast.success({ message: response.data.message, position: '__tagembed__is-top-right' });
387 }
388 window.location.replace(response.data.redirectUrl);
389 } else {
390 if (response.hasOwnProperty("data") && Object.keys(response.data).length > 0) {
391 if (response.data.hasOwnProperty("name")) {
392 __tagembed__name_error.style.display = 'block';
393 __tagembed__name_error.textContent = response.data.name;
394 }
395 } else {
396 if (response.hasOwnProperty("message")) {
397 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
398 } else {
399 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
400 }
401 }
402 }
403 }).catch((error) => {
404 console.log(error);
405 __tagembed__close_loader();
406 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
407 });
408 }
409 });
410 });
411 }
412 /*--End--Create Widget*/
413 /*--Start--Manage Menue Hide Show In Mobile*/
414 function __tagembed__manageMenueHideShowInMobile() {
415 let __tagembed__menulist = document.querySelector("#__tagembed__menulist");
416 let __tagembed__burger = document.querySelector("#__tagembed__burger");
417 if (__tagembed__menulist.style.display === "none") {
418 __tagembed__menulist.style.display = "block";
419 __tagembed__burger.classList.add("__tagembed__addclose");
420 } else {
421 __tagembed__menulist.style.display = "none";
422 __tagembed__burger.classList.remove("__tagembed__addclose");
423 }
424 }
425 /*--Start--Manage Menue Hide Show In Mobile*/
426 /*--Start--Manage Toggel On Press Space Button*/
427 function __tagembed__manageToggelOnPressSpace() {
428 let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog");
429 if (tagembedConfirmDialog)
430 return true;
431 return false;
432 }
433 /*--End--Manage Toggel On Press Space Button*/
434 /*--Start-- Add And Update Connected Account*/
435 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) {
436 if (__tagembed__networkId) {
437 let __tagembed__toast = new TagembedToast;
438 let formData = new FormData();
439 formData.append('action', 'tagembed_data');
440 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
441 formData.append('__tagembed__ajax_action', '__tagembed__add_or_update_account');
442 formData.append('type', __tagembed__type);
443 formData.append('connectedAccountId', __tagembed__connected_account_id);
444 formData.append('feedId', __tagembed__feed_id);
445 formData.append('networkId', __tagembed__networkId);
446 formData.append('filterId', __tagembed__feed_filter_id);
447 formData.append('otherData', __tagembed__other_data);
448 __tagembed__open_loader();
449 fetch(__tagembed__ajax_url, {
450 method: 'POST',
451 headers: {
452 'x-requested-with': 'XMLHttpRequest',
453 },
454 body: formData,
455 }).then(response => {
456 return response.json()
457 }).then(response => {
458 if (response.status == true) {
459 /*window.open(response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');*/
460 let __tagembed__Url = response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl;
461 __tagmebed__openWindowPopup(__tagembed__Url);
462
463 } else {
464 __tagembed__close_loader();
465 if (response.hasOwnProperty("message")) {
466 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
467 } else {
468 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
469 }
470 }
471 }).catch((error) => {
472 console.log(error);
473 __tagembed__close_loader();
474 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
475 });
476 }
477 }
478 /*--End-- Add And Update Connected Account*/
479 /*--Start-- Manage Short Code*/
480 window.addEventListener ? window.addEventListener("load", __tagembed__manageShotrCode, false) : window.attachEvent && window.attachEvent("onload", __tagembed__manageShotrCode);
481 function __tagembed__manageShotrCode() {
482 let widgetData = document.querySelector("#__tagembed__widgets");
483 if (widgetData) {
484 let __tagembed__widgetId = widgetData.selectedOptions[0].value.split('#')[0];
485 let __tagembed__shortCode = document.querySelector("#__tagembed__shortCode");
486 if (__tagembed__shortCode)
487 __tagembed__shortCode.textContent = `[tagembed widgetid ${__tagembed__widgetId}]`;
488 }
489 }
490 /*--Start--Copy Short Code*/
491 async function __tagembed__copyCodeEmbed(__tagembed__codeType, __tagembed__copyEmbedId) {
492
493 let ___tagembed__shouldStop = await __tagembed__upgradePlan();
494 if (___tagembed__shouldStop) return;
495
496 let __tagembed__toast = new TagembedToast;
497 let __tagembed__copyEmbedCode = "";
498 switch (__tagembed__codeType) {
499 case "shortCode":
500 __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).textContent;
501 break;
502 case "embedCode":
503 __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).value;
504 break;
505 }
506 navigator.clipboard.writeText(__tagembed__copyEmbedCode);
507 __tagembed__toast.success({ message: 'copied', position: '__tagembed__is-top-right' });
508 }
509 /*--End--Copy Short Code*/
510
511