Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.16 KB | None | 0 0
  1. function createCookie(a, b, c) {
  2. if (c) {
  3. var d = new Date;
  4. d.setTime(d.getTime() + c * 60 * 1e3);
  5. var e = "; expires=" + d.toUTCString()
  6. } else var e = "";
  7. document.cookie = a + "=" + b + e + "; path=/"
  8. }
  9.  
  10. function readCookie(a) {
  11. for (var b = a + "=", c = document.cookie.split(";"), d = 0; d < c.length; d++) {
  12. for (var e = c[d];
  13. " " == e.charAt(0);) e = e.substring(1, e.length);
  14. if (0 == e.indexOf(b)) return e.substring(b.length, e.length)
  15. }
  16. return null
  17. }
  18.  
  19. function eraseCookie(a) {
  20. createCookie(a, "", -1)
  21. }
  22.  
  23. function crtmedir(a) {
  24. var b = document.createDocumentFragment(),
  25. c = document.createElement("div");
  26. for (c.innerHTML = a; c.firstChild;) b.appendChild(c.firstChild);
  27. return b
  28. }
  29.  
  30. function startTimer(start, duration, display) {
  31. var diff, minutes, seconds;
  32.  
  33. function timer() {
  34. diff = duration - (((Date.now() - start) / 1000) | 0);
  35. minutes = (diff / 60) | 0;
  36. seconds = (diff % 60) | 0;
  37. minutes = minutes < 10 ? "0" + minutes : minutes;
  38. seconds = seconds < 10 ? "0" + seconds : seconds;
  39. display.textContent = minutes + ":" + seconds;
  40. if (diff <= 0) {
  41. clearInterval(inti);
  42. document.getElementById("countdownhere").innerHTML = "Order reservation ended.";
  43. start = Date.now() + 1000;
  44. }
  45. };
  46. timer();
  47. var inti = setInterval(timer, 1000);
  48. }
  49. var pdm = crtmedir('<div class="countdownholder"><div id="countdownhere" style="display:block;background:#fff5d2;padding:10px 20px;border:1px solid #e3df74;font-size:14px;color:#2c2c2c;font-weight:bold;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px; margin:20px 0px">Your order is reserved for <span id="time"></span> minutes!</div><div style="display:table;width:100%"><div style="width:33.3%;display:table-cell;float:none;height:100%;vertical-align:middle;text-align:center"><img src="https://cdn.shopify.com/s/files/1/1319/2435/t/3/assets/mcafeesecured.png" style="margin:0 auto"></div><div style="width:33.3%;display:table-cell;float:none;height:100%;vertical-align:middle;text-align:center"><img src="https://cdn.shopify.com/s/files/1/1319/2435/t/3/assets/paypalverified.png" style="margin:0 auto"></div><div style="width:33.3%;display:table-cell;float:none;height:100%;vertical-align:middle;text-align:center"><img src="https://cdn.shopify.com/s/files/1/1319/2435/t/3/assets/scanalert.png" style="margin:0 auto"></div></div></div>');
  50. setInterval(function(){
  51. if(document.querySelector(".mb_opc .step__sections") && !document.querySelector("#countdownholder")){
  52. document.getElementsByClassName('main__header')[0].appendChild(pdm);
  53. var dolzina = 10;
  54. var ten = 60 * dolzina;
  55. var starttime = Date.now();
  56. var xcnt = readCookie('prtcntdwn');
  57. if (xcnt) {
  58. if (starttime < xcnt) {
  59. ten = (xcnt - starttime) / 1000;
  60. } else {
  61. eraseCookie('ptcntdwn');
  62. createCookie('prtcntdwn', Date.now() + (ten * 1000), ten + 1);
  63. }
  64. } else {
  65. createCookie('prtcntdwn', Date.now() + (ten * 1000), ten + 1);
  66. }
  67. display = document.querySelector('#time');
  68. startTimer(starttime, ten, display);
  69. };
  70. },2000);
  71.  
  72. function showCouponField(){
  73. document.querySelector(".sidebar__content input[name='checkout[reduction_code]']").closest('.field').style.display = '';
  74. document.querySelector(".discountMinimize").style.display = 'none';
  75. }
  76.  
  77. function showSecondAddress(){
  78. document.querySelector("div[data-address-field='address2'] input").style.display = '';
  79. document.querySelector("div[data-address-field='address2'] label").style.display = '';
  80. document.querySelector(".addressMinimize").style.display = 'none';
  81. }
  82.  
  83. setInterval(function(){
  84. if(!document.querySelector(".discountMinimize") && $$("#checkout_reduction_code:visible").length && !$$(".order-summary-toggle:visible").length){
  85. document.querySelector(".sidebar__content input[name='checkout[reduction_code]']").closest('.field').style.display = 'none';
  86. $$(".sidebar__content input[name='checkout[reduction_code]']").closest('.fieldset').append('<p class="discountMinimize" onclick="showCouponField()" style="cursor:pointer;"><span style="display:inline-block;margin-right:3px;width: 10px;height: 10px;border: 1px solid grey;border-radius: 50%;font-size: 13px;line-height: 10px;text-align: center;background: #484848;color: white;">&#43;</span><span style="display:inline-block;">Discount code?</span></p>');
  87. }
  88.  
  89. if(!document.querySelector(".addressMinimize") && $$("#checkout_shipping_address_address2:visible").length && !$$(".order-summary-toggle:visible").length){
  90. document.querySelector("div[data-address-field='address2'] input").style.display = 'none';
  91. document.querySelector("div[data-address-field='address2'] label").style.display = 'none';
  92. $$("#checkout_shipping_address_address2").closest('.field__input-wrapper').append('<p class="addressMinimize" onclick="showSecondAddress()" style="cursor:pointer;"><span style="display:inline-block;margin-right:3px;width: 10px;height: 10px;border: 1px solid grey;border-radius: 50%;font-size: 13px;line-height: 10px;text-align: center;background: #484848;color: white;">&#43;</span><span style="display:inline-block;">Address line 2</span></p>');
  93. }
  94.  
  95. if($$(".section--shipping-address").length && !$$(".merged").length){
  96. $$("div[data-section='customer-information']").find('.fieldset').prependTo('.section--shipping-address .section__content')
  97. $$(".fieldset").css('clear','both')
  98. $$("div[data-section='customer-information']").addClass('merged')
  99. $$("#checkout_remember_me").closest('.checkbox-wrapper').replaceWith($$("div[data-buyer-accepts-marketing]"))
  100. $$(".section--contact-information").parent().remove()
  101. }
  102.  
  103. },500);
  104.  
  105. (function () {
  106. var title = "Why choose us?";
  107. var item1Title = "100% Satisfaction Guarantee"
  108. var item1Text = "If you're not satisfied with the products, we will replace or refund without any questions asked.";
  109. var item1Icon = "https://cdn.shopify.com/s/files/1/0052/2377/6291/files/guarantee.png?22";
  110. var item2Title = "Over 10,000+ Satisfied Customers";
  111. var item2Text = "We are a US based company and ship in 1-2 days.";
  112. var item2Icon = "https://cdn.shopify.com/s/files/1/0052/2377/6291/files/shipping.png?22";
  113.  
  114. var sidebarWait = setInterval(function(){
  115. if($$(".sidebar__content .order-summary__sections").length && !$$("#booster1").length){
  116. clearInterval(sidebarWait)
  117. $$(".order-summary__sections").append('<div id="booster1"><div id="booster1Title"><span>'+title+'</span></div><div class="booster1Item"><img src="'+item1Icon+'" /><div><h4>'+item1Title+'</h4><p>'+item1Text+'</p></div></div><div class="booster1Item"><img src="'+item2Icon+'" /><div><h4>'+item2Title+'</h4><p>'+item2Text+'</p></div></div></div>')
  118. var css = '#booster1Title{margin-top:25px;overflow:hidden;text-align:center;font-size:16px}#booster1Title span{position:relative;}#booster1Title span:before,#booster1Title span:after {content: "";position: absolute;height: 5px;border-bottom: 1px solid;border-top: 1px solid;top: 8px;width: 600px;}#booster1Title span:before {right: 100%;margin-right: 15px;}#booster1Title span:after{left: 100%;margin-left: 15px;}.booster1Item{margin-top:30px;font-size:15px;}.booster1Item p{line-height:1.2;}.booster1Item h4{font-weight:bold;}.booster1Item img{width:13%;float:left;}.booster1Item div{width:75%;margin-left:25%}.booster1Item::after{content:"";clear:both;height:0;display:block;}'
  119. var boosterCss = document.getElementById('booster1Title')
  120. style = document.createElement('style');
  121. boosterCss.appendChild(style);
  122. style.type = 'text/css';
  123. style.appendChild(document.createTextNode(css));
  124. }
  125. },200)
  126. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement