PageSourceSearch

https://matol.kz/resources/js/comment/editor.js

js matol.kz collected 2026-10-08 11:29:22 UTC 4,775 bytes, 123 lines download raw bytes

1$(document).ready(function () {
2    $("#menu-bold").click(function () {
3        var textarea = this.parentNode.nextSibling.nextSibling;
4        textarea.focus();
5        var s = textarea.selectionStart, e = textarea.selectionEnd;
6        var prefix = textarea.value.substring(0, s);
7        var midlix = textarea.value.substring(s, e);
8        var suffix = textarea.value.substring(e);
9        textarea.value = prefix + "bold_" + midlix + "_bold" + suffix;
10    });
11
12    $("#menu-italic").click(function () {
13        var textarea = this.parentNode.nextSibling.nextSibling;
14        textarea.focus();
15        var s = textarea.selectionStart, e = textarea.selectionEnd;
16        var prefix = textarea.value.substring(0, s);
17        var midlix = textarea.value.substring(s, e);
18        var suffix = textarea.value.substring(e);
19        textarea.value = prefix + "ital_" + midlix + "_ital" + suffix;
20    });
21
22    $("#menu-function").click(function () {
23        var textarea = this.parentNode.nextSibling.nextSibling;
24        textarea.focus();
25        var s = textarea.selectionStart, e = textarea.selectionEnd;
26        var prefix = textarea.value.substring(0, s);
27        var midlix = textarea.value.substring(s, e);
28        var suffix = textarea.value.substring(e);
29        textarea.value = prefix + "$" + midlix + "$" + suffix;
30    });
31    $("#menu-hyper").click(function () {
32        var url = prompt("ВВедите адресс", "http://");
33        var textarea = this.parentNode.nextSibling.nextSibling;
34        textarea.focus();
35        var s = textarea.selectionStart;
36        var prefix = textarea.value.substring(0, s);
37        var suffix = textarea.value.substring(s);
38        textarea.value = prefix + "href_ВВедите тескт...@" + url + "_href" + suffix;
39    });
40
41    $("#menu-img").click(function () {
42        var problemId = $('#problemId').val();
43        $.get('/user/images', {problemId: problemId},function(response){
44            var body = "";
45            for (var i = 0; i < response.data.length; i++) {
46                var template = $('#img-template').html().replace('?imageUrl', response.data[i].path)
47                    .replace('?imageId', response.data[i].id);
48                body += template;
49            }
50            $('#img-menu-body').html(body);
51            $('#imgMenuModal').modal();
52        },'json');
53    });
54
55    $("#menu-code").click(function () {
56        var textarea = this.parentNode.nextSibling.nextSibling;
57        textarea.focus();
58        var s = textarea.selectionStart, e = textarea.selectionEnd;
59        var prefix = textarea.value.substring(0, s);
60        var midlix = textarea.value.substring(s, e);
61        var suffix = textarea.value.substring(e);
62        textarea.value = prefix + "code_" + midlix + "_code" + suffix;
63    });
64
65    $('#imageUploadForm').on('submit',(function(e) {
66        e.preventDefault();
67        var formData = new FormData(this);
68
69        $.ajax({
70            type:'POST',
71            url: $(this).attr('action'),
72            data:formData,
73            cache:false,
74            contentType: false,
75            processData: false,
76            success:function(response){
77                //console.log("success");
78                if(response.success) {
79                    console.log(response.path);
80                    var body = $('#img-menu-body').html();
81                    var template = $('#img-template').html().replace('?imageUrl', response.data.path)
82                        .replace('?imageId', response.data.id);
83                    $('#img-menu-body').html(template + body);
84                } else {
85                    errors.showError(response.data);
86                }
87            }
88        });
89    }));
90
91    $("#imageBrowse").on("change", function() {
92        $("#imageUploadForm").submit();
93        $('#imageBrowse').val('');
94    });
95});
96
97$(document).on('click', '.btn-choose', function() {
98    var size = 40;
99    var position = 'C';
100
101    $(this).parent().find('input[name=size]:checked').each(function () {
102        size = $(this).val();
103    });
104
105    $(this).parent().find('input[name=position]:checked').each(function () {
106        position = $(this).val();
107    });
108
109    var imageId = $(this).attr('imageId');
110    var textarea = document.getElementById('new-comment-body');
111    textarea.focus();
112    var s = textarea.selectionStart;
113    var prefix = textarea.value.substring(0, s);
114    var suffix = textarea.value.substring(s);
115    textarea.value = prefix + 'img_[' + imageId+ '|' + position + '|' + size +']_img' + suffix;
116    $('#imgMenuModal').modal('toggle');
117});
118
119$(document).on('click', '.code-show', function(event){
120    event.preventDefault();
121    $(this).closest('#preview-area').find('pre').toggle(100);
122    $(this).closest('.comment-body').find('pre').toggle(100);
123});

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.