1 line
8.1 KiB
JavaScript
1 line
8.1 KiB
JavaScript
|
|
var A,API,API_THEME,H;A={init:function(){return A.w=$(window),A.P.init(),A.W.init(),A.FORM.init(),A.w.scroll(A.scroll),A.scroll()},scroll:function(){return A.P.scroll()},notify:function(t,n=""){return t.queue(function(){return t.html(n).show(300),t.dequeue()})},mail:/^([A-Za-z0-9_-]+\.)*[A-Za-z0-9_-]+@[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*\.[A-Za-z]{2,6}$/,FORM:{globalPrepareValidate:function(t,n){return $(".error_text",t.$wrap).remove(),t.$wrap.removeClass("error good")},globalGood:function(t,n){return t.$wrap.addClass("good")},globalBad:function(t,n){return t.$wrap.addClass("error"),t.$wrap.append($('<div class="error_text">'+n.errors.join("<br/>")+"</div>"))},init:function(){return $.fn.FORM("setGlobalGood",A.FORM.globalGood),$.fn.FORM("setGlobalBad",A.FORM.globalBad),$.fn.FORM("setPrepareValidate",A.FORM.globalPrepareValidate)}},setCookie:function(t,n,o){var r,e;return e=" domain="+window.location.host+";",r=t+"="+n+"; expires="+new Date(o||(new Date).getTime()+5184e6).toGMTString()+"; path=/;",document.cookie=r+e,console.log(r+e),r},getCookie:function(t){return!!new RegExp("(?:; )?"+t+"=([^;]*);?").test(document.cookie)&&decodeURIComponent(RegExp.$1)},reachYandex:function(t){},reachGoogle:function(t,n,o){return"function"==typeof ga?ga("send","event",t,n,o):void 0}},$(document).ready(A.init),API=function(t,n={},o=null,r={}){var e;return n.nocache=(new Date).getTime(),e="/api/"+t+"/",console.log(e,n),$.ajax({url:e,type:"POST",dataType:void 0!==n.dataType?n.dataType:"html",data:n,success:function(t){if(null!==o)return"function"==typeof o?o(t,r):void 0},error:function(){return"function"==typeof o?o({error:1},r):void 0}})},API_THEME="themes.opr/",H={menu:{},selected:{},top_selected:null,inited:!1,dir:"",title:null,data:null,scroll:[],isLoading:!1,data:null,ready:function(){if(!H.inited)return $(window).on("popstate",H.switchByWindow),H.inited=!0,H.body=$("#content"),H.title=$("title"),H.keywords=$("meta[name=keywords]"),H.description=$("meta[name=description]"),H.title=$("title"),H.$html=$("html,body"),$(window).on("scroll",H.onScroll),H.data=init_data},onScroll:function(){if(!H.isLoading)return H.scroll[window.location.href]=H.$html.scrollTop()},reload:function(){return H.switch({animate:!1})},formGo:function(t){var n,o,r;return r=(n=$(t)).serialize(),void 0===(o=n.attr("action"))&&(o=window.location.pathname),H.go(o+"?"+r),!1},go:function(t,n=null,o="",r=!0){var e;if("/"===t.substr(0,1)&&(t=t.substr(1)),e="/"+t,H.data=n,history.pushState(n,o,e),r)return H.switch()},setTitle:function(t){return H.title.text(t)},switchByWindow:function(t){var n,o;return H.now!==window.location.href?H.switch(t.state):""!==window.location.hash&&(n=$(window.location.hash)).length>0?(o=n.offset().top-65,H.$html.scrollTop(o)):void 0},getData:function(t){var n;return n=null,null!==H.data&&(n=H.data[t]),n},switch:function(t={animate:!0}){var n;return n="/"===(n=H.parse().join("/"))||""===n?"/?justContent=1":`/${n}/?justContent=1`,window.location.search.length>0&&(n+="&"+window.location.search.substr(1)),H.isLoading=!0,$.ajax({url:n,dataType:"JSON",success:function(t){var n,o,r,e,a,i,l,c,u;if(console.log("time_compile",t.time_compile,"bd_time",t.time_bd),"string"==typeof t.location&&""!==t.location)return H.go(t.location);if(H.data=t.data,H.title.text(t.title),o=$(t.content),r=$(o[0]),H.setTitle(t.data.title),H.keywords.attr("content",t.keywords),H.description.attr("content",t.description),H.body.html(r),u=0,void 0!==H.scroll[window.location.href]&&(u=H.scroll[window.location.href]),""!==window.location.hash&&(n=$(window.location.hash)).length>0&&(u=n.offset().top-80),A.P.initMini(r,t.data),o.length>1)for(e=a=1,i=o.length-1;1<=i?a<=i:a>=i;e=1<=i?++a:--a)c=document.createElement("script"),"SCRIPT"!==(l=o[e].tagName)&&"script"!==l||(c.innerHTML=$(o[e]).html(),H.body[0].appendChild(c));return H.$html.scrollTop(u),H.isLoading=!1},error:function(){return console.log("history error ")}})},SEARCH:{set:function(t,n=!1){var o;return o=window.location.pathname+"?"+t,H.go(o,null,"",n)},parse:function(){var t,n,o,r,e;if(o={},window.location.search.length>0)for(t
|