PageSourceSearch

https://libufim.ru/simai/asset/simai.property/sf4/js/script.js

js libufim.ru collected 2026-10-02 20:22:13 UTC 34,905 bytes, 850 lines download raw bytes

1
2function property() {
3
4    var list = document.body.querySelectorAll('input:not([type="hidden"])');
5    var select = document.body.querySelectorAll('select');
6    var textarea = document.body.querySelectorAll('textarea');
7    var checkbox = document.body.querySelectorAll('input[type="checkbox"]');
8    var listImage = document.body.querySelectorAll('[data-list]');
9    var cond = document.querySelectorAll('.radio-change');
10    var sort = document.querySelectorAll('[data-sort]');
11
12    function isTrue(el) {
13        if(el != null && el != undefined) return true; else return false;
14    }
15
16    var inactive = document.body.querySelectorAll('.sf4_property_inactive');
17
18    if(isTrue(inactive)) {
19        for(var k = 0; k < inactive.length; k++) {
20            var el = inactive[k];
21            el.addEventListener('click', function(e) {
22                e.currentTarget.classList.remove('sf4_property_inactive');
23                var input = e.currentTarget.querySelector('.hidden-input'),
24                    allElements = e.currentTarget.querySelectorAll('[disabled=""]');
25
26                for(var k = 0; k < allElements.length; k++)
27                    if(allElements[k].hasAttribute('disabled')) allElements[k].removeAttribute('disabled');
28                if(isTrue(input)) {
29                    input.setAttribute('value', "Y");
30                    input.value = "Y";
31                }
32                var allInput = e.currentTarget.querySelectorAll('input'),
33                    event = new Event('input');
34                if(isTrue(allInput)) {
35                    for(var x = 0; x < allInput.length; x++) {
36                        var eIn = allInput[x];
37                        if(eIn.classList.contains('hidden-input')) {
38                            eIn.focus();
39                        }
40                    }
41                }
42            })
43        }
44    }
45
46
47    var btnMulti = document.body.querySelectorAll('input[data-button-property=""]');
48        if(btnMulti != null) {
49            for(var k = 0; k < btnMulti.length; k++) {
50                btnMulti[k].onclick = function(e) {
51                    addField(e);
52                }
53            }
54        }
55
56
57    // ----------- SELECT ------------- //
58
59    if(select != null) {
60        for(var k = 0; k < select.length; k++) {
61            var slc = select[k];
62                slc.addEventListener('change', function(e) {
63                    var el = e.currentTarget;
64                    var chang = el.parentNode.querySelector('[if-type="checkbox"]');
65                    for(var s = 0; s < el.options.length; s++) {
66                        var opt = el.options[s];
67                        if(opt.selected) {
68                            opt.setAttribute('selected', '');
69                            chang.setAttribute('checked', 'checked');
70                            chang.setAttribute('value', opt.value);
71                        } else {
72                            opt.removeAttribute('selected');
73                            chang.removeAttribute('checked');
74                        }
75                    }
76                    var chan = new Event('change');
77                    chang.dispatchEvent(chan);
78                });
79        }
80    }
81
82    if(isTrue(list)) {
83        for(var k = 0; k < list.length; k++) {
84            var el = list[k];
85            el.addEventListener('input', function(e) {
86                var input = e.target,
87                    condition = input.nextElementSibling,
88                    event = new Event('change');
89                if(condition.type != "hidden" || condition.type != "hidden") {
90                    if(isTrue(condition)) {
91                        condition.setAttribute('value', linkConditionSetValue(input) + input.value)
92                        condition.setAttribute('checked', 'checked');
93                        condition.dispatchEvent(event);
94                        if(input.hasAttribute('data-protocol')) {
95                            condition.value = linkConditionSetValue(input) + input.value;
96                        } else condition.value = input.value;
97                        condition.checked = true;
98                    }
99                    if(isTrue(input)) {
100                        if(input.classList.contains('form-check-input')) {
101                            if(input.checked) {
102                                input.value = "Y";
103                                input.checked = true;
104                                input.setAttribute('value', 'Y');
105                                input.setAttribute('checked', 'checked');
106                            } else {
107                                input.setAttribute('value', 'N');
108                                input.removeAttribute('checked');
109                                input.checked = false;
110                                input.value = "N";
111                            }
112                        }
113                    }
114                }
115                
116                
117            });
118        }
119    }
120
121    function linkConditionSetValue(input) {
122        if(input) {
123            if(input.hasAttribute('data-protocol')) {
124                
125                var container = input.parentNode,
126                    selectProtocol = container.querySelector('select[data-protocol=""]');
127                if(selectProtocol) {
128                    for(var k = 0; k < selectProtocol.options.length; k++) {
129                        var opt = selectProtocol.options[k];
130                        if(opt.selected) {
131                            return opt.value;
132                        }
133                    }
134                }
135            }
136        }
137    }
138
139    if(isTrue(textarea)) {
140        for(var k = 0; k < textarea.length; k++) {
141            var el = textarea[k];
142            el.addEventListener('input', function(e) {
143                var input = e.target,
144                    condition = input.nextElementSibling,
145                    event = new Event('change');
146                if(isTrue(condition)) {
147                    condition.setAttribute('value', input.value)
148                    condition.setAttribute('checked', 'checked');
149                    condition.dispatchEvent(event);
150                    condition.value = input.value;
151                    condition.checked = true;
152                }
153            })
154        }
155    }
156
157    if(isTrue(listImage)) {
158        for(var k = 0; k < listImage.length; k++) {
159            var data = listImage[k];
160            if(data.hasAttribute('data-list')) {
161                var dataList = data.getAttribute('data-list');
162                //imageAction(data);
163            }
164        }
165    }
166
167    // ----------- CHECKBOX ------------- //
168
169    if(checkbox != null) {
170        for(var k = 0; k < checkbox.length; k++) {
171            var check = checkbox[k],
172                chang = check.nextElementSibling;
173
174            if(check.checked) {
175                check.setAttribute('checked', '');
176                if(chang != null && chang != undefined)
177                    chang.setAttribute('checked', 'checked');
178            } else {
179                check.removeAttribute('checked', '');
180                if(chang != null && chang != undefined)
181                    chang.removeAttribute('checked');
182            }
183
184            if(chang != null && chang != undefined) {
185                var chan = new Event('change');
186                chang.dispatchEvent(chan);
187            }
188        }
189    }
190
191    var checkbox = document.body.querySelectorAll('[data-property-checkbox]');
192
193    if(checkbox != null) {
194        for(var k = 0; k < checkbox.length; k++) {
195            checkbox[k].addEventListener('change', function(e) {
196                var el = e.target,
197                    chang = el.nextElementSibling
198                if(el.checked) {
199                    el.value = 'Y'
200                    el.setAttribute('value', 'Y');
201                    el.setAttribute('checked', '');
202                    chang.setAttribute('checked', 'checked');
203                    chang.setAttribute('value', el.value);
204                } else {
205                    el.value = "N";
206                    el.setAttribute('value', 'N');
207                    el.setAttribute('checked', '');
208                    el.removeAttribute('checked');      
209                    chang.removeAttribute('checked');   
210                    chang.setAttribute('value', el.value);
211                }
212                var chan = new Event('change');
213                chang.dispatchEvent(chan);
214            });
215        }
216    }
217        if(inactive != null) {
218            for(var i = 0; i < inactive.length; i++) {
219
220                var input = inactive[i].querySelectorAll('input'),
221                    select = inactive[i].querySelectorAll('select'),
222                    textarea = inactive[i].querySelectorAll('textarea');
223
224                if(inactive[i].hasAttribute('data-input')) {
225                    inactive[i].ondragend = function(e) {
226                        e.target.parentNode.parentNode.querySelector('.hidden-input').value = 'Y'; 
227                        searchParent(e.target);				
228                    }
229                }
230
231                if(input != null) {
232                    for(var k = 0; k < input.length; k++) {
233                        var data = input[k];
234
235                        
236
237                        if(data.hasAttribute('data-property-checkbox')) {
238                            var dataCheck = data.getAttribute('data-property-checkbox');
239                                data.addEventListener('input', function(e) {
240                                    var el = e.target,
241                                        elHidden = el.parentNode.querySelector('.hidden-input');
242
243                                    if(el.checked) {
244                                        el.value = 'Y';
245                                        el.setAttribute('value', 'Y');
246                                        el.setAttribute('checked', 'checked');
247                                    } else {
248                                        el.value = 'N';
249                                        el.setAttribute('value', 'N');
250                                        el.removeAttribute('checked')
251                                    }
252                                    
253                                    if(elHidden != null) {
254                                        elHidden.value = 'Y'; 
255                                        elHidden.setAttribute('value', 'Y');                                                                       
256                                    }
257                                    searchParent(el);
258                                });
259                        }
260
261                        if(data.hasAttribute('data-entity')) {
262                            if(data.getAttribute('data-entity')) {
263
264                                var btn = data.parentNode.querySelector('input[type="button"]');
265                                if(btn != null) {
266                                    btn.addEventListener('click', function(e) {
267                                        var el = e.target;
268                                        var hidden = el.parentNode.parentNode.querySelector('.hidden-input');
269                                        hidden.value = "Y";
270                                        hidden.setAttribute('value', 'Y');
271                                        searchParent(el);
272                                    });
273                                }
274                            }
275                        }
276
277                        if(data.hasAttribute('data-datetime')) {
278                            if(data.getAttribute('data-datetime') == 'inactive-public') {
279                                data.addEventListener('click', function(e) {
280                                    data.classList.remove("sf4_property_inactive");
281                                })
282                                inactiveMode(data);
283                            }
284                        }
285                    }
286                }
287            }
288        }
289
290
291        if(list != null) {
292            for(var k = 0; k < list.length; k++) {
293                var listOne = list[k];
294                
295                if(listOne.hasAttribute('data-list')) {
296                    switch(listOne.getAttribute('data-list')) {
297                        case 'public-button':
298                            imageAction(listOne, true);
299                            break;
300                        case 'public-button-radio':
301                            imageAction(listOne, true);
302                            break;
303                        case 'public-image-list-one':
304                            imageAction(listOne);
305                        break;
306                        case 'public-image-list-multi':
307                            imageAction(listOne);
308                            break;                  
309                    }
310                }
311
312                if(listOne.hasAttribute('data-number')) {
313                    switch(listOne.getAttribute('data-number')) {
314                        case 'public-one':
315                            
316                            listOne.addEventListener('input', function(e) {
317                                var chang = e.target.nextElementSibling;
318                                chang.setAttribute('value', e.target.value);
319                                chang.setAttribute('checked', 'checked')
320                                var chan = new Event('change');
321                                chang.dispatchEvent(chan);
322                            });
323                            break;
324                    }
325                }
326            }
327        }
328
329        function addField(e) {
330            var btn = e.target,
331                container = btn.parentNode;
332            if(container != null) {
333                var el = container.querySelectorAll("*");
334                var propContainerElement = btn.parentNode.parentNode.querySelectorAll('*');
335                var input = [],
336                    entity = [],
337                    string = [],
338                    text = [],
339                    number = [],
340                    phone = [],
341                    url = [],
342                    link = [],
343                    date = [];
344
345                for(var i = 0; i < el.length; i++) {
346                    if(el[i].hasAttribute('data-property-field')) {
347                        switch(el[i].getAttribute('data-property-field')) {
348                            case 'entity':
349                                entity.push(el[i]);
350                                break;
351                            case 'string':
352                                string.push(el[i]);
353                                break;
354                            case 'text':
355                                text.push(el[i]);
356                                break;
357                            case 'number':
358                                number.push(el[i]);
359                                break;
360                            case 'phone':
361                                phone.push(el[i]);
362                                break;
363                            case 'url':
364                                url.push(el[i]);
365                                break;
366                            /*case 'link':
367                                link.push(el[i]);
368                                break;*/
369                            case 'date':
370                                date.push(el[i]);
371                                break;
372                        }
373                    }
374                }
375                for(var k = 0; k < propContainerElement.length; k++) {
376                    if(propContainerElement[k].hasAttribute('data-property-field')) {
377                        switch(propContainerElement[k].getAttribute('data-property-field')) {
378                            case 'link':
379                                link.push(propContainerElement[k]);
380                                break;
381                        }
382                    }
383                }
384                if(entity.length != 0) addEntity(entity, e);
385                if(text.length != 0) addText(text, e);
386                if(string.length != 0) addString(string, e);
387                if(number.length != 0) addString(number, e);
388                if(phone.length != 0) addString(phone, e);
389                if(url.length != 0) addString(url, e);
390                if(link.length != 0) addStringLink(link, e);
391                if(date.length != 0) addDate(date, e);
392            }
393        }
394        
395        function inactiveMode(input) {
396
397
398            input.addEventListener('input', function(e) {
399                var el = e.target;
400                el.parentNode.parentNode.querySelector('.hidden-input').value = 'Y'; 
401                searchParent(el);
402            });
403
404            input.addEventListener('change', function(e) {
405                var el = e.target;            
406                el.parentNode.parentNode.querySelector('.hidden-input').value = 'Y'; 					
407                searchParent(el);
408            });
409        }
410
411        function imageAction(input, active) {
412            input.addEventListener('click', function(e) {
413                var el = e.target;
414                var radio = el.parentNode.parentNode.querySelectorAll('input');
415                
416
417                var chang = el.nextElementSibling;
418                if(isTrue(chang))
419                    var par = chang.parentNode.parentNode.querySelectorAll('.radio-ch
419ange');
420                else {
421                    chang = el.parentNode.parentNode.querySelector('.radio-change');
422                    par = el.parentNode.parentNode.querySelectorAll('.radio-change');
423                }
424
425                var checkedValue = '';
426
427                for(var k = 0; k < radio.length; k++) {
428                    if(radio[k].checked && radio.length == 1) {
429                        checkedValue += radio[k].value
430                    } else if(radio[k].checked && radio.length > 1) {
431                        checkedValue += radio[k].value;
432                    }
433                }
434
435                par[0].setAttribute('value', checkedValue)
436
437                chang.setAttribute('checked', 'checked')
438                
439
440                var chan = new Event('change');
441                chang.dispatchEvent(chan);
442                par[0].dispatchEvent(chan)
443                chang.setAttribute('value', el.value);
444
445
446                if(input.type == 'radio') {
447                    for(var k = 0; k < radio.length; k++) {
448                        radio[k].checked = false;
449                        radio[k].removeAttribute('checked');
450                        if(active) radio[k].parentNode.classList.remove('active');   
451                    }
452                    el.checked = true;
453                    el.setAttribute('checked', '');
454                    if(active) el.parentNode.classList.add('active');
455                } else if(input.type == 'checkbox') {
456                    if(!el.checked) {
457                        el.checked = false;
458                        el.removeAttribute('checked');
459                        if(active) el.parentNode.classList.remove('active');
460                    } else {
461                        el.checked = true;
462                        el.setAttribute('checked', '');
463                        if(active) el.parentNode.classList.add('active');
464                    }
465                }
466            });
467        }
468
469        function searchParent(el) {
470            if(el != null && el.tagName != 'BODY') {
471                if(!el.parentNode.classList.contains('sf4_property_inactive')) searchParent(el.parentNode);
472                else el.parentNode.classList.remove('sf4_property_inactive');
473            }
474        }
475        
476        function rand() {
477            return Math.random() * (500000000000000000 - 50000000000000000) + 50000000000000000;
478        }
479
480        function addStringLink(link, e) {
481            var btnContainer = document.createElement('div');
482            btnContainer.className = e.currentTarget.parentNode.getAttribute('class');
483            var endClone = link[link.length - 1].cloneNode(true),
484                btnClone = e.currentTarget.cloneNode(true),
485                input = endClone.querySelectorAll('input'),
486                name = [];
487            if(input) {
488                for(var k = 0; k < input.length; k++) name.push(input[k].name);
489                for(var k = 0; k < input.length; k++) {
490                    input[k].value = '';
491                    input[k].name = filedIncrementName(name[k], link);
492                }
493                btnClone.onclick = function(ev) {
494                    addField(ev);
495                }
496                btnContainer.appendChild(btnClone);
497                link.push(endClone);
498                link.push(btnContainer);
499                var parent = link[0].parentNode;
500                parent.innerHTML = '';
501                for(var i = 0; i < link.length; i++) parent.appendChild(link[i]);
502            }
503        }
504
505        function addString(string, e) {
506            var endClone = string[string.length - 1].cloneNode(true),
507                btnClone = e.target.cloneNode(true),
508                input = endClone.querySelectorAll('input'),
509                name = input[0].name;
510                btnClone.onclick = function(e) {
511                    addField(e);
512                }
513                if(input == null)
514                    input = endClone.querySelectorAll('textarea');
515                input[0].value = '';
516                input[0].name = nameReplace(name, string);
517
518                if(input[0].hasAttribute('data-phone')) {
519                    var id = 'phone_mask_' + rand();
520                    input[0].id = id;
521                    id = '#' + id;
522
523                    jQuery(function($) {
524                        $(id).mask('+9 (999) 999-9999');
525                    });
526                }
527
528                if(input[0].hasAttribute('data-url')) {
529                    var id = rand();
530                    input[0].id = id;
531                    var btn = input[1];
532                    if(btn != null) {
533                        btn.addEventListener('click', function(e) {
534                                BX.adminShowMenu(this, [
535                                    {'TEXT':'Site directory','TITLE':'#SITE_DIR# - Site directory','ONCLICK':'SF.SFSetUrlVar(\'#
535SITE_DIR#\', \''+ id + '\')'},
536                                    {'SEPARATOR':true},
537                                    {'TEXT':'Storage id','TITLE':'#STORAGE_ID# - Storage id','ONCLICK':'SF.SFSetUrlVar(\'#STORAGE_ID#\', \''+ id + '\')'},
538                                    {'TEXT':'Section id','TITLE':'#SECTION_ID# - Section id','ONCLICK':'SF.SFSetUrlVar(\'#SECTION_ID#\', \''+ id + '\')'},
539                                    {'TEXT':'Item id','TITLE':'#ITEM_ID# - Item id','ONCLICK':'SF.SFSetUrlVar(\'#ITEM_ID#\', \''+ id + '\')'}], ''
540                                );
541                            });
542                    }
543                }
544                
545                string.push(endClone);
546                string.push(btnClone);
547                var parent = string[0].parentNode;
548                parent.innerHTML = '';
549                for(var i = 0; i < string.length; i++) parent.appendChild(string[i]);
550        }
551
552        function addDate(date, e) {
553            var endClone = date[date.length - 1].cloneNode(true),
554                btnClone = e.target.cloneNode(true);
555                var input = endClone.querySelectorAll('input'),
556                name = input[0].name;
557                btnClone.onclick = function(e) {
558                    addField(e);
559                }
560                input[0].value = '';
561                input[0].name = nameReplace(name, date);
562                date.push(endClone);
563                date.push(btnClone);
564                var parent = date[0].parentNode;
565                parent.innerHTML = '';
566                for(var i = 0; i < date.length; i++) parent.appendChild(date[i]);
567
568                jQuery(function($) {
569                    $('input[name="' + input[0].name + '"]').flatpickr({
570                        dateFormat: "d.m.Y",
571                        allowInput: true,
572                        locale: 'ru',
573                    });
574                });
575        }
576
577        function addText(text, e) {
578            var endClone = text[text.length - 1].cloneNode(true),
579                btnClone = e.target.cloneNode(true),
580                textArea = endClone.querySelectorAll('textarea'),
581                name = textArea[0].name;
582                btnClone.onclick = function(e) {
583                    addField(e);
584                }
585                var newText = document.createElement('textarea'),
586                    conText = document.createElement('div');
587                conText.className = 'form-group';
588                conText.setAttribute('data-property-field', 'text');
589                newText.name = nameReplace(name, text);
590                newText.className = 'form-control';
591                newText.rows = textArea[0].rows;
592                newText.cols = textArea[0].cols;
593                conText.appendChild(newText);  
594                text.push(conText);
595                text.push(btnClone);
596                var parent = text[0].parentNode;
597                parent.innerHTML = '';
598                for(var i = 0; i < text.length; i++) parent.appendChild(text[i]);
599        }
600
601        function nameReplace(name, text) {
602            if(text.length > 11) {
603                var index = name.substr(name.indexOf('[n', 0) + 2, 2);
604                var name = name.substr(0, name.length - 3);                        
605            }
606            else {
607                var index = name.substr(name.indexOf('[n', 0) + 2, 1);
608                var name = name.substr(0, name.length - 2);                                                
609            }
610
611            name += (Number(index)) + rand() + ']';
612            return name;
613        }
614
615        function filedIncrementName(name, text) {
616            var limit = name.substr(name.indexOf('[n', 0) + 2),
617                index = name.substr(name.indexOf('[n', 0) + 2, limit.length - 2),
618                name = name.substr(0, name.indexOf('[n', 0) + 2);
619            index++;
620            return name + index + '1]';
621        }
622
623        function addEntity(entity, e) {
624            var cI = entity[entity.length - 1].cloneNode(true),
625                cB = e.target.cloneNode(true),
626                inp = cI.querySelectorAll('input'),
627                id = inp[0].id,
628                btn = inp[1].getAttribute('onclick'),
629                name = inp[0].name,
630                randId = rand();
631
632            cB.onclick = function(e) {
633                addField(e);
634            }
635            btn = btn.replace(id, randId);
636            inp[0].value = '';
637            inp[0].name = nameReplace(name, entity);
638            inp[0].setAttribute('id', randId);
639            inp[1].setAttribute('onclick', btn);
640            entity.push(cI);
641            entity.push(cB);
642            var parent = entity[0].parentNode;
643            parent.innerHTML = '';
644            for(var j = 0; j < entity.length; j++) parent.appendChild(entity[j]);
645        }
646
647
648    // #region Link
649    
650        var link = document.body.querySelectorAll('.container-link');
651        for(var k = 0; k < link.length; k++) {
652            var container = link[k].querySelectorAll('.property_link');
653            for(var w = 0; w < container.length; w++) {
654                var input = container[w].querySelectorAll('input');
655                var select = container[w].querySelector('select');
656                for(var h = 0; h < input.length; h++) {
657                    if(input[h].hasAttribute('data-protocol')) {
658                        deleteSpace(input[h]);
659                        replaiceProtocol(select, input[h]);
660                        identifyProtocol(input[h]);
661                    }
662                }
663            }
664        }
665
666       /* window.addEventListener('click', function(e) {
667            var el = e.target;
668            if(el.oninput != null)
669                identifyProtocol(el);
670            if(el.hasAttribute('data-protocol'))
671                identifyProtocol(el);
672        });*/
673
674        function deleteSpace(input) {
675            var str = '';                
676            for(var s = 0; s < input.value.length; s++) if(input.value[s] != ' ') str += input.value[s];
677            input.value = str;
678        }
679
680        function identifyProtocol(el) {
681            if(el.hasAttribute('data-protocol')) { 
682                var input = el;
683                var select = el.parentNode.querySelector('select');
684                if(input != null) {
685                    if(input.hasAttribute('data-protocol')) {
686                        el.elSelect = select;
687                        select.elInput = el;
688                        el.oninput = function(e) {
689                            let input = e.currentTarget;
690                            replaiceProtocol(input.elSelect, input);
691                        }
692                        select.addEventListener('change', function(e) {
693                            var sel = e.currentTarget;
694                            replaiceProtocol(sel, sel.elInput);
695                        })
696                    }
697                }
698            }
699        }
700
701        function replaiceProtocol(select, input) {
702            deleteSpace(input);
703            var fullLink = select.parentNode.querySelector('input[data-link-full=""]');
704            for(var j = 0; j < select.options.length; j++) {
705                var options = select.options[j];
706                if(input.value.substring(0, options.value.length) == options.value) {
707                    select.selectedIndex = j;
708                    input.value = input.value.substring(options.value.length, input.value.length);
709                    select.options[j].setAttribute('selected', '');
710                    select.options[j].selected = true;
711                } else if(input.value.substring(0, 1) === '/') {
712                    select.selectedIndex = 2;
713                    select.options[2].selected = true;
714                    select.options[2].setAttribute('selected', '');
715                } else if(input.value.substring(0, options.value.length) === './') {
716                    select.selectedIndex = 3;
717                    select.options[3].selected = true;
718                    select.options[3].setAttribute('selected', '');
719                } else if(input.value.substring(0, options.value.length) === '../') {
720                    select.selectedIndex = 4;
721                    select.options[4].selected = true;
722                    select.options[4].setAttribute('selected', '');
723                }
724            }
725            if(input.value != "") fullLink.value = setFullLink(select) + input.value;
726            else fullLink.value = '';
727        }
728
729        function setFullLink(select) {
730            for(var k = 0; k < select.options.length; k++) if(select.options[k].selected) return select.options[k].value;
731            return false;
732        }
733
734        if(isTrue(cond)) {
735            for(var k = 0; k < cond.length; k++) {
736                var el = cond[k],
737                    event = new Event('change');
738                el.dispatchEvent(event);
739            }
740        }
741
742    // #endregion Link
743
744    SF.SFSetUrlVar = function(id, el_id) {
745	var obj_ta = BX(el_id);
746	//IE
747	if (document.selection) {
748		obj_ta.focus();
749		var sel = document.selection.createRange();
750		sel.text = id;
751		//var range = obj_ta.createTextRange();
752		//range.move('character', caretPos);
753		//range.select();
754	}
755	//FF
756	else if (obj_ta.selectionStart || obj_ta.selectionStart == '0')
757	{
758		var startPos = obj_ta.selectionStart;
759		var endPos = obj_ta.selectionEnd;
760		var caretPos = startPos + id.length;
761		obj_ta.value = obj_ta.value.substring(0, startPos) + id + obj_ta.value.substring(endPos, obj_ta.value.length);
762		obj_ta.setSelectionRange(caretPos, caretPos);
763		obj_ta.focus();
764	}
765	else
766	{
767		obj_ta.value += id;
768		obj_ta.focus();
769	}
770
771	BX.fireEvent(obj_ta, 'change');
772	obj_ta.focus();
773}
774
775
776'use strict';
777
778;( function ( document, window, index ) {
779    var inputs = document.querySelectorAll( '[data-file=""]' );
780    
781	Array.prototype.forEach.call( inputs, function( input )
782	{
783		var label	 = input.nextElementSibling,
784            labelVal = label.innerHTML;
785
786		input.addEventListener( 'change', function(e) {  
787			var fileName = '';
788			if( this.files && this.files.length > 1 )
789				fileName = ( this.getAttribute( 'data-multiple-caption' ) || '' ).replace( '{count}', this.files.length );
790			else fileName = e.target.value.split( '\\' ).pop();
791
792			if( fileName ) {
793                if(fileName.length > 16)
794                    label.querySelector( 'span' ).innerHTML = fileName.slice(0, 16) + '...';
795                else label.querySelector( 'span' ).innerHTML = fileName;
796            }
797            else label.innerHTML = labelVal;
798
799            // Для свойств
800            var el = e.target;
801            if(el.hasAttribute('data-inactive'))
802                el.parentNode.parentNode.classList.remove('sf4_property_inactive')
803		});
804
805		// Firefox bug fix
806		input.addEventListener( 'focus', function(){ input.classList.add( 'has-focus' ); });
807		input.addEventListener( 'blur', function(){ input.classList.remove( 'has-focus' ); });
808	});
809}( document, window, 0 ));
810
811
812};
813
814
815try {
816    property();
817} catch(error) {
818    window.addEventListener('DOMContentLoaded', function(e) {
819        property();
820    });
821}
822
823
824
825
826
827SF.send = function(event, element) {
828    if(document.createEvent){
829        var e = document.createEvent('Events');
830        e.initEvent(event, true, false);
831    }
832    else if(document.createEventObject()) {
833        var e = document.createEventObject();
834    }
835    else return;
836
837    if(element.dispatchEvent)
838        element.dispatchEvent(e);
839    else if(element.fireEvent) element.fireEvent(event, e);
840}
841
842SF.receive = function(event, el, handler) {
843    if(window.addEventListener)
844        el.addEventListener(event, handler, false);
845    else if(window.attachEvent)
846        el.attachEvent(event, handler);
847}
848
849SF.receive('open-setting', window, property);
850

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.