1var selectedFileVacancy; 2$(function() { 3 // uload file 4 function fileUploadInitPopup() { 5 let ul = $('#ul-popup'); 6 $('#drop-popup a').click(function() { 7 // Simulate a click on the file input button 8 // to show the file browser dialog 9 $(this).parent().find('input').click(); 10 }); 11 // Initialize the jQuery File Upload plugin 12 $('#file_upload_popup').fileupload({ 13 // This element will accept file drag/drop uploading 14 dropZone: $('#drop-popup'), 15 // This function is called when a file is added to the queue; 16 // either via the browse button, or via drag/drop: 17 add: function(e, data) { 18 let tpl = $('<li class="working"><input type="text" value="0" data-width="0" data-height="0"' + 19 ' data-fgColor="#0788a5" data-readOnly="1" data-bgColor="#3e4043" /><p></p><span></span></li>'); 20 // Append the file name and file size 21 selectedFileVacancy = data.files[0]; 22 tpl.find('p').text(data.files[0].name) 23 .after('<i>(' + formatFileSize(data.files[0].size) + ')</i>'); 24 // Add the HTML to the UL element 25 data.context = tpl.appendTo(ul); 26 // Initialize the knob plugin 27 tpl.find('input').knob(); 28 // Listen for clicks on the cancel icon 29 tpl.find('span').click(function() { 30 if (tpl.hasClass('working')) { 31 jqXHR.abort(); 32 } 33 tpl.fadeOut(function() { 34 tpl.remove(); 35 }); 36 }); 37 // Automatically upload the file once it is added to the queue 38 let jqXHR = data.submit(); 39 }, 40 progress: function(e, data) { 41 // Calculate the completion percentage of the upload 42 let progress = parseInt(data.loaded / data.total * 100, 10); 43 // Update the hidden input field and trigger a change 44 // so that the jQuery knob plugin knows to update the dial 45 data.context.find('input').val(progress).change(); 46 if (progress == 100) { 47 data.context.removeClass('working'); 48 } 49 }, 50 fail: function(e, data) { 51 // Something has gone wrong! 52 data.context.addClass('error'); 53 } 54 }); 55 // Prevent the default action when a file is dropped on the window 56 $(document).on('drop dragover', function(e) { 57 e.preventDefault(); 58 }); 59 // Helper function that formats the file sizes 60 function formatFileSize(bytes) { 61 if (typeof bytes !== 'number') { 62 return ''; 63 } 64 if (bytes >= 1000000000) { 65 return (bytes / 1000000000).toFixed(2) + ' GB'; 66 } 67 if (bytes >= 1000000) { 68 return (bytes / 1000000).toFixed(2) + ' MB'; 69 } 70 return (bytes / 1000).toFixed(2) + ' KB'; 71 } 72 } 73 fileUploadInitPopup(); 74 75 76 77 78 // uload file 79 function fileUploadInit() { 80 let ul = $('#ul'); 81 $('#drop a').click(function() { 82 // Simulate a click on the file input button 83 // to show the file browser dialog 84 $(this).parent().find('input').click(); 85 }); 86 // Initialize the jQuery File Upload plugin 87 $('#file_upload').fileupload({ 88 // This element will accept file drag/drop uploading 89 dropZone: $('#drop'), 90 // This function is called when a file is added to the queue; 91 // either via the browse button, or via drag/drop: 92 add: function(e, data) { 93 let tpl = $('<li class="working"><input type="text" value="0" data-width="0" data-height="0"' + 94 ' data-fgColor="#0788a5" data-readOnly="1" data-bgColor="#3e4043" /><p></p><span></span></li>'); 95 // Append the file name and file size 96 selectedFileVacancy = data.files[0]; 97 tpl.find('p').text(data.files[0].name) 98 .after('<i>(' + formatFileSize(data.files[0].size) + ')</i>'); 99 // Add the HTML to the UL element 100 data.context = tpl.appendTo(ul); 101 // Initialize the knob plugin 102 tpl.find('input').knob(); 103 // Listen for clicks on the cancel icon 104 tpl.find('span').click(function() { 105 if (tpl.hasClass('working')) { 106 jqXHR.abort(); 107 } 108 tpl.fadeOut(function() { 109 tpl.remove(); 110 }); 111 }); 112 // Automatically upload the file once it is added to the queue 113 let jqXHR = data.submit(); 114 }, 115 progress: function(e, data) { 116 // Calculate the completion percentage of the upload 117 let progress = parseInt(data.loaded / data.total * 100, 10); 118 // Update the hidden input field and trigger a change 119 // so that the jQuery knob plugin knows to update the dial 120 data.context.find('input').val(progress).change(); 121 if (progress == 100) { 122 data.context.removeClass('working'); 123 } 124 }, 125 fail: function(e, data) { 126 // Something has gone wrong! 127 data.context.addClass('error'); 128 } 129 }); 130 // Prevent the default action when a file is dropped on the window 131 $(document).on('drop dragover', function(e) { 132 e.preventDefault(); 133 }); 134 // Helper function that formats the file sizes 135 function formatFileSize(bytes) { 136 if (typeof bytes !== 'number') { 137 return ''; 138 } 139 if (bytes >= 1000000000) { 140 return (bytes / 1000000000).toFixed(2) + ' GB'; 141 } 142 if (bytes >= 1000000) { 143 return (bytes / 1000000).toFixed(2) + ' MB'; 144 } 145 return (bytes / 1000).toFixed(2) + ' KB'; 146 } 147 } 148 fileUploadInit(); 149 // Prevent the default action when a file is dropped on the window
150 $(document).on('drop dragover', function(e) { 151 e.preventDefault(); 152 }); 153 // Helper function that formats the file sizes 154 function formatFileSize(bytes) { 155 if (typeof bytes !== 'number') { 156 return ''; 157 } 158 if (bytes >= 1000000000) { 159 return (bytes / 1000000000).toFixed(2) + ' GB'; 160 } 161 if (bytes >= 1000000) { 162 return (bytes / 1000000).toFixed(2) + ' MB'; 163 } 164 return (bytes / 1000).toFixed(2) + ' KB'; 165 } 166 167 $("body").on("click", ".snp-filters .def-clear.active", function(e) { 168 var url = $(this).closest("form").attr("action"); 169 location.href = url; 170 }); 171 172 173 $("body").on("click", ".swt-search .def-clear.active", function(e) { 174 var url = $(this).closest("form").attr("action"); 175 location.href = url; 176 }); 177 178 179 $("body").on("click", "#popup_search .def-clear", function(e) { 180 $("input#TOP_SEARCH").val(""); 181 var hostname= $(location).attr('hostname'); 182 if (hostname == "en.apicenna.ru") { 183 $(".dps-not-found p").html('Start looking in the catalog.'); 184 } else { 185 $(".dps-not-found p").html('ÐаÑниÑе иÑкаÑÑ Ð² каÑалоге.'); 186 } 187 188 $(".dps-not-found").removeClass("disable"); 189 $(".dps-result").addClass("disable"); 190 $(this).removeClass("active"); 191 }); 192 193 194 var searchTimer; 195 196 $("body").on("change paste keypress keyup input", "input#TOP_SEARCH", function (e) { 197 if (e.type === "input" || e.type === "paste") { 198 clearTimeout(searchTimer); // ÐÑиÑаем пÑедÑдÑÑий ÑÐ°Ð¹Ð¼ÐµÑ 199 var q_str = $(this).val(); //$("input#TOP_SEARCH").val(); 200 201 searchTimer = setTimeout(function () { 202 203 if (q_str != "" && q_str.length > 3) { 204 $(".def-clear").addClass("active"); 205 // $("#search-popup .dsr-items").html(""); 206 // $("#search-popup .dsl-result ul").html(""); 207 208 $.post( 209 "/ajax/ajax_search.php", 210 { q: q_str }, 211 function (res) { 212 if (res.NOT_FOUND == "Y") { 213 var hostname= $(location).attr('hostname'); 214 if (hostname == "en.apicenna.ru") { 215 $(".dps-not-found p").html('Sorry, nothing was found for your search <br> query.'); 216 } else { 217 $(".dps-not-found p").html('Ð ÑожалениÑ, на Ð²Ð°Ñ Ð¿Ð¾Ð¸ÑковÑй <br> запÑÐ¾Ñ Ð½Ð¸Ñего не найдено.'); 218 } 219 220 $(".dps-not-found").removeClass("disable"); 221 $(".dps-result").addClass("disable"); 222 } 223 else { 224 $(".dps-l-show").remove(); 225 $(".dps-l-found").text(res.COUNT_TEXT); 226 $(".dps-r-found").text(res.COUNT_PRODUCTS); 227 $(".dps-result").removeClass("disable"); 228 $(".dps-not-found").addClass("disable"); 229 if (res.ALL) $(".dps-l-items").after(res.ALL); 230 } 231 232 if (res.SECTIONS) $("#popup_search .dps-l-items").html(res.SECTIONS); 233 if (res.PRODUCTS) $("#popup_search .dps-r-items").html(res.PRODUCTS); 234 235 $('#popup_search .mCustomScrollbar').each(function(){ 236 var $el = $(this); 237 $el.mCustomScrollbar('destroy'); // ÑдалиÑÑ ÑÑаÑÑй ÑкземплÑÑ 238 $el.mCustomScrollbar( 239 { 240 mouseWheel: { 241 enable: true 242 }, 243 // scrollButtons: { 244 // enable: true, 245 // scrollType: "stepless", 246 // scrollAmount: 60 247 // } 248 } 249 ); // ÑеиниÑиализиÑоваÑÑ Ñ Ð½ÑжнÑми опÑиÑми 250 }); 251 }, "json" 252 ); 253 } 254 255 }, 1000);
255 // задеÑжка 256 } 257 258 if (q_str == "") { 259 $(".def-clear").removeClass("active"); 260 } 261 }); 262 263 264 function getCookie(name) { 265 let matches = document.cookie.match( 266 new RegExp( 267 "(?:^|; )" + 268 name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + 269 "=([^;]*)" 270 ) 271 ); 272 return matches ? decodeURIComponent(matches[1]) : ""; 273 } 274 275 function setCookie(name, value) { 276 let updatedCookie = 277 encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/"; 278 document.cookie = updatedCookie; 279 } 280 281 282 283 284 285 286 $("body").on("submit", "#farm-form", function(e) { 287 288 e.preventDefault(); 289 var form = $(this); 290 var files = []; 291 if(form.find(".list_dwn li").length > 0) 292 { 293 form.find(".list_dwn li").each(function() { 294 files.push($(this).find("p").text()); 295 }); 296 } 297 298 $.post( 299 "/ajax/ajax_farm_form_send.php", 300 {data: form.serialize(), files: files, page: $("#page").val()}, 301 function(res) 302 { 303 $.post( 304 "/ajax/ajax_delete_files.php", 305 {files: files}, 306 function() {} 307 ); 308 form.trigger("reset"); 309 form.closest(".default-popup").removeClass("active"); 310 $("#popup_thx_f").addClass("active"); 311 } 312 ); 313 }); 314 315 $("body").on("submit", "#workers_feedback_form", function(e) { 316 e.preventDefault(); 317 var form = $(this); 318 var files = []; 319 if(form.find(".list_dwn li").length > 0) 320 { 321 form.find(".list_dwn li").each(function() { 322 files.push($(this).find("p").text()); 323 }); 324 } 325 326 $.post( 327 "/ajax/ajax_workers_feedback_form_send.php", 328 {data: form.serialize(), page: $("#page").val()}, 329 function(res) 330 { 331 $.post( 332 "/ajax/ajax_delete_files.php", 333 function() {} 334 ); 335 form.trigger("reset"); 336 form.closest(".default-popup").removeClass("active"); 337 $("#popup_thx_f").addClass("active"); 338 } 339 ); 340 }); 341 342 343 $("body").on("submit", "#feedback-form, #contacts-form", function(e) { 344 e.preventDefault(); 345 var form = $(this); 346 $.post( 347 "/ajax/ajax_feedback_form_send.php", 348 {data: form.serialize(), page: $("#page").val()}, 349 function(res) 350 { 351 form.trigger("reset"); 352 form.closest(".default-popup").removeClass("active"); 353 $("#popup_thx").addClass("active"); 354 } 355 ); 356 }); 357 358 359 $("body").on("click", ".s-news-detail .snd-btm-positive .plus, .s-news-detail .snd-btm-positive .min", function(e) { 360 var item = $(this); 361 var product = item.closest(".snd-btm-positive").data("item"); 362 var cur_count = parseInt(item.find(".sbp-b-descr-2").text()); 363 var inc = "Y"; 364 if(item.hasClass("active")) inc = "N"; 365 var type = "like"; 366 var cookie_name = "liked"; 367 if(item.hasClass("min")) 368 { 369 type = "dislike"; 370 cookie_name = "disliked"; 371 } 372 $.post( 373 "/local/include/ajax-like.php", 374 {type: type, id: product, inc: inc}, 375 function(res) 376 { 377 item.toggleClass("active"); 378 if(inc == "Y") 379 { 380 cur_count++; 381 item.find(".sbp-b-descr-2").text(cur_count); 382 setCookie(cookie_name, getCookie(cookie_name) + "." + product + "."); 383 } 384 else 385 { 386 cur_count--; 387 item.find(".sbp-b-descr-2").text(cur_count); 388 setCookie(cookie_name, getCookie(cookie_name).replace("." + product + ".", "")); 389 } 390 if(type == "like") $(".s-news-detail .snd-top .snd-t-btn.likes").text(cur_count); 391 } 392 ); 393 }); 394 395 396 $("body").on("click", ".catalog-item .ci-text .cit-likes", function(e) { 397 e.preventDefault(); 398 399 var product = $(this).data("item"); 400 var item = $(this); 401 var cur_count = parseInt(item.text()); 402 var inc = "Y"; 403 if(item.hasClass("active")) inc = "N"; 404 $.post( 405 "/local/include/ajax-like.php", 406 {type: "like", id: product, inc: inc}, 407 function(res) 408 { 409 item.toggleClass("active"); 410 if(inc == "Y") 411 { 412 cur_count++; 413 item.text(cur_count); 414 setCookie("liked", getCookie("liked") + "." + product + "."); 415 } 416 else 417 { 418 cur_count--; 419 item.text(cur_count); 420 setCookie("liked", getCookie("liked").replace("." + product + ".", "")); 421 } 422 } 423 ); 424 }); 425 426 427 $("body").on("click", ".s-product-page .spp-content .spp-mid .spp-items .spp-like", function(e) { 428 e.preventDefault(); 429 var product = $(this).data("item"); 430 var item = $(this); 431 var cur_count = parseInt(item.find(".spp-lk-value").text()); 432 var inc = "Y"; 433 if(item.hasClass("active")) inc = "N"; 434 $.post( 435 "/local/include/ajax-like.php", 436 {type: "like", id: product, inc: inc}, 437 function(res) 438 { 439 item.toggleClass("active"); 440 if(inc == "Y") 441 { 442 cur_count++; 443 item.find(".spp-lk-value").text(cur_count);
444 setCookie("liked", getCookie("liked") + "." + product + "."); 445 } 446 else 447 { 448 cur_count--; 449 item.find(".spp-lk-value").text(cur_count); 450 setCookie("liked", getCookie("liked").replace("." + product + ".", "")); 451 } 452 } 453 ); 454 }); 455 456 457 458 $("body").on("click", ".s-catalog-filter .custom-select .select-items div", function(e) { 459 location.href = $(this).attr("value"); 460 }); 461 462 463 $("body").on("click", ".s-news-page .snp-filters .snp-select-wrap .custom-select .select-items div", function(e) { 464 location.href = $(this).attr("value"); 465 }); 466 467 468 $("body").on("click", ".def-sort-animals.small .def-sort-slider .swiper-slide div.def-ss-itm", function(e) { 469 e.preventDefault(); 470 var group = $(this).data("pid"); 471 if($(this).hasClass("active")) return false; 472 $(".catalog-menu .cm-content.active .def-sort-slider .swiper-slide.active").removeClass("active"); 473 $(this).parent().addClass("active"); 474 $(".catalog-menu .cm-content.active .cmc-list-wrap.active").removeClass("active"); 475 $("#"+group).addClass("active"); 476 }); 477 478 479 $("body").on("click", ".show_more", function(e) { 480 var btn = $(this); 481 var param_name = "is_ajax"; 482 if($(this).data("index")) param_name += $(this).data("index"); 483 var dest = '.items'; 484 if(btn.find("a").data("dest")) dest = btn.find("a").data("dest"); 485 e.preventDefault(); 486 var link = btn.find("a").attr("href"); 487 prefix = "?"; 488 if(link.indexOf("?") > 0) prefix = "&"; 489 $.get( 490 link+prefix+param_name+'=Y', 491 function(res) { 492 btn.remove(); 493 $(dest).append(res); 494 495 setTimeout(() => { 496 ScrollTrigger.refresh() 497 }, 300) 498 } 499 ); 500 }); 501 502 // подгÑÑзка ÑлеменÑов каÑалога 503 $("body").on("click", ".items-more", function(e) { 504 var btn = $(this); 505 var param_name = "is_ajax"; 506 if($(this).data("index")) param_name += $(this).data("index"); 507 var dest = '.items'; 508 if(btn.data("dest")) dest = btn.data("dest"); 509 e.preventDefault(); 510 511 if (btn.is('.s-words .sw-content .swc-right .swc-btn-wrap .btn')) { 512 $('.s-words .sw-content .swc-right .swc-btn-wrap').addClass('disabled'); 513 $('.s-words .sw-content .swc-right .swc-r-items .swc-r-itm.hidden').removeClass('hidden'); 514 } else if (btn.is('.s-catalog-filter .scf-content .scf-right .scf-btn-wrap .btn')) { 515 $('.s-catalog-filter .scf-content .scf-right .scf-btn-wrap').addClass('disabled'); 516 $('.s-catalog-filter .scf-content .scf-right .scf-r-items .catalog-item.hidden').removeClass('hidden'); 517 } 518 519 var link = btn.attr("href"); 520 prefix = "?"; 521 if(link.indexOf("?") > 0) prefix = "&"; 522 $.get( 523 link+prefix+param_name+'=Y', 524 function(res) { 525 history.replaceState(null, "", link); 526 btn.closest(".scf-btn-wrap").remove(); 527 $(".def-pagination").remove(); 528 $(dest).append(res); 529 530 setTimeout(() => { 531 ScrollTrigger.refresh() 532 }, 300) 533 } 534 ); 535 }); 536 537 $("body").on("click", ".full-search-products__show-more", function(e) { 538 var btn = $(this); 539 var param_name = "is_ajax"; 540 if($(this).data("index")) param_name += $(this).data("index"); 541 var dest = '.items'; 542 if(btn.data("dest")) dest = btn.data("dest"); 543 e.preventDefault(); 544 545 var link = btn.attr("href"); 546 prefix = "?"; 547 if(link.indexOf("?") > 0) prefix = "&"; 548 $.get( 549 link+prefix+param_name+'=Y', 550 function(res) { 551 history.replaceState(null, "", link); 552 btn.closest(".full-search-products__nav").remove(); 553 $(".def-pagination").remove(); 554 $(dest).append($(res).find('.full-search-products__list').html()); 555 556 setTimeout(() => { 557 ScrollTrigger.refresh() 558 }, 300) 559 } 560 ); 561 }); 562 563 $('body').on('click', '.dp-search--new .dps-l-toggle', function() { 564 let toggle = $(this), 565 searchModal = toggle.closest('.dp-content'), 566 articlesBlock = searchModal.find('.dps-l-scroll-wrap'), 567 toggleText = ''; 568 569 searchModal.toggleClass('dp-content--articles-open'); 570 if (searchModal.hasClass('dp-content--articles-open')) { 571 toggleText = 'СкÑÑÑÑ Ð½Ð°Ð¹Ð´ÐµÐ½Ð½Ñе ÑÑаÑÑи'; 572 articlesBlock.slideDown(300); 573 } else { 574 toggleText = 'ÐоказаÑÑ Ð½Ð°Ð¹Ð´ÐµÐ½Ð½Ñе ÑÑаÑÑи'; 575 articlesBlock.slideUp(300); 576 } 577 578 toggle.text(toggleText); 579 }); 580});
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.