Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- window.addEventListener('load', function () {
- var allRazd = document.querySelectorAll('.razd')
- allRazd.forEach(function (el) {
- var ordersNum = el.dataset.razdid
- el.addEventListener('click', function () {
- allRazd.forEach(function (el) {
- el.classList.remove('razd_Active')
- el.children[0].classList.remove('logobox_Active')
- })
- el.classList.add('razd_Active')
- el.children[0].classList.add('logobox_Active')
- for (var i = 1; i <= 3; i++) {
- if (i == ordersNum)
- document.querySelector('#orders-' + i).classList.remove('hiddenOrders')
- else
- document.querySelector('#orders-' + i).classList.add('hiddenOrders')
- }
- })
- })
- $('[data-target="#modal5"]').each(function (id) {
- var btn = $(this)
- // console.log(id,btn.parent().children('.cena').text(),btn.parent().children('.cena2').text())
- btn.click(function () {
- $('#steamid').trigger('focus')
- $('#product').text(btn.parent().children('.cena').text())
- $('#sum').text(btn.parent().children('.cena2').text())
- $('#productId').val(id)
- })
- })
- var err = $('#errBox'),
- timeout = undefined
- function showError(text) {
- err.text(text)
- if(timeout != undefined)
- clearTimeout(timeout)
- timeout = setTimeout(function() {
- err.text('')
- timeout = undefined
- }, 3000);
- }
- window.submitModal = function (form) {
- var fd = new FormData(form),
- rqo = new XMLHttpRequest();
- if(!fd.get('steamid')){
- showError('Заполните поле steamid')
- return false
- }
- if(!fd.get('productId')){
- showError('Произошла ошибка! Попробуйте выбрать товар снова!')
- return false
- }
- rqo.open('POST', window.location.href,false);
- rqo.send(fd);
- if (rqo.status != 200) {
- alert('Ошибка' + rqo.status + ': ' + rqo.statusText);
- } else {
- if(rqo.responseText == 'err')
- showError('Произошла ошибка! Попробуйте выбрать товар снова!')
- else
- window.open(rqo.responseText, '_blank');
- }
- return false
- }
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement