PageSourceSearch

https://r2grupp.ru/local/templates/r2/public/js/calc.js

js r2grupp.ru collected 2026-10-09 03:35:44 UTC 42,179 bytes, 1,439 lines download raw bytes

1const feInit = () => {
2  switcher()
3  stickySidebar()
4  termSelect()
5  customSelect()
6  changeTab()
7  rangeSliderLoad()
8  deliveryTypeChange()
9  dateInit()
10  /*   addSpot()
11   */ autoCalc()
12  switchDepend()
13  initMask()
14  initMaskDepend()
15  clearError()
16
17  stepForm()
18}
19let currentStep = 1
20const stepitems = {
21  properties: [],
22  radio: [],
23  set: [],
24}
25
26const dateInit = (disabledDays = []) => {
27  // 0 = Р’РЎ, 1 = РџРќ, 2 = Р’Рў, 3 = РЎР , 4 = Р§Рў, 5 = РџРў, 6 = РЎР‘
28  $(".js-datepicker").each(function () {
29    $(this).datepicker().data("datepicker").destroy()
30    $(this).datepicker({
31      minDate: new Date(),
32      onRenderCell: function (date, cellType) {
33        if (cellType == "day") {
34          var day = date.getDay(),
35            isDisabled = disabledDays.indexOf(day) != -1
36
37          return {
38            disabled: isDisabled,
39          }
40        }
41      },
42    })
43  })
44}
45
46function initMask() {
47  $('[type="tel"]').inputmask({
48    showMaskOnHover: true,
49    showMaskOnFocus: true,
50    mask: "+7 (999) 999-99-99",
51  })
52  $('[data-mask="inn"]').inputmask({
53    showMaskOnHover: true,
54    showMaskOnFocus: true,
55    mask: "9999999999",
56  })
57  $('[data-mask="inn_ip"]').inputmask({
58    showMaskOnHover: true,
59    showMaskOnFocus: true,
60    mask: "999999999999",
61  })
62  $('[data-mask="kpp"]').inputmask({
63    showMaskOnHover: true,
64    showMaskOnFocus: true,
65    mask: "999999999",
66  })
67  $('[data-mask="passport_1"]').inputmask({
68    showMaskOnHover: true,
69    showMaskOnFocus: true,
70    mask: "9999",
71  })
72  $('[data-mask="passport_2"]').inputmask({
73    showMaskOnHover: true,
74    showMaskOnFocus: true,
75    mask: "999999",
76  })
77}
78
79function initMaskDepend() {
80  console.log('initMaskDepend')
81  $('[data-dependmask="inn"]').each(function (index) {
82  $(this).on("change", function (e) {
83    const $inputinn = $(this).closest(".calcform__content").find('[data-dependmak="target_inn"]')
84    if ($(this).val() === "ИП") {
85      $inputinn.attr("data-mask", "inn_ip")
86      initMask()
87    } else {
88      $inputinn.attr("data-mask", "inn")
89      initMask()
90    }
91  })
92})
93}
94
95
96
97function clearError() {
98  $('input[data-required="required"]').on("input", function () {
99    $(this).removeClass("error")
100  })
101}
102
103function checkExist(obj) {
104  const objfound = stepitems.properties.filter(
105    (item) => item.property === obj.property
106  )
107
108  if (objfound.length === 0) {
109    stepitems.properties.push(obj)
110  } else {
111    objfound[0].value = obj.value
112    objfound[0].text = obj.text
113  }
114}
115
116function checkExistRadio(obj) {
117  const objfound = stepitems.properties.filter(
118    (item) => item.property === obj.property
119  )
120
121  if (objfound.length === 0) {
122    stepitems.radio.push(obj)
123  } else {
124    objfound[0].value = obj.value
125    objfound[0].text = obj.text
126  }
127}
128
129function getInputData(selector) {
130  $(`[data-stepvisible="${selector}"]`)
131    .find(
132      'input[type="text"][data-steptype="source"], input[type="tel"][data-steptype="source"], input[type="email"][data-steptype="source"],  input[type="hidden"][data-steptype="source"]'
133    )
134    .each(function (index) {
135      var obj = {}
136      obj.property = $(this).data("stepdata")
137      obj.value = $(this).val()
138      obj.text = ""
139      obj.type = "textinput"
140      checkExist(obj)
141    })
142}
143
144function getCheckboxData(selector) {
145  $(`[data-stepvisible="${selector}"]`)
146    .find('input[type="checkbox"][data-steptype="source"]')
147    .each(function (index) {
148      var obj = {}
149      obj.property = $(this).data("stepdata")
150      obj.value = $(this).is(":checked") ? 1 : 0
151      obj.text = $(this)
152        .parent()
153        .find("[data-text]")
154        .text()
155        .replace(/\s+/g, " ")
156      obj.type = "checkbox"
157      checkExist(obj)
158    })
159}
160
161function getRadioData(selector) {
162  $(`[data-stepvisible="${selector}"]`)
163    .find('input[type="radio"][data-steptype="source"]')
164    .each(function (index) {
165      var obj = {}
166      obj.property = $(this).data("stepdata")
167      obj.value = $(this).is(":checked") ? 1 : 0
168      obj.text = $(this).siblings("[data-text]").text().replace(/\s+/g, " ")
169      obj.type = "radio"
170      checkExist(obj)
171    })
172}
173
174function getSpanData(selector) {
175  $(`[data-stepvisible="${selector}"]`)
176    .find('span[data-steptype="source"]')
177    .each(function (index) {
178      var obj = {}
179      obj.property = $(this).data("stepdata")
180      obj.value = $(this).text().replace(/\s+/g, " ")
181      obj.text = ""
182      obj.type = "text"
183      checkExist(obj)
184    })
185}
186
187function getSelectData(selector) {
188  $(`[data-stepvisible="${selector}"]`)
189    .find('select[data-steptype="source"]:visible option:selected')
190    .each(function (index) {
191      var obj = {}
192      obj.property = $(this).closest("select").data("stepdata")
193      obj.value = $(this).text().replace(/\s+/g, " ")
194      obj.text = ""
195      obj.type = "select"
196      checkExist(obj)
197    })
198}
199
200function initData() {
201  getInputData("anyway")
202  getCheckboxData("anyway")
203  getSpanData("anyway")
204  getRadioData("anyway")
205  getSelectData("anyway")
206
207  stepitems.radio = []
208  $('input[type="radio"][data-radiotab="tab"]:checked').each(function (index) {
209    if ($(this).val()) {
210      var obj = {}
211      obj.property = $(this).attr("id")
212      obj.value = $(this).val()
213      obj.text = $(this).closest("label").text().replace(/\s+/g, " ")
214      obj.type = "radio"
215      checkExistRadio(obj)
216    }
217  })
218
219  stepitems.radio.forEach((item) => {
220    getInputData(item.property)
221    getCheckboxData(item.property)
222    getSpanData(item.property)
223    getRadioData(item.property)
224    getSelectData(item.property)
225  })
226}
227
228function ifMap(selector) {
229  $(`[data-ifmap="${selector}"]`).hide()
230
231  let val = 0
232  $(`[data-map="${selector}"]`).each(function () {
233    val = val | $(this).is(":checked")
234  })
235  if (val) {
236    $(`[data-ifmap="${selector}"]`).show()
237  } else {
238    $(`[data-ifmap="${selector}"]`).hide()
239  }
240  return val
241}
242
243function isSizeSet() {
244  const isSize = stepitems.radio.filter(
245    (item) => item.property === "set_size"
246  )[0]
247
248  $(`[data-show="obweight"]`).show()
249
250  ifMap("switches_palet")
251
252  if (isSize) {
253    $(`[data-show="obweight"]`).hide()
254    $("[data-inputset]").each(function () {
255      stepitems.set.push({
256        set: $(this).data("inputset"),
257        text: `${$(this).data("inputset")}`,
258        values: $(this)
259          .find('[data-steptype="source_set"]')
260          .toArray()
261          .map((item) => {
262            return {
263              property: item.dataset.stepdata,
264              value: item.value,
265            }
266          }),
267      })
268    })
269
270    /* const MathUtils = {
271          roundToPrecision: function (subject, precision) {
272              return +(+subject).toFixed(precision)
273          },
274      } */
275
276    /*  let len = stepitems.set.reduce(
277          (sum, item) =>
278              MathUtils.roundToPrecision(
279                  sum + parseFloat(item.values[0].value.replace(/[^0-9]/g, "")),
280                  1
281              ),
282          0
283      ) */
284
285    /* stepitems.properties.push({
286          property: "ob_len",
287          value: len,
288          text: "",
289          type: "textinput",
290      })
291      let shir = stepitems.set.reduce(
292          (sum, item) =>
293              MathUtils.roundToPrecision(
294                  sum + parseFloat(item.values[1].value.replace(/[^0-9]/g, "")),
295                  1
296              ),
297          0
298      ) */
299
300    /*     stepitems.properties.push({
301          property: "ob_shir",
302          value: shir,
303          text: "",
304          type: "textinput",
305      })
306      let h = stepitems.set.reduce(
307          (sum, item) =>
308              MathUtils.roundToPrecision(
309                  sum + parseFloat(item.values[2].value.replace(/[^0-9]/g, "")),
310                  1
311              ),
312          0
313      ) */
314
315    /*   stepitems.properties.push({
316          property: "ob_h",
317          value: h,
318          text: "",
319          type: "textinput",
320      }) */
321    /*    let w = stepitems.set.reduce(
322          (sum, item) =>
323              MathUtils.roundToPrecision(
324                  sum + parseFloat(item.values[3].value.replace(/[^0-9]/g, "")),
325                  1
326              ),
327          0
328      )
329 */
330    stepitems.properties.push({
331      property: "tot_weight",
332      value: $('[data-stepdata="tot_weight"]').val(),
333      text: "",
334      type: "textinput",
335    })
336    /*     let count = stepitems.set.reduce(
337          (sum, item) =>
338              MathUtils.roundToPrecision(
339                  sum + parseFloat(item.values[4].value.replace(/[^0-9]/g, "")),
340                  1
341              ),
342          0
343      ) */
344
345    /*  stepitems.properties.push({
346          property: "ob_count",
347          value: count,
348          text: "",
349          type: "textinput",
350      }) */
351
352    /*      let vol = stepitems.set.reduce(
353          (sum, item) =>
354              MathUtils.roundToPrecision(
355                  sum + parseFloat(item.values[5].value.replace(/[^0-9]\./g, "")),
356                  3
357              ),
358          0
359      ) */
360
361    stepitems.properties.push({
362      property: "tot_volume",
363      value: $('[data-stepdata="tot_volume"]').val(),
364      text: "",
365      type: "textinput",
366    })
367  }
368}
369
370const fillStepData = (step) => {
371  if (step == 2) {
372    setData()
373    isSizeSet()
374  }
375
376  //confirm.html
377  if (step == 3) {
378    setData()
379    setPayer()
380  }
381
382  if (step == 4) {
383    $("#calcForm").prop("action", "/calc/save/")
384    $("input:checkbox, input:text").prop("disabled", false)
385    $("#calcForm").submit()
386  }
387}
388
389const getMailData = () => {
390  const $stepBlock = $('[data-entity="form-step-3"]')
391
392  let _html = ""
393  let from = ""
394  let to = ""
395  from += $stepBlock.find('.fromto__title[data-stepdata="f_otpravki"]').text()
396  from += $stepBlock
397    .find('.fromto__title[data-stepdata="f_otpravki"]')
398    .next("div")
399    .text()
400
401  to += $stepBlock.find('.fromto__title[data-stepdata="f_otpravki"]').text()
402  to += $stepBlock
403    .find('.fromto__title[data-stepdata="f_otpravki"]')
404    .next("div")
405    .text()
406}
407
408function validateEmail() {
409  let valid = true
410  const email = []
411  const $email = $("input[type=email]:visible")
412
413  $email.each(function () {
414    const obj = {
415      input: $(this),
416      val: $(this).val().toString(),
417    }
418    email.push(obj)
419  })
420
421  email.forEach(function (item) {
422    var emailReg = /^[A-Z0-9._%+-]+@([A-Z0-9-]+\.)+[A-Z]{2,4}$/i
423
424    if (!emailReg.test(item.val)) {
425      valid = false
426      item.input.addClass("error")
427    } else {
428      valid = true
429      item.input.removeClass("error")
430    }
431  })
432  return valid
433}
434
435function validateRequired() {
436  let valid = true
437
438  valid = validateEmail()
439
440  const required = []
441  const $required = $('input[data-required="required"]:visible')
442
443  $required.each(function () {
444    const obj = {
445      input: $(this),
446      val: $(this).val().toString(),
447      min: +$(this).data("min") || 1,
448      max: +$(this).data("max") || 9999,
449    }
450    required.push(obj)
451  })
452
453  required.forEach(function (item) {
454    if (item.val.length < 1) {
455      valid = false
456      item.input.addClass("error")
457    }
458  })
459
460  if ($(".checkbox_required:visible").length) {
461    return false
462  }
463
464  if ($(".error").length) {
465    $("html, body").animate(
466      {
467        scrollTop: $(".error").offset().top - 220,
468      },
469      300
470    )
471  }
472
473  return valid
474}
475
476function validateDepending() {
477  let valid = true
478  const required = []
479  const $required = $("input[data-isrequired]:checked")
480
481  if ($required) {
482    $required.each(function () {
483      const obj = {
484        input: $(this),
485        val: $(this).val(),
486        depinput: $(this).data("isrequired"),
487      }
488      required.push(obj)
489    })
490  }
491
492  required.forEach(function (item) {
493    const depending = $(`[data-mbrequired="${item.depinput}"]`)
494    if (depending) {
495      if (!depending.val().length) {
496        valid = false
497        depending.addClass("error")
498      }
499    }
500  })
501
502  return valid
503}
504
505const checkConfirm = () => {
506  if ($('input[name="privacy"]').is(":checked")) {
507    return true
508  } else {
509    $('input[name="privacy"]')
510      .closest(".pageform__check")
511      .find(".checkbox__box")
512      .addClass("error")
513    return false
514  }
515}
516
517const validateStepData = (step) => {
518  let validation = true
519  $("input").removeClass("error")
520
521  if (step == 2) {
522    let isTerminal = true
523    $("[data-ternimalresult]").each(function () {
524      if ($(this).text().length > 0) {
525        $(this).closest(".calcselect__wrapper").removeClass("error")
526      } else {
527        $(this).closest(".calcselect__wrapper").addClass("error")
528        isTerminal = false
529      }
530    })
531
532    validation =
533      /* validateDepending() && */
534      validateRequired() && isTerminal
535  }
536
537  if (step == 3) {
538    validation = /* validateDepending() && */ validateRequired()
539  }
540  if (step == 4) {
541    validation = validateRequired() && checkConfirm()
542  }
543
544  return validation
545}
546
547const stepForm = () => {
548  $(document).on("click", '[data-entity="step-next"]', function (e) {
549    e.preventDefault()
550    //console.log(stepitems)
551    let flag = validateStepData(currentStep + 1)
552    //console.log(flag)
553    if (flag) {
554      initData()
555      $(".form-step").hide()
556      ++currentStep
557      fillStepData(currentStep)
558      $('[data-entity="form-step-' + currentStep + '"]').show()
559
560      /*  if (currentStep === 1) {
561              $('.form-step .calcpage__nav [data-entity="step-next"]').show()
562              $('[data-entity="step-prev"]').removeClass("active")
563          }
564          if (currentStep === 2) {
565              $('.form-step .calcpage__nav [data-entity="step-next"]').show()
566              $('[data-entity="step-prev"]').addClass("active")
567          }
568          if (currentStep === 3) {
569              $('[data-entity="step-prev"]').addClass("active")
570              $('.form-step .calcpage__nav [data-entity="step-next"]').hide()
571          }
572 */
573
574      if (currentStep === 4) {
575        //отправка результатов формы на email
576        app.sendCalcForm()
577        $(".calcpage__aside").hide()
578      }
579
580      $("html, body").animate(
581        {
582          scrollTop: $("main").offset().top,
583        },
584        300
585      )
586    }
587  })
588
589  $(document).on(
590    "click",
591    '[data-entity="step-prev"]',
592    function (e) {
593      e.preventDefault()
594      /* if (validateStepData(currentStep - 1)) { */
595      --currentStep
596      if (currentStep < 1) {
597        currentStep = 1
598      }
599      fillStepData(currentStep)
600      $(".form-step").hide()
601      $('[data-entity="form-step-' + currentStep + '"]').show()
602      $("html, body").animate(
603        {
604          scrollTop: $("main").offset().top,
605        },
606        300
607      )
608
609      if (currentStep === 1) {
610        $('[data-entity="step-prev"]').removeClass("active")
611      }
612      if (currentStep === 2) {
613        $('[data-entity="step-prev"]').addClass("active")
614      }
615      if (currentStep === 3) {
616        $('[data-entity="step-prev"]').addClass("active")
617      }
618    }
619    /*  } */
620  )
621}
622
623function setPayer() {
624  if (stepitems && stepitems.properties) {
625    const val = stepitems.properties.filter(
626      (item) => item.property === "payeer"
627    )[0].value
628    let tel = ""
629    let email = ""
630   // console.log(val)
631    switch (val) {
632      case "Отправитель":
633        $("#radio2-1").prop("checked", true)
634        tel = stepitems.properties.filter(
635          (item) => item.property === "send_tel"
636        )[0].value
637        email = stepitems.properties.filter(
638          (item) => item.property === "send_email"
639        )[0].value
640
641        break
642      case "Получатель":
643        $("#radio2-2").prop("checked", true)
644        tel = stepitems.properties.filter(
645          (item) => item.property === "receive_tel"
646        )[0].value
647        email = stepitems.properties.filter(
648          (item) => item.property === "receive_email"
649        )[0].value
650        break
651      case "Третье лицо":
652        $("#radio2-3").prop("checked", true)
653        $("#radio2-2").prop("checked", true)
654        tel = stepitems.properties.filter(
655          (item) => item.property === "receive_othertel"
656        )[0].value
657        email = stepitems.properties.filter(
658          (item) => item.property === "receive_otheremail"
659        )[0].value
660        break
661    }
662    $('[name="NOTIFY_PHONE"]').val(tel)
663    $('[name="NOTIFY_EMAIL"]').val(email)
664  }
665}
666
667function setData() {
668  $('[data-steptype="result"]').each(function () {
669    const current = $(this).data("stepdata")
670    let input = stepitems.properties.filter((item) => item.property === current)
671    if (input.length && input[0].type === "textinput" && input[0].value != "") {
672      $(this).text(input[0].value)
673    }
674    if (input.length && input[0].type === "checkbox" && input[0].value != 0) {
675      $(this).text(input[0].text)
676    }
677    if (input.length && input[0].type === "select" && input[0].value != "") {
678      $(this).text(input[0].value)
679    }
680    if (input.length && input[0].type === "text" && input[0].value != "") {
681      $(this).text(input[0].value)
682    }
683
684    let radio = stepitems.radio.filter((item) => item.property === current)
685    if (radio.length && radio[0].type === "radio" && radio[0].value != 0) {
686      $(this).text(radio[0].text)
687    }
688  })
689
690  $("[data-if]").each(function () {
691    //console.log(stepitems)
692    const current = $(this).data("if")
693    let input = stepitems.properties.filter((item) => item.property === current)
694    if (
695      input.length &&
696      input[0].value != 0 &&
697      input[0].value != "" &&
698      input[0].value != "N"
699    ) {
700      $(this).show()
701    } else {
702      $(this).hide()
703    }
704  })
705
706  $('[data-totaltype="fizyur"]').each(function () {
707    const current = $(this).data("stepdata")
708    if (stepitems.radio.filter((item) => item.property === current).length) {
709      $(this).show()
710    } else {
711      $(this).hide()
712    }
713  })
714}
715
716const autoCalc = () => {
717  const calcOver = function (e) {
718    $(".calcform__inputs_spot").each(function () {
719      let isover = false
720      let len = +$(this)
721        .find(".calc_length")
722        .val()
723        .replace(/\s/g, "")
724        .match(/\d+/)[0]
725      let wid = +$(this)
726        .find(".calc_width")
727        .val()
728        .replace(/\s/g, "")
729        .match(/\d+/)[0]
730      let hei = +$(this)
731        .find(".calc_height")
732        .val()
733        .replace(/\s/g, "")
734        .match(/\d+/)[0]
735      let weight = +$(this)
736        .find(".calc_weight")
737        .val()
738        .replace(/\s/g, "")
739        .match(/\d+/)[0]
740
741      let weiover = $("input[name=delivery_type]:checked").data("over
741weight")
742      let sizeover = $("input[name=delivery_type]:checked").data("oversize")
743
744      let size = len + wid + hei
745      if (size / 100 > sizeover) {
746        isover = true
747      }
748
749      if (weight > weiover) {
750        isover = true
751      }
752
753      if (isover) {
754        $(this).find(".warn_over").addClass("active")
755      } else {
756        $(this).find(".warn_over").removeClass("active")
757      }
758    })
759  }
760
761  const calcVolume = function (e) {
762    let resVolume = 0
763
764    $(".calcform__inputs_spot").each(function () {
765      let len = +$(this)
766        .find(".calc_length")
767        .val()
768        .replace(/\s/g, "")
769        .match(/\d+/)[0]
770      let wid = +$(this)
771        .find(".calc_width")
772        .val()
773        .replace(/\s/g, "")
774        .match(/\d+/)[0]
775      let hei = +$(this)
776        .find(".calc_height")
777        .val()
778        .replace(/\s/g, "")
779        .match(/\d+/)[0]
780
781      let volume =
782        len *
783        wid *
784        hei *
785        Number($(this).find('[data-change="identical"]').val())
786      calcOver()
787      resVolume += volume
788    })
789
790    $(".auto_volume").val(resVolume / 1000000)
791  }
792  const calcWeight = function (e) {
793    let resWeigth = 0
794
795    $(".calcform__inputs_spot").each(function () {
796      let result = +$(this)
797        .find(".calc_weight")
798        .val()
799        .replace(/\s/g, "")
800        .match(/\d+/)[0]
801      calcOver()
802
803      resWeigth +=
804        result * Number($(this).find('[data-change="identical"]').val())
805    })
806
807    $(".auto_weight").val(resWeigth)
808  }
809
810  $(document).on("change", ".calc_length", calcVolume)
811  $(document).on("change", ".calc_width", calcVolume)
812  $(document).on("change", ".calc_height", calcVolume)
813  $(document).on("change", ".calc_weight", calcWeight)
814  $(document).on("change", '[data-change="identical"]', calcWeight)
815  $(document).on("change", '[data-change="identical"]', calcVolume)
816}
817
818const onSpotAdd = (th, count) => {
819  $(".calctabs__close").hide()
820
821  th
822    .closest(".calcpage__block")
823    .find(".calcform-js.active")
824    .find(".calcform__content").append(`
825      <div class="calcform__inputs calcform__inputs_spot js-calcform__inputs calcform__inputs-${count}" data-inputset="${count}">
826        <div class="calcform__titlespot js-calcspot"">
827          <span class="calcform__titlespotname"> ${count} место</span><span class="calcform__titlespotremove">
828            <a href="#" class="calctabs__remove">Удалить</a>
829          </span>
830       </div>
831          <div class="calcform__items calcform__items_three">
832            <div class="calcform__item">
833              <div class="calcform__title">Длина</div>
834              <div class=" form-control__wrapper" data-range-slider-type="size">
835                <input data-stepdata="ob_len-${count}" data-stepset="${count}"  data-steptype="source_set" class="calc_length form-control range-slider__control" data-max="1000" data-min="1" data-size-format=""
836                data-new-${count} name="boxLength[]"  type="text" inputmode="decimal" value="1">
837              </div>
838            </div>
839            <div class="calcform__item">
840              <div class="calcform__title">Ширина</div>
841              <div class="form-control__wrapper" data-range-slider-type="size">
842                <input data-stepdata="ob_shir-${count}" data-stepset="${count}"  data-steptype="source_set" class="calc_width form-control range-slider__control" data-max="1000" data-min="1"
843                data-size-format="" data-new-${count} name="boxWidth[]"  type="text" inputmode="decimal" value="1">
844              </div>
845            </div>
846            <div class="calcform__item">
847              <div class="calcform__title">Высота</div>
848              <div class="form-control__wrapper" data-range-slider-type="size">
849                <input data-stepdata="ob_h-${count}" data-stepset="${count}"  data-steptype="source_set" class="calc_height form-control range-slider__control" 
850                data-max="1000" data-min="1" data-size-format="" data-new-${count} name="boxHeight[]" placeholder="" type="text" inputmode="decimal" value="1">
851              </div>
852            </div>
853            <div class="calcform__item calcform__item_xl">
854              <div class="calcform__title">Вес места</div>
855              <div class="form-control__wrapper range-slider range-slider-${count}" data-range-slider-type="weight">
856                <input data-stepdata="ob_w-${count}" data-stepset="${count}"  data-steptype="source_set" class="form-control range-slider__control calc_weight" data-max="5000" data-min="1"
857                data-weight-format="" data-new-${count} name="boxWeight[]"type="text" inputmode="decimal" value="1">
858                <div class="range-slider__ui"></div>
859              </div>
860            </div>
861            <div class="calcform__item">
862                    <div class="calcform__title">Одинаковые места</div>
863                    <div class=" form-control__wrapper">
864                      <input data-stepset="${count}"
865                        data-steptype="source_set"
866                        class=" form-control"
867                        data-max="1000"
868                        data-change="identical"
869                        data-min="1" name="identical[]"
870                        placeholder="1" type="text" inputmode="decimal"
871                        value="1">
872                    </div>
873                  </div>
874                   <div class="calcform__item">
875                    <div class="calcform__title">Палеты</div>
876                    <ol class="switches">
877                      <li>
878                        <!--    <span class="switches__name">
879                          <img src="/local/templates/r2/public/img/zabor.svg" alt="">
880                          <span data-text="checkboxtext">Палеты</span>
881                        </span> -->
882                        <input type="checkbox" id="switches_palet_${count}" data-entity="calc" name="switches_palet_${count}"
883                          value="Y" data-stepdata="switches_palet_${count}" data-steptype="source" data-map="switches_palet">
884                        <label for="switches_palet_${count}" style="margin-left:0;">
885                          <span></span>
886                        </label>
887                      </li>
888                    </ol>
889         
890          </div>
891          <div class="calcform__warn warn_over">
892          <div class="warnmessage warnmessage_type2">
893            <div class="warnmessage__icon">
894              <img src="img/warnmessage.svg" alt="">
895            </div>
896            <div class="warnmessage__text">Данные размеры груза превышают максимально допустимые габариты и груз будет оценен как “Негабаритный” </div>
897          </div>
898        </div>
899        </div>
900      </div>
901      </div>
902      `)
903
904  $(`.calcform__inputs-${count}`)
905    .addClass("active")
906    .siblings()
907    .removeClass("active")
908
909  $(`[data-weight-format][data-new-${count}]`).inputmask("integer", {
910    mask: "( 999){+|1}",
911    numericInput: true,
912    showMaskOnHover: false,
913    showMaskOnFocus: false,
914    rightAlign: false,
915  })
916
917  if ($(`.range-slider-${count}`).length) {
918    var rangeSliders = $(`.range-slider-${count}`)
919    rangeSliderInit(rangeSliders)
920  }
921
922  $('[data-change="identical"]').trigger("change")
923}
924
925const onSpotRemove = (th, count) => {
926  const result = 1 /* window.confirm(`Вы уверены, что хотите удалить место №${count}?`) */
927  if (result) {
928    th.closest(`.calctabs__item-${count}`).remove()
929    $(`.calcform__inputs-${count}`).remove()
930    $(`.calcform__inputs-${count - 1}`)
931      .find(".calctabs__remove")
932      .show()
933  }
934}
935
936const onChangeSize = (th) => {
937  if (
938    $(this).closest(".range-slider").attr("data-range-slider-type") === "size"
939  ) {
940    if (
941      this.value.replace(/[^0-9]/g, "") >
942      parseInt(this.getAttribute("data-max"))
943    ) {
944      this.value = parseInt(this.getAttribute("data-max"))
945    } else if (
946      this.value.replace(/[^0-9]/g, "") <
947        parseInt(this.getAttribute("data-min")) ||
948      this.value.replace(/[^0-9]/g, "") === ""
949    ) {
950      this.value = parseInt(this.getAttribute("data-min"))
951    }
952    $(this)
953      .next()
954      .data("slider")
955      .set(parseInt(this.value.replace(/[^0-9]/g, "")))
956  }
957
958  if (
959    $(this).closest(".range-slider").attr("data-range-slider-type") === "weight"
960  ) {
961    if (
962      this.value.replace(/[^0-9]/g, "") >
963      parseInt(this.getAttribute("data-max"))
964    ) {
965      this.value = parseInt(this.getAttribute("data-max"))
966    } else if (
967      this.value.replace(/[^0-9]/g, "") <
968        parseInt(this.getAttribute("data-min")) ||
969      this.value.replace(/[^0-9]/g, "") === ""
970    ) {
971      this.value = parseInt(this.getAttribute("data-min"))
972    }
973    $(this)
974      .next()
975      .data("slider")
976      .set(parseInt(this.value.replace(/[^0-9]/g, "")))
977  } else if (
978    $(this).closest(".range-slider").attr("data-range-slider-type") === "volume"
979  ) {
980    if (parseFloat(this.value) > parseFloat(this.getAttribute("data-max"))) {
981      this.value = parseFloat(this.getAttribute("data-max"))
982    } else if (
983      parseFloat(this.value) < parseFloat(this.getAttribute("data-min")) ||
984      parseFloat(this.value) === ""
985    ) {
986      this.value = parseFloat(this.getAttribute("data-min"))
987    }
988    if (!parseFloat(this.value) || parseFloat(this.value) === 0) {
989      this.value = parseFloat(this.getAttribute("data-min"))
990    }
991    $(this)
992      .next()
993      .data("slider")
994      .set(parseFloat(this.value /*.replace(/[^0-9]/g, '')*/).toFixed(5))
995  }
996}
997
998function rangeSliderInit(rangeSliders) {
999  for (var i = 0; i < rangeSliders.length; i++) {
1000    rangeSliderCreate(i, rangeSliders[i])
1001  }
1002  /* 
1003  $('.range-slider__control').on('change', function () {
1004    if ($(this).closest('.range-slider').attr('data-range-slider-type') === 'size' ) {
1005      if (this.value.replace(/[^0-9]/g, '') > parseInt(this.getAttribute('data-max'))) {
1006          this.value = parseInt(this.getAttribute('data-max'));
1007      } else if (this.value.replace(/[^0-9]/g, '') < parseInt(this.getAttribute('data-min')) || this.value.replace(/[^0-9]/g, '') === '') {
1008          this.value = parseInt(this.getAttribute('data-min'));
1009      }
1010      $(this).next().data('slider').set(parseInt(this.value.replace(/[^0-9]/g, '')));
1011  }
1012
1013  if ($(this).closest('.range-slider').attr('data-range-slider-type') === 'weight' ) {
1014      if (this.value.replace(/[^0-9]/g, '') > parseInt(this.getAttribute('data-max'))) {
1015          this.value = parseInt(this.getAttribute('data-max'));
1016
1017      } else if (this.value.replace(/[^0-9]/g, '') < parseInt(this.getAttribute('data-min')) || this.value.replace(/[^0-9]/g, '') === '') {
1018          this.value = parseInt(this.getAttribute('data-min'));
1019      }
1020      $(this).next().data('slider').set(parseInt(this.value.replace(/[^0-9]/g, '')));
1021
1022
1023
1024  } else if ($(this).closest('.range-slider').attr('data-range-slider-type') === 'volume') {
1025      if (parseFloat(this.value) > parseFloat(this.getAttribute('data-max'))) {
1026          this.value = parseFloat(this.getAttribute('data-max'));
1027      } else if (parseFloat(this.value) < parseFloat(this.getAttribute('data-min')) || parseFloat(this.value) === '') {
1028          this.value = parseFloat(this.getAttribute('data-min'));
1029      } if ( (!(parseFloat(this.value))) || (parseFloat(this.value) === 0)) {
1030          this.value = parseFloat(this.getAttribute('data-min'));
1031      }
1032      $(this).next().data('slider').set(parseFloat(this.value ).toFixed(5));
1033  }
1034
1035  }); */
1036}
1037
1038const checkdisabled = () => {
1039  $(document).on("click", ".checkdisabled", function (e) {
1040    $(this).find(".help-tooltip").addClass("visibility")
1041    setTimeout(() => {
1042      $(".help-tooltip").removeClass("visibility")
1043    }, 3000)
1044  })
1045}
1046
1047function reCalc() {}
1048
1049const deliveryTypeChange = () => {
1050  checkdisabled()
1051
1052  const setAuto = () => {
1053    $(".calcpage__main").addClass("delivery_auto")
1054    $(".calcpage__main").removeClass("delivery_zhd")
1055    $('input[name="warm_2_5"]').removeAttr("disabled")
1056    $('input[name="warm_2_5"]').closest("li").removeClass("checkdisabled")
1057
1058    $('input[name="Insulation_1_layer"]').attr("disabled", true)
1059    $('input[name="Insulation_1_layer"]')
1060      .closest("li")
1061      .addClass("checkdisabled")
1062    $('input[name="Insulation_1_layer"]').removeAttr("checked")
1063    /* $('input[name="Insulation_1_layer"]').val('') */
1064
1065    $('input[name="Insulation_2_layer"]').attr("disabled", true)
1066    $('input[name="Insulation_2_layer"]')
1067      .closest("li")
1068      .addClass("checkdisabled")
1069    $('input[name="Insulation_2_layer"]').removeAttr("checked")
1070    /* $('input[name="Insulation_2_layer"]').val('') */
1071
1072    $('input[name="Insulation_3_layer"]').attr("disabled", true)
1073    $('input[name="Insulation_3_layer"]')
1074      .closest("li")
1075      .addClass("checkdisabled")
1076    $('input[name="Insulation_3_layer"]').removeAttr("checked")
1077
1078    /*     $('input[name="Insulation_3_layer"]').val('') */
1079  }
1080  const setZhd = () => {
1081    $(".calcpage__main").addClass("delivery_zhd")
1082    $(".calcpage__main").removeClass("delivery_auto")
1083    $('input[name="warm_2_5"]').attr("disabled", true)
1084    $('input[name="warm_2_5"]').closest("li").addClass("checkdisabled")
1085    $('input[name="warm_2_5"]').removeAttr("checked")
1086
1087    $('input[name="Insulation_1_layer"]').removeAttr("disabled")
1088    $('input[name="Insulation_1_layer"]')
1089      .closest("li")
1090      .removeClass("checkdisabled")
1091
1092    $('input[name="Insulation_2_layer"]').removeAttr("disabled")
1093    $('input[name="Insulation_2_layer"]')
1094      .closest("li")
1095      .removeClass("checkdisabled")
1096
1097    $('input[name="Insulation_3_layer"]').removeAttr("disabled")
1098    $('input[name="Insulation_3_layer"]')
1099      .closest("li")
1100      .removeClass("checkdisabled")
1101  }
1102  $('[name="delivery_type"]').on("change", function () {
1103    $(this).attr("id") === "delivery_auto" ? setAuto() : setZhd()
1104    checkDepend()
1105    checkdisabled()
1106  })
1107}
1108
1109const rangeSliderLoad = () => {
1110  if ($(".range-slider").length) {
1111    var rangeSliders = $(".range-slider")
1112    rangeSliderInit(rangeSliders)
1113
1114    $("[data-weight-format], [data-size-format]").inputmask("integer", {
1115      mask: "( 999){+|1}",
1116      numericInput: true,
1117      showMaskOnHover: false,
1118      showMaskOnFocus: false,
1119      rightAlign: false,
1120    })
1121
1122    $("[data-volume-format]").inputmask({
1123      rightAlign: false,
1124      alias: "numeric",
1125      digits: 5,
1126      suffix: "",
1127      showMaskOnHover: false,
1128      showMaskOnFocus: false,
1129    })
1130  }
1131}
1132var rangeTimeout
1133
1134const rangeSliderCreate = (slideIndex, slide) => {
1135  var rangeSliderOptions
1136  var rangeSliderType = $(slide).attr("data-range-slider-type")
1137  var rangeSliderStart = parseFloat(
1138    $(slide).closest(".range-slider").find(".form-control").val()
1139  )
1140  var rangeSliderMin = parseFloat(
1141    $(slide).closest(".range-slider").find(".form-control").data("min")
1142  )
1143  var rangeSliderMax = parseFloat(
1144    $(slide).closest(".range-slider").find(".form-control").data("max")
1145  )
1146
1147  if (rangeSliderType === "weight") {
1148    rangeSliderOptions = {
1149      start: [rangeSliderStart],
1150      range: {
1151        min: [rangeSliderMin, 1],
1152        "28%": [15, 1],
1153        "48%": [30, 5],
1154        "60%": [100, 10],
1155        "70%": [300, 50],
1156        "80%": [1000, 100],
1157        max: [rangeSliderMax],
1158      },
1159      connect: "lower",
1160    }
1161  } else if (rangeSliderType === "volume") {
1162    rangeSliderOptions = {
1163      start: [rangeSliderStart],
1164      range: {
1165        min: [rangeSliderMin, 0.01],
1166        "40%": [0.5, 0.05],
1167        "50%": [1, 0.1],
1168        "76%": [3, 0.5],
1169        "88%": [10, 1],
1170        max: [rangeSliderMax],
1171      },
1172      connect: "lower",
1173    }
1174  } else {
1175    rangeSliderOptions = {
1176      start: [1],
1177      range: {
1178        min: [rangeSliderMin],
1179        max: [rangeSliderMax],
1180      },
1181      connect: "lower",
1182    }
1183  }
1184
1185  $(slide).attr("data-range-slider-index", slideIndex)
1186
1187  var rangeSlidersItem = noUiSlider.create(
1188    slide.querySelector(".range-slider__ui"),
1189    rangeSliderOptions
1190  )
1191
1192  $(slide.querySelector(".range-slider__ui")).data("slider", rangeSlidersItem)
1193
1194  rangeSlidersItem.on("slide", function (values, handle) {
1195    clearTimeout(rangeTimeout)
1196    if (
1197      rangeSliderType === "weight" ||
1198      rangeSliderType === "size" ||
1199      rangeSliderType === "height" ||
1200      rangeSliderType === "count"
1201    ) {
1202      $(this.target)
1203        .closest(".range-slider")
1204        .find(".form-control")
1205        .val(Math.round(values[handle]))
1206    } else if (rangeSliderType === "volume") {
1207      $(this.target)
1208        .closest(".range-slider")
1209        .find(".form-control")
1210        .val(parseFloat(values[handle]).toFixed(2) /* + ' РјВі'*/)
1211    } else {
1212      $(this.target)
1213        .closest(".range-slider")
1214        .find(".form-control")
1215        .val(values[handle])
1216    }
1217  })
1218  rangeSlidersItem.on("change", function () {
1219    var target = $(this.target)
1220    rangeTimeout = setTimeout(function () {
1221      target.closest(".range-slider").find(".form-control").trigger("change")
1222    }, 500)
1223  })
1224}
1225
1226const changeTab = () => {
1227  jQuery(".calctabs-js").on("click", "label:not(.active)", function () {
1228    jQuery(this).addClass("active").siblings().removeClass("active")
1229    jQuery(this)
1230      .closest("div.calcitem_tabs-js")
1231      .find("div.calcitem__content")
1232      .find("div.calcform-js")
1233      .removeClass("active")
1234      .eq(jQuery(this).index())
1235      .addClass("active")
1236  })
1237}
1238
1239const checkDepend = () => {
1240  const inputSet = document.querySelectorAll(
1241    '.calcform__switches input[type="checkbox"]'
1242  )
1243
1244  inputSet.forEach((input) => {
1245    let depend = input.getAttribute("name")
1246    if (input.checked) {
1247      document
1248        .querySelector(`.calcpage__aside [data-code=${depend}]`)
1249        .classList.remove("hidden")
1250    } else {
1251      document
1252        .querySelector(`.calcpage__aside [data-code=${depend}]`)
1253        .classList.add("hidden")
1254    }
1255  })
1256}
1257
1258const switchDepend = () => {
1259  $("input[data-depend]").on("change", function (e) {
1260    let depend = $(this).data("depend")
1261    if ($(this).is(":checked")) {
1262      $(`[data-dependfrom=${depend}]`).addClass("active")
1263    } else {
1264      $(`[data-dependfrom=${depend}]`).removeClass("active")
1265    }
1266  })
1267
1268  $('.calcform__switches input[type="checkbox"]').on("change", function (e) {
1269    let depend = $(this).attr("name")
1270    if ($(this).is(":checked")) {
1271      $(`.calcpage__aside [data-code=${depend}]`).removeClass("hidden")
1272    } else {
1273      $(`.calcpage__aside [data-code=${depend}]`).addClass("hidden")
1274    }
1275  })
1276}
1277
1278const switcher = () => {
1279  jQuery(".switcher a").on("click", function (e) {
1280    e.preventDefault()
1281    let input1 = jQuery("#cityInput1").val()
1282    let input2 = jQuery("#cityInput2").val()
1283    jQuery("#cityInput1").val(input2)
1284    jQuery("#cityInput2").val(input1).trigger("change")
1285  })
1286}
1287
1288const customSelect = () => {
1289  jQuery(document).on(
1290    "click",
1291    ".customselect [data-selectbutton]",
1292    function (e) {
1293      e.preventDefault()
1294      jQuery(this)
1295        .closest(".customselect")
1296        .find(".calcselect__list")
1297        .toggleClass("active")
1298      jQuery(this).toggleClass("active")
1299    }
1300  )
1301  jQuery(document).on("click", ".customselect li", function (e) {
1302    e.preventDefault()
1303    const $wrapper = $(this).closest(".customselect")
1304    let value = $(this).text()
1305    let code = $(this).data("value")
1306    $wrapper.find(`[data-calchidden]`).removeClass("active")
1307    $wrapper.find(`[data-calchidden=${code}]`).addClass("active")
1308    $wrapper.find("[data-customselect]").text(value)
1309    // что подставлять в инпут
1310    $wrapper.find("[data-input]").val(value)
1311    $wrapper.find(".calcselect__list").removeClass("active")
1312    $wrapper.find("[data-selectbutton]").removeClass("active")
1313
1314    initMaskDepend()
1315  })
1316}
1317
1318const termSelect = () => {
1319  jQuery(document).on(
1320    "click",
1321    ".calcselectblock:not(.disabled) [data-selectbutton]",
1322    function (e) {
1323      e.preventDefault()
1324      jQuery(this)
1325        .closest(".calcselect")
1326        .find(".calcselect__list")
1327        .addClass("active")
1328    }
1329  )
1330  jQuery(document).on(
1331    "click",
1332    ".calcselectblock .calcselect__list li",
1333    function (e) {
1334      e.preventDefault()
1335      const $element = jQuery(this)
1336      const $wrapper = $element.closest("[data-calcselect]")
1337      let termname = $element.find("[data-terminalname]").data("terminalname")
1338      let termid = $element.find("[data-terminalid]").data("terminalid")
1339
1340      $wrapper.addClass("selected")
1341      $wrapper
1342        .find("[data-ternimalresult]")
1343        .text(termname)
1344        .attr("data-ternimalresult", termname)
1345      $wrapper
1346        .find("[data-ternimalresult_id]")
1347        .text(termid)
1348        .attr("data-ternimalresult_id", termid)
1349      $wrapper.find("[terminalinput_name]").val(termname)
1350      $wrapper.find("[terminalinput_id]").val(termid)
1351      $wrapper.find(".calcselect__list").removeClass("active")
1352      $wrapper.find(".calcselect__buttontext").text("Другой терминал")
1353
1354      if (jQuery('[data-calcselect="from"]').hasClass("selected")) {
1355        jQuery('[data-calcselect="to"]').removeClass("disabled")
1356      }
1357
1358      $wrapper
1359        .find('input[data-input="terminal"]')
1360        .val($element.find("[data-terminalid]").data("terminalid"))
1361        .trigger("change")
1362
1363      // что подставлять в инпут
1364      $wrapper.find(".calcselect__wrapper ").removeClass("error")
1365    }
1366  )
1367}
1368
1369const stickySidebar = () => {
1370  if (jQuery(document).width() > 1023) {
1371    if (document.querySelector(".calcpage__aside")) {
1372      var a = document.querySelector(".calcpage__aside"),
1373        b = null,
1374        P = 190
1375      window.addEventListener("scroll", Ascroll, false)
1376      document.body.addEventListener("scroll", Ascroll, false)
1377
1378      function Ascroll() {
1379        if (b == null) {
1380          var Sa = getComputedStyle(a, ""),
1381            s = ""
1382          for (var i = 0; i < Sa.length; i++) {
1383            if (
1384              Sa[i].indexOf("overflow") == 0 ||
1385              Sa[i].indexOf("padding") == 0 ||
1386              Sa[i].indexOf("border") == 0 ||
1387              Sa[i].indexOf("outline") == 0 ||
1388              Sa[i].indexOf("box-shadow") == 0 ||
1389              Sa[i].indexOf("background") == 0
1390            ) {
1391              s += Sa[i] + ": " + Sa.getPropertyValue(Sa[i]) + "; "
1392            }
1393          }
1394          b = document.createElement("div")
1395          b.style.cssText =
1396            s + " box-sizing: border-box; width: " + a.offsetWidth + "px;"
1397          a.insertBefore(b, a.firstChild)
1398          var l = a.childNodes.length
1399          for (var i = 1; i < l; i++) {
1400            b.appendChild(a.childNodes[1])
1401          }
1402          a.style.height = b.getBoundingClientRect().height + "px"
1403          a.style.padding = "0"
1404          a.style.border = "0"
1405        }
1406        var Ra = a.getBoundingClientRect(),
1407          R = Math.round(
1408            Ra.top +
1409              b.getBoundingClientRect().height -
1410              document.querySelector("footer").getBoundingClientRect().top +
1411              0
1412          )
1413        if (Ra.top - P <= 0) {
1414          if (Ra.top - P <= R) {
1415            b.className = "stop"
1416            b.style.top = -R + "px"
1417          } else {
1418            b.className = "sticky"
1419            b.style.top = P + "px"
1420          }
1421        } else {
1422          b.className = ""
1423          b.style.top = ""
1424        }
1425        window.addEventListener(
1426          "resize",
1427          function () {
1428            a.children[0].style.width = getComputedStyle(a, "").width
1429          },
1430          false
1431        )
1432      }
1433    }
1434  }
1435}
1436
1437jQuery(function (jQuery) {
1438  feInit()
1439})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.