PageSourceSearch

https://minoxidil-ukraine.com/catalog/view/javascript/simple.js?v=10.82

js minoxidil-ukraine.com collected 2026-10-06 08:11:33 UTC 43,771 bytes, 1,096 lines download raw bytes

1(function($) {
2    var Simple = function() {
3    };
4
5    Simple.prototype.human = false;
6
7    Simple.prototype.instances = [];
8
9    Simple.prototype.resources = {
10        loading: "catalog/view/image/loading.gif",
11        next: "catalog/view/image/next_gray.png",
12        nextCompleted: "catalog/view/image/next_green.png"
13    };
14
15    Simple.prototype.serializeFields = function($block) {
16        var serialized = $block.find("input,select,textarea").serializeArray();
17
18        $block.find('input:checkbox:not(:checked)').each(function() {
19            var found = false;
20
21            for (var i in serialized) {
22                if (!serialized.hasOwnProperty(i)) continue;
23
24                if (serialized[i].name == this.name) {
25                    found = true;
26                }
27            }
28
29            if (!found) {
30                serialized.push({
31                    name: this.name,
32                    value: this.dataset && this.dataset.uncheckedValue ? this.dataset.uncheckedValue : ''
33                });
34            }
35        });
36
37        return serialized;
38    };
39
40    Simple.prototype.getValidationRules = function() {
41        var self = this;
42
43        return {
44            notEmpty: function($rule, silent) {
45                var fieldId = $rule.attr("data-for");
46                var fieldType = $rule.attr("data-for-type");
47
48                if (typeof silent === "undefined") {
49                    silent = false;
50                }
51
52                if (fieldId) {
53                    var $field = $(self.params.mainContainer).find("#" + fieldId);
54
55                    if (fieldType == 'checkbox' || fieldType == 'radio') {
56                        $field = $(self.params.mainContainer).find("[id*=" + fieldId + "_]");
57                    }
58                    
59                    if ($field.length) {
60                        if (!$rule.attr("data-required")) {
61                            $rule.hide();
62                            return true;
63                        }
64
65                        var value = "";
66
67                        if (fieldType == "checkbox" || fieldType == "radio") {
68                            var arr = $field.serializeArray();
69                            var values = [];
70                            for (var i in arr) {
71                                if (!arr.hasOwnProperty(i)) continue;
72                                values.push(arr[i].value);                                   
73                            }
74                            value = values.join(',');
75                        } else {
76                            value = $field.val();
77                        }
78
79                        if (!value) {
80                            if (!silent) {
81                                if (typeof toastr !== 'undefined' && self.params.notificationToasts) {
82                                    toastr.error($rule.text());
83                                }
84                                
85                                if (self.params.notificationDefault) {
86                                    $rule.show();
87                                }
88                            }
89                            return false;
90                        } else {
91                            $rule.hide();
92                            return true;
93                        }
94                    }
95                }
96                return true;
97            },
98            equal: function($rule, silent) {
99                var fieldId = $rule.attr("data-for");
100                var equalId = $rule.attr("data-equal");
101
102                if (typeof silent === "undefined") {
103                    silent = false;
104                }
105
106                if (fieldId && equalId) {
107                    var $mainContainer = $(self.params.mainContainer);
108
109                    var $field = $mainContainer.find("#" + fieldId);
110                    var $equal = $mainContainer.find("#" + equalId);
111
112                    if ($field.length && $equal.length) {
113                        if ($equal.val() != $field.val()) {
114                            if (!silent) {
115                                if (typeof toastr !== 'undefined' && self.params.notificationToasts) {
116                                    toastr.error($rule.text());
117                                }
118                                
119                                if (self.params.notificationDefault) {
120                                    $rule.show();
121                                }
122                            }
123                            return false;
124                        } else {
125                            $rule.hide();
126                            return true;
127                        }
128                    }
129                }
130                return true;
131            },
132            byLength: function($rule, silent) {
133                var fieldId = $rule.attr("data-for");
134
135                if (typeof silent === "undefined") {
136                    silent = false;
137                }
138
139                if (fieldId) {
140                    var $field = $(self.params.mainContainer).find("#" + fieldId);
141
142                    if ($field.length) {
143                        var min = 0;
144                        var max = 1000;
145
146                        if ($rule.attr("data-length-min")) {
147                            min = ~~$rule.attr("data-length-min");
148                        }
149
150                        if ($rule.attr("data-length-max")) {
151                            max = ~~$rule.attr("data-length-max");
152                        }
153
154                        var value = ($field.val() + '').trim();
155
156                        if (!value && !$rule.attr("data-required")) {
157                            $rule.hide();
158                            return true;
159                        }
160
161                        if (value.length < min || value.length > max) {
162                            if (!silent) {
163                                if (typeof toastr !== 'undefined' && self.params.notificationToasts) {
164                                    toastr.error($rule.text());
165                                }
166                                
167                                if (self.params.notificationDefault) {
168                                    $rule.show();
169                                }
170                            }
171                            return false;
172                        } else {
173                            $rule.hide();
174
175                            return true;
176                        }
177                    }
178                }
179                return true;
180            },
181            regexp: function($rule, silent) {
182                var fieldId = $rule.attr("data-for");
183                var fieldType = $rule.attr("data-for-type");
184
185                if (typeof silent === "undefined") {
186                    silent = false;
187                }
188
189                if (fieldId) {
190                    var $field = $(self.params.mainContainer).find("#" + fieldId);
191
192                    if (fieldType == 'checkbox' || fieldType == 'radio') {
193                        $field = $(self.params.mainContainer).find("[id*=" + fieldId + "_]");
194                    }
195                    
196                    if ($field.length) {
197                        var regexp = $rule.attr("data-regexp");
198
199                        if (regexp) {
200                            var value = "";
201
202                            if (fieldType == "checkbox" || fieldType == "radio") {
203                                var arr = $field.serializeArray();
204                                var values = [];
205                                for (var i in arr) {
206                                    if (!arr.hasOwnProperty(i)) continue;
207                                    values.push(arr[i].value);                                   
208                                }
209                                value = values.join(',');
210                            } else {
211                                value = $field.val();
212                            }
213
214                            if (!value && !$rule.attr("data-required")) {
215                                $rule.hide();
216                                return true;
217                            }
218
219                            try {
220                                if (!value.match(regexp)) {
221                                    if (!silent) {
222                                        if (typeof toastr !== 'undefined' && self.params.notificationToasts) {
223                                            toastr.error($rule.text());
224                                        }
225                                        
226                                        if (self.params.notificationDefault) {
227                                            $rule.show();
228                                        }
229                                    }
230                                    return false;
231                                } else {
232                                    $rule.hide();
233                                    return true;
234                                }
235                            } catch (err) {
236
237                            }
238                        }
239                    }
240                }
241                return true;
242            },
243            api: function($rule, silent) {
244                var fieldId = $rule.attr("data-for");
245                var fieldType = $rule.attr("data-for-type");
246
247                var $mainContainer = $(self.params.mainContainer);
248
249                if (typeof silent === "undefined") {
250                    silent = false;
251                }
252
253                if (fieldId) {
254                    var $field = $mainContainer.find("#" + fieldId);
255
256                    if (fieldType == 'checkbox' || fieldType == 'radio') {
257                        $field = $(self.params.mainContainer).find("[id*=" + fieldId + "_]");
258                    }
259
260                    if ($field.length) {
261                        var method = $rule.attr("data-method");
262
263                        if (method) {
264                            var filter = "";
265
266                            if ($rule.attr("data-filter")) {
267                                var filterType = $rule.attr("data-filter-type");
268
269                                var $filter = $mainContainer.find("#" + $rule.attr("data-filter"));
270
271                                if (filterType == 'checkbox' || filterType == 'radio') {
272                                    $filter = $mainContainer.find("[id*=" + $rule.attr("data-filter") + "_]");
273                                }
274
275                                if ($filter.length) {
276                                    if (filterType == "radio" || filterType == "checkbox") {
277                                        var arr = $filter.serializeArray();
278                                        var values = [];
279                                        for (var i in arr) {
280                                            if (!arr.hasOwnProperty(i)) continue;
281                                            values.push(arr[i].value);                                   
282                                        }
283                                        filter = values.join(',');
284                                    } else {
285                                        filter = $filter.val();
286                                    }
287                                } else if ($rule.attr("data-filter-value")) {
288                                    filter = $rule.attr("data-filter-value");
289                                }
290                            }
291
292                            var custom = $rule.attr("data-custom") ? true : false;
293
294                            var deferred = $.Deferred();
295
296                            var value = "";
297
298                            if (fieldType == "checkbox" || fieldType == "radio") {
299                                var arr = $field.serializeArray();
300                                var values = [];
301                                for (var i in arr) {
302                                    if (!arr.hasOwnProperty(i)) continue;
303                                    values.push(arr[i].value);                                   
304                                }
305                                value = values.join(',');
306                            } else {
307                                value = $field.val();
308                            }
309
310                            $.get("index.php?" + self.params.additionalParams + "route=common/simple_connector/validate&method=" + method + "&filter=" + encodeURIComponent(filter) + "&value=" + encodeURIComponent(value) + (custom ? "&custom=1 " : ""), function(data) {
311                                data = data.trim();
312                                
313                                if (data == "invalid") {
314                                    if (!silent) {
315                                        if (typeof toastr !== 'undefined' && self.params.notificationToasts) {
316                                            toastr.error($rule.text());
317                                        }
318                                        
319                                        if (self.params.notificationDefault) {
320                                            $rule.show();
321                                        }
322                                    }
323                                    deferred.resolve(false);
324                                } else {
325                                    $rule.hide();
326                                    deferred.resolve(true);
327                                }
328
329                                const inputField = $('#simplepage_form #edit_email');
330                                if (inputField && inputField.val() === '') {
331                                    $('[data-method="checkEmailForUniqueness"]').hide();
332                                    $('[data-rule="regexp"]').hide();
333                                }
334                            });
335
336                            return deferred.promise();
337                        }
338                    }
339                }
340
341                return true;
342            }
343        };
344    };
345
346    Simple.prototype.initValidationRules = function() {
347        var self = this;
348        var $mainContainer = $(self.params.mainContainer);
349
350        $mainContainer.find(".simplecheckout-rule-group").each(function() {
351            var $ruleGroup = $(this);
352            var fieldId = $(this).attr("data-for");
353            var promises = [];
354
355            if (fieldId) {
356                var $field = $mainContainer.find("#" + fieldId);
357                
358                if (!$field.length) {
359                    $field = $mainContainer.find("[id*=" + fieldId + "_]");
360                }
361
362                if ($field.length) {
363                    var checker = function() {
364                        var result = true;
365
366                        $ruleGroup.find(".simplecheckout-rule").each(function() {
367                            var $rule = $(this);
368                            var type = $(this).attr("data-rule");
369                            var rules = self.getValidationRules();
370                            
371                            if (typeof rules[type] === "function") {
372                                var promise = $.when(rules[type]($rule)).then(function(ruleResult){
373                                    if (!ruleResult) {
374                                        result = false;
375                                    }
376
377                                    return $.when(ruleResult);
378                                });
379
380                                promises.push(promise);
381                            }
382                        });
383
384                        $.when.apply($, promises).then(function() {
385                            $field.attr("data-valid", result ? "true" : "false");
386
387                            if (!result) {
388                                $field.parents(".form-group").addClass("has-error")
389                            } else  {
390                                $field.parents(".form-group").removeClass("has-error")
391                            }
392                        });
393                    };
394
395                    var $pairField = false;
396                    
397                    $ruleGroup.find(".simplecheckout-rule").each(function() {
398                        if ($(this).attr("data-rule") == 'equal' && $(this).attr("data-equal")) {
399                            if ($("#" + $(this).attr("data-equal")).length) {
400                                $pairField = $("#" + $(this).attr("data-equal"));
401                            }
402                        }
403                    });
404
405                    if (!self.params.notificationToasts && $field.attr('data-validate-on') && typeof $field[$field.attr('data-validate-on')] === 'function') {
406                        $field[$field.attr('data-validate-on')](checker);
407
408                        if ($pairField) {
409                            $pairField[$field.attr('data-validate-on')](checker);
410                        }                  
411                    } else {
412                        $field.change(checker);
413
414                        if ($pairField) {
415                            $pairField.change(function() { 
416                                if ($field.val()) {
417                                    checker.call($field);
418                                }
419                            });
420                        }
421                    }                    
422                }
423            }
424        });
425    };
426
427    Simple.prototype.checkRules = function(container, silent) {
428        var self = this;
429        var fields = {};
430        var resultAll = true;
431        var allPromises = [];
432        var $mainContainer =  $(self.params.mainContainer);
433        var $container = $mainContainer;
434
435        if (container) {
436            $container = $mainContainer.find(container);
437        }
438
439        if (typeof silent === "undefined") {
440            silent = false;
441        }
442
443        if ($container.length && ($container.is(":visible") || $container.find('*').is(":visible"))) {
444            $container.find(".simplecheckout-rule-group").each(function() {
445                var ruleGroupResult = true;
446                var promises = [];
447                var $ruleGroup = $(this);
448                var fieldId = $(this).attr("data-for");
449
450                if (fieldId) {
451                    var $field = $mainContainer.find("#" + fieldId);
452
453                    if (!$field.length) {
454                        $field = $mainContainer.find("[id*=" + fieldId + "_]");
455                    }
456
457                    if ($field.length) {
458                        $ruleGroup.find(".simplecheckout-rule").each(function() {
459                            var $rule = $(this);
460                            var type = $(this).attr("data-rule");
461                            var rules = self.getValidationRules();
462
463                            if (typeof rules[type] === "function") {
464                                var promise = $.when(rules[type]($rule, silent)).then(function(ruleResult){
465                                    if (!ruleResult) {
466                                        ruleGroupResult = false;
467                                    }
468
469                                    return $.when(ruleResult);
470                                });
471
472                                promises.push(promise);
473                            }
474                        });
475
476                        var groupPromise = $.when.apply($, promises).then(function() {
477                            $field.attr("data-valid", ruleGroupResult ? "true" : "false");
478
479                            if (!ruleGroupResult) {
480                                $field.parents(".form-group").addClass("has-error")
481                            } else  {
482                                $field.parents(".form-group").removeClass("has-error")
483                            }
484
485                            if (!ruleGroupResult) {
486                                resultAll = false;
487                            }
488                        });
489
490                        allPromises.push(groupPromise);
491                    }
492                }
493            });
494        }
495
496        var deferred = $.Deferred();
497
498        $.when.apply($, allPromises).then(function() {
499            deferred.resolve(resultAll);
500        });
501
502        return deferred.promise();
503    };
504
505    Simple.prototype.setAddressFields = function(block, countryId, zoneId, city, postcode, callbackAfterChanging) {
506        var self = this;
507        var $mainContainer = $(self.params.mainContainer);
508
509        var setFields = function() {
510            if (countryId) {
511                $mainContainer.find("#" + block + "_country_id").val(countryId);
512            }
513            if (zoneId) {
514                $mainContainer.find("#" + block + "_zone_id").val(zoneId);
515            }
516            if (city) {
517                $mainContainer.find("#" + block + "_city").val(city);
518            }
519            if (postcode) {
520                $mainContainer.find("#" + block + "_postcode").val(postcode);
521            }
522
523            if (typeof callbackAfterChanging === "function") {
524                callbackAfterChanging();
525            } else if (typeof reloadAll === "function") {
526                reloadAll();
527            }
528        };
529
530        if ($mainContainer.find("#" + block + "_country_id").val() != countryId) {
531            $mainContainer.find("#" + block + "_zone_id").load("index.php?" + self.params.additionalParams + "route=common/simple_connector/zone&country_id=" + countryId, function() {
532                setFields();
533            });
534        } else {
535            setFields();
536        }
537    };
538
539    Simple.prototype.initFileUploader = function(beforeUploading, afterUploading) {
540        var self = this;
541        var $mainContainer = $(self.params.mainContainer);
542
543        $mainContainer.find("[data-file]").each(function() {
544            var hiddenInputId = $(this).attr("data-file");
545            var fileNameId = hiddenInputId ? "text_" + hiddenInputId : "";
546
547            $(this).on("click", function() {
548                $("#form-upload").remove();
549
550                $("body").prepend("<form enctype='multipart/form-data' id='form-upload' style='display: none;'><input type='file' name='file' /></form>");
551
552                $("#form-upload input[name='file']").trigger("click");
553
554                if (typeof fileUploaderTimer !== "undefined") {
555                    clearInterval(fileUploaderTimer);
556                }
557
558                fileUploaderTimer = setInterval(function() {
559                    if ($("#form-upload input[name='file']").val() != "") {
560                        clearInterval(fileUploaderTimer);
561
562                        $.ajax({
563                            url: "index.php?" + self.params.additionalParams + "route=common/simple_connector/upload",
564                            type: "post",
565                            dataType: "json",
566                            data: new FormData($("#form-upload")[0]),
567                            cache: false,
568                            contentType: false,
569                            processData: false,
570                            beforeSend: function() {
571                                if (typeof beforeUploading === "function") {
572                                    beforeUploading();
573                                }
574                            },
575                            complete: function() {
576                                $("#form-upload").remove();
577
578                                if (typeof afterUploading === "function") {
579                                    afterUploading();
580                                }
581                            },
582                            success: function(json) {
583                                if (json["file"]) {
584                                    if (hiddenInputId) {
585                                        $mainContainer.find("#" + hiddenInputId).val(json["file"]).trigger('change');
586                                    }
587                                    if (fileNameId) {
588                                        var fname = typeof json["filename"] !== "undefined" && json["filename"] ? json["filename"] : file;
589                                        $mainContainer.find("#" + fileNameId).text(fname);
590                                    }
591                                }
592
593                                if (json["error"]) {
594                                    if (hiddenInputId) {
595                                        $mainContainer.find("#" + hiddenInputId).attr("value", "");
596                                    }
597                                    if (fileNameId) {
598                                        $mainContainer.find("#" + fileNameId).text(json["error"]);
599                                    }
600                                }
601                            },
602                            error: function(xhr, ajaxOptions, thrownError) {
603                                alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
604                            }
605                        });
606                    }
607                }, 500);
608            });            
609        });
610    };
611
612    Simple.prototype.initAutocomplete = function(callbackAfterChanging) {
613        var self = this;
614        var $fields = $(self.params.mainContainer).find("#payment_address_city, #shipping_address_city, #register_city, #address_city");
615        if (typeof($fields.autocomplete) !== "undefined") {
616            $fields.each(function() {
617                var $field = $(this)
618                var tmp = $field.attr("data-onchange");
619                if (tmp) {
620                    $field.removeAttr("data-onchange");
621                    $field.removeAttr("data-reload-payment-form");
622                    $field.attr("data-onchange-delayed", tmp);
623                }
624
625                $field.on("keydown", function(){
626                    $field.data("status", "started");
627                });
628            
629                $field.autocomplete({
630                    source: function(request, response) {
631                        $.ajax({
632                            url: "index.php?" + self.params.additionalParams + "route=common/simple_connector/geo",
633                            dataType: "json",
634                            data: {
635                                term: typeof request.term !== "undefined" ? request.term : request
636                            },
637                            success: function(data) {
638                                response($.map(data, function(item) {
639                                    if (typeof request.term === "undefined") {
640                                        return {
641                                            id: item.id,
642                                            label: item.full,
643                                            value: item.id,
644                                            postcode: item.postcode,
645                                            zone_id: item.zone_id,
646                                            country_id: item.country_id,
647                                            city: item.city
648                                        };
649                                    } else {
650                                        return {
651                                            id: item.id,
652                                            label: item.full,
653                                            value: item.city,
654                                            postcode: item.postcode,
655                                            zone_id: item.zone_id,
656                                            country_id: item.country_id,
657                                            city: item.city
658                                        };
659                                    }
660
661                                }));
662                            }
663                        });
664                    },
665                    minLength: 2,
666                    delay: 300,
667                    close: function( event, ui ) {
668                        if ($field.data("status") == "started") {
669                            //$field.val("");
670                            callbackAfterChanging($field);
671                        }
672                    },
673                    select: function(event, ui) {
674                        $field.data("status", "selected");
675                        var name = $field.attr("name");
676                        var from = name.substr(0, name.indexOf("["));
677                        
678                        if (ui !== undefined) {
679                            self.setAddressFields(from, ui.item.country_id, ui.item.zone_id, ui.item.city, ui.item.postcode, function() {
680                                callbackAfterChanging($field);
681                            });
682                        } else {
683                            self.setAddressFields(from, event.country_id, event.zone_id, event.city, event.postcode, function() {
684                                callbackAfterChanging($field);
685                            });
686                        }
687                    }
688                });
689            });
690        }
691    };
692
693    Simple.prototype.initPopups = function() {
694        var self = this;
695        var $mainContainer = $(self.params.mainContainer);
696
697        if (typeof($.fancybox) == "function") {
698            $mainContainer.find(".fancybox").fancybox({
699                width: 560,
700                height: 560,
701                autoDimensions: false
702            });
703        }
704
705        if (typeof($.colorbox) == "function") {
706            $mainContainer.find(".colorbox").colorbox({
707                width: 560,
708                height: 560
709            });
710        }
711
712        if (typeof($.prettyPhoto) !== "undefined") {
713            $mainContainer.find("a[rel^='prettyPhoto']").prettyPhoto({
714                theme: "light_square",
715                opacity: 0.5,
716                social_tools: "",
717                deeplinking: false
718            });
719        }
720    };
721
722    Simple.prototype.initTooltips = function(bootstrap) {
723        var self = this;
724        var $mainContainer = $(self.params.mainContainer);
725
726        $mainContainer.find(".simplecheckout-tooltip[data-for]").each(function() {
727            var $target = $mainContainer.find("#" + $(this).attr("data-for"));
728
729            if ($target.length) {
730                if ($target.attr("data-file")) {
731                    $(this).show();
732                } else {
733                    if (bootstrap && typeof $target.tooltip === "function") {
734                        $target.tooltip({
735                            html: true,
736                            title: $(this).html(),
737                            placement: 'bottom',
738                            container: 'body'
739                        });
740                    } else if (typeof $target.easyTooltip === "function") {
741                        $target.easyTooltip({
742                            useElement: self.params.mainContainer + " .simplecheckout-tooltip[data-for='" + $(this).attr("data-for") + "']",
743                            clickRemove: true
744                        });
745                    }
746                }
747            }
748        });
749    };
750
751    Simple.prototype.initMasks = function() {
752        var self = this;
753        var $mainContainer = $(self.params.mainContainer);
754
755        if (typeof $(document).inputmask !== "undefined" /*&& !window.localStorage.getItem('inputmaskFailed')*/) {
756            var masked = [];
757            $mainContainer.find("input[data-simple-mask]").each(function(indx) {
758                var mask = $(this).attr("data-simple-mask");
759                var id = $(this).attr("id");
760                if (mask && id) {
761                    masked[masked.length] = [id, mask];
762                }
763            });
764            try {
765                for (var i = 0; i < masked.length; i++) {
766                    var id = masked[i][0];
767                    var mask = masked[i][1];
768
769                    $mainContainer.find("input[id=" + id + "]")
770                        .inputmask({
771                            mask: mask,
772                            clearMaskOnLostFocus: true,
773                            clearIncomplete: true,
774                        });
775                        /*.on('change', function() {
776                            if ($(this).val().indexOf('_') > -1) {
777                                window.localStorage.setItem('inputmaskFailed', true);
778                                $(this).inputmask('remove');
779                            }                      
780                        });*/
781                }
782            } catch (err) {}
783        }
784    };
785
786    Simple.prototype.initSelect2 = function() {
787        var self = this;
788       
789        if (typeof $(document).select2 !== "undefined") {
790            $(self.params.mainContainer).find("select[data-type=select2]").each(function() {
791                $(this).select2({
792                    
793                });
794            });
795        }
796    };
797
798    Simple.prototype.initDatepickers = function(callbackAfterChanging) {
799        var self = this;
800        var days = false;
801
802        var checkWeekendAndHoliday = function(date) {
803            if (typeof $.datepicker !== "undefined") {
804                var noWeekend = $.datepicker.noWeekends(date);
805            } else {
806                var noWeekend = [(date.getDay() == 0 || date.getDay() == 6), ""];
807            }
808
809            if (noWeekend[0]) {
810                return checkNationalDay(date);
811            } else {
812                return noWeekend;
813            }
814        };
815
816        var checkNationalDay = function(date) {
817            var days = [
818                [1, 1, "ru"],
819                [1, 7, "ru"],
820                [5, 9, "ru"]
821            ];
822
823            for (i = 0; i < days.length; i++) {
824                if (date.getMonth() == days[i][0] - 1 && date.getDate() == days[i][1]) {
825                    return [false, days[i][2] + "_day"];
826                }
827            }
828            return [true, ""];
829        };
830
831        var addDays = function(add, onlyWeekdays) {
832            var result = add | 0;
833            var self = this;
834            if (onlyWeekdays) {
835                var i = 1;
836                while (i <= result) {
837                    var d = new Date();
838                    d.setDate(d.getDate() + i);
839                    var test = checkWeekendAndHoliday(d);
840                    if (!test[0]) {
841                        result++;
842                    }
843                    i++;
844                }
845            }
846
847            return result;
848        };
849
850        var checkDays = function(date) {
851            for (var i = 0; i < days.length; i++) {
852                if (date.getDay() == days[i]) {
853                    return [true, ""];
854                }
855            }
856
857            return [false, ""];
858        };
859
860        $(self.params.mainContainer).find("input[type=date],input[type=datetime],input[data-type=date],input[data-type=datetime]").each(function() {
861            var onlyWeekdays = $(this).attr("data-weekdays-only") ? true : false,
862                min = new Date(),
863                max = new Date();
864            
865            if ($(this).attr("data-days-only")) {
866                days = $(this).attr("data-days-only").split(",");
867                onlyWeekdays = false;
868            }
869            
870            if ($(this).attr("data-start-day")) {
871                min = $(this).attr("data-start-day");
872            } else if ($(this).attr("data-start-after")) {
873                min.setDate(min.getDate() + addDays($(this).attr("data-start-after"), onlyWeekdays));
874            }
875            
876            if ($(this).attr("data-end-day")) {
877                max = $(this).attr("data-end-day");
878            } else if ($(this).attr("data-end-after")) {
879                max.setDate(max.getDate() + addDays($(this).attr("data-end-after"), onlyWeekdays));
880            }
881            
882            if (typeof($(this).datetimepicker) !== "undefined") {
883                var disabledDays = [];
884
885                if (onlyWeekdays || typeof days.length !== "undefined") {
886                    var useDays = false;
887
888                    if (days.length !== "undefined" && days.length) {
889                        useDays = true;
890                    }
891
892                    for (var i = 0; i < 7; i++) {
893                        if (((i == 6 || i == 0) && onlyWeekdays) || (useDays && $.inArray(i + "", days) == -1)) {
894                            disabledDays.push(i);
895                        }
896                    }
897                }
898                
899                var $el = $(this);
900 
901                $el.datetimepicker({
902                    pickDate: true,
903                    pickTime: $el.attr("data-type") == "datetime" ? true : false,
904                    showTimepicker: false,
905                    daysOfWeekDisabled: disabledDays,
906                    firstDay: 1,
907                    beforeShowDay: onlyWeekdays ? checkWeekendAndHoliday : (days ? checkDays : null),
908                    minDate: min ? min : null,
909                    maxDate: max ? max : null,
910                    useCurrent: false,
911                    showButtonPanel: false,
912                    language: self.params.languageCode,
913                    locale: self.params.languageCode,
914                    onSelect: function() {
915                        $el.datetimepicker('hide');
916                    }
917                }).on('dp.change', function(dateText, inst) {
918                    if (typeof callbackAfterChanging === "function") {
919                        callbackAfterChanging($el);
920                    }
921                });
922
923                $el.next().on('click', function () {
924                    $el.focus();
925                });
926            } else if (typeof($(this).datepicker) !== "undefined") {
927                $(this).datepicker({
928                    firstDay: 1,
929                    beforeShowDay: onlyWeekdays ? checkWeekendAndHoliday : (days ? checkDays : null),
930                    minDate: min ? min : null,
931                    maxDate: max ? max : null,
932                    onSelect: function(dateText, inst) {
933                        if (typeof callbackAfterChanging === "function") {
934                            callbackAfterChanging($(this));
935                        }
936                    }
937                });
938            }
939        });
940    };
941
942    Simple.prototype.initTimepickers = function(callbackAfterChanging) {
943        var self = this;
944        var min = "";
945
946        if ($(this).attr("data-min-time")) {
947            min = ~~ ($(this).attr("data-min-time").split(":")[0]);
948        }
949
950        var max = "";
951
952        if ($(this).attr("data-max-time")) {
953            max = ~~ ($(this).attr("data-max-time").split(":")[0]);
954        }
955
956        var onlyHours = $(this).attr("data-hours-only") ? true : false;
957
958        $(self.params.mainContainer).find("input[type=time],input[data-type=time]").each(function() {
959            if (typeof($(this).datetimepicker) !== "undefined") {
960                var $el = $(this);
961                
962                $el.datetimepicker({
963                    pickDate: false,
964                    //language: document.cookie.match(new RegExp('language=([^;]+)')) && document.cookie.match(new RegExp('language=([^;]+)'))[1],
965                    language: self.params.languageCode,
966                    locale: self.params.languageCode,
967                    pickTime: true,
968                    showMinute: !onlyHours,
969                    useCurrent: false
970                }).on('dp.change', function(dateText, inst) {
971                    if (typeof callbackAfterChanging === "function") {
972                        callbackAfterChanging($el);
973                    }
974                });
975
976                $el.next().on('click', function () {
977                    $el.focus();
978                });
979            } else if (typeof($(this).timepicker) !== "undefined") {
980                $(this).timepicker({
981                    hourMin: min,
982                    hourMax: max,
983                    showMinute: !onlyHours,
984                    onSelect: function(datetimeText, datepickerInstance) {
985                        if (typeof callbackAfterChanging === "function") {
986                            callbackAfterChanging($(this));
987                        }
988                    },
989                    onClose: function() {
990                        if (typeof callbackAfterChanging === "function") {
991                            callbackAfterChanging($(this));
992                        }
993                    }
994                });
995            }
996        });
997    };
998
999    Simple.prototype.checkIsHuman = function() {
1000        var self = this;
1001        var timeoutId = 0;
1002
1003        $("body").on("mousemove", function() {
1004            if (!self.human) {
1005                clearTimeout(timeoutId);
1006
1007                timeoutId = window.setTimeout(function(){
1008                    self.human = true;
1009                    $.get("index.php?" + self.params.additionalParams + "route=common/simple_connector/human");
1010                }, 300);
1011            }
1012        });
1013    };
1014
1015    $.ajaxSetup({ cache: false });
1016
1017    window.Simple = Simple;
1018})(jQuery || $);
1019
1020if (typeof String.prototype.trim !== "function") {
1021    String.prototype.trim = function() {
1022        return this.replace(/^\s+|\s+$/g, "");
1023    };
1024}
1025
1026function includeScript(url) {
1027    document.write("<script type='text/javascript' src='" + url + "'></script>");
1028}
1029
1030function includeStyle(url) {
1031    document.write("<link rel='stylesheet' type='text/css' href='" + url + "' media='screen' />");
1032}
1033
1034function bind(func, context) {
1035    return function() {
1036        return func.apply(context, arguments);
1037    };
1038}
1039
1040function inherit(proto) {
1041    function F() {}
1042    F.prototype = proto;
1043    var object = new F();
1044    return object;
1045}
1046
1047function reloadAll() {
1048    if (typeof Simple.prototype.instances !== "undefined") {
1049        for (var i in Simple.prototype.instances) {
1050            if (!Simple.prototype.instances.hasOwnProperty(i)) continue;
1051
1052            if (typeof Simple.prototype.instances[i].reloadAll === "function") {
1053                Simple.prototype.instances[i].reloadAll();
1054            }
1055        }
1056    }
1057}
1058
1059function reloadBlock() {
1060    if (typeof Simple.prototype.instances !== "undefined") {
1061        for (var i in Simple.prototype.instances) {
1062            if (!Simple.prototype.instances.hasOwnProperty(i)) continue;
1063
1064            if (typeof Simple.prototype.instances[i].reloadBlock === "function") {
1065                Simple.prototype.instances[i].reloadBlock.apply(Simple.prototype.instances[i], arguments);
1066            }
1067        }
1068    }
1069}
1070
1071if (!window.localStorage) {
1072  window.localStorage = {
1073    getItem: function (sKey) {
1074      if (!sKey || !this.hasOwnProperty(sKey)) { return null; }
1075      return unescape(document.cookie.replace(new RegExp("(?:^|.*;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"), "$1"));
1076    },
1077    key: function (nKeyId) {
1078      return unescape(document.cookie.replace(/\s*\=(?:.(?!;))*$/, "").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/)[nKeyId]);
1079    },
1080    setItem: function (sKey, sValue) {
1081      if(!sKey) { return; }
1082      document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";
1083      this.length = document.cookie.match(/\=/g).length;
1084    },
1085    length: 0,
1086    removeItem: function (sKey) {
1087      if (!sKey || !this.hasOwnProperty(sKey)) { return; }
1088      document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
1089      this.length--;
1090    },
1091    hasOwnProperty: function (sKey) {
1092      return (new RegExp("(?:^|;\\s*)" + escape(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
1093    }
1094  };
1095  window.localStorage.length = (document.cookie.match(/\=/g) || window.localStorage).length;
1096}

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.