PageSourceSearch

https://wooordhunt.ru/js/fn_common_1.js?v=16102025

js wooordhunt.ru collected 2026-10-02 04:49:38 UTC 10,199 bytes, 346 lines download raw bytes

1
2$(document).ready(function(){
3
4    if (!isGuest && document.location.href.search(/\/word\/[a-z \%20\+\-]+$/i) !== -1) {
5       $('#wd_content .plus').css('display','inline');
6       let word_ = document.location.href.substring(document.location.href.lastIndexOf("/")+1).replace(/%20/g," ");
7        setWordEduStatus(word_, 0);
8        checkWordStatusInPDic(word_);
9        printPersonalEx(word_);
10    };
11
12    if (!isGuest && $.cookie("checkin") == null) {
13        let responce = $.ajax({type: 'GET', url: '/user/checkin', async: true});
14
15        responce.done(function(data) {
16          $.cookie("checkin", 1, {path: "/", expires: 1});
17        });
18    };
19
20    $('.info_popup_link').magnificPopup({type: 'iframe'});
21
22
23});
24
25
26function treatItem(idata, uri, async){
27	let result;
28    let response = $.ajax({type: 'POST', dataType: 'json', url: '/'+uri, data: idata, async: async});
29    
30    response.done(function( data ) {
31    	result = data;
32    });
33    
34    return result;
35}
36
37
38function showWordInFrame(word){
39    word = word.trim();
40    
41    $.magnificPopup.open({
42      alignTop: true,
43      preloader: true,
44      items: {
45        src: '/word/'+word, 
46        type: 'iframe'
47      },
48      
49      callbacks: {
50        beforeOpen: function() {
51          $.ajax({type: 'GET', url: '/openscripts/forjs/set_frame.php',  async: false});
52        },
53        close: function() {
54          $.ajax({type: 'GET', url: '/openscripts/forjs/unset_frame.php',  async: true});
55        }
56      }
57          
58    }); 
59    $('.mfp-content').css("height","100%");
60}
61
62
63let pos_word_tip=0;
64let total_tips = 0;
65let click_on_tips = false;
66
67function showTips(){
68    $('#word_tips').css('display', 'block');
69    $('#hunted_word').css('border-radius', '3px 0px 0px 0px');
70
71    $( "#word_tips div" ).hover(
72      function() {
73//         $(this).css("background-color","#D5FFD3"); 
74         $(this).addClass("light_on"); 
75      }, function() {
76       $(this).removeClass("light_on");
77//       $(this).css('background-color', '#F7F7F7');
78      }
79    );    
80
81    $("#word_tips div").click(function () {
82        $("#hunted_word").val($(this).attr("value"));
83        click_on_tips = true;
84        $("#hunted_word_form").submit();  
85    });
86
87
88}
89
90function hideTips(){
91    $('#word_tips').empty();
92    $('#word_tips').css('display', 'none');
93    $('#hunted_word').css('border-radius', '3px 0px 0px 3px');
94
95    total_tips = 0;
96}
97
98function lightTip(direction, abc){
99    if (direction == 40) {
100      pos_word_tip = (pos_word_tip == total_tips) ? 0 : ++pos_word_tip;
101    };  
102    if (direction == 38) {
103      pos_word_tip = (pos_word_tip == 0) ? total_tips : --pos_word_tip;
104    };  
105    
106    // $('#word_tips div').css('background-color', '#F7F7F7');
107    // $('#word_tips div[row="'+pos_word_tip+'"]').css('background-color', '#D5FFD3');
108    $('#word_tips div').removeClass('light_on');
109    $('#word_tips div[row="'+pos_word_tip+'"]').addClass('light_on');
110    if (pos_word_tip == 0) {
111        $('#hunted_word').val(abc);
112    } else {
113        $('#hunted_word').val($('#word_tips div[row="'+pos_word_tip+'"] span').html());  
114    };
115}
116
117
118let switched_query_direction = "";
119
120function getSwitchedQuery(query){
121  let ru_en = {"й":"q","ц":"w","у":"e","к":"r","е":"t","н":"y","г":"u","ш":"i","щ":"o","з":"p","ф":"a","ы":"s","в":"d","а":"f","п":"g","р":"h","о":"j","л":"k","д":"l","я":"z","ч":"x","с":"c","м":"v","и":"b","т":"n","ь":"m"};
122  let en_ru = {"q":"й","w":"ц","e":"у","r":"к","t":"е","y":"н","u":"г","i":"ш","o":"щ","p":"з","[":"х","]":"ъ","a":"ф","s":"ы","d":"в","f":"а","g":"п","h":"р","j":"о","k":"л","l":"д",";":"ж","'":"э","z":"я","x":"ч","c":"с","v":"м","b":"и","n":"т","m":"ь",",":"б",".":"ю"};
123
124  let switched_query = "";
125  let arr_for_switch = (switched_query_direction == "to_en") ? ru_en : en_ru;
126
127  for (let i = 0; i < query.length; i++) {
128      switched_query += (arr_for_switch.hasOwnProperty(query[i])) ? arr_for_switch[query[i]] : query[i];
129  }
130
131  return switched_query;
132}
133
134
135
136function slideToggle(id){
137    $("#"+id).slideToggle(150);
138}
139
140function saveState(label, state){
141    $.cookie(label, state, { expires : 300000});
142}
143
144function saveSetting(label, state){
145
146   $.ajax({type: 'POST', url: '/user/saveSettingFromJS', data:{label:label, value:state}, async: true});  
147
148}
149
150function saveWordHistory(){
151
152    let word_history = $.cookie("word_history");
153    let word_url;
154
155    
156    word_url = decodeURIComponent(window.location.pathname);    
157    if(word_url.match(/^[a-z\-\'\/ а-яё]+$/i) == null){
158      return false;
159    }
160
161
162    if (word_history == undefined || word_history =="") {
163      word_history = word_url;
164    } else {
165      regex = new RegExp('(^|\,)'+word_url+'($|\,)','i');
166      if (!regex.test(word_history)){
167          word_history = word_url + "," + word_history;  
168      }
169    }
170
171    if(!isGuest){
172      $.ajax({type: 'POST', url: '/history/update',data: {word:word_url}, async: true});  
173    }
174
175    word_history_arr = word_history.split(',');
176
177    if (word_history_arr.length > 10) {
178        word_history_arr = word_history_arr.slice(0, 10);
179        word_history = word_history_arr.join(",");
180    }
181
182    $.cookie("word_history", word_history, { expires : 300000, path: "/" });
183}
184
185function printWordHistory(device_type){
186
187    if (document.location.href.search(/\/exn\/|\/editor\//i) !== -1) {
188      $('#word_history_box').css('display','none');
189      $('#adv_left_block').css('display','none');
190      return;
191    }
192
193    let word_history = "";
194    let word_history_arr = new Array();
195    let word, word_url, history_item, word_sup;
196
197    if(!isGuest){
198      let responce = $.ajax({type: 'POST', dataType: 'text', url: '/history/GetLastForBlock', async: false});  
199      responce.done(function(data) {
200        word_history = data;
201      });
202    }
203
204    if (word_history == "") {
205        word_history = $.cookie("word_history");
206    }
207
208    if (word_history == undefined || word_history == "") {
209        word_history = "welcome,hush,tan,murmur,frantic,passion";
210    }
211
212    let show_history_in_bottom = false;
213
214    if (window_width <= 1200) {
215      $('#word_history_box_mobile').css('display','block');
216      $('#gap_for_mobile_history').css('display','block');
217      show_history_in_bottom = true;
218    }
219
220    word_history_arr = word_history.split(",");
221    let pointer = 0;
222    for (key in word_history_arr) {
223      if (pointer > 10) {break;}
224      history_item = decodeURIComponent(word_history_arr[key]);
225      if (history_item.includes("/")){
226        word = history_item.slice(history_item.lastIndexOf('/') + 1);
227        word_url = history_item;
228      } else {
229        word = history_item;
230        word_url = '/word/' + word;
231      }
232      word_sup = history_item.includes("/переводы/") ? ' <sup>2.0</sup>' : ''; 
233
234      $('<span><a href="' + word_url + '">' + word + '</a>' + word_sup + '</span>').appendTo('#word_history_box');
235      if (show_history_in_bottom) {
236        $('<span><a href="' + word_url + '">' + word + '</a>' + word_sup + '&emsp;</span>').appendTo('#word_history_box_mobile');
237      }
238      pointer++;
239    }
240
241    if(device_type == 'pc'){
242      if (show_history_in_bottom) {
243          $('<br/><a href="/history/last">Вся история</a>&emsp;<a href="/history/top">Мой словарь</a>').appendTo('#word_history_box_mobile');
244      } else {
245          $('<br/><span><a href="/history/last">Вся история</a></span><span><a href="/history/top">Мой словарь</a></span>').appendTo('#word_history_box');
246      }
247    }
248
249
250}
251
252
253let is_alert_open = false;
254
255function openPrjDialog(template){
256
257      if (!is_alert_open) {
258        let responce = $.ajax({url:'/data/dialog_content/'+template+'.html', dataType: 'html', async: true,
259            beforeSend: function( xhr ) {
260               //$("#loader_win_bar").css("display","block");
261              }
262            });
263
264        responce.done(function(data) {
265          //$("#loader_win_bar").css("display","none");
266          $('#dialog_win_data').html(data);
267          is_alert_open = true;
268          $('#dialog_win_bar').css("display","block");
269        });
270      }
271
272  }
273
274function closePrjDialog(){
275  is_alert_open = false;
276  $('#dialog_win_bar').css('display','none');
277}
278
279
280function openPrjAlert(alert_msg){
281  if (!is_alert_open) {
282	let responce = $.ajax({url:'/data/dialog_content/prj_alert.html', dataType: 'html', async: true,
283		beforeSend: function( xhr ) {
284		   //$("#loader_win_bar").css("display","block");
285		  }
286		});
287
288	responce.done(function(data) {
289	  //$("#loader_win_bar").css("display","none");
290	  data = data.replace('{ALERT_MSG}', alert_msg);
291	  $('#dialog_win_data').html(data);
292	  is_alert_open = true;
293	  $('#dialog_win_bar').css("display","block");
294	});
295  }
296
297}
298
299
300
301function openWindow(w_location, h, w)
302{
303    window.open(w_location,'','height='+h+', width='+w+', top=100, left=100, toolbar=no, location=no, scrollbars=no')
304    return false;
305}
306
307
308String.prototype.PA = function (_hamper,_prefix,_postfix,_face)
309    {
310      _hamper=_prefix+"@"+this+(_postfix || '');
311      document.write(_face+(_hamper).link("mailto:"+_hamper));
312    }
313
314function urlExists(url)
315{
316  	let http = new XMLHttpRequest();
317    http.open('HEAD', url, false);
318    http.send();
319    return http.status!=404;
320}
321
322
323/*
324  function playPronunciation(lng, file) {
325
326    const audioUrl = '/data/sound/sow/'+lng+'/'+file+'.mp3'; 
327    
328    const audio = new Audio(audioUrl);
329
330    // Блокируем повторные клики, пока идёт загрузка/воспроизведение
331    audio.addEventListener('play', () => {
332      // Можно добавить класс кнопке, чтобы показать состояние «играет»
333    });    
334
335    audio.play().catch(error => {
336      console.error("Не удалось воспроизвести аудио:", error);
337    });
338
339
340  }
341*/
342
343    
344    
345
346

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.