116 lines
55 KiB
JavaScript
116 lines
55 KiB
JavaScript
function FastClick(a){var b,c=this;this.trackingClick=!1;this.trackingClickStart=0;this.targetElement=null;this.lastTouchIdentifier=this.touchStartY=this.touchStartX=0;this.touchBoundary=10;this.layer=a;if(!a||!a.nodeType)throw new TypeError("Layer must be a document node");this.onClick=function(){return FastClick.prototype.onClick.apply(c,arguments)};this.onMouse=function(){return FastClick.prototype.onMouse.apply(c,arguments)};this.onTouchStart=function(){return FastClick.prototype.onTouchStart.apply(c,
|
|
arguments)};this.onTouchEnd=function(){return FastClick.prototype.onTouchEnd.apply(c,arguments)};this.onTouchCancel=function(){return FastClick.prototype.onTouchCancel.apply(c,arguments)};FastClick.notNeeded(a)||(this.deviceIsAndroid&&(a.addEventListener("mouseover",this.onMouse,!0),a.addEventListener("mousedown",this.onMouse,!0),a.addEventListener("mouseup",this.onMouse,!0)),a.addEventListener("click",this.onClick,!0),a.addEventListener("touchstart",this.onTouchStart,!1),a.addEventListener("touchend",
|
|
this.onTouchEnd,!1),a.addEventListener("touchcancel",this.onTouchCancel,!1),Event.prototype.stopImmediatePropagation||(a.removeEventListener=function(b,c,k){var l=Node.prototype.removeEventListener;"click"===b?l.call(a,b,c.hijacked||c,k):l.call(a,b,c,k)},a.addEventListener=function(b,c,k){var l=Node.prototype.addEventListener;"click"===b?l.call(a,b,c.hijacked||(c.hijacked=function(a){a.propagationStopped||c(a)}),k):l.call(a,b,c,k)}),"function"===typeof a.onclick&&(b=a.onclick,a.addEventListener("click",
|
|
function(a){b(a)},!1),a.onclick=null))}FastClick.prototype.deviceIsAndroid=0<navigator.userAgent.indexOf("Android");FastClick.prototype.deviceIsIOS=/iP(ad|hone|od)/.test(navigator.userAgent);FastClick.prototype.deviceIsIOS4=FastClick.prototype.deviceIsIOS&&/OS 4_\d(_\d)?/.test(navigator.userAgent);FastClick.prototype.deviceIsIOSWithBadTarget=FastClick.prototype.deviceIsIOS&&/OS ([6-9]|\d{2})_\d/.test(navigator.userAgent);
|
|
FastClick.prototype.needsClick=function(a){switch(a.nodeName.toLowerCase()){case "button":case "select":case "textarea":if(a.disabled)return!0;break;case "input":if(this.deviceIsIOS&&"file"===a.type||a.disabled)return!0;break;case "label":case "video":return!0}return/\bneedsclick\b/.test(a.className)};
|
|
FastClick.prototype.needsFocus=function(a){switch(a.nodeName.toLowerCase()){case "textarea":case "select":return!0;case "input":switch(a.type){case "button":case "checkbox":case "file":case "image":case "radio":case "submit":return!1}return!a.disabled&&!a.readOnly;default:return/\bneedsfocus\b/.test(a.className)}};
|
|
FastClick.prototype.sendClick=function(a,b){var c,e;document.activeElement&&document.activeElement!==a&&document.activeElement.blur();e=b.changedTouches[0];c=document.createEvent("MouseEvents");c.initMouseEvent("click",!0,!0,window,1,e.screenX,e.screenY,e.clientX,e.clientY,!1,!1,!1,!1,0,null);c.forwardedTouchEvent=!0;a.dispatchEvent(c)};FastClick.prototype.focus=function(a){var b;this.deviceIsIOS&&a.setSelectionRange?(b=a.value.length,a.setSelectionRange(b,b)):a.focus()};
|
|
FastClick.prototype.updateScrollParent=function(a){var b,c;b=a.fastClickScrollParent;if(!b||!b.contains(a)){c=a;do{if(c.scrollHeight>c.offsetHeight){b=c;a.fastClickScrollParent=c;break}c=c.parentElement}while(c)}b&&(b.fastClickLastScrollTop=b.scrollTop)};FastClick.prototype.getTargetElementFromEventTarget=function(a){return a.nodeType===Node.TEXT_NODE?a.parentNode:a};
|
|
FastClick.prototype.onTouchStart=function(a){var b,c,e;if(1<a.targetTouches.length)return!0;b=this.getTargetElementFromEventTarget(a.target);c=a.targetTouches[0];if(this.deviceIsIOS){e=window.getSelection();if(e.rangeCount&&!e.isCollapsed)return!0;if(!this.deviceIsIOS4){if(c.identifier===this.lastTouchIdentifier)return a.preventDefault(),!1;this.lastTouchIdentifier=c.identifier;this.updateScrollParent(b)}}this.trackingClick=!0;this.trackingClickStart=a.timeStamp;this.targetElement=b;this.touchStartX=
|
|
c.pageX;this.touchStartY=c.pageY;200>a.timeStamp-this.lastClickTime&&a.preventDefault();return!0};FastClick.prototype.touchHasMoved=function(a){a=a.changedTouches[0];var b=this.touchBoundary;return Math.abs(a.pageX-this.touchStartX)>b||Math.abs(a.pageY-this.touchStartY)>b?!0:!1};FastClick.prototype.findControl=function(a){return void 0!==a.control?a.control:a.htmlFor?document.getElementById(a.htmlFor):a.querySelector("button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea")};
|
|
FastClick.prototype.onTouchEnd=function(a){var b,c,e;e=this.targetElement;if(this.touchHasMoved(a)||300<a.timeStamp-this.trackingClickStart)this.trackingClick=!1,this.targetElement=null;if(!this.trackingClick)return!0;if(200>a.timeStamp-this.lastClickTime)return this.cancelNextClick=!0;this.lastClickTime=a.timeStamp;b=this.trackingClickStart;this.trackingClick=!1;this.trackingClickStart=0;this.deviceIsIOSWithBadTarget&&(e=a.changedTouches[0],e=document.elementFromPoint(e.pageX-window.pageXOffset,
|
|
e.pageY-window.pageYOffset));c=e.tagName.toLowerCase();if("label"===c){if(b=this.findControl(e)){this.focus(e);if(this.deviceIsAndroid)return!1;e=b}}else if(this.needsFocus(e)){if(100<a.timeStamp-b||this.deviceIsIOS&&window.top!==window&&"input"===c)return this.targetElement=null,!1;this.focus(e);if(!this.deviceIsIOS4||"select"!==c)this.targetElement=null,a.preventDefault();return!1}if(this.deviceIsIOS&&!this.deviceIsIOS4&&(b=e.fastClickScrollParent)&&b.fastClickLastScrollTop!==b.scrollTop)return!0;
|
|
this.needsClick(e)||(a.preventDefault(),this.sendClick(e,a));return!1};FastClick.prototype.onTouchCancel=function(){this.trackingClick=!1;this.targetElement=null};FastClick.prototype.onMouse=function(a){return!this.targetElement||a.forwardedTouchEvent||!a.cancelable?!0:!this.needsClick(this.targetElement)||this.cancelNextClick?(a.stopImmediatePropagation?a.stopImmediatePropagation():a.propagationStopped=!0,a.stopPropagation(),a.preventDefault(),!1):!0};
|
|
FastClick.prototype.onClick=function(a){if(this.trackingClick)return this.targetElement=null,this.trackingClick=!1,!0;if("submit"===a.target.type&&0===a.detail)return!0;a=this.onMouse(a);a||(this.targetElement=null);return a};
|
|
FastClick.prototype.destroy=function(){var a=this.layer;this.deviceIsAndroid&&(a.removeEventListener("mouseover",this.onMouse,!0),a.removeEventListener("mousedown",this.onMouse,!0),a.removeEventListener("mouseup",this.onMouse,!0));a.removeEventListener("click",this.onClick,!0);a.removeEventListener("touchstart",this.onTouchStart,!1);a.removeEventListener("touchend",this.onTouchEnd,!1);a.removeEventListener("touchcancel",this.onTouchCancel,!1)};
|
|
FastClick.notNeeded=function(a){if("undefined"===typeof window.ontouchstart)return!0;if(/Chrome\/[0-9]+/.test(navigator.userAgent))if(FastClick.prototype.deviceIsAndroid){if((a=document.querySelector("meta[name=viewport]"))&&-1!==a.content.indexOf("user-scalable=no"))return!0}else return!0;return!1};FastClick.cache=[];FastClick.attach=function(a){if(-1!=FastClick.cache.indexOf(a))return!1;FastClick.cache.push(a);return new FastClick(a)};
|
|
"undefined"!==typeof define&&define.amd?define(function(){return FastClick}):"undefined"!==typeof module&&module.exports?(module.exports=FastClick.attach,module.exports.FastClick=FastClick):window.FastClick=FastClick;FastClick.attach(document);var Zepto=function(){function a(a){return null==a?String(a):M[S.call(a)]||"object"}function b(L){return"function"==a(L)}function c(a){return null!=a&&a==a.window}function e(a){return null!=a&&a.nodeType==a.DOCUMENT_NODE}function g(L){return"object"==a(L)}function k(a){return g(a)&&!c(a)&&Object.getPrototypeOf(a)==Object.prototype}function l(a){return"number"==typeof a.length}function x(a){return s.call(a,function(a){return null!=a})}function B(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,
|
|
"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function t(a){return a in H?H[a]:H[a]=RegExp("(^|\\s)"+a+"(\\s|$)")}function E(a){return"children"in a?p.call(a.children):d.map(a.childNodes,function(a){if(1==a.nodeType)return a})}function C(a,b,c){for(m in b)c&&(k(b[m])||F(b[m]))?(k(b[m])&&!k(a[m])&&(a[m]={}),F(b[m])&&!F(a[m])&&(a[m]=[]),C(a[m],b[m],c)):b[m]!==q&&(a[m]=b[m])}function y(a,b){return null==b?d(a):d(a).filter(b)}function v(a,c,f,h){return b(c)?c.call(a,f,
|
|
h):c}function w(a,b){var c=a.className,f=c&&c.baseVal!==q;if(b===q)return f?c.baseVal:c;f?c.baseVal=b:a.className=b}function D(a){var b;try{return a?"true"==a||("false"==a?!1:"null"==a?null:!/^0/.test(a)&&!isNaN(b=Number(a))?b:/^[\[\{]/.test(a)?d.parseJSON(a):a):a}catch(c){return a}}function z(a,b){b(a);for(var c=0,f=a.childNodes.length;c<f;c++)z(a.childNodes[c],b)}var q,m,d,A,u=[],p=u.slice,s=u.filter,f=window.document,h={},H={},O={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,
|
|
"z-index":1,zoom:1},G=/^\s*<(\w+|!)[^>]*>/,I=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,T=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,n=/^(?:body|html)$/i,U=/([A-Z])/g,V="val css html text data width height offset".split(" "),N=f.createElement("table"),P=f.createElement("tr"),Q={tr:f.createElement("tbody"),tbody:N,thead:N,tfoot:N,td:P,th:P,"*":f.createElement("div")},W=/complete|loaded|interactive/,X=/^[\w-]*$/,M={},S=M.toString,r={},J,K,R=f.createElement("div"),Y={tabindex:"tabIndex",
|
|
readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},F=Array.isArray||function(a){return a instanceof Array};r.matches=function(a,b){if(!b||!a||1!==a.nodeType)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var f;f=a.parentNode;(c=!f)&&
|
|
(f=R).appendChild(a);f=~r.qsa(f,b).indexOf(a);c&&R.removeChild(a);return f};J=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})};K=function(a){return s.call(a,function(b,c){return a.indexOf(b)==c})};r.fragment=function(a,b,c){var h,e,s;I.test(a)&&(h=d(f.createElement(RegExp.$1)));h||(a.replace&&(a=a.replace(T,"<$1></$2>")),b===q&&(b=G.test(a)&&RegExp.$1),b in Q||(b="*"),s=Q[b],s.innerHTML=""+a,h=d.each(p.call(s.childNodes),function(){s.removeChild(this)}));k(c)&&(e=
|
|
d(h),d.each(c,function(a,b){if(-1<V.indexOf(a))e[a](b);else e.attr(a,b)}));return h};r.Z=function(a,b){a=a||[];a.__proto__=d.fn;a.selector=b||"";return a};r.isZ=function(a){return a instanceof r.Z};r.init=function(a,c){var h;if(a)if("string"==typeof a)if(a=a.trim(),"<"==a[0]&&G.test(a))h=r.fragment(a,RegExp.$1,c),a=null;else{if(c!==q)return d(c).find(a);h=r.qsa(f,a)}else{if(b(a))return d(f).ready(a);if(r.isZ(a))return a;if(F(a))h=x(a);else if(g(a))h=[a],a=null;else if(G.test(a))h=r.fragment(a.trim(),
|
|
RegExp.$1,c),a=null;else{if(c!==q)return d(c).find(a);h=r.qsa(f,a)}}else return r.Z();return r.Z(h,a)};d=function(a,b){return r.init(a,b)};d.extend=function(a){var b,c=p.call(arguments,1);"boolean"==typeof a&&(b=a,a=c.shift());c.forEach(function(c){C(a,c,b)});return a};r.qsa=function(a,b){var c,f="#"==b[0],h=!f&&"."==b[0],d=f||h?b.slice(1):b,s=X.test(d);return e(a)&&s&&f?(c=a.getElementById(d))?[c]:[]:1!==a.nodeType&&9!==a.nodeType?[]:p.call(s&&!f?h?a.getElementsByClassName(d):a.getElementsByTagName(b):
|
|
a.querySelectorAll(b))};d.contains=f.documentElement.contains?function(a,b){return a!==b&&a.contains(b)}:function(a,b){for(;b&&(b=b.parentNode);)if(b===a)return!0;return!1};d.type=a;d.isFunction=b;d.isWindow=c;d.isArray=F;d.isPlainObject=k;d.isEmptyObject=function(a){for(var b in a)return!1;return!0};d.inArray=function(a,b,c){return u.indexOf.call(b,a,c)};d.camelCase=J;d.trim=function(a){return null==a?"":String.prototype.trim.call(a)};d.uuid=0;d.support={};d.expr={};d.map=function(a,b){var c,f=[],
|
|
h;if(l(a))for(h=0;h<a.length;h++)c=b(a[h],h),null!=c&&f.push(c);else for(h in a)c=b(a[h],h),null!=c&&f.push(c);return 0<f.length?d.fn.concat.apply([],f):f};d.each=function(a,b){var c;if(l(a))for(c=0;c<a.length&&!1!==b.call(a[c],c,a[c]);c++);else for(c in a)if(!1===b.call(a[c],c,a[c]))break;return a};d.grep=function(a,b){return s.call(a,b)};window.JSON&&(d.parseJSON=JSON.parse);d.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){M["[object "+b+"]"]=b.toLowerCase()});
|
|
d.fn={forEach:u.forEach,reduce:u.reduce,push:u.push,sort:u.sort,indexOf:u.indexOf,concat:u.concat,map:function(a){return d(d.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return d(p.apply(this,arguments))},ready:function(a){W.test(f.readyState)&&f.body?a(d):f.addEventListener("DOMContentLoaded",function(){a(d)},!1);return this},get:function(a){return a===q?p.call(this):this[0<=a?a:a+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=
|
|
this.parentNode&&this.parentNode.removeChild(this)})},each:function(a){u.every.call(this,function(b,c){return!1!==a.call(b,c,b)});return this},filter:function(a){return b(a)?this.not(this.not(a)):d(s.call(this,function(b){return r.matches(b,a)}))},add:function(a,b){return d(K(this.concat(d(a,b))))},is:function(a){return 0<this.length&&r.matches(this[0],a)},not:function(a){var c=[];if(b(a)&&a.call!==q)this.each(function(b){a.call(this,b)||c.push(this)});else{var f="string"==typeof a?this.filter(a):
|
|
l(a)&&b(a.item)?p.call(a):d(a);this.forEach(function(a){0>f.indexOf(a)&&c.push(a)})}return d(c)},has:function(a){return this.filter(function(){return g(a)?d.contains(this,a):d(this).find(a).size()})},eq:function(a){return-1===a?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!g(a)?a:d(a)},last:function(){var a=this[this.length-1];return a&&!g(a)?a:d(a)},find:function(a){var b=this;return a?"object"==typeof a?d(a).filter(function(){var a=this;return u.some.call(b,function(b){return d.contains(b,
|
|
a)})}):1==this.length?d(r.qsa(this[0],a)):this.map(function(){return r.qsa(this,a)}):[]},closest:function(a,b){var c=this[0],f=!1;for("object"==typeof a&&(f=d(a));c&&!(f?0<=f.indexOf(c):r.matches(c,a));)c=c!==b&&!e(c)&&c.parentNode;return d(c)},parents:function(a){for(var b=[],c=this;0<c.length;)c=d.map(c,function(a){if((a=a.parentNode)&&!e(a)&&0>b.indexOf(a))return b.push(a),a});return y(b,a)},parent:function(a){return y(K(this.pluck("parentNode")),a)},children:function(a){return y(this.map(function(){return E(this)}),
|
|
a)},contents:function(){return this.map(function(){return p.call(this.childNodes)})},siblings:function(a){return y(this.map(function(a,b){return s.call(E(b.parentNode),function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return d.map(this,function(b){return b[a]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display="");if("none"==getComputedStyle(this,"").getPropertyValue("display")){var a=this.style,
|
|
b=this.nodeName,c,e;h[b]||(c=f.createElement(b),f.body.appendChild(c),e=getComputedStyle(c,"").getPropertyValue("display"),c.parentNode.removeChild(c),"none"==e&&(e="block"),h[b]=e);a.display=h[b]}})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){var c=b(a);if(this[0]&&!c)var f=d(a).get(0),h=f.parentNode||1<this.length;return this.each(function(b){d(this).wrapAll(c?a.call(this,b):h?f.cloneNode(!0):f)})},wrapAll:function(a){if(this[0]){d(this[0]).before(a=d(a));for(var b;(b=
|
|
a.children()).length;)a=b.first();d(a).append(this)}return this},wrapInner:function(a){var c=b(a);return this.each(function(b){var f=d(this),h=f.contents();b=c?a.call(this,b):a;h.length?h.wrapAll(b):f.append(b)})},unwrap:function(){this.parent().each(function(){d(this).replaceWith(d(this).children())});return this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(a){return this.each(function(){var b=d(this);
|
|
(a===q?"none"==b.css("display"):a)?b.show():b.hide()})},prev:function(a){return d(this.pluck("previousElementSibling")).filter(a||"*")},next:function(a){return d(this.pluck("nextElementSibling")).filter(a||"*")},html:function(a){return 0 in arguments?this.each(function(b){var c=this.innerHTML;d(this).empty().append(v(this,a,b,c))}):0 in this?this[0].innerHTML:null},text:function(a){return 0 in arguments?this.each(function(b){b=v(this,a,b,this.textContent);this.textContent=null==b?"":""+b}):0 in this?
|
|
this[0].textContent:null},attr:function(a,b){var c;return"string"==typeof a&&!(1 in arguments)?!this.length||1!==this[0].nodeType?q:!(c=this[0].getAttribute(a))&&a in this[0]?this[0][a]:c:this.each(function(c){if(1===this.nodeType)if(g(a))for(m in a){var f=m;c=a[m];null==c?this.removeAttribute(f):this.setAttribute(f,c)}else f=a,c=v(this,b,c,this.getAttribute(a)),null==c?this.removeAttribute(f):this.setAttribute(f,c)})},removeAttr:function(a){return this.each(function(){1===this.nodeType&&this.removeAttribute(a)})},
|
|
prop:function(a,b){a=Y[a]||a;return 1 in arguments?this.each(function(c){this[a]=v(this,b,c,this[a])}):this[0]&&this[0][a]},data:function(a,b){var c="data-"+a.replace(U,"-$1").toLowerCase(),c=1 in arguments?this.attr(c,b):this.attr(c);return null!==c?D(c):q},val:function(a){return 0 in arguments?this.each(function(b){this.value=v(this,a,b,this.value)}):this[0]&&(this[0].multiple?d(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(a){if(a)return this.each(function(b){var c=
|
|
d(this);b=v(this,a,b,c.offset());var f=c.offsetParent().offset();b={top:b.top-f.top,left:b.left-f.left};"static"==c.css("position")&&(b.position="relative");c.css(b)});if(!this.length)return null;var b=this[0].getBoundingClientRect();return{left:b.left+window.pageXOffset,top:b.top+window.pageYOffset,width:Math.round(b.width),height:Math.round(b.height)}},css:function(b,c){if(2>arguments.length){var f=this[0],h=getComputedStyle(f,"");if(!f)return;if("string"==typeof b)return f.style[J(b)]||h.getPropertyValue(b);
|
|
if(F(b)){var e={};d.each(F(b)?b:[b],function(a,b){e[b]=f.style[J(b)]||h.getPropertyValue(b)});return e}}var p="";if("string"==a(b))!c&&0!==c?this.each(function(){this.style.removeProperty(B(b))}):p=B(b)+":"+("number"==typeof c&&!O[B(b)]?c+"px":c);else for(m in b)!b[m]&&0!==b[m]?this.each(function(){this.style.removeProperty(B(m))}):p+=B(m)+":"+("number"==typeof b[m]&&!O[B(m)]?b[m]+"px":b[m])+";";return this.each(function(){this.style.cssText+=";"+p})},index:function(a){return a?this.indexOf(d(a)[0]):
|
|
this.parent().children().indexOf(this[0])},hasClass:function(a){return!a?!1:u.some.call(this,function(a){return this.test(w(a))},t(a))},addClass:function(a){return!a?this:this.each(function(b){A=[];var c=w(this);v(this,a,b,c).split(/\s+/g).forEach(function(a){d(this).hasClass(a)||A.push(a)},this);A.length&&w(this,c+(c?" ":"")+A.join(" "))})},removeClass:function(a){return this.each(function(b){if(a===q)return w(this,"");A=w(this);v(this,a,b,A).split(/\s+/g).forEach(function(a){A=A.replace(t(a)," ")});
|
|
w(this,A.trim())})},toggleClass:function(a,b){return!a?this:this.each(function(c){var f=d(this);v(this,a,c,w(this)).split(/\s+/g).forEach(function(a){(b===q?!f.hasClass(a):b)?f.addClass(a):f.removeClass(a)})})},scrollTop:function(a){if(this.length){var b="scrollTop"in this[0];return a===q?b?this[0].scrollTop:this[0].pageYOffset:this.each(b?function(){this.scrollTop=a}:function(){this.scrollTo(this.scrollX,a)})}},scrollLeft:function(a){if(this.length){var b="scrollLeft"in this[0];return a===q?b?this[0].scrollLeft:
|
|
this[0].pageXOffset:this.each(b?function(){this.scrollLeft=a}:function(){this.scrollTo(a,this.scrollY)})}},position:function(){if(this.length){var a=this[0],b=this.offsetParent(),c=this.offset(),f=n.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(d(a).css("margin-top"))||0;c.left-=parseFloat(d(a).css("margin-left"))||0;f.top+=parseFloat(d(b[0]).css("border-top-width"))||0;f.left+=parseFloat(d(b[0]).css("border-left-width"))||0;return{top:c.top-f.top,left:c.left-f.left}}},offsetParent:function(){return this.map(function(){for(var a=
|
|
this.offsetParent||f.body;a&&!n.test(a.nodeName)&&"static"==d(a).css("position");)a=a.offsetParent;return a})}};d.fn.detach=d.fn.remove;["width","height"].forEach(function(a){var b=a.replace(/./,function(a){return a[0].toUpperCase()});d.fn[a]=function(f){var h,p=this[0];return f===q?c(p)?p["inner"+b]:e(p)?p.documentElement["scroll"+b]:(h=this.offset())&&h[a]:this.each(function(b){p=d(this);p.css(a,v(this,f,b,p[a]()))})}});["after","prepend","before","append"].forEach(function(b,c){var h=c%2;d.fn[b]=
|
|
function(){var b,e=d.map(arguments,function(c){b=a(c);return"object"==b||"array"==b||null==c?c:r.fragment(c)}),p,s=1<this.length;return 1>e.length?this:this.each(function(a,b){p=h?b:b.parentNode;b=0==c?b.nextSibling:1==c?b.firstChild:2==c?b:null;var l=d.contains(f.documentElement,p);e.forEach(function(a){if(s)a=a.cloneNode(!0);else if(!p)return d(a).remove();p.insertBefore(a,b);l&&z(a,function(a){null!=a.nodeName&&("SCRIPT"===a.nodeName.toUpperCase()&&(!a.type||"text/javascript"===a.type)&&!a.src)&&
|
|
window.eval.call(window,a.innerHTML)})})})};d.fn[h?b+"To":"insert"+(c?"Before":"After")]=function(a){d(a)[b](this);return this}});r.Z.prototype=d.fn;r.uniq=K;r.deserializeValue=D;d.zepto=r;return d}();window.Zepto=Zepto;void 0===window.$&&(window.$=Zepto);
|
|
(function(a){function b(a){return a._zid||(a._zid=B++)}function c(a,c,f,h){c=e(c);if(c.ns)var d=RegExp("(?:^| )"+c.ns.replace(" "," .* ?")+"(?: |$)");return(v[b(a)]||[]).filter(function(a){return a&&(!c.e||a.e==c.e)&&(!c.ns||d.test(a.ns))&&(!f||b(a.fn)===b(f))&&(!h||a.sel==h)})}function e(a){a=(""+a).split(".");return{e:a[0],ns:a.slice(1).sort().join(" ")}}function g(c,d,f,h,H,g,k){var I=b(c),m=v[I]||(v[I]=[]);d.split(/\s/).forEach(function(b){if("ready"==b)return a(document).ready(f);var d=e(b);
|
|
d.fn=f;d.sel=H;d.e in q&&(f=function(b){var c=b.relatedTarget;if(!c||c!==this&&!a.contains(this,c))return d.fn.apply(this,arguments)});var s=(d.del=g)||f;d.proxy=function(a){a=l(a);if(!a.isImmediatePropagationStopped()){a.data=h;var b=s.apply(c,a._args==t?[a]:[a].concat(a._args));!1===b&&(a.preventDefault(),a.stopPropagation());return b}};d.i=m.length;m.push(d);"addEventListener"in c&&c.addEventListener(q[d.e]||D&&z[d.e]||d.e,d.proxy,d.del&&!D&&d.e in z||!!k)})}function k(a,e,f,h,d){var l=b(a);(e||
|
|
"").split(/\s/).forEach(function(b){c(a,b,f,h).forEach(function(b){delete v[l][b.i];"removeEventListener"in a&&a.removeEventListener(q[b.e]||D&&z[b.e]||b.e,b.proxy,b.del&&!D&&b.e in z||!!d)})})}function l(b,c){if(c||!b.isDefaultPrevented)if(c||(c=b),a.each(u,function(a,h){var e=c[a];b[a]=function(){this[h]=m;return e&&e.apply(c,arguments)};b[h]=d}),c.defaultPrevented!==t?c.defaultPrevented:"returnValue"in c?!1===c.returnValue:c.getPreventDefault&&c.getPreventDefault())b.isDefaultPrevented=m;return b}
|
|
function x(a){var b,c={originalEvent:a};for(b in a)!A.test(b)&&a[b]!==t&&(c[b]=a[b]);return l(c,a)}var B=1,t,E=Array.prototype.slice,C=a.isFunction,y=function(a){return"string"==typeof a},v={},w={},D="onfocusin"in window,z={focus:"focusin",blur:"focusout"},q={mouseenter:"mouseover",mouseleave:"mouseout"};w.click=w.mousedown=w.mouseup=w.mousemove="MouseEvents";a.event={add:g,remove:k};a.proxy=function(c,e){var f=2 in arguments&&E.call(arguments,2);if(C(c)){var h=function(){return c.apply(e,f?f.concat(E.call(arguments)):
|
|
arguments)};h._zid=b(c);return h}if(y(e))return f?(f.unshift(c[e],c),a.proxy.apply(null,f)):a.proxy(c[e],c);throw new TypeError("expected function");};a.fn.bind=function(a,b,c){return this.on(a,b,c)};a.fn.unbind=function(a,b){return this.off(a,b)};a.fn.one=function(a,b,c,h){return this.on(a,b,c,h,1)};var m=function(){return!0},d=function(){return!1},A=/^([A-Z]|returnValue$|layer[XY]$)/,u={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};
|
|
a.fn.delegate=function(a,b,c){return this.on(b,a,c)};a.fn.undelegate=function(a,b,c){return this.off(b,a,c)};a.fn.live=function(b,c){a(document.body).delegate(this.selector,b,c);return this};a.fn.die=function(b,c){a(document.body).undelegate(this.selector,b,c);return this};a.fn.on=function(b,c,f,h,e){var l,G,m=this;if(b&&!y(b))return a.each(b,function(a,b){m.on(a,c,f,b,e)}),m;!y(c)&&(!C(h)&&!1!==h)&&(h=f,f=c,c=t);if(C(f)||!1===f)h=f,f=t;!1===h&&(h=d);return m.each(function(d,n){e&&(l=function(a){k(n,
|
|
a.type,h);return h.apply(this,arguments)});c&&(G=function(b){var f,e=a(b.target).closest(c,n).get(0);if(e&&e!==n)return f=a.extend(x(b),{currentTarget:e,liveFired:n}),(l||h).apply(e,[f].concat(E.call(arguments,1)))});g(n,b,h,f,c,G||l)})};a.fn.off=function(b,c,f){var h=this;if(b&&!y(b))return a.each(b,function(a,b){h.off(a,c,b)}),h;!y(c)&&(!C(f)&&!1!==f)&&(f=c,c=t);!1===f&&(f=d);return h.each(function(){k(this,b,f,c)})};a.fn.trigger=function(b,c){b=y(b)||a.isPlainObject(b)?a.Event(b):l(b);b._args=
|
|
c;return this.each(function(){"dispatchEvent"in this?this.dispatchEvent(b):a(this).triggerHandler(b,c)})};a.fn.triggerHandler=function(b,e){var f,h;this.each(function(d,l){f=x(y(b)?a.Event(b):b);f._args=e;f.target=l;a.each(c(l,b.type||b),function(a,b){h=b.proxy(f);if(f.isImmediatePropagationStopped())return!1})});return h};"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(b){a.fn[b]=
|
|
function(a){return a?this.bind(b,a):this.trigger(b)}});["focus","blur"].forEach(function(b){a.fn[b]=function(a){a?this.bind(b,a):this.each(function(){try{this[b]()}catch(a){}});return this}});a.Event=function(a,b){y(a)||(b=a,a=b.type);var c=document.createEvent(w[a]||"Events"),h=!0;if(b)for(var e in b)"bubbles"==e?h=!!b[e]:c[e]=b[e];c.initEvent(a,h,!0);return l(c)}})(Zepto);
|
|
(function(a){function b(b,c,e,d){if(b.global)return b=c||w,e=a.Event(e),a(b).trigger(e,d),!e.isDefaultPrevented()}function c(c){c.global&&0===a.active++&&b(c,null,"ajaxStart")}function e(a,c){var e=c.context;if(!1===c.beforeSend.call(e,a,c)||!1===b(c,e,"ajaxBeforeSend",[a,c]))return!1;b(c,e,"ajaxSend",[a,c])}function g(a,c,e,d){var g=e.context;e.success.call(g,a,"success",c);d&&d.resolveWith(g,[a,"success",c]);b(e,g,"ajaxSuccess",[c,e,a]);l("success",c,e)}function k(a,c,e,d,g){var k=d.context;d.error.call(k,
|
|
e,c,a);g&&g.rejectWith(k,[e,c,a]);b(d,k,"ajaxError",[e,d,a||c]);l(c,e,d)}function l(c,e,d){var l=d.context;d.complete.call(l,e,c);b(d,l,"ajaxComplete",[e,d]);d.global&&!--a.active&&b(d,null,"ajaxStop")}function x(){}function B(a){a&&(a=a.split(";",2)[0]);return a&&(a==u?"html":a==A?"json":m.test(a)?"script":d.test(a)&&"xml")||"text"}function t(a,b){return""==b?a:(a+"&"+b).replace(/[&?]{1,2}/,"?")}function E(b){b.processData&&(b.data&&"string"!=a.type(b.data))&&(b.data=a.param(b.data,b.traditional));
|
|
if(b.data&&(!b.type||"GET"==b.type.toUpperCase()))b.url=t(b.url,b.data),b.data=void 0}function C(b,c,e,d){a.isFunction(c)&&(d=e,e=c,c=void 0);a.isFunction(e)||(d=e,e=void 0);return{url:b,data:c,success:e,dataType:d}}function y(b,c,e,d){var l,g=a.isArray(c),k=a.isPlainObject(c);a.each(c,function(c,h){l=a.type(h);d&&(c=e?d:d+"["+(k||"object"==l||"array"==l?c:"")+"]");!d&&g?b.add(h.name,h.value):"array"==l||!e&&"object"==l?y(b,h,e,c):b.add(c,h)})}var v=0,w=window.document,D,z,q=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
|
|
m=/^(?:text|application)\/javascript/i,d=/^(?:text|application)\/xml/i,A="application/json",u="text/html",p=/^\s*$/;a.active=0;a.ajaxJSONP=function(b,c){if(!("type"in b))return a.ajax(b);var d=b.jsonpCallback,l=(a.isFunction(d)?d():d)||"jsonp"+ ++v,m=w.createElement("script"),x=window[l],t,n=function(b){a(m).triggerHandler("error",b||"abort")},p={abort:n},B;c&&c.promise(p);a(m).on("load error",function(e,d){clearTimeout(B);a(m).off().remove();"error"==e.type||!t?k(null,d||"error",p,b,c):g(t[0],p,
|
|
b,c);window[l]=x;t&&a.isFunction(x)&&x(t[0]);x=t=void 0});if(!1===e(p,b))return n("abort"),p;window[l]=function(){t=arguments};m.src=b.url.replace(/\?(.+)=\?/,"?$1="+l);w.head.appendChild(m);0<b.timeout&&(B=setTimeout(function(){n("timeout")},b.timeout));return p};a.ajaxSettings={type:"GET",beforeSend:x,success:x,error:x,complete:x,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:A,xml:"application/xml, text/xml",
|
|
html:u,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0};a.ajax=function(b){var d=a.extend({},b||{}),l=a.Deferred&&a.Deferred();for(D in a.ajaxSettings)void 0===d[D]&&(d[D]=a.ajaxSettings[D]);c(d);d.crossDomain||(d.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(d.url)&&RegExp.$2!=window.location.host);d.url||(d.url=window.location.toString());E(d);var m=d.dataType,q=/\?.+=\?/.test(d.url);q&&(m="jsonp");if(!1===d.cache||(!b||!0!==b.cache)&&("script"==m||"jsonp"==m))d.url=t(d.url,"_="+
|
|
Date.now());if("jsonp"==m)return q||(d.url=t(d.url,d.jsonp?d.jsonp+"=?":!1===d.jsonp?"":"callback=?")),a.ajaxJSONP(d,l);b=d.accepts[m];var s={},q=function(a,b){s[a.toLowerCase()]=[a,b]},v=/^([\w-]+:)\/\//.test(d.url)?RegExp.$1:window.location.protocol,n=d.xhr(),w=n.setRequestHeader,u;l&&l.promise(n);d.crossDomain||q("X-Requested-With","XMLHttpRequest");q("Accept",b||"*/*");if(b=d.mimeType||b)-1<b.indexOf(",")&&(b=b.split(",",2)[0]),n.overrideMimeType&&n.overrideMimeType(b);if(d.contentType||!1!==
|
|
d.contentType&&d.data&&"GET"!=d.type.toUpperCase())q("Content-Type",d.contentType||"application/x-www-form-urlencoded");if(d.headers)for(z in d.headers)q(z,d.headers[z]);n.setRequestHeader=q;n.onreadystatechange=function(){if(4==n.readyState){n.onreadystatechange=x;clearTimeout(u);var b,c=!1;if(200<=n.status&&300>n.status||304==n.status||0==n.status&&"file:"==v){m=m||B(d.mimeType||n.getResponseHeader("content-type"));b=n.responseText;try{"script"==m?(0,eval)(b):"xml"==m?b=n.responseXML:"json"==m&&
|
|
(b=p.test(b)?null:a.parseJSON(b))}catch(e){c=e}c?k(c,"parsererror",n,d,l):g(b,n,d,l)}else k(n.statusText||null,n.status?"error":"abort",n,d,l)}};if(!1===e(n,d))return n.abort(),k(null,"abort",n,d,l),n;if(d.xhrFields)for(z in d.xhrFields)n[z]=d.xhrFields[z];n.open(d.type,d.url,"async"in d?d.async:!0,d.username,d.password);for(z in s)w.apply(n,s[z]);0<d.timeout&&(u=setTimeout(function(){n.onreadystatechange=x;n.abort();k(null,"timeout",n,d,l)},d.timeout));n.send(d.data?d.data:null);return n};a.get=
|
|
function(){return a.ajax(C.apply(null,arguments))};a.post=function(){var b=C.apply(null,arguments);b.type="POST";return a.ajax(b)};a.getJSON=function(){var b=C.apply(null,arguments);b.dataType="json";return a.ajax(b)};a.fn.load=function(b,c,d){if(!this.length)return this;var e=this,l=b.split(/\s/),g;b=C(b,c,d);var k=b.success;1<l.length&&(b.url=l[0],g=l[1]);b.success=function(b){e.html(g?a("<div>").html(b.replace(q,"")).find(g):b);k&&k.apply(e,arguments)};a.ajax(b);return this};var s=encodeURIComponent;
|
|
a.param=function(a,b){var c=[];c.add=function(a,b){this.push(s(a)+"="+s(b))};y(c,a,b);return c.join("&").replace(/%20/g,"+")}})(Zepto);
|
|
(function(a){a.fn.serializeArray=function(){var b=[],c;a([].slice.call(this.get(0).elements)).each(function(){c=a(this);var e=c.attr("type");"fieldset"!=this.nodeName.toLowerCase()&&(!this.disabled&&"submit"!=e&&"reset"!=e&&"button"!=e&&("radio"!=e&&"checkbox"!=e||this.checked))&&b.push({name:c.attr("name"),value:c.val()})});return b};a.fn.serialize=function(){var a=[];this.serializeArray().forEach(function(c){a.push(encodeURIComponent(c.name)+"="+encodeURIComponent(c.value))});return a.join("&")};
|
|
a.fn.submit=function(b){b?this.bind("submit",b):this.length&&(b=a.Event("submit"),this.eq(0).trigger(b),b.isDefaultPrevented()||this.get(0).submit());return this}})(Zepto);(function(a){"__proto__"in{}||a.extend(a.zepto,{Z:function(b,c){b=b||[];a.extend(b,a.fn);b.selector=c||"";b.__Z=!0;return b},isZ:function(b){return"array"===a.type(b)&&"__Z"in b}});try{getComputedStyle(void 0)}catch(b){var c=getComputedStyle;window.getComputedStyle=function(a){try{return c(a)}catch(b){return null}}}})(Zepto);var WIN=window,DOC=document,SKIPVC=!0,hostApi="12306.cn/otsweb",baseProxyUrl="/12306/proxy.php",isMobile=!0,isIos="undefined"!=typeof window.__gChrome||"undefined"!=typeof liebaoExtentions&&liebaoExtentions.isWebviewLiebao&&liebaoExtentions.isWebviewLiebao(),isAndLiebao="undefined"!=typeof liebaoExtentions,isWebApp=!1;DOC.addEventListener("mobileSupportInitialized",function(){isWebApp=!0});
|
|
var Public={init:function(){$(".query_box .query_bigcheck").live("click",function(){$(".query_bigcheck",$(this).parent(".query_box")).removeClass("query_bigcheck_checked");$("input[type=radio]",this).attr("checked","checked");$(this).addClass("query_bigcheck_checked")})},toast:function(a,b){if(!a)return!1;var c=$('<div class="public_toast">'+a+"</div>");b=b||1500;$("body").append(c);setTimeout(function(){c.addClass("public_toast_show")},10);setTimeout(function(){c.removeClass("public_toast_show");
|
|
c.on("webkitTransitionEnd",function(){c.remove()})},b)},popHtml:function(a,b){var c="",e=DOC.createElement("div"),g="";if("object"==typeof b)for(var k in b)g+='<a href="javascript:;" data-val="'+k+'">'+b[k]+"</a>";e.className="public_layer";c+='<div class="public_pop"><p>'+a+"</p>"+(""==g?'<div class="public_btns"><a href="javascript:;" data-type="sure">\u786e\u5b9a</a></div>':'<div class="public_btns">'+g+"</div>")+"</div>";e.innerHTML=c;document.getElementsByTagName("body")[0].appendChild(e);setTimeout(function(){$(".public_pop",
|
|
e).addClass("public_pop_show")},0);$(e).on("touchmove",function(a){a.preventDefault();return!1});return $(e)},alert:function(a,b){var c=Public.popHtml(a,{sure:"\u786e\u5b9a"});$(".public_btns a",c).on("click",function(){c.remove();"function"==typeof b&&b()})},confirm:function(a,b){var c=Public.popHtml(a,{cancel:"\u53d6\u6d88",sure:"\u786e\u5b9a"});$(".public_btns a",c).on("click",function(){var a=$(this).attr("data-val");c.remove();"function"==typeof b&&"sure"==a&&b()})}};var Util={isImageFile:function(a){a=a.substring(a.lastIndexOf("."),a.length).toLowerCase();return".bmp"==a||".png"==a||".jpg"==a||".gif"==a},isEmpty:function(a,b,c){if(!a[b]){with($("#"+b).addError())0<length&&get(0).focus();c&&$.showTip(c);return!0}return!1},checkNumber:function(a,b,c){a=parseFloat(a);return!isNaN(a)&&(null==b||a>=b)&&(null==c||a<=c)},convertNumberToString:function(a,b){a=""+a;for(var c=[],e=0;e<b-a.length;e++)c.push("0");return c.join("")+a},convertDecimalToString:function(a,b){b=
|
|
b||2;a=""+Math.round(a*(10^b))/(10^b);var c=b,e=a.indexOf(".");-1!=e?c=b-a.length-e-1:a+=".";for(var e=[],g=0;g<c;g++)e.push("0");return a+e.join("")},isEmail:function(a){return/^\w+[\.\-_0-9a-z]+@[0-9a-z]+([\-_\.][0-9a-z]+)*\.(com|net|org|edu|cn)$/i.test(a)},loadJS:function(a,b,c){var e=document.createElement("script");e.onload=e.onreadystatechange=function(){if(!e||!e.readyState||!/^(?!(?:loaded|complete)$)/.test(e.readyState))e.onload=e.onreadystatechange=null,e.src="",e.parentNode.removeChild(e),
|
|
e=null,b&&b()};e.charset=c||document.charset||document.characterSet;e.src=a;try{document.getElementsByTagName("head")[0].appendChild(e)}catch(g){}}},base64={base64map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("")},base64=$.extend({base64DeMap:!function(){var a={};return $.each(base64.base64map,function(b,c){a[c]=b}),a}(),encode:function(a){for(var b=[],c=base64.base64map,e=a.length,g,k=0;k<e;)g=a[k]<<16|a[k+1]<<8|a[k+2],b.push(c[g>>18],c[g>>12&63],c[g>>6&63],c[g&63]),
|
|
k+=3;return 1==e%3?(b.pop(),b.pop(),b.push("=","=")):(b.pop(),b.push("=")),b.join("")},decode:function(a){var b=[];a=a.split("");var c=base64.base64DeMap,e=a.length,g,k=0;if(e%4)return null;for(;k<e;)g=c[a[k]]<<18|c[a[k+1]]<<12|c[a[k+2]]<<6|c[a[k+3]],b.push(g>>16,g>>8&255,g&255),k+=4;for(;"="==a[--e];)b.pop();return b},encodeArrayBuffer:function(a){a=new DataView(a);for(var b=a.byteLength,c=[],e=0;e<b;e++)c.push(a.getUint8(e));return base64.encode(c)},toObjectUrl:function(a,b){return"data:"+b+";base64,"+
|
|
a}},base64);function DateDifference(a){this.TicksCount=a;this.getSeconds=function(){return this.TicksCount/1E3};this.getMinutes=function(){return this.getSeconds()/60};this.getHours=function(){return this.getMinutes()/60};this.getDays=function(){return this.getHours()/24};this.getYears=function(){return this.getDays()/365};return this}Date.prototype.isValid=function(a){return!isNaN(this.getFullYear())};
|
|
Date.prototype.addDays=function(a){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+a)};Date.prototype.addMonthes=function(a){return new Date(this.getFullYear(),this.getMonth()+a,this.getDate())};Date.prototype.addYears=function(a){return new Date(this.getFullYear()+a,this.getMonth(),this.getDate())};Date.prototype.subtract=function(a){return a instanceof Date?new DateDifference(this-a):null};
|
|
Date.prototype.__defineGetter__("date",function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0)});
|
|
Date.prototype.format=function(a){a=a||"yyyy-MM-dd";var b={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/i.test(a)&&(a=a.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(var c in b)RegExp("("+c+")").test(a)&&(a=a.replace(RegExp.$1,1==RegExp.$1.length?b[c]:("00"+b[c]).substr((""+b[c]).length)));return a};
|
|
Date.prototype.__defineGetter__("isToday",function(){return this.date.getTime()==(new Date).date.getTime()});Date.prototype.day=function(a){var b="\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d".split("");switch(a){case 1:return b[this.getDay()];case 2:return"\u5468"+b[this.getDay()];default:return"\u661f\u671f"+b[this.getDay()]}};
|
|
function asDate(a){return/\/Date\((\d+)\)\//i.exec(a)?new Date(parseInt(RegExp.$1)):/(\d+)-0*(\d+)-0*(\d+)T0*(\d+):0*(\d+):0*(\d+)/i.exec(a)?new Date(parseInt(RegExp.$1),parseInt(RegExp.$2)-1,parseInt(RegExp.$3),parseInt(RegExp.$4),parseInt(RegExp.$5),parseInt(RegExp.$6)):/(\d{4})-0?(\d{1,2})-0?(\d{1,2})/.exec(a)?new Date(RegExp.$1,RegExp.$2-1,RegExp.$3):new Date(a)}String.prototype.toDate=function(){return asDate(this+"")};
|
|
String.prototype.padLeft=function(a,b){if(this.length>=a)return this;for(var c=[];c.length+this.length<a;)c.push(b);return c.join("")+this};String.prototype.padRight=function(a,b){if(this.length>=a)return this;for(var c=[];c.length+this.length<a;)c.push(b);return this+c.join("")};String.prototype.format=function(a,b){var c=parseInt(a);return 0<c?this.padLeft(c,b||" "):this.padRight(c,b||" ")};
|
|
String.prototype.temp=function(a){return this.replace(/\$\w+\$/gi,function(b){b=a[b.replace(/\$/g,"")];return"undefined"==b+""?"":b})};Number.prototype.toSize=function(){for(var a=["\u5b57\u8282","KB","MB","GB","TB"],b=0,c=1*this;1E3<c&&b<a.length;)b++,c/=1024;return Math.round(100*c)/100+a[b]};
|
|
Number.prototype.format=function(a){a=a.split(":");var b=this.toString(a[0]||10);if(!a[1])return b;var b=b.split("."),c="",e="",c=a[1]?b[0].padLeft(a[1],"0"):b[0],e=a[2]?(b[1]||"").padRight(a[2],"0"):b[1]||"";return c+(e?".":"")+e};Boolean.prototype.format=function(a){a=a.split(":");return!0==this?a[0]:a[1]};var cn12306={coreVersion:"1.0.0.0",baseUri:"https://kyfw.12306.cn/otn/",queryBaseUri:"http://dynamic.12306.cn/otsquery/",ajaxQueue:{},ajaxCount:0,getFullUri:function(a){return":"===a[4]||":"===a[5]?a:cn12306.baseUri+a},loadRandCode:function(a,b,c){var e=cn12306.getFullUri(":"===a[4]||":"===a[5]?a:function(b){if("sjrand"==a)return"/passcodeNew/getPassCodeNew?module=login&rand=sjrand";if("randp"==a)return"/passcodeNew/getPassCodeNew?module=passenger&rand=randp";Public.alert("\u4e0d\u652f\u6301\u7684\u9a8c\u8bc1\u7801\u7c7b\u578b\uff01")}(a));
|
|
c=cn12306.getFullUri(c||"loginAction.do?method=init");var g=new window.XMLHttpRequest;isAndLiebao||isIos||isWebApp?g.open("GET",e,!0):(g.open("GET",baseProxyUrl,!0),g.setRequestHeader("Fish-RawUrl",e));g.onreadystatechange=function(){4==g.readyState&&(200!=g.status?Public.alert("\u52a0\u8f7d\u9a8c\u8bc1\u7801\u5931\u8d25\uff0c\u8bf7\u70b9\u51fb\u9a8c\u8bc1\u7801\u5237\u65b0"):b(base64.toObjectUrl(base64.encodeArrayBuffer(g.response),"image/jpeg")))};var k=isAndLiebao?"":"Fish-";g.responseType="arraybuffer";
|
|
g.setRequestHeader(k+"Referer",c);g.setRequestHeader(k+"User-Agent","Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");g.setRequestHeader(k+"Origin",/(https?:\/\/[^\/]+\/)/.exec(e)[1]);g.send(null)},getAjaxUrl:function(a){return isAndLiebao||isIos||isWebApp?cn12306.getFullUri(a):baseProxyUrl},getHeaders:function(a,b){a=cn12306.getFullUri(a);b=cn12306.getFullUri(b);var c={},e=isAndLiebao?"":"Fish-";c[e+"User-Agent"]="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
|
|
c[e+"Origin"]=/(https?:\/\/[^\/]+\/)/.exec(a)[1];c[e+"RawUrl"]=a;c[e+"Referer"]=b;!isAndLiebao&&(!isIos&&!isWebApp)&&(c["Fish-RawUrl"]=a);return c},checkRandCode:function(a,b,c,e,g){var k=cn12306.getFullUri("passcodeNew/checkRandCodeAnsyn");g=cn12306.getFullUri(g);var l=cn12306.getHeaders(k,g);$.ajax({type:"POST",url:cn12306.getAjaxUrl(k),data:{randCode:b,rand:a},dataType:"json",refer:g,headers:l,success:function(a){"function"==typeof c&&c(a)},error:function(a,b){"function"==typeof e&&e(a,b)}})},
|
|
isUserLogined:function(a,b,c){var e=cn12306.getFullUri("login/checkUser"),g=cn12306.getFullUri("leftTicket/init"),k=cn12306.getHeaders(e,g);$.ajax({type:"POST",url:cn12306.getAjaxUrl(e),data:{_json_att:""},dataType:"json",refer:g,headers:k,success:function(c){c&&c.data&&c.data.flag?(c.attributes&&(sessionStorage.useratts=c.attributes),"function"==typeof a&&a()):"function"==typeof b&&b()},error:function(a,b){"function"==typeof c&&c()}})}};(function(a){function b(a){this.date=a||new Date;var b=0,e=0,g=(this.date-k)/864E5;this.daycyl=g+40;this.moncyl=14;for(a=1900;2050>a&&0<g;a++){b=void 0;e=348;for(b=32768;8<b;b>>=1)e+=c[a-1900]&b?1:0;e+=c[a-1900]&15?c[a-1900]&65536?30:29:0;g-=e;this.moncyl+=12}0>g&&(g+=e,a--,this.moncyl-=12);this.year=a;this.yearcyl=a-1864;b=c[a-1900]&15;this.isleap=!1;for(a=1;13>a&&0<g;a++)0<b&&a==b+1&&!1==this.isleap?(--a,this.isleap=!0,e=c[this.year-1900]&15?c[this.year-1900]&65536?30:29:0):e=c[this.year-1900]&
|
|
65536>>a?30:29,!0==this.isleap&&a==b+1&&(this.isleap=!1),g-=e,!1==this.isleap&&this.moncyl++;0==g&&(0<b&&a==b+1)&&(this.isleap?this.isleap=!1:(this.isleap=!0,--a,--this.moncyl));0>g&&(g+=e,--a,--this.moncyl);this.month=a;this.day=g+1}var c=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,
|
|
22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,
|
|
53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448],e="\u65e5\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d\u5341".split(""),g=["\u521d","\u5341","\u5eff","\u5345","\u3000"],k=new Date(1900,0,31);b.prototype.getLunarMonth=function(){var a="",a=10<this.month?a+("\u5341"+e[this.month-10]):a+e[this.month],a=a+"\u6708";"\u5341\u4e8c\u6708"==a?a="\u814a\u6708":"\u4e00\u6708"==a&&(a="\u6b63\u6708");return a};
|
|
b.prototype.getLunarDay=function(){var a="";switch(this.day){case 10:a+="\u521d\u5341";break;case 20:a+="\u4e8c\u5341";break;case 30:a+="\u4e09\u5341";break;default:a+=g[Math.floor(this.day/10)],a+=e[Math.floor(this.day%10)]}return a};b.prototype.getLunar=function(){return this.getLunarMonth()+this.getLunarDay()};b.prototype.getMOD=function(){var a=this.getLunarDay();"\u521d\u4e00"==a&&(a=this.getLunarMonth());return a};a.LunarCalendar=b})(window);function DateComponent(a){var b={_TODAY:(new Date).date,wrap:$("#date"),tdHtml:'<td><a href="javascript:;" class="$class$$isCheckClass$" data-time="$time$">$day$<span class="lunar">$lunar$</span></a></td>',curDate:(new Date).date,startDate:(new Date).date,minDate:(new Date).date,maxDate:(new Date).date.addDays(19),arr:[]};$.extend(this,b);"object"==typeof a&&$.extend(this,a);this.fd=this.curDate.format("yyyy\u5e74 MM\u6708");this.pageCurDate=new Date(this.curDate.getFullYear(),this.curDate.getMonth(),
|
|
1,0,0,0);this.pageCurMonth=this.curDate.getMonth();this.generateArray();this.setHtml()}
|
|
DateComponent.prototype.generateArray=function(){var a=this.pageCurMonth,b=this.pageCurDate,c=b.getDay(),e=b.date.getTime(),g=[],k=this.minDate.date.getTime(),l=this.maxDate.date.getTime();do g.push({year:b.getFullYear(),month:b.getMonth()+1,day:b.getDate(),format:b.format("yyyy/MM/dd"),time:b.date.getTime(),"class":b.isToday?" today"+(this.curDate.date.getTime()==b.date.getTime()?" cur":""):this.curDate.date.getTime()==b.date.getTime()?" cur":"",isCheckClass:e<k?" disable":e>l?" remind":"",lunar:(new LunarCalendar(b)).getMOD()}),
|
|
b=new Date(b.getTime()+864E5),e=b.date.getTime();while(a==b.getMonth());for(a=b.getDay();7>a&&0!=a;a++)g.push({year:b.getFullYear(),month:b.getMonth()+1,day:b.getDate(),format:b.format("yyyy/MM/dd"),time:b.date.getTime(),"class":b.isToday?" today"+(this.curDate.date.getTime()==b.date.getTime()?" cur":""):this.curDate.date.getTime()==b.date.getTime()?" cur":"",isCheckClass:e<k?" disable":e>l?" remind":"",lunar:(new LunarCalendar(b)).getMOD()}),b=new Date(b.getTime()+864E5),e=b.date.getTime();a=c;b=
|
|
new Date((new Date(this.pageCurDate.getFullYear(),this.pageCurDate.getMonth(),1,0,0,0)).getTime()-864E5);for(e=b.date.getTime();0<a;a--)g.unshift({year:b.getFullYear(),month:b.getMonth()+1,day:b.getDate(),format:b.format("yyyy/MM/dd"),time:b.date.getTime(),"class":b.isToday?" today"+(this.curDate.date.getTime()==b.date.getTime()?" cur":""):this.curDate.date.getTime()==b.date.getTime()?" cur":"",isCheckClass:e<k?" disable":e>l?" remind":"",lunar:(new LunarCalendar(b)).getMOD()}),b=new Date(b.getTime()-
|
|
864E5),e=b.date.getTime();this.arr=g};
|
|
DateComponent.prototype.setHtml=function(){for(var a='<div class="date_title"><span class="date_prev"><i class="icon icon_left"></i></span>'+this.fd+'<span class="date_next"><i class="icon icon_right"></i></span></div><table class="date_component"><tr><th>\u65e5</th><th>\u4e00</th><th>\u4e8c</th><th>\u4e09</th><th>\u56db</th><th>\u4e94</th><th>\u516d</th></tr><tr>',b=0,c=this.arr.length;b<c;b++)0!=b&&0==b%7&&(a+="</tr><tr>"),a+=this.tdHtml.temp(this.arr[b]);this.wrap.html(a+"</tr></table>");this.bindDomEvent()};
|
|
DateComponent.prototype.bindDomEvent=function(){var a=this;$("table a",a.wrap).on("click",function(b){b=new Date(parseInt($(this).attr("data-time")));a.minDate.date.getTime();a.maxDate.date.getTime();if(!$(this).hasClass("cur")){if(b.getTime()<a._TODAY.date.getTime())return!1;a.pageCurMonth==b.getMonth()?($("table a",a.wrap).removeClass("cur"),$(this).addClass("cur"),a.curDate=b):(a.curDate=b,a.startDate=b,a.pageCurDate=new Date(a.curDate.getFullYear(),a.curDate.getMonth(),1,0,0,0),a.pageCurMonth=
|
|
a.curDate.getMonth(),a.fd=a.curDate.format("yyyy\u5e74 MM\u6708"),a.generateArray(),a.setHtml())}a.checkCallback&&a.checkCallback(b)});$(".date_prev,.date_next",a.wrap).on("click",function(b){$(this).hasClass("date_prev")?a.monthPrev():a.monthNext()})};DateComponent.prototype.setBasic=function(){this.fd=this.pageCurDate.format("yyyy\u5e74 MM\u6708");this.generateArray();this.setHtml()};
|
|
DateComponent.prototype.monthPrev=function(){var a=this.pageCurMonth-1,b;0>a?(a=11,b=new Date(this.pageCurDate.getFullYear()-1,a,1,0,0,0)):b=new Date(this.pageCurDate.getFullYear(),a,1,0,0,0);if(b.getTime()<(new Date(this._TODAY.getFullYear(),this._TODAY.getMonth(),1,0,0,0)).getTime())return!1;this.pageCurMonth=a;this.pageCurDate=b;this.setBasic()};
|
|
DateComponent.prototype.monthNext=function(){this.pageCurMonth++;11<this.pageCurMonth?(this.pageCurMonth=0,this.pageCurDate=new Date(this.pageCurDate.getFullYear()+1,this.pageCurMonth,1,0,0,0)):this.pageCurDate=new Date(this.pageCurDate.getFullYear(),this.pageCurMonth,1,0,0,0);this.setBasic()};
|
|
DateComponent.prototype.dayPrev=function(){var a=new Date(this.curDate.getTime()-864E5);if(a.date.getTime()<this._TODAY.date.getTime())return this.curDate;this.curDate=a;this.pageCurDate=new Date(this.curDate.getFullYear(),this.curDate.getMonth(),1,0,0,0);this.pageCurMonth=this.pageCurDate.getMonth();this.setBasic();return this.curDate};
|
|
DateComponent.prototype.dayNext=function(){var a=new Date(this.curDate.getTime()+864E5);if(a.date.getTime()>this.maxDate.date.getTime())return this.curDate;this.curDate=a;this.pageCurDate=new Date(this.curDate.getFullYear(),this.curDate.getMonth(),1,0,0,0);this.pageCurMonth=this.pageCurDate.getMonth();this.setBasic();return this.curDate};DateComponent.prototype.setSection=function(a,b){this.minDate=a;this.maxDate=this.minDate.addDays(b)};
|
|
DateComponent.prototype.setMinDay=function(a){this.minDate=a};DateComponent.prototype.setMaxDay=function(a){this.maxDate=a};var Login={init:function(){if(0!=$("#login_page").length){var a=new Date;$("#interval").html(a.format("M\u6708dd\u65e5")+"-"+a.addDays(19).format("M\u6708d\u65e5"));Login.recode();$("#randcodeimg").click(function(a){Login.recode();return!1});$("#randcode").keyup(function(){this.value=this.value.replace(/[^0-9a-zA-Z]/g,"");document.getElementById("autosubmit").checked&&4==this.value.length&&$("#loginForm").submit()});$("#loginForm").submit(function(a){var c={username:$("[name=username]",this).val(),
|
|
password:$("[name=password]",this).val(),randcode:$("[name=randcode]",this).val()};if(c.username)if(c.password){if(!c.randcode)return Public.toast("\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801"),!1}else return Public.toast("\u8bf7\u8f93\u5165\u767b\u5f55\u5bc6\u7801"),!1;else return Public.toast("\u8bf7\u8f93\u5165\u7528\u6237\u540d"),!1;Login.formData=c;SKIPVC?Login.submitLogin():Login.getRandCode();a.preventDefault();return!1});localStorage.getItem("useraccount")&&(Login.formData=JSON.parse(localStorage.getItem("useraccount")),
|
|
$("#loginForm [name=username]").val(Login.formData.username),$("#loginForm [name=password]").val(Login.formData.password),cn12306.isUserLogined(function(){sessionStorage.setItem("user",Login.formData.username);Public.toast("\u767b\u5f55\u6210\u529f\uff0c\u6b63\u5728\u8fdb\u5165\u8ba2\u7968\u9875\u9762\uff0c\u8bf7\u7a0d\u7b49 \u2764");setTimeout(function(){location.href="query/index.html"},1E3)}))}},recode:function(){$("#randcodeimg").attr("src",$("#randcodeimg").attr("data-loading"));$("#randcode").html("").focus();
|
|
cn12306.loadRandCode("sjrand",function(a){$("#randcodeimg").attr("src",a)})},getRandCode:function(){cn12306.checkRandCode("sjrand",Login.formData.randcode,function(a){"Y"!==a.data?(Login.recode(),Public.toast("\u9a8c\u8bc1\u7801\u4e0d\u6b63\u786e\uff01")):Login.submitLogin(a)},function(a,b){Login.recode();Public.toast("\u6821\u9a8c\u9a8c\u8bc1\u7801\u5931\u8d25")},"login/init")},formData:null,submitLogin:function(){var a={"loginUserDTO.user_name":Login.formData.username,"userDTO.password":Login.formData.password,
|
|
randCode:Login.formData.randcode},b=cn12306.getHeaders("login/loginAysnSuggest","login/init");$.ajax({type:"POST",url:cn12306.getAjaxUrl("login/loginAysnSuggest"),data:a,dataType:"json",refer:"login/init",headers:b,success:function(a){a&&a.data&&"Y"===a.data.loginCheck?Login.userPostLogin():(a=(a.messages||["\u672a\u77e5\u9519\u8bef"]).join(";"),Login.recode(),-1!=a.indexOf("\u767b\u5f55\u540d")?($("#username").focus(),Public.toast("\u7528\u6237\u540d\u8f93\u5165\u9519\u8bef\u3002")):-1!=a.indexOf("\u9a8c\u8bc1\u7801")?
|
|
($("#randcode").focus(),Public.toast("\u9a8c\u8bc1\u7801\u4e0d\u6b63\u786e\u3002")):-1!=a.indexOf("\u90ae\u7bb1")?($("#username").focus(),Public.toast("\u90ae\u7bb1\u8f93\u5165\u9519\u8bef\u3002")):-1<a.indexOf("\u5bc6\u7801")?($("#password").val("").focus(),Public.toast("\u5bc6\u7801\u4e0d\u6b63\u786e\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\u3002",2E3)):-1<a.indexOf("\u9501\u5b9a")?ui.postMessage(!1,"\u60a8\u7684\u8d26\u6237\u5df2\u7ecf\u88ab\u9501\u5b9a\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u3002","login"):
|
|
-1!==a.indexOf("\u7cfb\u7edf\u7ef4\u62a4")?Public.toast("\u7cfb\u7edf\u7ef4\u62a4\u4e2d"):Public.toast("\u672a\u77e5\u9519\u8bef"))},error:function(a,b){403==a.status?Public.alert("\u8b66\u544a\uff01\u60a8\u7684IP\u5df2\u7ecf\u88ab\u5c01\u9501\uff0c\u8bf7\u91cd\u8bd5"):Public.alert("\u767b\u5f55\u65f6\u7f51\u7edc\u9519\u8bef")}})},userPostLogin:function(){var a=cn12306.getHeaders("login/userLogin","login/init");$.ajax({type:"POST",url:cn12306.getAjaxUrl("login/userLogin"),dataType:"text",refer:"login/init",
|
|
headers:a,success:function(){Login.checkJsonAttr()},error:function(a,c){Login.checkJsonAttr()}})},checkJsonAttr:function(a){a=Login.formData;cn12306.isUserLogined(function(){sessionStorage.setItem("user",a.username);localStorage.setItem("useraccount",JSON.stringify(a));Public.toast("\u767b\u5f55\u6210\u529f\uff0c\u6b63\u5728\u8fdb\u5165\u8ba2\u7968\u9875\u9762\uff0c\u8bf7\u7a0d\u7b49 \u2764");setTimeout(function(){location.href="query.html"},1E3)},function(){Public.toast("\u672a\u80fd\u6210\u529f\u767b\u5f55\uff0c\u8bf7\u91cd\u8bd5\u3002")},
|
|
function(){Public.toast("\u767b\u5f55\u65f6\u7f51\u7edc\u9519\u8bef")})}};var Query={calendar:null,init:function(){Query.checkLogin();var a=(new Date).addDays(19);Query.setDate(a);$("#menu_btn").on("click",function(){$("#user_menu").toggle()});$("#user_menu").on("click",function(a){"user_menu"==$(a.target).attr("id")&&$("#user_menu").hide()});$("#open_filter").on("click",function(){$("#search_station").addClass("fixed_box_show")})},setDate:function(a){a=a||(new Date).date;$("#start_date").html(a.format("yyyy\u5e74M\u6708d\u65e5")+" "+a.day(3)).attr("data-date",a.date.getTime());
|
|
Query.calendar||(Query.calendar=new DateComponent({wrap:$("#calendar"),curDate:a,checkCallback:Query.dateChangeCallback}));$(".check_left,.check_right").on("click",function(){var a;(a=$(this).hasClass("check_left")?Query.calendar.dayPrev():Query.calendar.dayNext())&&$("#start_date").html(a.format("yyyy\u5e74M\u6708d\u65e5")+" "+a.day(3)).attr("data-date",a.date.getTime())});$("#start_date").on("click",function(){$("#date_box").addClass("fixed_box_show")});$("#date_sure").on("click",function(){$("#start_date").html(Query.calendar.curDate.format("yyyy\u5e74M\u6708d\u65e5")+
|
|
" "+Query.calendar.curDate.day(3)).attr("data-date",Query.calendar.curDate.date.getTime());$("#date_box").removeClass("fixed_box_show")});$("[name=type]").on("change",function(){var a=$("[name=type]:checked").val();1==a?(Query.calendar.maxDate=Query.calendar._TODAY.addDays(19),Query.calendar.curDate.date.getTime()>Query.calendar.maxDate.date.getTime()&&(Query.calendar.curDate=Query.calendar.maxDate,Query.dateChangeCallback(Query.calendar.curDate)),Query.calendar.setBasic()):2==a&&(Query.calendar.maxDate=
|
|
Query.calendar._TODAY.addDays(29),Query.calendar.setBasic())})},dateChangeCallback:function(a){var b=a.date.getTime();b>=Query.calendar.minDate.date.getTime()&&b<=Query.calendar.maxDate.date.getTime()?($("#date_tip").hide(),$("#date_box").removeClass("fixed_box_show"),$("#start_date").html(Query.calendar.curDate.format("yyyy\u5e74M\u6708d\u65e5")+" "+Query.calendar.curDate.day(3)).attr("data-date",Query.calendar.curDate.date.getTime())):(b=$("a.cur",Query.calendar.wrap).offset(),$("#date_tip").css({left:b.left,
|
|
top:b.top}).html("<p>"+a.format("M\u6708d\u65e5")+'\u4e0d\u5728\u9884\u552e\u671f</p><a href="#" class="btn btn_m btn_success">\u9884\u7ea6\u63d0\u9192</a>').show(),0.75<b.left/window.innerWidth?$("#date_tip").attr("class","tip_small tip_left"):0.25>b.left/window.innerWidth?$("#date_tip").attr("class","tip_small tip_right"):$("#date_tip").attr("class","tip_small"))},checkNum:0,checkLogin:function(){Query.checkNum++;cn12306.isUserLogined(Query.hasLogin,Query.noLogin,function(){Query.noLogin();2>Query.checkNum&&
|
|
Query.checkLogin()})},hasLogin:function(){$("#login").attr("href","javascript:;").attr("data-fn","loginout").html("\u9000\u51fa");$("#menu_btn .icon_user").addClass("icon_user2");$("#login_tip").hide()},noLogin:function(){$("#login").attr("href","/12306/login.html").attr("data-fn","login").html("\u767b\u5f55");$("#menu_btn .icon_user").removeClass("icon_user2");$("#login_tip").show()}};$().ready(function(){Public.init();Login.init();Query.init()});
|