Advertisement
I_GRIN_I

Untitled

Jul 11th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.addEventListener('load', function () {
  2.         var allRazd = document.querySelectorAll('.razd')
  3.         allRazd.forEach(function (el) {
  4.             var ordersNum = el.dataset.razdid
  5.             el.addEventListener('click', function () {
  6.                 allRazd.forEach(function (el) {
  7.                     el.classList.remove('razd_Active')
  8.                     el.children[0].classList.remove('logobox_Active')
  9.                 })
  10.                 el.classList.add('razd_Active')
  11.                 el.children[0].classList.add('logobox_Active')
  12.                 for (var i = 1; i <= 3; i++) {
  13.                     if (i == ordersNum)
  14.                         document.querySelector('#orders-' + i).classList.remove('hiddenOrders')
  15.                     else
  16.                         document.querySelector('#orders-' + i).classList.add('hiddenOrders')
  17.                 }
  18.             })
  19.         })
  20.         $('[data-target="#modal5"]').each(function (id) {
  21.             var btn = $(this)
  22.             // console.log(id,btn.parent().children('.cena').text(),btn.parent().children('.cena2').text())
  23.             btn.click(function () {
  24.                 $('#steamid').trigger('focus')
  25.                 $('#product').text(btn.parent().children('.cena').text())
  26.                 $('#sum').text(btn.parent().children('.cena2').text())
  27.                 $('#productId').val(id)
  28.             })
  29.         })
  30.         var err = $('#errBox'),
  31.             timeout = undefined
  32.         function showError(text) {
  33.             err.text(text)
  34.             if(timeout != undefined)
  35.                 clearTimeout(timeout)
  36.             timeout = setTimeout(function() {
  37.                 err.text('')
  38.                 timeout = undefined
  39.             }, 3000);
  40.         }
  41.         window.submitModal = function (form) {
  42.             var fd = new FormData(form),
  43.                 rqo = new XMLHttpRequest();
  44.             if(!fd.get('steamid')){
  45.                 showError('Заполните поле steamid')
  46.                 return false
  47.             }
  48.             if(!fd.get('productId')){
  49.                 showError('Произошла ошибка! Попробуйте выбрать товар снова!')
  50.                 return false
  51.             }
  52.             rqo.open('POST', window.location.href,false);
  53.             rqo.send(fd);
  54.             if (rqo.status != 200) {
  55.                 alert('Ошибка' + rqo.status + ': ' + rqo.statusText);
  56.             } else {
  57.                 if(rqo.responseText == 'err')
  58.                     showError('Произошла ошибка! Попробуйте выбрать товар снова!')
  59.                 else
  60.                     window.open(rqo.responseText, '_blank');
  61.             }
  62.             return false
  63.         }
  64.     }
  65. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement