Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. <script>
  2. (function(ownerId) {
  3. document.addEventListener("pageChange", function() {
  4. loadEcwid();
  5. }, false);
  6. loadEcwid();
  7.  
  8. function loadEcwid() {
  9. var containerId = 'my-store-' + ownerId;
  10. var container = document.getElementById(containerId);
  11. var isEcwidPage = container != null;
  12. var ecwidLoaded = isEcwidPage && container.childNodes.length > 0;
  13. if (ecwidLoaded && isEcwidPage) return;
  14. if (!isEcwidPage) {
  15. if (typeof Ecwid != 'undefined') {
  16. Ecwid.destroy();
  17. removeElementsByClassName("ecwid-minicart");
  18. removeElementsByClassName("ecwid-pswp");
  19. }
  20. return;
  21. }
  22.  
  23. window.ecwid_script_defer = true;
  24. window.ecwid_dynamic_widgets = true;
  25. window.css_selectors_prefix = encodeURIComponent('div#' + containerId);
  26.  
  27. var defaultCategoryId = (!!container.dataset['defaultCategoryId']?'defaultCategoryId=' + container.dataset['defaultCategoryId'] : '')
  28. window._xnext_initialization_scripts = [];
  29.  
  30. if (typeof Ecwid != 'undefined') {
  31. window.ecwid_bodyDone = false;
  32. ecwid_onBodyDone();
  33. Ecwid.init();
  34. } else {
  35. var script = document.createElement('script');
  36. script.charset = 'utf-8';
  37. script.type = 'text/javascript';
  38. script.id = 'ecwid-script';
  39. script.onload = function(){Ecwid.init()};
  40. script.src = 'https://app.ecwid.com/script.js?' + ownerId;
  41. container.parentNode.appendChild(script);
  42. }
  43. }
  44.  
  45. function removeElementsByClassName(className) {
  46. var elements = document.getElementsByClassName(className);
  47. for (var i = 0; i < elements.length; i++) {
  48. elements[i].parentNode.removeChild(elements[i]);
  49. }
  50. }
  51.  
  52. // init watch function
  53. window.onload = watch;
  54. function watch() {
  55. var observedAttributeName = "id";
  56. MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  57. var a = new MutationObserver(function (a) {
  58. var dispatchedId;
  59. for (var b = 0; b < a.length; b++) {
  60. var c = a[b];
  61. if ("attributes" === c.type) {
  62. var targetId = c.target[observedAttributeName];
  63. if (dispatchedId && dispatchedId == targetId) return;
  64. dispatchedId = targetId;
  65. var d = new Event("pageChange");
  66. document.dispatchEvent(d)
  67. }
  68. }
  69. });
  70. a.observe(document.body, {attributes: !0, attributeFilter: [observedAttributeName]})
  71. }
  72. function getValueSave(id, attribute) {
  73. var node = document.querySelector("#" + id);
  74. return !node
  75. ? ""
  76. : (!node.getAttribute(attribute)
  77. ? ""
  78. : node.getAttribute(attribute))
  79. }
  80. })(12744044);
  81. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement