PageSourceSearch

https://vyvoz-musora-v-moskve.ru/wp-content/plugins/n5-calculator/assets/js/calc-script.js?v=1.1&ver=7.1.3

js vyvoz-musora-v-moskve.ru collected 2026-10-09 22:41:44 UTC 13,836 bytes, 299 lines download raw bytes

1"use strict"
2
3// Select
4!function (e) { e.fn.niceSelect = function (t) { function s(t) { t.after(e("<div/>").addClass("nice-select").addClass(t.attr("class") || "").addClass(t.attr("disabled") ? "disabled" : "").attr("tabindex", t.attr("disabled") ? null : "0").html('<span class="current"></span><ul class="select-list"></ul>')); var s = t.next(), n = t.find("option"), i = t.find("option:selected"); s.find(".current").html(i.data("display") || i.text()), n.each(function (t) { var n = e(this), i = n.data("display"); s.find("ul").append(e("<li></li>").attr("data-value", n.val()).attr("data-display", i || null).addClass("option" + (n.is(":selected") ? " selected" : "") + (n.is(":disabled") ? " disabled" : "")).html(n.text())) }) } if ("string" == typeof t) return "update" == t ? this.each(function () { var t = e(this), n = e(this).next(".nice-select"), i = n.hasClass("open"); n.length && (n.remove(), s(t), i && t.next().trigger("click")) }) : "destroy" == t ? (this.each(function () { var t = e(this), s = e(this).next(".nice-select"); s.length && (s.remove(), t.css("display", "")) }), 0 == e(".nice-select").length && e(document).off(".nice_select")) : console.log('Method "' + t + '" does not exist.'), this; this.hide(), this.each(function () { var t = e(this); t.next().hasClass("nice-select") || s(t) }), e(document).off(".nice_select"), e(document).on("click.nice_select", ".nice-select", function (t) { var s = e(this); e(".nice-select").not(s).removeClass("open"), s.toggleClass("open"), s.hasClass("open") ? (s.find(".option"), s.find(".focus").removeClass("focus"), s.find(".selected").addClass("focus")) : s.focus() }), e(document).on("click.nice_select", function (t) { 0 === e(t.target).closest(".nice-select").length && e(".nice-select").removeClass("open").find(".option") }), e(document).on("click.nice_select", ".nice-select .option:not(.disabled)", function (t) { var s = e(this), n = s.closest(".nice-select"); n.find(".selected").removeClass("selected"), s.addClass("selected"); var i = s.data("display") || s.text(); n.find(".current").text(i), n.prev("select").val(s.data("value")).trigger("change") }), e(document).on("keydown.nice_select", ".nice-select", function (t) { var s = e(this), n = e(s.find(".focus") || s.find(".list .option.selected")); if (32 == t.keyCode || 13 == t.keyCode) return s.hasClass("open") ? n.trigger("click") : s.trigger("click"), !1; if (40 == t.keyCode) { if (s.hasClass("open")) { var i = n.nextAll(".option:not(.disabled)").first(); i.length > 0 && (s.find(".focus").removeClass("focus"), i.addClass("focus")) } else s.trigger("click"); return !1 } if (38 == t.keyCode) { if (s.hasClass("open")) { var l = n.prevAll(".option:not(.disabled)").first(); l.length > 0 && (s.find(".focus").removeClass("focus"), l.addClass("focus")) } else s.trigger("click"); return !1 } if (27 == t.keyCode) s.hasClass("open") && s.trigger("click"); else if (9 == t.keyCode && s.hasClass("open")) return !1 }); var n = document.createElement("a").style; return n.cssText = "pointer-events:auto", "auto" !== n.pointerEvents && e("html").addClass("no-csspointerevents"), this } }(jQuery);
5
6
7document.addEventListener("DOMContentLoaded", function () {
8
9    [].forEach.call(document.querySelectorAll('[type=tel]'), function (input) {
10        var keyCode;
11        function mask(event) {
12            event.keyCode && (keyCode = event.keyCode);
13            var pos = this.selectionStart;
14            if (pos < 3) event.preventDefault();
15            var matrix = "+7 (___) ___ ____",
16                i = 0,
17                def = matrix.replace(/\D/g, ""),
18                val = this.value.replace(/\D/g, ""),
19                new_value = matrix.replace(/[_\d]/g, function (a) {
20                    return i < val.length ? val.charAt(i++) || def.charAt(i) : a
21                });
22            i = new_value.indexOf("_");
23            if (i != -1) {
24                i < 5 && (i = 3);
25                new_value = new_value.slice(0, i)
26            }
27            var reg = matrix.substr(0, this.value.length).replace(/_+/g,
28                function (a) {
29                    return "\\d{1," + a.length + "}"
30                }).replace(/[+()]/g, "\\$&");
31            reg = new RegExp("^" + reg + "$");
32            if (!reg.test(this.value) || this.value.length < 5 || keyCode > 47 && keyCode < 58) this.value = new_value;
33            if (event.type == "blur" && this.value.length < 5) this.value = ""
34        }
35
36        input.addEventListener("input", mask, false);
37        input.addEventListener("focus", mask, false);
38        input.addEventListener("blur", mask, false);
39        input.addEventListener("keydown", mask, false)
40
41    });
42});
43
44jQuery(document).ready(function ($) {
45	// calculator range slider
46    const calcSlider = $(".js-range-boxes").ionRangeSlider({
47        min: 1,
48        max: 10,
49        from: 1,
50        grid: true,
51        grid_num: 9,
52        hide_from_to: true,
53        hide_min_max: true
54    });
55
56    const containerCountsEl = $('.js-data-box')
57    const boxPriceEl = $('.js-tab-price')
58    const boxCountsEl = $('.js-data-number')
59    function findItem(prop, val, arr) {
60        return arr.find(i => i[prop] === +val)
61    }
62
63    function getBoxCountsHtml(count) {
64        switch (count) {
65            case 1:
66                return `${count} контейнер`
67                break
68            case 2:
69                return `${count} контейнера`
70                break
71            case 3:
72                return `${count} контейнера`
73                break
74            case 4:
75                return `${count} контейнера`
76                break
77            default:
78                return `${count} контейнеров`
79        }
80    }
81
82    let currentWorkersPrice, currentBox, boxCounts, currentTrashType, currentBoxPrice;
83    if (typeof boxTypes !== 'undefined'
84        && typeof trashTypes !== 'undefined') {
85        currentBox = findItem('cube', 8, boxTypes)
86        boxCounts = +calcSlider.val()
87        currentTrashType = findItem('index', 0, trashTypes)
88        currentBoxPrice = +currentBox.prices[+currentTrashType.index]
89        currentWorkersPrice = 0
90        // let currentWorkersPrice = currentBox.workersPrice * boxCounts
91
92        containerCountsEl.html(currentBox.html == '32м<sup>3</sup>' ? '32-38м<sup>3</sup>' : currentBox.html)
93        boxCountsEl.html(getBoxCountsHtml(boxCounts))
94        boxPriceEl.html(currentBoxPrice)
95    }
96
97    // Custom Select
98    const trashTypeEl = $('select').niceSelect();
99
100    const withWorkersEl = $('.calculator-block .form-checkbox__btn')
101
102    // Calculator tabs
103    $('ul.calculator-block__tab--items').on('click', 'li:not(.active)', function () {
104        $(this)
105            .addClass('active').siblings().removeClass('active')
106            .closest('div.calculator-block__tab').find('p.calculator-block__tab--contents').removeClass('active').eq($(this).index()).addClass('active');
107
108        currentBox = findItem('cube', +this.dataset.box, boxTypes)
109        containerCountsEl.html(currentBox.html == '32м<sup>3</sup>' ? '32-38м<sup>3</sup>' : currentBox.html)
110        currentBoxPrice = +currentBox.prices[+currentTrashType.index]
111        boxPriceEl.html(currentBoxPrice)
112        // currentWorkersPrice = currentBox.workersPrice
113    });
114
115    // onChangeBoxCounts
116    calcSlider.change(function () {
117        boxCounts = +this.value
118        boxCountsEl.html(getBoxCountsHtml(+this.value))
119
120        // currentWorkersPrice = currentBox.workersPrice * boxCounts
121    })
122
123    // onChangeTrashType
124    trashTypeEl.change(function () {
125        currentTrashType = findItem('index', +this.value, trashTypes)
126        currentBoxPrice = +currentBox.prices[+this.value]
127        boxPriceEl.html(currentBoxPrice)
128    })
129
130    //onWorkersChange
131    withWorkersEl.change(function () {
132        const { checked } = this
133
134        withWorkersEl.each((_, e) => {
135            $(e).prop('checked', checked)
136        })
137
138        if (!checked) {
139            currentWorkersPrice = 0
140        } else {
141            currentWorkersPrice = currentBox.workersPrice * boxCounts
142        }
143    })
144
145    $('.js-finish-form').on('click', function () {
146        withWorkersEl.each((_, el) => {
147            const { checked } = el
148
149            if (!checked) {
150                currentWorkersPrice = 0
151            } else {
152                currentWorkersPrice = currentBox.workersPrice * boxCounts
153            }
154        })
155        const data = {
156            box: currentBox,
157            boxCounts,
158            workersPrice: currentWorkersPrice,
159            trashType: currentTrashType.type,
160            boxPrice: currentBoxPrice
161        }
162
163        $('.two.size').html(data.box.html == '32м<sup>3</sup>' ? '32-38м<sup>3</sup>' : data.box.html)
164        $('.two.count').html(data.boxCounts)
165        $('.two.gruz').html(data.workersPrice ? 'Да' : 'Нет')
166        $('.two.type').html(data.trashType)
167
168        const priceForBox = data.boxCounts * data.boxPrice
169
170        $('.two.price').html(priceForBox + '₽')
171        $('.two.gruz.price').html(data.workersPrice + "₽ погрузка")
172        $('.two.summa').html(priceForBox + data.workersPrice + "₽")
173		
174		$('input[name=calc_size]').val(data.box.html == '32м<sup>3</sup>' ? '32-38м<sup>3</sup>' : data.box.html)
175        $('input[name=calc_count]').val(data.boxCounts)
176        $('input[name=calc_gruz]').val(data.workersPrice ? 'Да' : 'Нет')
177        $('input[name=calc_type]').val(data.trashType)
178
179        $('input[name=calc_subtotal]').val(priceForBox + '₽')
180        $('input[name=calc_gruz_price]').val(data.workersPrice + "₽ погрузка")
181        $('input[name=calc_total]').val(priceForBox + data.workersPrice + "₽")
182    });
183	
184    $('.popup-open.popup3').click(function () {
185        $('body, html').addClass('no-scroll');
186        $('.popup-fade.popup3').show();
187        return false;
188    });
189
190    $('.last-step').hide();
191
192    $('.popup-close').click(function () {
193        $('body, html').removeClass('no-scroll');
194        $('.first-step').css({ display: 'flex' });
195        $('.last-step').hide();
196        $(this).parents('.popup-fade').hide();
197        return false;
198    });
199
200    $('.send.btn--orange').click(function () {
201        $('.first-step').hide().css({ display: 'none' });
202        $('.last-step').css({ display: 'flex' });
203        return false;
204    });
205
206    $(document).keydown(function (e) {
207        if (e.keyCode === 27) {
208            e.stopPropagation();
209            $('body, html').removeClass('no-scroll');
210            $('.popup-fade.popup3').hide();
211        }
212    });
213
214    $('.popup-fade.popup3').click(function (e) {
215        if ($(e.target).closest('.popup.popup3').length == 0) {
216            $('body, html').removeClass('no-scroll');
217            $(this).hide();
218        }
219    });
220
221    $('.popup-close').click(function () {
222        $('body, html').removeClass('no-scroll');
223        $(this).parents('.popup-fade.popup4').hide();
224        return false;
225    });
226
227    $(document).keydown(function (e) {
228        if (e.keyCode === 27) {
229            e.stopPropagation();
230            $('body, html').removeClass('no-scroll');
231            $('.popup-fade.popup4').hide();
232        }
233    });
234
235    $('.popup-fade.popup4').click(function (e) {
236        if ($(e.target).closest('.popup.popup4').length == 0) {
237            $('body, html').removeClass('no-scroll');
238            $(this).hide();
239        }
240    });
241
242    $('.btn-calc').click(function (e) {
243        $('.calculator-block').show();
244    });
245
246    $('.nav-back-link').click(function (e) {
247        $('.calculator-block').hide();
248    });
249
250    $(document).on('submit', '.calc-form', function (e) {
251        e.preventDefault();
252        let form = $(this);
253        let field = form.find('input');
254        let btn = form.find('button');
255    
256        if (!btn.prop('disabled') && form.find('.form-checkbox__btn').is(':checked')) {
257            btn.prop('disabled', true);
258            grecaptcha.ready(function () {
259                grecaptcha.execute('6LegqWUnAAAAAEUXQGHtvJNwD-AnY5QRf1ui6NUH', { action: 'submit' }).then(function (token) {
260                    
261                    form.find(".google_response").val(token);
262
263                    $.ajax({
264                        url: '/wp-content/plugins/n5-calculator/inc/contact-form.php',
265                        type: "POST",
266                        dataType: 'json',
267                        data: form.serialize(),
268                        beforeSend: function () {
269                            btn.find('.loader').addClass('active');
270                            field.removeClass('novalid');
271                        },
272                        success: function (data, status, XHR) {
273                            btn.find('.loader').removeClass('active');
274							btn.removeAttr("disabled");
275                            if (data.success) {
276                                form[0].reset();
277                                field.removeClass("novalid");
278                                $('.popup-fade.popup3').hide();
279                                $('.popup-fade.popup4').show();
280                                setTimeout(function () {
281                                    $('.popup-fade.popup4').hide();
282                                }, 3000);
283                            } else {
284                                field.removeClass("novalid");
285                                $.each(data.data, function (index, value) {
286                                    form.find("[name=" + index + "]").addClass("novalid");
287                                });
288                            }
289                        },
290                        error: function (jqXHR, exception) {
291                            console.log('ОШИБКА AJAX запроса: ' + status, jqXHR);
292                        }
293                    });
294                });
295            });
296        }
297    });
298
299});

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.