1
function add(e,t){return e.appendChild(t)}
2
function createElem(e,t=null,o=[]){var n=document.createElement(e);if(null!==o)for(var l in o)n.setAttribute(l,o[l]);return n.innerHTML=t,n}
3
function createElemIn(e,t,o=null,n=[]){var l=document.createElement(t);if(l.innerHTML=o,null!==n)for(var r in n)l.setAttribute(r,n[r]);return e.appendChild(l),e}
4
$(".report").click(function(e){e.preventDefault(),$("#reportModal").addClass("show")}
5
),$("#reportModalClose").click(function(){$("#reportModal").removeClass("show")}
6
),$("#send-report").click(function(){const e=$("#reportForm").serializeArray();e[0].value?$.post("/limit/report",e,function(e){e?(new Noty({type:"success",text:"Success",timeout:3e3}
7
).show(),$("#reportForm").trigger("reset")):new Noty({type:"error",text:"Something went wrong",timeout:3e3}
8
).show(),$("#reportModal").removeClass("show")}
9
):new Noty({type:"error",text:"Fill in the bug description field",timeout:3e3}
10
).show()}
11
),$("body").on("click",function(e){let t=!0;if(e.originalEvent.path)for(let o of e.originalEvent.path)if(o.classList&&o.classList.contains("search")){t=!1;break}
12
t&&$(".search-result").hide()}
13
),$("#cpu-compare").on("submit",function(e){e.preventDefault();let t=$(this).serializeArray();if(t[0].value&&t[1].value){let e=t[0].value+"-vs-"+t[1].value;window.location=langLink+"cpu/compare/"+e}
14
else new Noty({type:"error",text:"Select a processor from the list",timeout:3e3}
15
).show()}
16
),$("#gpu-compare").on("submit",function(e){e.preventDefault();let t=$(this).serializeArray();if(t[0].value&&t[1].value){let e=t[0].value+"-vs-"+t[1].value;window.location=langLink+"gpu/compare/"+e}
17
else new Noty({type:"error",text:"Select a video card from the list",timeout:3e3}
18
).show()}
19
),$(".typing").keyup(function(e){let t=$(this).val(),o=$(this),n=o.attr("data-type");if(0===t.length)return o.next().next(".autocomplete-dropdown").children(".autocomplete-dropdown-scroll").empty(),0;$.get("/"+n+"/autocomplete?str="+t,function(e){let t=createElem("div","",{class:"autocomplete-dropdown-list"}
20
);if(0===e.length)return o.next().next(".autocomplete-dropdown").children(".autocomplete-dropdown-scroll").empty().html("<div class='autocomplete-empty'>Ничего не найдено</div>"),0;for(let n of e){let e=createElem("div","",{class:"autocomplete-dropdown-item"}
21
);createElemIn(e,"img","",{src:n.image_mini}
22
),createElemIn(e,"span",n.name),e.addEventListener("click",function(){o.hide(),o.val(n.name),o.next().next(".autocomplete-dropdown").hide(),o.next().show().text(n.name),o.parent().removeClass("autocomplete-open"),o.parent(".autocomplete").children(".autocomplete-image").css({"background-image":"url("+n.image_mini+")"}
23
),o.parent(".autocomplete").children(".processor-id").val(n.alias)}
24
),add(t,e)}
25
o.next().next(".autocomplete-dropdown").children(".autocomplete-dropdown-scroll").empty().html(t)}
26
)}
27
),$(document).on("click",function(e){var t=$(".autocomplete.autocomplete-open");t.length&&(t===e.target||t.has(e.target).length||($(".autocomplete-input").hide(),$(".autocomplete-dropdown").hide(),$(".processor-typing").hide(),$(".autocomplete-placeholder").show(),$(".autocomplete").removeClass("autocomplete-open")))}
28
),$(document).ready(function(){$(window).scroll(function(){$(this).scrollTop()>100?$(".scrollup").fadeIn():$(".scrollup").fadeOut()}
29
),$(".scrollup").click(function(){return $("html, body").animate({scrollTop:0}
30
,600),!1}
31
)}
32
);