PageSourceSearch

https://naurok.com.ua/mistakes/mistakes.js

js naurok.com.ua collected 2026-09-24 09:18:47 UTC 4,103 bytes, 145 lines download raw bytes

1// ������ �������� ��������� �� ������ http://mistakes.ru/script/mistakes_dev
2// ������ 4.1
3// 27.04.2015
4var loc = window.location;
5var mis;
6nN = navigator.appName;
7
8function createMessage(mis) {
9    $('#MistakeAlert').modal('show');
10    $('#mistake_message').html(mis);
11}
12
13function getText(e)
14{
15    if (!e) e= window.event;
16    if((e.ctrlKey) && ((e.keyCode==10)||(e.keyCode==13)))
17        {CtrlEnter();}
18    return true;
19}
20
21function mis_get_sel_text(){
22   if (window.getSelection) {
23    txt = window.getSelection();
24    selected_text = txt.toString();
25    full_text = txt.anchorNode.textContent;
26    selection_start = txt.anchorOffset;
27    selection_end = txt.focusOffset;
28  }
29  else if (document.getSelection) {
30    txt = document.getSelection();
31    selected_text = txt.toString();
32    full_text = txt.anchorNode.textContent;
33    selection_start = txt.anchorOffset;
34    selection_end = txt.focusOffset;
35  }
36  else if (document.selection) {
37    txt = document.selection.createRange();
38    selected_text = txt.text;
39    full_text = txt.parentElement().innerText;
40
41    var stored_range = txt.duplicate();
42    stored_range.moveToElementText(txt.parentElement());
43    stored_range.setEndPoint('EndToEnd', txt);
44    selection_start = stored_range.text.length - txt.text.length;
45    selection_end = selection_start + selected_text.length;
46  }
47  else {
48    return;
49  }
50  var txt = {
51    selected_text: selected_text,
52    full_text: full_text,
53    selection_start: selection_start,
54    selection_end: selection_end
55  };
56  return txt;
57}
58
59function mis_get_sel_context(sel) {
60  selection_start = sel.selection_start;
61  selection_end = sel.selection_end;
62  if (selection_start > selection_end) {
63    tmp = selection_start;
64    selection_start = selection_end;
65    selection_end = tmp;
66  }
67
68  context = sel.full_text;
69
70  context_first = context.substring(0, selection_start);
71  context_second = context.substring(selection_start, selection_end);
72  context_third = context.substring(selection_end, context.length);
73  context = context_first + '<span>' + context_second + '</span>' + context_third;
74
75  context_start = selection_start - 100;
76  if (context_start < 0) {
77    context_start = 0;
78  }
79
80  context_end = selection_end + 100;
81  if (context_end > context.length) {
82    context_end = context.length;
83  }
84
85  context = context.substring(context_start, context_end);
86
87  context_start = context.indexOf(' ') + 1;
88
89  if (selection_start + 60 < context.length) {
90    context_end = context.lastIndexOf(' ', selection_start + 60);
91  }
92  else {
93    context_end = context.length;
94  }
95
96  selection_start = context.indexOf('<strong>');
97  if (context_start > selection_start) {
98    context_start = 0;
99  }
100
101  if (context_start) {
102    context = context.substring(context_start, context_end);
103  }
104
105  return context;
106}
107
108function CtrlEnter(){
109    var sel = mis_get_sel_text();
110    if (sel.selected_text.length > 300) {
111		alert('Спробуте виділити менший шматок тексту!');
112    }
113    else if (sel.selected_text.length == 0) {
114		alert('Ви нічого не виділили!');
115    }
116    else {
117      // Get selection context.
118      mis = mis_get_sel_context(sel);
119     createMessage(mis);
120
121    }
122  };
123
124 function PressLink(){
125		mis = '����������, ������� ������ � �����������.';
126		createMessage();
127  };
128 function sendMistake(){
129     var content = $('.mistake_message').html();
130     var comment = $('.comment-mistake').val();
131     var title = $('.title-mistake').val();
132     var id = $('.id-mistake').val();
133     var author = $('.author-mistake').val();
134     var url = window.location.href;
135     $.ajax({
136          type: "POST",
137          url: '/api/push/mistake',
138          data: { _csrf: document.head.querySelector("[name=csrf-token]").content, content:content, url:url, comment:comment,title:title,id:id,author:author},
139          success:function(result){
140
141          },
142          error:function(result){}
143     });
144 }
145document.onkeypress = getText;

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.