Team:SUSTC-Shenzhen/static/js/jquery.pjax.js
From 2014.igem.org
/*! jquery.pjax.js v2.13.0 | (c) 2012, falsandtru | MIT Licence */ !new function(window,document,undefined,$){"use strict";var MODULE;!function(a){a.NAME="pjax",a.NAMESPACE=jQuery,function(a){a[a.wait=-1]="wait",a[a.ready=0]="ready",a[a.lock=1]="lock",a[a.seal=2]="seal",a[a.error=3]="error"}(a.State||(a.State={}));a.State;a.GEN_UUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16).toUpperCase()})}}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c,d=function(){function b(b,d,e){this.model_=b,this.controller_=d,this.state_=-1,this.queue_=[],this.HANDLERS={},c=d,this.UUID=a.GEN_UUID(),this.CONTEXT=e,this.OBSERVE(),this.state_=0}return b.prototype.OBSERVE=function(){},b.prototype.RELEASE=function(){},b.prototype.BIND=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];return this.UNBIND(),this},b.prototype.UNBIND=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];return this},b.EVENTS={},b.TRIGGERS={},b}();b.Template=d}(a.VIEW||(a.VIEW={}));a.VIEW}(MODULE||(MODULE={}));var __extends=this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);c.prototype=b.prototype,a.prototype=new c},MODULE;!function(a){!function(a){var b,c=function(a){function c(c,d,e){a.call(this,c,d,e),this.model_=c,this.controller_=d,this.HANDLERS={CLICK:function(){for(var a=[],c=0;c<arguments.length-0;c++)a[c]=arguments[c+0];b.CLICK.apply(b,a)},SUBMIT:function(){for(var a=[],c=0;c<arguments.length-0;c++)a[c]=arguments[c+0];b.SUBMIT.apply(b,a)},POPSTATE:function(){for(var a=[],c=0;c<arguments.length-0;c++)a[c]=arguments[c+0];b.POPSTATE.apply(b,a)},SCROLL:function(){for(var a=[],c=0;c<arguments.length-0;c++)a[c]=arguments[c+0];b.SCROLL.apply(b,a)}},b=d}return __extends(c,a),c.prototype.BIND=function(a){return this.UNBIND(a),this.CONTEXT.delegate(a.link,a.nss.click,this.HANDLERS.CLICK).delegate(a.form,a.nss.submit,this.HANDLERS.SUBMIT),jQuery(window).bind(a.nss.popstate,this.HANDLERS.POPSTATE),a.fix.scroll&&jQuery(window).bind(a.nss.scroll,this.HANDLERS.SCROLL),this},c.prototype.UNBIND=function(a){return this.CONTEXT.undelegate(a.link,a.nss.click).undelegate(a.form,a.nss.submit),jQuery(window).unbind(a.nss.popstate),a.fix.scroll&&jQuery(window).unbind(a.nss.scroll),this},c.prototype.OBSERVE=function(){return this.RELEASE(),this},c.prototype.RELEASE=function(){return this},c.EVENTS={},c.TRIGGERS={},c}(a.Template);a.Main=c}(a.VIEW||(a.VIEW={}));a.VIEW}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c,d,e=function(){function b(a,b){c=b,d=a}return b.prototype.enable=function(){return c.enable(),this},b.prototype.disable=function(){return c.disable(),this},b.prototype.click=function(b,e){var f,g=c.getActiveSetting();switch(typeof b){case"undefined":f=this.end().filter("a").first().clone();break;case"object":f=jQuery(b).clone();break;case"string":e=e||{},e.href=b,f=jQuery("<a/>",e);break;default:return this}return f.first().one(g.nss.click,function(b){return new a.VIEW.Main(c,d,null).HANDLERS.CLICK(b)}).click()},b.prototype.submit=function(b,e,f){var g,h,i,j=c.getActiveSetting(),k=document.createDocumentFragment();switch(!0){case"undefined"==typeof b:g=this.end().filter("form").first().clone();break;case"object"==typeof b:g=jQuery(b).clone();break;case!!f:e=e||{},e.action=b,h=f instanceof Array&&Array||f instanceof Object&&Object||undefined;for(var l in f){switch(h){case Object:i=jQuery("<textarea/>",{name:l}).val(f[l]);break;case Array:f[l].attr=f[l].attr||{},f[l].attr.name=f[l].name,i=jQuery(f[l].tag.indexOf("<")?"<"+f[l].tag+"/>":f[l].tag,f[l].attr||{}).val(f[l].value);break;default:continue}k.appendChild(i[0])}g=jQuery("<form/>",e).append(k);break;default:return this}return g.first().one(j.nss.submit,function(b){return new a.VIEW.Main(c,d,null).HANDLERS.SUBMIT(b)}).submit()},b.prototype.getCache=function(a){"undefined"==typeof a&&(a=window.location.href);var b=c.getCache(a);return b&&(b={data:b.data,textStatus:b.textStatus,jqXHR:b.jqXHR,expires:b.expires}),b},b.prototype.setCache=function(a,b,d,e){switch("undefined"==typeof a&&(a=window.location.href),arguments.length){case 0:return this.setCache(a,document.documentElement.outerHTML);case 1:return this.setCache(a,null);case 2:case 3:case 4:default:c.setCache(a,b,d,e)}return this},b.prototype.removeCache=function(a){return"undefined"==typeof a&&(a=window.location.href),c.removeCache(a),this},b.prototype.clearCache=function(){return c.clearCache(),this},b.prototype.follow=function(b,d,e,f){if(!c.isDeferrable)return!1;var g=b.currentTarget;return d.follow=!0,d.host=e||"",isFinite(b.timeStamp)&&(d.timeStamp=f||b.timeStamp),c.setActiveXHR(d),jQuery.when(d).done(function(){!c.getCache(g.href)&&c.isImmediateLoadable(b)&&c.setCache(g.href,undefined,undefined,d)}),jQuery[a.NAME].click(g.href),!0},b.prototype.host=function(){return c.requestHost},b}();b.ControllerFunction=e}(a.CONTROLLER||(a.CONTROLLER={}));a.CONTROLLER}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(a){function b(b,c){a.call(this,b,c)}return __extends(b,a),b}(a.ControllerFunction);a.ControllerMethod=b}(a.CONTROLLER||(a.CONTROLLER={}));a.CONTROLLER}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c,d,e=function(){function e(e){this.state_=-1,this.HANDLERS={},c=e,d=this,this.UUID=a.GEN_UUID(),a.NAMESPACE[a.NAME]=a.NAMESPACE&&a.NAMESPACE==a.NAMESPACE.window?this.EXEC:a.NAMESPACE.prototype[a.NAME]=this.EXEC;var f=new b.ControllerFunction(d,c);this.REGISTER_FUNCTIONS(a.NAMESPACE[a.NAME],f),this.UPDATE_PROPERTIES(a.NAMESPACE[a.NAME],f),this.OBSERVE(),this.state_=0}return e.prototype.EXTEND=function(e){if(e===a.NAMESPACE||a.NAMESPACE&&a.NAMESPACE==a.NAMESPACE.window){var f=new b.ControllerFunction(d,c);e=a.NAMESPACE[a.NAME]}else var f=new b.ControllerMethod(d,c);return e instanceof a.NAMESPACE&&(e instanceof jQuery&&(e=e.add()),this.REGISTER_FUNCTIONS(e,f)),this.UPDATE_PROPERTIES(e,f),e},e.prototype.EXEC=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];var e=d.EXTEND(this);return a=[e].concat(a),a=d.exec_.apply(d,a),a=a instanceof Array?a:[a],c.MAIN.apply(c,a)},e.prototype.exec_=function(a){for(var b=[],c=0;c<arguments.length-1;c++)b[c]=arguments[c+1];return[a].concat(b)},e.prototype.REGISTER_FUNCTIONS=function(a,c){{var d;b.Template.PROPERTIES}for(d in c)a[d]=c[d];return a},e.prototype.UPDATE_PROPERTIES=function(a,c){var d,e,f,g=b.Template.PROPERTIES;for(d=0,e=g.length;e>d;d++)f=g[d],c[f]&&(a[f]=c[f].call(a));return a},e.prototype.OBSERVE=function(){},e.prototype.RELEASE=function(){},e.EVENTS={},e.FUNCTIONS={},e.METHODS={},e.PROPERTIES=[],e.TRIGGERS={},e}();b.Template=e}(a.CONTROLLER||(a.CONTROLLER={}));a.CONTROLLER}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c=function(b){function c(a){b.call(this,a),this.model_=a,this.HANDLERS={}}return __extends(c,b),c.prototype.exec_=function(b,c){b=b instanceof jQuery?b:this.EXTEND(jQuery(document));var d;return d=b instanceof a.NAMESPACE?"m:":"f:",d+=c?{}.toString.call(c).split(" ").pop().slice(0,-1).toLowerCase():c,d.toLowerCase(),[b,c]},c.prototype.OBSERVE=function(){},c.prototype.CLICK=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];this.model_.CLICK.apply(this.model_,a)},c.prototype.SUBMIT=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];this.model_.SUBMIT.apply(this.model_,a)},c.prototype.POPSTATE=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];this.model_.POPSTATE.apply(this.model_,a)},c.prototype.SCROLL=function(){for(var a=[],b=0;b<arguments.length-0;b++)a[b]=arguments[b+0];this.model_.SCROLL.apply(this.model_,a)},c.EVENTS={},c.PROPERTIES=[],c.TRIGGERS={},c}(b.Template);b.Main=c}(a.CONTROLLER||(a.CONTROLLER={}));a.CONTROLLER}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c=function(){function b(){this.NAME=a.NAME,this.NAMESPACE=a.NAMESPACE,this.state_=-1,this.stock=function c(d,e,f){if(this instanceof c)switch(typeof d){case"object":case"function":return this.uuid=a.GEN_UUID(),c[this.uuid]=this,jQuery.extend.apply(jQuery,[!0,this].concat([].slice.call(arguments)).concat({uuid:this.uuid}));case"string":return delete c[d]}else if("object"==typeof d){var g,h=d;for(g in h)b.store(g,h[g])}else switch(arguments.length){case 0:return new this.stock;case 1:return this.stock[d]||b.store(d);case 2:return b.store(d,e);case 3:return b.store(d,e,f)}},this.UUID=a.GEN_UUID()}return b.prototype.MAIN=function(a){for(var b=[],c=0;c<arguments.length-1;c++)b[c]=arguments[c+1];return this.main_.apply(this,[a].concat(b))},b.prototype.main_=function(a){for(var b=[],c=0;c<arguments.length-1;c++)b[c]=arguments[c+1];return this.state_=0,a},b.store=function(a,c){switch(arguments.length){case 0:break;case 1:return b.store[a];case 2:return b.store[a]=c;case 3:return b.store[a]=jQuery.extend(!0,b.store[a],c)}},b}();b.Template=c}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(){function a(){}return a.canonicalizeUrl=function(a){var b;return b=this.trim(a),b=b.replace(/["`^|\\<>{}\[\]\s].*/,""),b=/^https?:/i.test(b)?b:function(a,b){return b.href=a,b.href}(b,document.createElement("a")),b=encodeURI(decodeURI(b)),b=b.replace(/(?:%\w{2})+/g,function(b){return a.match(b.toLowerCase())||b})},a.trim=function(a){if(a=a||"",String.prototype.trim)a=a.toString().trim();else if(a=String(a).replace(/^[\s\uFEFF\xA0]+/,""))for(var b=a.length;--b;)if(/[^\s\uFEFF\xA0]/.test(a.charAt(b))){a=a.substring(0,b+1);break}return a},a.fire=function(a,b,c,d){return"undefined"==typeof b&&(b=window),"undefined"==typeof c&&(c=[]),"undefined"==typeof d&&(d=!1),"function"==typeof a?d?setTimeout(function(){a.apply(b||window,c)},0):a.apply(b||window,c):a},a}();a.Util=b,a.UTIL=a.Util}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c=function(){function c(a,b,c,d,e,f){this.model_=a,this.app_=b,this.loadwaits_=[],this.ready_(c,d,e,f)}return c.prototype.ready_=function(a,c,d,e){function f(d){b.UTIL.fire(a.callbacks.ajax.done,this,[c,a.param].concat(d))}function g(d){k.errorThrown_=d[2],b.UTIL.fire(a.callbacks.ajax.fail,this,[c,a.param].concat(d))}function h(d){b.UTIL.fire(a.callbacks.ajax.fail,this,[c,a.param].concat(d)),k.model_.setActiveXHR(null);k.errorThrown_?a.fallback&&"abort"!==d[0].statusText&&(a.balance.self&&(k.app_.data.saveServerToDB(a.balance.server.host,(new Date).getTime()),k.app_.disableBalance()),k.model_.fallback(c,a)):(k.data_=d[0],k.textStatus_=d[1],k.jqXHR_=d[2],k.update_())}var i=a.speedcheck,j=this.model_.stock("speed");i&&(j.fire=c.timeStamp),i&&j.time.splice(0,100,0),i&&j.name.splice(0,100,"pjax("+j.time.slice(-1)+")");var k=this;if(b.UTIL.fire(a.callbacks.before,null,[c,a.param])!==!1){this.app_.isScrollPosSavable=!1,a.fix.reset&&/click|submit/.test(c.type.toLowerCase())&&window.scrollTo(jQuery(window).scrollLeft(),0);var l=this.model_.getActiveXHR();if(c=jQuery.extend(!0,{},c),this.setting_=a,this.cache_=e,this.event_=c,this.register_=d,e&&e.jqXHR)i&&j.name.splice(0,1,"cache("+j.time.slice(-1)+")"),a.loadtime=0,this.model_.setActiveXHR(null),this.host_=e.host||"",this.data_=e.data,this.textStatus_=e.textStatus,this.jqXHR_=e.jqXHR,this.model_.isDeferrable?jQuery.when(jQuery.Deferred().resolve(),k.wait_(b.UTIL.fire(a.wait,null,[c,a.param,a.origLocation.href,a.destLocation.href]))).done(function(){return k.update_()})&&undefined:k.update_();else if(l&&l.follow&&"abort"!==l.statusText&&"error"!==l.statusText){i&&j.time.splice(0,1,l.timeStamp-j.fire),i&&j.name.splice(0,1,"preload("+j.time.slice(-1)+")"),i&&j.time.push(j.now()-j.fire),i&&j.name.push("continue("+j.time.slice(-1)+")"),this.host_=l.host||"",a.loadtime=l.timeStamp;var m=a.wait&&isFinite(l.timeStamp)?Math.max(a.wait-(new Date).getTime()+l.timeStamp,0):0;jQuery.when(l,k.wait_(m)).done(f).fail(g).always(h)}else{a.loadtime=c.timeStamp;var n=a.destLocation.cloneNode(),o={},p={};switch(this.app_.chooseRequestServer(a),this.host_=a.balance.self&&this.model_.requestHost.split("//").pop()||"",n.host=this.host_||a.destLocation.host,o.url=a.server.query?[n.protocol,"//",n.host,"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname,(1<n.search.length?n.search+"&":"?")+a.server.query,n.hash].join(""):n.href,c.type.toLowerCase()){case"click":o.type="GET";break;case"submit":switch(o.type=c.currentTarget.method.toUpperCase(),o.type){case"POST":jQuery(c.currentTarget).has(":file").length?"function"==typeof FormData&&(o.data=new FormData(c.currentTarget),o.contentType=!1,o.processData=!1):o.data=jQuery(c.currentTarget).serializeArray();break;case"GET":}break;case"popstate":o.type="GET"}p={xhr:a.callbacks.ajax.xhr?function(){var d;return d=b.UTIL.fire(a.callbacks.ajax.xhr,this,[c,a.param]),d="object"==typeof d&&d||jQuery.ajaxSettings.xhr()}:undefined,beforeSend:a.callbacks.ajax.beforeSend||a.server.header?function(d,e){a.server.header&&d.setRequestHeader(a.nss.requestHeader,"true"),"object"==typeof a.server.header&&(d.setRequestHeader(a.nss.requestHeader,"true"),a.server.header.area&&d.setRequestHeader(a.nss.requestHeader+"-Area",this.app_.chooseArea(a.area,document,document)),a.server.header.head&&d.setRequestHeader(a.nss.requestHeader+"-Head",a.load.head),a.server.header.css&&d.setRequestHeader(a.nss.requestHeader+"-CSS",a.load.css.toString()),a.server.header.script&&d.setRequestHeader(a.nss.requestHeader+"-Script",a.load.script.toString())),b.UTIL.fire(a.callbacks.ajax.beforeSend,this,[c,a.param,d,e])}:undefined,dataFilter:a.callbacks.ajax.dataFilter?function(d,e){return b.UTIL.fire(a.callbacks.ajax.dataFilter,this,[c,a.param,d,e])||d}:undefined,success:function(d,e,f){k.data_=d,b.UTIL.fire(a.callbacks.ajax.success,this,[c,a.param,d,e,f])},error:function(d,e,f){k.errorThrown_=f,b.UTIL.fire(a.callbacks.ajax.error,this,[c,a.param,d,e,f])},complete:function(d,e){b.UTIL.fire(a.callbacks.ajax.complete,this,[c,a.param,d,e]),k.model_.setActiveXHR(null),k.errorThrown_?a.fallback&&"abort"!==e&&(a.balance.self&&k.app_.disableBalance(),k.model_.fallback(c,a)):k.model_.isDeferrable||(k.textStatus_=e,k.jqXHR_=d,k.update_())}},o=jQuery.extend(!0,{},a.ajax,p,o),i&&j.time.push(j.now()-j.fire),i&&j.name.push("request("+j.time.slice(-1)+")"),l=this.model_.setActiveXHR(jQuery.ajax(o)),jQuery(document).trigger(jQuery.Event(a.gns+".request",l)),this.model_.isDeferrable&&jQuery.when(l,k.wait_(b.UTIL.fire(a.wait,null,[c,a.param,a.origLocation.href,a.destLocation.href]))).done(f).fail(g).always(h)}b.UTIL.fire(a.callbacks.after,null,[c,a.param])===!1}},c.prototype.update_=function(){a:{var a=this.app_,c=this.setting_,d=this.event_,e=(this.register_,this.data_,this.textStatus_,this.jqXHR_),f=c.callbacks.update;c.loadtime=c.loadtime&&(new Date).getTime()-c.loadtime,c.loadtime=c.loadtime<100?0:c.loadtime;var g=c.speedcheck,h=this.model_.stock("speed");if(g&&h.time.push(h.now()-h.fire),g&&h.name.push("load("+h.time.slice(-1)+")"),this.model_.setActiveSetting(c),b.UTIL.fire(f.before,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_,this.cache_])!==!1){if(c.cache.mix&&"popstate"!==d.type.toLowerCase()&&(new Date).getTime()-d.timeStamp<=c.cache.mix)return this.model_.fallback(d,c);try{if(a.landing=null,!~(e.getResponseHeader("Content-Type")||"").toLowerCase().search(c.contentType))throw new Error("throw: content-type mismatch");this.srcDocument_=a.createHTMLDocument(e.responseText),this.dstDocument_=document;var i=this.srcDocument_,j=this.dstDocument_;if(c.area=this.app_.chooseArea(c.area,i,j),!c.area)throw new Error("throw: area notfound");if(c.areas=c.area.match(/(?:[^,\(\[]+|\(.*?\)|\[.*?\])+/g),g&&h.time.push(h.now()-h.fire),g&&h.name.push("parse("+h.time.slice(-1)+")"),this.updateRewrite_(),this.updateCache_(),jQuery("noscript",i).children().parent().each(function(){this.children.length&&jQuery(this).text(this.innerHTML)}),this.updateRedirect_(),jQuery(window).trigger(c.gns+".unload"),this.updateUrl_(),c.origLocation.href=c.destLocation.href,this.updateVerify_(),this.updateTitle_(),this.updateHead_(),g&&h.time.push(h.now()-h.fire),g&&h.name.push("head("+h.time.slice(-1)+")"),this.loadwaits_=this.updateContent_(),g&&h.time.push(h.now()-h.fire),g&&h.name.push("content("+h.time.slice(-1)+")"),jQuery("noscript",i).remove(),this.updateBalance_(),this.updateLoad_(),b.UTIL.fire(f.success,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1)break a;if(b.UTIL.fire(f.complete,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1)break a;if(b.UTIL.fire(c.callback,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1)break a}catch(k){if(!k)return;if(this.cache_&&this.model_.removeCache(c.destLocation.href),b.UTIL.fire(f.error,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1)break a;if(b.UTIL.fire(f.complete,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1)break a;this.model_.fallback(d,c)}b.UTIL.fire(f.after,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])!==!1}}},c.prototype.updateRewrite_=function(){var a=this.setting_,c=this.event_,d=a.callbacks.update;a.rewrite&&b.UTIL.fire(d.rewrite.before,null,[c,a.param])!==!1&&(b.UTIL.fire(a.rewrite,null,[this.srcDocument_,a.area,this.host_]),b.UTIL.fire(d.rewrite.before,null,[c,a.param])===!1)},c.prototype.updateCache_=function(){var a=this.setting_,c=this.cache_,d=this.event_,e=(this.data_,this.textStatus_),f=this.jqXHR_,g=a.callbacks.update;if((a.cache.click||a.cache.submit||a.cache.popstate)&&("submit"!==d.type.toLowerCase()||a.cache[d.currentTarget.method.toLowerCase()])&&b.UTIL.fire(g.cache.before,null,[d,a.param,c])!==!1){if(this.model_.setCache(a.destLocation.href,c&&c.data||null,e,f),c=this.model_.getCache(a.destLocation.href),this.cache_=c,c&&c.data){var h=this.app_.createHTMLDocument(c.data),i=this.srcDocument_;i.title=h.title;for(var j,k,l=-1;a.areas[++l];){j=jQuery(a.areas[l],h).clone(),k=jQuery(a.areas[l],i);for(var m=-1;j[++m];)k.eq(m).replaceWith(j.eq(m))}}b.UTIL.fire(g.cache.after,null,[d,a.param,c])===!1}},c.prototype.updateRedirect_=function(){var c=this.setting_,d=this.event_,e=this.register_,f=c.callbacks.update;if(jQuery('head meta[http-equiv="Refresh"][content*="URL="]',this.srcDocument_).length&&b.UTIL.fire(f.redirect.before,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])!==!1){var g=c.destLocation.cloneNode();switch(g.href=jQuery(g).attr("content").match(/\w+:\/\/[^;\s]+/i).shift(),!0){case!c.redirect:case g.protocol!==c.destLocation.protocol:case g.host!==c.destLocation.host:case"submit"===d.type.toLowerCase()&&"GET"===d.currentTarget.method.toUpperCase():switch(d.type.toLowerCase()){case"click":case"submit":return window.location.assign(g.href);case"popstate":return window.location.replace(g.href)}default:switch(jQuery[a.NAME].enable(),d.type.toLowerCase()){case"click":return void jQuery[a.NAME].click(g.href);case"submit":return void 0===d.currentTarget.method.toUpperCase()?jQuery[a.NAME].click(g):window.location.assign(g.href);case"popstate":return window.history.replaceState(window.history.state,this.srcDocument_.title,g.href),e&&c.fix.location&&(jQuery[a.NAME].disable(),window.history.back(),window.history.forward(),jQuery[a.NAME].enable()),void jQuery(window).trigger("popstate."+c.gns)}}b.UTIL.fire(f.redirect.after,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1}},c.prototype.updateUrl_=function(){var c=this.setting_,d=this.event_,e=this.register_,f=c.callbacks.update;b.UTIL.fire(f.url.before,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])!==!1&&(e&&window.history.pushState(b.UTIL.fire(c.state,null,[d,c.param,c.origLocation.href,c.destLocation.href]),window.opera||~window.navigator.userAgent.toLowerCase().indexOf("opera")?this.dstDocument_.title:this.srcDocument_.title,c.destLocation.href),e&&c.fix.location&&(jQuery[a.NAME].disable(),window.history.back(),window.history.forward(),jQuery[a.NAME].enable()),b.UTIL.fire(f.url.after,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])===!1)},c.prototype.updateTitle_=function(){var a=this.setting_,c=this.event_,d=a.callbacks.update;b.UTIL.fire(d.title.before,null,[c,a.param,this.data_,this.textStatus_,this.jqXHR_])!==!1&&(this.dstDocument_.title=this.srcDocument_.title,a.database&&a.fix.history&&this.app_.data.saveTitleToDB(a.destLocation.href,this.srcDocument_.title),b.UTIL.fire(d.title.after,null,[c,a.param,this.data_,this.textStatus_,this.jqXHR_])===!1)},c.prototype.updateHead_=function(){var a=this.setting_,c=this.event_,d=this.srcDocument_,e=this.dstDocument_,f=a.callbacks.update;if(a.load.head&&b.UTIL.fire(f.head.before,null,[c,a.param,this.data_,this.textStatus_,this.jqXHR_])!==!1){var g,h,i=jQuery("title"),j=[];g=jQuery("head",d).find(a.load.head).not(a.load.ignore).not('link[rel~="stylesheet"], style, script'),h=jQuery("head",e).find(a.load.head).not(a.load.ignore).not('link[rel~="stylesheet"], style, script');for(var k,l,m=0;k=g[m];m++){switch(k=e.importNode?e.importNode(k,!0):jQuery(k.outerHTML),k.tagName.toLowerCase()){case"base":l="*";break;case"link":switch(l='[rel="'+k.getAttribute("rel")+'"]',(k.getAttribute("rel")||"").toLowerCase()){case"alternate":l+="string"==typeof k.getAttribute("type")?'[type="'+k.getAttribute("type")+'"]':":not([type])"}break;case"meta":if(k.getAttribute("charset"))l="[charset]";else if(k.getAttribute("http-equiv"))l='[http-equiv="'+k.getAttribute("http-equiv")+'"]';else if(k.getAttribute("name"))l='[name="'+k.getAttribute("name")+'"]';else{if(!k.getAttribute("property"))continue;l='[property="'+k.getAttribute("property")+'"]'}break;default:l=null}if(l){for(var n=h.filter(k.tagName).filter(l),o=n.length;o--;)if(n[o].outerHTML===k.outerHTML){h=h.not(n[o]),k=null;break}k&&j.push(k)}}i.before(j),h.remove(),b.UTIL.fire(f.head.after,null,[c,a.param,this.data_,this.textStatus_,this.jqXHR_])===!1}},c.prototype.updateContent_=function(){function a(){return this?(l=l.add(this),k.clone()):void 0}function c(){if(l.length){var a=l.first()[0];l=l.not(a);var b=jQuery(a).is("[type]")?a.type:undefined;a.type=e.gns+"/noexec",this.parentNode.insertBefore(a,this.nextSibling),this.parentNode.removeChild(this),"string"==typeof b?a.type=b:a.removeAttribute("type")}}function d(){var a=jQuery.Deferred();return jQuery(this).one("load error",a.resolve),a}var e=this.setting_,f=this.event_,g=this.srcDocument_,h=this.dstDocument_,i=e.callbacks.update,j=jQuery(),k=jQuery(),l=jQuery(),m=[];if(b.UTIL.fire(i.content.before,null,[f,e.param,this.data_,this.textStatus_,this.jqXHR_])===!1)return m;jQuery(e.area).children("."+e.nss.class4html+"-check").remove(),j=jQuery("<div/>",{"class":e.nss.class4html+"-check",style:"background: none !important; display: block !important; visibility: hidden !important; position: absolute !important; top: 0 !important; left: 0 !important; z-index: -9999 !important; width: auto !important; height: 0 !important; margin: 0 !important; padding: 0 !important; border: none !important; font-size: 12px !important; text-indent: 0 !important;"}).text(e.gns),k=j.clone().removeAttr("class").addClass(e.nss.class4html+"-mark");for(var n,o,p=-1;e.areas[++p];){if(n=jQuery(e.areas[p],g).clone(),o=jQuery(e.areas[p],h),!n.length||!o.length||n.length!==o.length)throw new Error("throw: area mismatch");l=jQuery(),n.find("script").replaceWith(a),jQuery.when&&m.concat(n.find("img, iframe, frame").map(d).get());for(var q=-1;n[++q];)o.eq(q).replaceWith(n.eq(q).append(j.clone()));jQuery(e.areas[p],h).find("."+e.nss.class4html+"-mark").each(c)}return jQuery(h).trigger(e.gns+".DOMContentLoaded"),b.UTIL.fire(i.content.after,null,[f,e.param,this.data_,this.textStatus_,this.jqXHR_])===!1?m:m},c.prototype.updateLoad_=function(){var a=this,c=this.setting_,d=this.dstDocument_;this.updateCSS_('link[rel~="stylesheet"], style'),jQuery(window).one(c.gns+".rendering",function(e){e.preventDefault(),e.stopImmediatePropagation(),a.updateScroll_(!1);var f=a.updateScript_(":not([defer]), :not([src])"),g=function(){jQuery(d).trigger(c.gns+".ready");var e=jQuery(c.area).children("."+c.nss.class4html+"-check"),f=(new Date).getTime()+5e3,g=function(){switch(!0){case c.destLocation.href!==b.UTIL.canonicalizeUrl(window.location.href).replace(/(?:%\w{2})+/g,function(a){return String(c.destLocation.href.match(a.toLowerCase())||a)}):break;case(new Date).getTime()>f:case e.length===e.filter(function(){return this.clientWidth||this.clientHeight||jQuery(this).is(":hidden")}).length:a.updateRender_();break;default:setTimeout(g,100)}};g()};a.model_.isDeferrable?jQuery.when.apply(jQuery,f).always(function(){return g()}):g()}).trigger(c.gns+".rendering")},c.prototype.updateScroll_=function(a){var c=this.setting_,d=this.event_,e=c.callbacks.update;if(b.UTIL.fire(e.scroll.before,null,[d,c.param])!==!1){var f,g;switch(d.type.toLowerCase()){case"click":case"submit":f=a&&"function"==typeof c.scrollLeft?b.UTIL.fire(c.scrollLeft,null,[d,c.param,c.origLocation.href,c.destLocation.href]):c.scrollLeft,f=f>=0?f:0,f=f===!1||null===f?jQuery(window).scrollLeft():parseInt(Number(f)+"",10),g=a&&"function"==typeof c.scrollTop?b.UTIL.fire(c.scrollTop,null,[d,c.param,c.origLocation.href,c.destLocation.href]):c.scrollTop,g=g>=0?g:0,g=g===!1||null===g?jQuery(window).scrollTop():parseInt(Number(g)+"",10),jQuery(window).scrollTop()===g&&jQuery(window).scrollLeft()===f||window.scrollTo(f,g),a&&c.database&&this.app_.isScrollPosSavable&&c.fix.scroll&&this.app_.data.saveScrollPositionToCacheAndDB(c.destLocation.href,f,g);break;case"popstate":a&&c.fix.scroll&&c.database&&this.app_.data.loadScrollPositionFromCacheOrDB(c.destLocation.href)}b.UTIL.fire(e.scroll.after,null,[d,c.param])===!1}},c.prototype.updateCSS_=function(a){var c=this.setting_,d=this.event_,e=this.srcDocument_,f=this.dstDocument_,g=c.callbacks.update;if(c.load.css&&b.UTIL.fire(g.css.before,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])!==!1){for(var h,i=jQuery(a,e).not(jQuery(c.area,e).find(a)).not(c.load.ignore),j=jQuery(a,f).not(jQuery(c.area,f).find(a)).not(c.load.ignore),k=[],l=0;h=i[l];l++){for(var m,n=0;j[n];n++){switch(h.tagName.toLowerCase()){case"link":m=h.href===j[n].href;break;case"style":m=b.UTIL.trim(h.innerHTML)===b.UTIL.trim(j[n].innerHTML)}if(m){k.length&&(h=j.eq(n).prevAll(a)[0],h?jQuery(h).after(jQuery(k).clone()):j.eq(n).before(jQuery(k).clone()),k=[]),j=j.not(j[n]),n-=Number(!!n),h=null;break}}h&&k.push(h)}if(jQuery("head",f).append(jQuery(jQuery.grep(k,function(a){return e.head===a.parentElement})).clone()),jQuery("body",f).append(jQuery(jQuery.grep(k,function(a){return e.head!==a.parentElement})).clone()),j.remove(),b.UTIL.fire(g.css.after,null,[d,c.param,this.data_,this.textStatus_,this.jqXHR_])!==!1){var o=c.speedcheck,p=this.model_.stock("speed");o&&p.time.push(p.now()-p.fire),o&&p.name.push("css("+p.time.slice(-1)+")")}}},c.prototype.updateScript_=function(a){var c=this,d=this.setting_,e=this.event_,f=this.srcDocument_,g=this.dstDocument_,h=d.callbacks.update;if(d.load.script&&b.UTIL.fire(h.script.before,null,[e,d.param,this.data_,this.textStatus_,this.jqXHR_])!==!1){for(var i,j=jQuery("script",f).not(d.load.ignore),k=[],l=[],m=/^$|(?:application|text)\/(?:java|ecma)script/i,n=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,o=this.app_.stock("executed"),p=0;i=j[p];p++)if(jQuery(i).is(a)&&(i.src||b.UTIL.trim(i.innerHTML))&&!(i.src in o)){var q=jQuery(i).parent(d.load.log);if(q.length&&!jQuery(i).parents(d.area).length){var r=jQuery(i).is("[type]")?i.type:undefined;i.type=d.gns+"/noexec",jQuery(q[0].id||q[0].tagName,g)[0].appendChild(i),"string"==typeof r?i.type=r:i.removeAttribute("type")}this.model_.isDeferrable?!function(a){if(i.src){if(d.load.reload&&jQuery(i).is(d.load.reload)||(o[i.src]=!0),"string"==typeof i.getAttribute("async"))return void jQuery.ajax(jQuery.extend(!0,{},d.ajax,d.load.ajax,{url:i.src,async:!0,global:!1}));jQuery.ajax(jQuery.extend(!0,{},d.ajax,d.load.ajax,{url:i.src,dataType:"text",async:!0,global:!1})).always(function(){return"string"==typeof arguments[0]&&a.resolve(arguments[0])})}else a.resolve("object"==typeof i&&(!i.type||m.test(i.type))&&(i.text||i.textContent||i.innerHTML||"").replace(n,""));l.push(a)}(jQuery.Deferred()):k.push(i)}try{if(this.model_.isDeferrable)jQuery.when.apply(jQuery,l).always(function(){for(var a=0,b=arguments.length;b>a;a++)arguments[a]&&eval.call(window,arguments[a])});else for(var i,p=0;i=k[p];p++)i.src?(d.load.reload&&jQuery(i).is(d.load.reload)||(o[i.src]=!0),jQuery.ajax(jQuery.extend(!0,{},d.ajax,d.load.ajax,{url:i.src,async:"string"==typeof i.getAttribute("async"),global:!1}))):"object"==typeof i&&(!i.type||m.test(i.type))&&eval.call(window,(i.text||i.textContent||i.innerHTML||"").replace(n,""))}catch(s){throw setTimeout(function(){return c.model_.fallback(e,d)},50),s}if(b.UTIL.fire(h.script.after,null,[e,d.param,this.data_,this.textStatus_,this.jqXHR_])!==!1){var t=d.speedcheck,u=this.model_.stock("speed");return t&&u.time.push(u.now()-u.fire),t&&u.name.push(("[src][defer]"===a?"defer":"script")+"("+u.time.slice(-1)+")"),l}}},c.prototype.updateRender_=function(){var a=this,c=this.setting_,d=this.event_,e=jQuery(c.area).children("."+c.nss.class4html+"-check"),f=this.loadwaits_,g=c.callbacks.update,h=c.speedcheck,i=this.model_.stock("speed");if(h&&i.time.push(i.now()-i.fire),h&&i.name.push("renderd("+i.time.slice(-1)+")"),b.UTIL.fire(g.render.before,null,[d,c.param])!==!1){e.remove(),setTimeout(function(){a.app_.isScrollPosSavable=!0,"popstate"!==d.type.toLowerCase()?a.scrollByHash_(c.destLocation.hash)||a.updateScroll_(!0):a.updateScroll_(!0)},100),jQuery(document).trigger(c.gns+".render");var j=function(){jQuery(window).trigger(c.gns+".load"),a.updateScript_("[src][defer]")};jQuery.when&&f.length?jQuery.when.apply(jQuery,f).always(j):j(),h&&console.log(i.time),h&&console.log(i.name),b.UTIL.fire(g.render.after,null,[d,c.param])===!1}},c.prototype.updateVerify_=function(){var a=this.setting_,c=this.event_,d=a.callbacks.update;if(b.UTIL.fire(d.verify.before,null,[c,a.param])!==!1){if(a.destLocation.href!==b.UTIL.canonicalizeUrl(window.location.href).replace(/(?:%\w{2})+/g,function(b){return String(a.destLocation.href.match(b.toLowerCase())||b)}))throw a.retriable?(a.retriable=!1,a.destLocation.href=b.UTIL.canonicalizeUrl(window.location.href),new this.app_.Update(this.model_,this.app_,a,c,!1,a.cache[c.type.toLowerCase()]&&this.model_.getCache(a.destLocation.href)),!1):new Error("throw: location mismatch");a.retriable=!0,b.UTIL.fire(d.verify.after,null,[c,a.param])===!1}},c.prototype.updateBalance_=function(){var a=this.setting_,c=this.event_,d=a.callbacks.update;if(a.balance.self&&a.loadtime&&b.UTIL.fire(d.balance.before,null,[c,a.param])!==!1){var e=(this.jqXHR_.getResponseHeader(a.balance.server.header)||"").split("//").pop();this.app_.data.saveLogToDB({host:e,performance:Math.ceil(a.loadtime/(this.jqXHR_.responseText.length||1)*1e5),date:(new Date).getTime()}),this.app_.data.saveServerToDB(e,0,a.destLocation.href,this.app_.calExpires(this.jqXHR_)),this.app_.chooseRequestServer(a),b.UTIL.fire(d.balance.after,null,[c,a.param])===!1}},c.prototype.wait_=function(a){var b=jQuery.Deferred();return a?(setTimeout(function(){b.resolve()},a),b):b.resolve()},c.prototype.scrollByHash_=function(a){if(a="#"===a.charAt(0)?a.slice(1):a,!a)return!1;var b=jQuery("#"+(a?a:", [name~="+a+"]")).first();return b.length?(isFinite(b.offset().top)&&window.scrollTo(jQuery(window).scrollLeft(),parseInt(Number(b.offset().top)+"",10)),!0):!1},c}();b.AppUpdate=c}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(){function a(a){this.buffer_=[],this.DB_=a}return a.prototype.accessStore=function(a,b){var c=this;"undefined"==typeof b&&(b="readwrite"),this.DB_.conExtend();try{var d=this.DB_.database(),e=d.transaction(this.name,b).objectStore(this.name)}catch(f){}e?a(e):this.DB_.opendb(function(){c.accessStore(a)})},a.prototype.accessRecord=function(a,b,c){"undefined"==typeof c&&(c="readwrite"),this.accessStore(function(c){c.get(a).onsuccess=b},c)},a.prototype.loadBuffer=function(a){var b=this,c=this;this.accessStore(function(d){var e=d.indexNames.length?d.indexNames[0]:d.keyPath; d.index(e).openCursor(b.DB_.IDBKeyRange.lowerBound(0),"prev").onsuccess=function(){if(this.result){var b=this.result,e=b.value;c.buffer_[e[d.keyPath]]=e,--a&&b["continue"]&&b["continue"]()}}})},a.prototype.saveBuffer=function(){},a.prototype.getBuffer=function(a){return a?this.buffer_[a]:this.buffer_},a.prototype.setBuffer=function(a,b){var c=a[this.keyPath];return this.buffer_[c]=b?jQuery.extend(!0,{},this.buffer_[c],a):a,this.buffer_[a[this.keyPath]]},a.prototype.addBuffer=function(a){return a[this.keyPath]=this.buffer_.length||1,this.buffer_.push(a),a},a.prototype.add=function(a){var b=a[this.keyPath];delete a[this.keyPath],this.accessRecord(b,function(){"undefined"!=typeof b&&this.source["delete"](b),this.source.add(a)})},a.prototype.set=function(a){var b=a[this.keyPath];this.accessRecord(b,function(){this.source.put(jQuery.extend(!0,{},this.result,a))})},a.prototype.get=function(a,b){this.accessRecord(a,b)},a.prototype.del=function(a){this.accessRecord(a,function(){this.source["delete"](a)})},a}();a.DataStore=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.name="meta",this.keyPath="id"}return __extends(b,a),b}(a.DataStore);a.DataStoreMeta=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.name="history",this.keyPath="id"}return __extends(b,a),b.prototype.clean=function(){var a=this;this.accessStore(function(b){b.count().onsuccess=function(){this.result>1e3&&(b.index("date").openCursor(a.DB_.IDBKeyRange.upperBound((new Date).getTime()-2592e5)).onsuccess=function(){if(this.result){var a=this.result;a?(a["delete"](a.value[b.keyPath]),a["continue"]&&a["continue"]()):b.count().onsuccess=function(){1e3<this.result&&b.clear()}}})}})},b}(a.DataStore);a.DataStoreHistory=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.name="log",this.keyPath="id"}return __extends(b,a),b.prototype.clean=function(){this.accessStore(function(a){var b=50;a.count().onsuccess=function(){this.result>b+10&&(b=this.result-b,a.index(a.keyPath).openCursor(this.DB_.IDBKeyRange.lowerBound(0)).onsuccess=function(){if(this.result){var c=this.result;c&&(0>--b&&c["delete"](c.value[a.keyPath]),c["continue"]&&c["continue"]())}})}})},b}(a.DataStore);a.DataStoreLog=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(a){function b(){a.apply(this,arguments),this.name="server",this.keyPath="id"}return __extends(b,a),b}(a.DataStore);a.DataStoreServer=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(b){var c=function(){function c(){var c=this;this.IDBFactory=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.msIndexedDB,this.IDBKeyRange=window.IDBKeyRange||window.webkitIDBKeyRange||window.mozIDBKeyRange||window.msIDBKeyRange,this.name_=a.NAME,this.version_=4,this.refresh_=10,this.upgrade_=1,this.state_=-1,this.database=function(){return c.database_},this.state=function(){return c.state_},this.nowInitializing=!1,this.nowRetrying=!1,this.conAge_=1e4,this.conInterval_=1e3,this.tasks_=[],this.store={meta:new b.DataStoreMeta(this),history:new b.DataStoreHistory(this),log:new b.DataStoreLog(this),server:new b.DataStoreServer(this)},this.metaNames={version:"version",update:"update"};var d=function(){var a=(new Date).getTime(),b=c.conExpires_;b&&a>b&&(c.closedb(),c.conExpires_=0),setTimeout(d,Math.max(c.conExpires_-a+100,c.conInterval_)),c.tasks_.length&&!c.nowInitializing&&!c.nowRetrying&&c.opendb(null,!0)};this.conAge_&&setTimeout(d,this.conInterval_)}return c.prototype.opendb=function(a,b){var c=this;if(c.conExtend(),c.IDBFactory&&(a||c.tasks_.length)&&("function"==typeof a&&c.reserveTask_(a),!c.nowInitializing&&!c.nowRetrying))try{c.nowInitializing=!0;var d=c.IDBFactory.open(c.name_,c.upgrade_?c.version_:1);d.onblocked=function(){c.closedb(1);try{this.result.close(),!b&&setTimeout(function(){return c.opendb(null,!0)},1e3)}catch(a){!b&&c.initdb_(1e3)}},d.onupgradeneeded=function(){try{for(var a=this.result,d=a.objectStoreNames?a.objectStoreNames.length:0;d--;)a.deleteObjectStore(a.objectStoreNames[d]);a.createObjectStore(c.store.meta.name,{keyPath:c.store.meta.keyPath,autoIncrement:!1}).createIndex(c.store.meta.keyPath,c.store.meta.keyPath,{unique:!0}),a.createObjectStore(c.store.history.name,{keyPath:c.store.history.keyPath,autoIncrement:!1}).createIndex("date","date",{unique:!1}),a.createObjectStore(c.store.log.name,{keyPath:c.store.log.keyPath,autoIncrement:!0}).createIndex("date","date",{unique:!1}),a.createObjectStore(c.store.server.name,{keyPath:c.store.server.keyPath,autoIncrement:!1}).createIndex(c.store.server.keyPath,c.store.server.keyPath,{unique:!0})}catch(e){!b&&c.initdb_(1e3)}},d.onsuccess=function(){try{var a=this.result;c.checkdb_(a,c.version_,function(){c.database_=a,c.state_=0,c.conExtend(),c.nowInitializing=!1,c.digestTask_(),c.nowRetrying=!1},function(){!b&&c.initdb_()})}catch(d){a.close(),!b&&c.initdb_(1e3)}},d.onerror=function(){c.closedb(3);try{this.result.close(),!b&&setTimeout(function(){return c.opendb(null,!0)},1e3)}catch(a){!b&&c.initdb_(1e3)}}}catch(e){c.closedb(3),!b&&c.initdb_(1e3)}},c.prototype.closedb=function(a){"undefined"==typeof a&&(a=-1),this.database_=null,this.state_=a;var b=this.database_;b&&b.close&&b.close()},c.prototype.deletedb_=function(){this.closedb();var a=this.IDBFactory;a&&a.deleteDatabase&&a.deleteDatabase(this.name_)},c.prototype.initdb_=function(a){var b=this,c=function(){b.nowRetrying||(b.nowRetrying=!0,b.deletedb_()),b.opendb(null,!0)};a?void setTimeout(c,a):c()},c.prototype.checkdb_=function(a,b,c,d){var e=this,f=a.transaction(e.store.meta.name,"readwrite").objectStore(e.store.meta.name).get(e.metaNames.version);f.onsuccess=function(){var f=this.result;if(!f||e.upgrade_)this.source.put({id:e.metaNames.version,value:b});else if(f.value!==b)return void d();if(e.refresh_){var g=a.transaction(e.store.meta.name,"readwrite").objectStore(e.store.meta.name).get(e.metaNames.update);g.onsuccess=function(){var a=this.result,b=Math.floor((new Date).getTime()/864e5);if(a){if(a.value<=b)return void d()}else this.source.put({id:e.metaNames.update,value:b+e.refresh_});c()}}else c()}},c.prototype.conExtend=function(){this.conExpires_=(new Date).getTime()+this.conAge_},c.prototype.reserveTask_=function(a){(3!==this.state()||this.tasks_.length<100)&&this.tasks_.push(a)},c.prototype.digestTask_=function(a){"undefined"==typeof a&&(a=0),a=a||-1;for(var b;b=a--&&this.tasks_.pop();)b()},c}();b.DataDB=c}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(){function a(a){this.age_=a}return a.prototype.getCookie=function(a){if(window.navigator.cookieEnabled){var b=new RegExp("(?:^|; )("+encodeURIComponent(a)+"=[^;]*)"),c=(document.cookie.match(b)||[]).pop();return c&&decodeURIComponent(c.split("=").pop())}},a.prototype.setCookie=function(a,b,c){return"undefined"==typeof c&&(c={}),window.navigator.cookieEnabled?(c.age=c.age||this.age_,document.cookie=[encodeURIComponent(a)+"="+encodeURIComponent(b),c.age?"; expires="+new Date((new Date).getTime()+1e3*c.age).toUTCString():"",c.secure?"; secure":""].join(""),this.getCookie(a)):void 0},a}();a.DataCookie=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(){function b(){this.DB=new a.DataDB,this.Cookie=new a.DataCookie(864e3)}return b}();a.Data=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(a){!function(a){var b=function(){function b(b,c){this.model_=b,this.app_=c,this.data_=new a.Data,this.storeNames={meta:this.data_.DB.store.meta.name,history:this.data_.DB.store.history.name,log:this.data_.DB.store.log.name,server:this.data_.DB.store.server.name}}return b.prototype.getCookie=function(a){return this.data_.Cookie.getCookie(a)},b.prototype.setCookie=function(a,b,c){return this.data_.Cookie.setCookie(a,b,c)},b.prototype.opendb=function(a){var b=this;a.database=!1,this.data_.DB.opendb(function(){b.saveTitleToDB(a.origLocation.href,document.title),b.saveScrollPositionToCacheAndDB(a.origLocation.href,jQuery(window).scrollLeft(),jQuery(window).scrollTop()),a.database=!0})},b.prototype.getBuffer=function(a,b){return this.data_.DB.store[a].getBuffer(b)},b.prototype.setBuffer=function(a,b,c,d){return this.data_.DB.store[a].setBuffer(b,c,d)},b.prototype.loadBuffer=function(a,b){return"undefined"==typeof b&&(b=0),this.data_.DB.store[a].loadBuffer(b)},b.prototype.saveBuffer=function(a){return this.data_.DB.store[a].saveBuffer()},b.prototype.loadBufferAll=function(a){"undefined"==typeof a&&(a=0);for(var b in this.storeNames)this.loadBuffer(b,a)},b.prototype.saveBufferAll=function(){for(var a in this.storeNames)this.saveBuffer(a)},b.prototype.loadTitleFromDB=function(b){var c=this.model_.convertUrlToKeyUrl(a.UTIL.canonicalizeUrl(b)),d=this,e=this.data_.DB.store.history.getBuffer(c);e&&"string"==typeof e.title?document.title=e.title:this.data_.DB.store.history.get(c,function(){c===d.model_.convertUrlToKeyUrl(a.UTIL.canonicalizeUrl(window.location.href))&&this.result&&this.result.title&&(document.title=this.result.title)})},b.prototype.saveTitleToDB=function(b,c){var d=this.model_.convertUrlToKeyUrl(a.UTIL.canonicalizeUrl(b)),e={id:d,title:c,date:(new Date).getTime()};this.data_.DB.store.history.setBuffer(e,!0),this.data_.DB.store.history.set(e),this.data_.DB.store.history.clean()},b.prototype.loadScrollPositionFromCacheOrDB=function(b){function c(a,b){"number"==typeof a&&"number"==typeof b&&window.scrollTo(parseInt(Number(a)+"",10),parseInt(Number(b)+"",10))}var d=this.model_.convertUrlToKeyUrl(a.UTIL.canonicalizeUrl(b)),e=this.data_.DB.store.history.getBuffer(d);e&&"number"==typeof e.scrollX?c(e.scrollX,e.scrollY):this.data_.DB.store.history.get(d,function(){this.result&&d===this.result.id&&(e=this.result,c(e.scrollX,e.scrollY))})},b.prototype.saveScrollPositionToCacheAndDB=function(b,c,d){var e=this.model_.convertUrlToKeyUrl(a.UTIL.canonicalizeUrl(b)),f={id:e,scrollX:c,scrollY:d,date:(new Date).getTime()};this.data_.DB.store.history.setBuffer(f,!0),this.data_.DB.store.history.set(f)},b.prototype.loadExpiresFromDB=function(){},b.prototype.saveExpiresToDB=function(a,b,c){var d={id:a,host:b,expires:c};this.data_.DB.store.history.setBuffer(d,!0),this.data_.DB.store.history.set(d)},b.prototype.loadLogFromDB=function(){},b.prototype.saveLogToDB=function(a){this.data_.DB.store.log.addBuffer(a),this.data_.DB.store.log.add(a),this.data_.DB.store.log.clean()},b.prototype.loadServerFromDB=function(){},b.prototype.saveServerToDB=function(a,b,c,d){"undefined"==typeof b&&(b=0),"undefined"==typeof d&&(d=0);var e={id:a||"",state:b};this.data_.DB.store.server.setBuffer(e),this.data_.DB.store.server.set(e),c&&this.saveExpiresToDB(c,a,d)},b}();a.AppData=b}(a.MODEL||(a.MODEL={}));a.MODEL}(MODULE||(MODULE={}));var MODULE;!function(MODULE){!function(MODEL){var App=function(_super){function App(a,b){_super.call(this),this.model_=a,this.controller_=b,this.Update=MODEL.AppUpdate,this.data=new MODEL.AppData(this.model_,this),this.landing=MODEL.UTIL.canonicalizeUrl(window.location.href),this.recent={order:[],data:{},size:0},this.isScrollPosSavable=!0}return __extends(App,_super),App.prototype.configure=function(option,origURL,destURL){origURL=MODEL.UTIL.canonicalizeUrl(origURL||option.origLocation.href),destURL=MODEL.UTIL.canonicalizeUrl(destURL||option.destLocation.href),option=option.option||option;var scope=option.scope?jQuery.extend(!0,{},option,this.scope_(option,origURL,destURL)||{disable:!0}):jQuery.extend(!0,{},option),initial={gns:MODULE.NAME,ns:"",disable:!1,area:"body",link:"a:not([target])",filter:function(){return/(\/[^.]*|\.html?|\.php)$/.test("/"+this.pathname)},form:null,scope:null,rewrite:null,state:null,scrollTop:0,scrollLeft:0,ajax:{dataType:"text"},contentType:"text/html",cache:{click:!1,submit:!1,popstate:!1,get:!0,post:!0,mix:0,limit:100,size:1048576,expires:{max:null,min:3e5}},buffer:{limit:30,delay:500},load:{head:"",css:!1,script:!1,execute:!0,log:"head, body",reload:"",ignore:'[src*="jquery.js"], [src*="jquery.min.js"], [href^="chrome-extension://"]',ajax:{dataType:"script",cache:!0}},balance:{self:!1,weight:3,client:{support:{userAgent:/msie|trident.+ rv:|chrome|firefox|safari/i,redirect:/chrome|firefox|safari/i},exclude:/mobile|phone|android|iphone|blackberry/i,cookie:{balance:"ajax_balanceable",redirect:"ajax_redirectable",host:"ajax_host"}},server:{header:"X-Ajax-Host",filter:null,error:6e5},log:{expires:864e6,limit:30},option:{server:{header:!1},ajax:{crossDomain:!0},callbacks:{ajax:{beforeSend:null}}}},callback:null,callbacks:{ajax:{},update:{rewrite:{},cache:{},redirect:{},url:{},title:{},head:{},content:{},scroll:{},css:{},script:{},render:{},verify:{},balance:{}}},param:null,redirect:!0,wait:0,scroll:{delay:300},fix:{location:!0,history:!0,scroll:!0,reset:!1},fallback:!0,database:!0,server:{query:"pjax=1",header:!0},speedcheck:!1},force={origLocation:function(a,b){return b.href=a,b}(origURL,document.createElement("a")),destLocation:function(a,b){return b.href=a,b}(destURL,document.createElement("a")),balance:{server:{host:""}},scroll:{queue:[]},loadtime:null,retriable:!0,option:option},compute=function(){var nsArray=[setting.gns||MODULE.NAME].concat(setting.ns&&String(setting.ns).split(".")||[]),query=setting.server.query;switch(query&&typeof query){case"string":query=eval("({"+query.replace(/"/g,'\\"').replace(/([^?=&]+)=([^&]*)/g,'"$1": "$2"').replace(/&/g,",")+"})");case"object":query=jQuery.param(query)}return{nss:{name:setting.ns||"",array:nsArray,event:nsArray.join("."),data:nsArray.join("-"),class4html:nsArray.join("-"),click:["click"].concat(nsArray.join(":")).join("."),submit:["submit"].concat(nsArray.join(":")).join("."),popstate:["popstate"].concat(nsArray.join(":")).join("."),scroll:["scroll"].concat(nsArray.join(":")).join("."),requestHeader:["X",nsArray[0].replace(/^\w/,function(a){return a.toUpperCase()})].join("-")},fix:/android|iphone os|like mac os x/i.test(window.navigator.userAgent)?{}:{location:!1,reset:!1},contentType:setting.contentType.replace(/\s*[,;]\s*/g,"|").toLowerCase(),server:{query:query},timeStamp:(new Date).getTime()}},setting;return setting=jQuery.extend(!0,initial,scope),setting=jQuery.extend(!0,setting,setting.balance.self&&setting.balance.option,force),setting=jQuery.extend(!0,setting,compute())},App.prototype.registrate=function(a,b){var c=this,d=this.stock("executed");b.load.script&&jQuery("script").each(function(){var a=this;a.src in d||!a.src||b.load.reload&&jQuery(a).is(b.load.reload)||(d[a.src]=!0)}),new MODULE.VIEW.Main(this.model_,this.controller_,a).BIND(b),setTimeout(function(){return c.createHTMLDocument("")},50),setTimeout(function(){return c.data.loadBufferAll(b.buffer.limit)},b.buffer.delay),b.balance.self&&setTimeout(function(){return c.enableBalance()},b.buffer.delay),setTimeout(function(){return c.landing=null},1500)},App.prototype.enableBalance=function(a){var b=this.model_.getActiveSetting();return!b.balance.client.support.userAgent.test(window.navigator.userAgent)||b.balance.client.exclude.test(window.navigator.userAgent)?void this.disableBalance():Number(!this.data.setCookie(b.balance.client.cookie.balance,"1"))?void this.disableBalance():(b.balance.client.support.redirect.test(window.navigator.userAgent)&&this.data.setCookie(b.balance.client.cookie.redirect,"1"),void(a&&this.switchRequestServer(a,b)))},App.prototype.disableBalance=function(){var a=this.model_.getActiveSetting();this.data.setCookie(a.balance.client.cookie.balance,"0"),this.data.setCookie(a.balance.client.cookie.redirect,"0"),this.switchRequestServer(null,a)},App.prototype.switchRequestServer=function(a,b){a=a||"",b=b||this.model_.getActiveSetting(),this.model_.requestHost=a,b.balance.server.host=a,this.data.setCookie(b.balance.client.cookie.host,a)},App.prototype.chooseRequestServer=function(a){function b(a,b){return a-b}if(a.balance.self&&this.enableBalance(),!a.balance.self||"1"!==this.data.getCookie(a.balance.client.cookie.balance))return void this.disableBalance();this.data.loadBufferAll(a.buffer.limit);var c,d=this.data.getBuffer(this.data.storeNames.history,this.model_.convertUrlToKeyUrl(a.destLocation.href));if(c=d&&d.expires,c&&c>=(new Date).getTime())return void this.switchRequestServer(d.host,a);var e=this.data.getBuffer(this.data.storeNames.log),f=[],g={},h=(new Date).getTime();if(!e)return l=this.data.getCookie(a.balance.client.cookie.host),void(l?this.enableBalance(l):this.disableBalance());var i;for(var j in e)h>e[j].date+a.balance.log.expires||(f.push(e[j].performance),g[e[j].performance]=e[j]);f=f.sort(b);var k=this.data.getBuffer(this.data.storeNames.server),i=f.shift();if(!k)return void this.disableBalance();var i,l="";for(a.balance.log.limit;i=j--&&f.shift();)if(l=g[i].host.split("//").pop()||"",k[l]&&!(k[l].state&&(new Date).getTime()<k[l].state+a.balance.server.error)&&(l||!a.balance.weight||Math.floor(Math.random())*a.balance.weight))return void this.switchRequestServer(l,a);this.disableBalance()},App.prototype.chooseArea=function(a,b,c){a=a instanceof Array?a:[a];var d,e=-1;a:for(;d=a[++e];){for(var f=d.match(/(?:[^,\(\[]+|\(.*?\)|\[.*?\])+/g),g=-1;f[++g];)if(!jQuery(f[g],b).length||!jQuery(f[g],c).length)continue a;return d}},App.prototype.scope_=function(a,b,c,d){"undefined"==typeof d&&(d="");var e,f,g,h,i,j,k,l,m,n,o,p=a.scope;if(e=this.model_.convertUrlToKeyUrl(b).match(/.+?\w(\/.*)/).pop(),f=this.model_.convertUrlToKeyUrl(c).match(/.+?\w(\/.*)/).pop(),d=d.replace(/[#?].*/,""),h=(d||f).replace(/^\/|\/$/g,"").split("/"),d){if(!~d.indexOf("*"))return undefined;g=[];for(var q=e.replace(/^\/|\/$/g,"").split("/"),r=0,s=h.length;s>r;r++)"*"===h[r]&&g.push(q[r])}for(var r=h.length+1;r--;)if(l=o=m=n=undefined,i=h.slice(0,r).join("/"),i="/"+i+("/"===(d||e).charAt(i.length+1)?"/":""),i&&i in p){if(p[i]instanceof Array?(j="",k=p[i]):(j=p[i],k=p[j]),!k||!k.length)return!1;k=k.concat();for(var t,u=0;(t=k[u])&&(m!==!1&&n!==!1);u++)if("#"===t[0]&&(j=t.slice(1),[].splice.apply(k,[u,1].concat(p[j])),t=k[u]),"inherit"===t)l=!0;else if("rewrite"!==t||"function"!=typeof p.rewrite||d){if("string"==typeof t){var v="!"===t[0];t=v?t.slice(1):t;var w="*"===t[0];if(t=w?t.slice(1):t,d&&~t.indexOf("/*/"))for(var x=0,s=g.length;s>x;x++)t=t.replace("/*/","/"+g[x]+"/");if(w?!e.search(t):!e.indexOf(t)){if(v)return!1;m=!0}if(w?!f.search(t):!f.indexOf(t)){if(v)return!1;n=!0,o=p["$"+j]||p["$"+t]||null}}}else{var y=this.scope_.apply(this,[].slice.call(arguments).slice(0,3).concat([MODEL.UTIL.fire(p.rewrite,null,[f])]));if(y){m=n=!0,o=y;break}if(!1===y)return!1}if(m&&n)return jQuery.extend(!0,{},a,o);if(!l)break}},App.prototype.movePageNormally=function(a){switch(a.type.toLowerCase()){case"click":window.location.assign(a.currentTarget.href);break;case"submit":a.currentTarget.submit();break;case"popstate":window.location.reload()}},App.prototype.createHTMLDocument=function(a){function b(a){try{var b=a&&a('
');return b&&jQuery("html",b).is(".html[lang=en]")&&jQuery("head>link",b)[0].href&&jQuery("head>noscript",b).html()&&"noscript"===jQuery("body>noscript",b).text()&&jQuery("body>a",b)[0].href}catch(c){}}return this.createHTMLDocument=function(a){return window.DOMParser&&window.DOMParser.prototype&&(new window.DOMParser).parseFromString(a,"text/html")},b(this.createHTMLDocument)?this.createHTMLDocument(a):(this.createHTMLDocument=function(a){if(document.implementation&&document.implementation.createHTMLDocument){var b=document.implementation.createHTMLDocument("");"object"==typeof b.activeElement&&b.activeElement&&(b.open(),b.write(a),b.close())}return b},b(this.createHTMLDocument)?this.createHTMLDocument(a):(this.createHTMLDocument=function(a){if(document.implementation&&document.implementation.createHTMLDocument){var b=document.implementation.createHTMLDocument(""),c=document.createElement("html"),d=document.createElement("div");d.innerHTML=(a.match(/<html(?: [^>]*)?>/i)||[""]).shift().replace(/html/i,"div")+"