PageSourceSearch

https://tricolor-nnov.ru/g/s3/misc/includeform/0.0.3/s3.includeform.js

js tricolor-nnov.ru collected 2026-10-08 16:34:54 UTC 3,153 bytes, 121 lines download raw bytes

1/* masalygin 0.0.3 */
2'use strict';
3
4(function(factory) {
5
6    if (typeof define === 'function' && define.amd) {
7
8        define(['jquery'], factory);
9
10    } else {
11
12        factory(jQuery);
13
14    }
15
16})(function($) {
17
18    $.fn.s3IncludeForm = function(url, type, callback) {
19
20        if ($.isFunction(type)) {
21            callback = type;
22            type = null;
23        }
24
25        url += (~url.indexOf('?') ? '&' : '?') + $.now();
26        type = type || 'comment';
27        callback = callback || $.noop;
28
29        if (~document.location.search.indexOf('screengrabber=1')) {
30            url += '&screengrabber=1';
31        }
32
33        return this.each(function() {
34
35            var _this = this;
36            var $this = $(this);
37            var id = $.now();
38            var key = 's3-include-form-id';
39
40            $this.data(key, id);
41
42            function init() {
43
44                $this.find('form').on('submit', function(e) {
45                    e.preventDefault();
46                    $.post(url, $(this).serialize(), update);
47                });
48
49                try {
50
51                    $this.find('.init-calendar').each(function(i){
52                        new tcal({
53                            'controlname': this.id,
54                            'place': this.parentNode,
55                            'lang': 'ru'
56                        });
57                    });
58
59                    $this.find('.init-calendar-interval').each(function(){
60
61                        for(var j=0; j<2; ++j){
62
63                            var e = f_getElement(this.id + '['+j+']');
64
65                            new tcal({
66                                'controlname': e.id,
67                                'place': e.parentNode,
68                                'lang': 'ru',
69                                'intervalpair': [
70                                    this.id + '[0]',
71                                    this.id + '[1]'
72                                ],
73                                'intervalupdatecont': this.id
74                            });
75                        }
76                    });
77
78                } catch (err) {}
79
80                try {
81                    Onicon.core.liveFormsApply();
82                } catch (e) {}
83
84            }
85
86
87            function update(html, status) {
88
89                if (status !== 'success' || $this.data(key) !== id) {
90                    return;
91                }
92
93                switch (type) {
94                    case 'comment':
95                        html = html.split('<!--includeForm-->');
96                        html = html.length === 3 ? html[1] : '';
97                        html = $.parseHTML(html);
98                        break;
99
100                    case 'all':
101                        html = $.parseHTML(html);
102                        break;
103
104                    default:
105                        html = $('<div>').append($.parseHTML(html)).find(type);
106                        break;
107                }
108
109                $this.html(html);
110                init();
111                callback.call(_this, html, status);
112
113            }
114
115            $.get(url, update);
116
117        });
118
119    };
120
121});

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.