-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcode.js
More file actions
3 lines (3 loc) · 71.2 KB
/
code.js
File metadata and controls
3 lines (3 loc) · 71.2 KB
1
2
3
var Zepto=function(){function t(t){return null==t?t+"":U[Z.call(t)]||"object"}function e(e){return"function"==t(e)}function n(t){return null!=t&&t==t.window}function r(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function i(e){return"object"==t(e)}function s(t){return i(t)&&!n(t)&&Object.getPrototypeOf(t)==Object.prototype}function a(t){return"number"==typeof t.length}function o(t){return O.call(t,function(t){return null!=t})}function u(t){return t.length>0?j.fn.concat.apply([],t):t}function c(t){return t.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 l(t){return t in A?A[t]:A[t]=RegExp("(^|\\s)"+t+"(\\s|$)")}function h(t,e){return"number"!=typeof e||P[c(t)]?e:e+"px"}function p(t){var e,n;return N[t]||(e=C.createElement(t),C.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),N[t]=n),N[t]}function f(t){return"children"in t?T.call(t.children):j.map(t.childNodes,function(t){return 1==t.nodeType?t:w})}function d(t,e,n){for(_ in e)n&&(s(e[_])||K(e[_]))?(s(e[_])&&!s(t[_])&&(t[_]={}),K(e[_])&&!K(t[_])&&(t[_]=[]),d(t[_],e[_],n)):e[_]!==w&&(t[_]=e[_])}function g(t,e){return null==e?j(t):j(t).filter(e)}function m(t,n,r,i){return e(n)?n.call(t,r,i):n}function v(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function y(t,e){var n=t.className,r=n&&n.baseVal!==w;return e===w?r?n.baseVal:n:(r?n.baseVal=e:t.className=e,w)}function x(t){var e;try{return t?"true"==t||("false"==t?!1:"null"==t?null:/^0/.test(t)||isNaN(e=Number(t))?/^[\[\{]/.test(t)?j.parseJSON(t):t:e):t}catch(n){return t}}function b(t,e){e(t);for(var n in t.childNodes)b(t.childNodes[n],e)}var w,_,j,E,$,S,k=[],T=k.slice,O=k.filter,C=window.document,N={},A={},P={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},I=/^\s*<(\w+|!)[^>]*>/,M=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,z=/^(?:body|html)$/i,H=/([A-Z])/g,D=["val","css","html","text","data","width","height","offset"],V=["after","prepend","before","append"],L=C.createElement("table"),q=C.createElement("tr"),F={tr:C.createElement("tbody"),tbody:L,thead:L,tfoot:L,td:q,th:q,"*":C.createElement("div")},B=/complete|loaded|interactive/,J=/^[\w-]*$/,U={},Z=U.toString,W={},X=C.createElement("div"),G={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},K=Array.isArray||function(t){return t instanceof Array};return W.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,s=!i;return s&&(i=X).appendChild(t),r=~W.qsa(i,e).indexOf(t),s&&X.removeChild(t),r},$=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},S=function(t){return O.call(t,function(e,n){return t.indexOf(e)==n})},W.fragment=function(t,e,n){var r,i,a;return M.test(t)&&(r=j(C.createElement(RegExp.$1))),r||(t.replace&&(t=t.replace(R,"<$1></$2>")),e===w&&(e=I.test(t)&&RegExp.$1),e in F||(e="*"),a=F[e],a.innerHTML=""+t,r=j.each(T.call(a.childNodes),function(){a.removeChild(this)})),s(n)&&(i=j(r),j.each(n,function(t,e){D.indexOf(t)>-1?i[t](e):i.attr(t,e)})),r},W.Z=function(t,e){return t=t||[],t.__proto__=j.fn,t.selector=e||"",t},W.isZ=function(t){return t instanceof W.Z},W.init=function(t,n){var r;if(!t)return W.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&I.test(t))r=W.fragment(t,RegExp.$1,n),t=null;else{if(n!==w)return j(n).find(t);r=W.qsa(C,t)}else{if(e(t))return j(C).ready(t);if(W.isZ(t))return t;if(K(t))r=o(t);else if(i(t))r=[t],t=null;else if(I.test(t))r=W.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==w)return j(n).find(t);r=W.qsa(C,t)}}return W.Z(r,t)},j=function(t,e){return W.init(t,e)},j.extend=function(t){var e,n=T.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){d(t,n,e)}),t},W.qsa=function(t,e){var n,i="#"==e[0],s=!i&&"."==e[0],a=i||s?e.slice(1):e,o=J.test(a);return r(t)&&o&&i?(n=t.getElementById(a))?[n]:[]:1!==t.nodeType&&9!==t.nodeType?[]:T.call(o&&!i?s?t.getElementsByClassName(a):t.getElementsByTagName(e):t.querySelectorAll(e))},j.contains=function(t,e){return t!==e&&t.contains(e)},j.type=t,j.isFunction=e,j.isWindow=n,j.isArray=K,j.isPlainObject=s,j.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},j.inArray=function(t,e,n){return k.indexOf.call(e,t,n)},j.camelCase=$,j.trim=function(t){return null==t?"":String.prototype.trim.call(t)},j.uuid=0,j.support={},j.expr={},j.map=function(t,e){var n,r,i,s=[];if(a(t))for(r=0;t.length>r;r++)n=e(t[r],r),null!=n&&s.push(n);else for(i in t)n=e(t[i],i),null!=n&&s.push(n);return u(s)},j.each=function(t,e){var n,r;if(a(t)){for(n=0;t.length>n;n++)if(e.call(t[n],n,t[n])===!1)return t}else for(r in t)if(e.call(t[r],r,t[r])===!1)return t;return t},j.grep=function(t,e){return O.call(t,e)},window.JSON&&(j.parseJSON=JSON.parse),j.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(t,e){U["[object "+e+"]"]=e.toLowerCase()}),j.fn={forEach:k.forEach,reduce:k.reduce,push:k.push,sort:k.sort,indexOf:k.indexOf,concat:k.concat,map:function(t){return j(j.map(this,function(e,n){return t.call(e,n,e)}))},slice:function(){return j(T.apply(this,arguments))},ready:function(t){return B.test(C.readyState)&&C.body?t(j):C.addEventListener("DOMContentLoaded",function(){t(j)},!1),this},get:function(t){return t===w?T.call(this):this[t>=0?t:t+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(t){return k.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return e(t)?this.not(this.not(t)):j(O.call(this,function(e){return W.matches(e,t)}))},add:function(t,e){return j(S(this.concat(j(t,e))))},is:function(t){return this.length>0&&W.matches(this[0],t)},not:function(t){var n=[];if(e(t)&&t.call!==w)this.each(function(e){t.call(this,e)||n.push(this)});else{var r="string"==typeof t?this.filter(t):a(t)&&e(t.item)?T.call(t):j(t);this.forEach(function(t){0>r.indexOf(t)&&n.push(t)})}return j(n)},has:function(t){return this.filter(function(){return i(t)?j.contains(this,t):j(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!i(t)?t:j(t)},last:function(){var t=this[this.length-1];return t&&!i(t)?t:j(t)},find:function(t){var e,n=this;return e="object"==typeof t?j(t).filter(function(){var t=this;return k.some.call(n,function(e){return j.contains(e,t)})}):1==this.length?j(W.qsa(this[0],t)):this.map(function(){return W.qsa(this,t)})},closest:function(t,e){var n=this[0],i=!1;for("object"==typeof t&&(i=j(t));n&&!(i?i.indexOf(n)>=0:W.matches(n,t));)n=n!==e&&!r(n)&&n.parentNode;return j(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=j.map(n,function(t){return(t=t.parentNode)&&!r(t)&&0>e.indexOf(t)?(e.push(t),t):w});return g(e,t)},parent:function(t){return g(S(this.pluck("parentNode")),t)},children:function(t){return g(this.map(function(){return f(this)}),t)},contents:function(){return this.map(function(){return T.call(this.childNodes)})},siblings:function(t){return g(this.map(function(t,e){return O.call(f(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return j.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=p(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var n=e(t);if(this[0]&&!n)var r=j(t).get(0),i=r.parentNode||this.length>1;return this.each(function(e){j(this).wrapAll(n?t.call(this,e):i?r.cloneNode(!0):r)})},wrapAll:function(t){if(this[0]){j(this[0]).before(t=j(t));for(var e;(e=t.children()).length;)t=e.first();j(t).append(this)}return this},wrapInner:function(t){var n=e(t);return this.each(function(e){var r=j(this),i=r.contents(),s=n?t.call(this,e):t;i.length?i.wrapAll(s):r.append(s)})},unwrap:function(){return this.parent().each(function(){j(this).replaceWith(j(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var e=j(this);(t===w?"none"==e.css("display"):t)?e.show():e.hide()})},prev:function(t){return j(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return j(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0===arguments.length?this.length>0?this[0].innerHTML:null:this.each(function(e){var n=this.innerHTML;j(this).empty().append(m(this,t,e,n))})},text:function(t){return 0===arguments.length?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=t===w?"":""+t})},attr:function(t,e){var n;return"string"==typeof t&&e===w?0==this.length||1!==this[0].nodeType?w:"value"==t&&"INPUT"==this[0].nodeName?this.val():!(n=this[0].getAttribute(t))&&t in this[0]?this[0][t]:n:this.each(function(n){if(1===this.nodeType)if(i(t))for(_ in t)v(this,_,t[_]);else v(this,t,m(this,e,n,this.getAttribute(t)))})},removeAttr:function(t){return this.each(function(){1===this.nodeType&&v(this,t)})},prop:function(t,e){return t=G[t]||t,e===w?this[0]&&this[0][t]:this.each(function(n){this[t]=m(this,e,n,this[t])})},data:function(t,e){var n=this.attr("data-"+t.replace(H,"-$1").toLowerCase(),e);return null!==n?x(n):w},val:function(t){return 0===arguments.length?this[0]&&(this[0].multiple?j(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value):this.each(function(e){this.value=m(this,t,e,this.value)})},offset:function(t){if(t)return this.each(function(e){var n=j(this),r=m(this,t,e,n.offset()),i=n.offsetParent().offset(),s={top:r.top-i.top,left:r.left-i.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(0==this.length)return null;var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(e,n){if(2>arguments.length){var r=this[0],i=getComputedStyle(r,"");if(!r)return;if("string"==typeof e)return r.style[$(e)]||i.getPropertyValue(e);if(K(e)){var s={};return j.each(K(e)?e:[e],function(t,e){s[e]=r.style[$(e)]||i.getPropertyValue(e)}),s}}var a="";if("string"==t(e))n||0===n?a=c(e)+":"+h(e,n):this.each(function(){this.style.removeProperty(c(e))});else for(_ in e)e[_]||0===e[_]?a+=c(_)+":"+h(_,e[_])+";":this.each(function(){this.style.removeProperty(c(_))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(j(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?k.some.call(this,function(t){return this.test(y(t))},l(t)):!1},addClass:function(t){return t?this.each(function(e){E=[];var n=y(this),r=m(this,t,e,n);r.split(/\s+/g).forEach(function(t){j(this).hasClass(t)||E.push(t)},this),E.length&&y(this,n+(n?" ":"")+E.join(" "))}):this},removeClass:function(t){return this.each(function(e){return t===w?y(this,""):(E=y(this),m(this,t,e,E).split(/\s+/g).forEach(function(t){E=E.replace(l(t)," ")}),y(this,E.trim()),w)})},toggleClass:function(t,e){return t?this.each(function(n){var r=j(this),i=m(this,t,n,y(this));i.split(/\s+/g).forEach(function(t){(e===w?!r.hasClass(t):e)?r.addClass(t):r.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var e="scrollTop"in this[0];return t===w?e?this[0].scrollTop:this[0].pageYOffset:this.each(e?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var e="scrollLeft"in this[0];return t===w?e?this[0].scrollLeft:this[0].pageXOffset:this.each(e?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),r=z.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(j(t).css("margin-top"))||0,n.left-=parseFloat(j(t).css("margin-left"))||0,r.top+=parseFloat(j(e[0]).css("border-top-width"))||0,r.left+=parseFloat(j(e[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||C.body;t&&!z.test(t.nodeName)&&"static"==j(t).css("position");)t=t.offsetParent;return t})}},j.fn.detach=j.fn.remove,["width","height"].forEach(function(t){var e=t.replace(/./,function(t){return t[0].toUpperCase()});j.fn[t]=function(i){var s,a=this[0];return i===w?n(a)?a["inner"+e]:r(a)?a.documentElement["scroll"+e]:(s=this.offset())&&s[t]:this.each(function(e){a=j(this),a.css(t,m(this,i,e,a[t]()))})}}),V.forEach(function(e,n){var r=n%2;j.fn[e]=function(){var e,i,s=j.map(arguments,function(n){return e=t(n),"object"==e||"array"==e||null==n?n:W.fragment(n)}),a=this.length>1;return 1>s.length?this:this.each(function(t,e){i=r?e:e.parentNode,e=0==n?e.nextSibling:1==n?e.firstChild:2==n?e:null,s.forEach(function(t){if(a)t=t.cloneNode(!0);else if(!i)return j(t).remove();b(i.insertBefore(t,e),function(t){null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src||window.eval.call(window,t.innerHTML)})})})},j.fn[r?e+"To":"insert"+(n?"Before":"After")]=function(t){return j(t)[e](this),this}}),W.Z.prototype=j.fn,W.uniq=S,W.deserializeValue=x,j.zepto=W,j}();window.Zepto=Zepto,void 0===window.$&&(window.$=Zepto),function(t){function e(t){return t._zid||(t._zid=p++)}function n(t,n,s,a){if(n=r(n),n.ns)var o=i(n.ns);return(m[e(t)]||[]).filter(function(t){return!(!t||n.e&&t.e!=n.e||n.ns&&!o.test(t.ns)||s&&e(t.fn)!==e(s)||a&&t.sel!=a)})}function r(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function i(t){return RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function s(t,e){return t.del&&!y&&t.e in x||!!e}function a(t){return b[t]||y&&x[t]||t}function o(n,i,o,u,l,p,f){var d=e(n),g=m[d]||(m[d]=[]);i.split(/\s/).forEach(function(e){if("ready"==e)return t(document).ready(o);var i=r(e);i.fn=o,i.sel=l,i.e in b&&(o=function(e){var n=e.relatedTarget;return!n||n!==this&&!t.contains(this,n)?i.fn.apply(this,arguments):h}),i.del=p;var d=p||o;i.proxy=function(t){if(t=c(t),!t.isImmediatePropagationStopped()){t.data=u;var e=d.apply(n,t._args==h?[t]:[t].concat(t._args));return e===!1&&(t.preventDefault(),t.stopPropagation()),e}},i.i=g.length,g.push(i),"addEventListener"in n&&n.addEventListener(a(i.e),i.proxy,s(i,f))})}function u(t,r,i,o,u){var c=e(t);(r||"").split(/\s/).forEach(function(e){n(t,e,i,o).forEach(function(e){delete m[c][e.i],"removeEventListener"in t&&t.removeEventListener(a(e.e),e.proxy,s(e,u))})})}function c(e,n){return(n||!e.isDefaultPrevented)&&(n||(n=e),t.each(E,function(t,r){var i=n[t];e[t]=function(){return this[r]=w,i&&i.apply(n,arguments)},e[r]=_}),(n.defaultPrevented!==h?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(e.isDefaultPrevented=w)),e}function l(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===h||(n[e]=t[e]);return c(n,t)}var h,p=1,f=Array.prototype.slice,d=t.isFunction,g=function(t){return"string"==typeof t},m={},v={},y="onfocusin"in window,x={focus:"focusin",blur:"focusout"},b={mouseenter:"mouseover",mouseleave:"mouseout"};v.click=v.mousedown=v.mouseup=v.mousemove="MouseEvents",t.event={add:o,remove:u},t.proxy=function(n,r){if(d(n)){var i=function(){return n.apply(r,arguments)};return i._zid=e(n),i}if(g(r))return t.proxy(n[r],n);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var w=function(){return!0},_=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$)/,E={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,n,r,i,s){var a,c,p=this;return e&&!g(e)?(t.each(e,function(t,e){p.on(t,n,r,e,s)}),p):(g(n)||d(i)||i===!1||(i=r,r=n,n=h),(d(r)||r===!1)&&(i=r,r=h),i===!1&&(i=_),p.each(function(p,d){s&&(a=function(t){return u(d,t.type,i),i.apply(this,arguments)}),n&&(c=function(e){var r,s=t(e.target).closest(n,d).get(0);return s&&s!==d?(r=t.extend(l(e),{currentTarget:s,liveFired:d}),(a||i).apply(s,[r].concat(f.call(arguments,1)))):h}),o(d,e,i,r,n,c||a)}))},t.fn.off=function(e,n,r){var i=this;return e&&!g(e)?(t.each(e,function(t,e){i.off(t,n,e)}),i):(g(n)||d(r)||r===!1||(r=n,n=h),r===!1&&(r=_),i.each(function(){u(this,e,r,n)}))},t.fn.trigger=function(e,n){return e=g(e)||t.isPlainObject(e)?t.Event(e):c(e),e._args=n,this.each(function(){"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,r){var i,s;return this.each(function(a,o){i=l(g(e)?t.Event(e):e),i._args=r,i.target=o,t.each(n(o,e.type||e),function(t,e){return s=e.proxy(i),i.isImmediatePropagationStopped()?!1:h})}),s},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return t?this.bind(e,t):this.trigger(e)}}),["focus","blur"].forEach(function(e){t.fn[e]=function(t){return t?this.bind(e,t):this.each(function(){try{this[e]()}catch(t){}}),this}}),t.Event=function(t,e){g(t)||(e=t,t=e.type);var n=document.createEvent(v[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),c(n)}}(Zepto),function($){function triggerAndReturn(t,e,n){var r=$.Event(e);return $(t).trigger(r,n),!r.isDefaultPrevented()}function triggerGlobal(t,e,n,r){return t.global?triggerAndReturn(e||document,n,r):void 0}function ajaxStart(t){t.global&&0===$.active++&&triggerGlobal(t,null,"ajaxStart")}function ajaxStop(t){t.global&&!--$.active&&triggerGlobal(t,null,"ajaxStop")}function ajaxBeforeSend(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||triggerGlobal(e,n,"ajaxBeforeSend",[t,e])===!1?!1:(triggerGlobal(e,n,"ajaxSend",[t,e]),void 0)}function ajaxSuccess(t,e,n,r){var i=n.context,s="success";n.success.call(i,t,s,e),r&&r.resolveWith(i,[t,s,e]),triggerGlobal(n,i,"ajaxSuccess",[e,n,t]),ajaxComplete(s,e,n)}function ajaxError(t,e,n,r,i){var s=r.context;r.error.call(s,n,e,t),i&&i.rejectWith(s,[n,e,t]),triggerGlobal(r,s,"ajaxError",[n,r,t||e]),ajaxComplete(e,n,r)}function ajaxComplete(t,e,n){var r=n.context;n.complete.call(r,e,t),triggerGlobal(n,r,"ajaxComplete",[e,n]),ajaxStop(n)}function empty(){}function mimeToDataType(t){return t&&(t=t.split(";",2)[0]),t&&(t==htmlType?"html":t==jsonType?"json":scriptTypeRE.test(t)?"script":xmlTypeRE.test(t)&&"xml")||"text"}function appendQuery(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function serializeData(t){t.processData&&t.data&&"string"!=$.type(t.data)&&(t.data=$.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()||(t.url=appendQuery(t.url,t.data),t.data=void 0)}function parseArguments(t,e,n,r){return $.isFunction(e)&&(r=n,n=e,e=void 0),$.isFunction(n)||(r=n,n=void 0),{url:t,data:e,success:n,dataType:r}}function serialize(t,e,n,r){var i,s=$.isArray(e),a=$.isPlainObject(e);$.each(e,function(e,o){i=$.type(o),r&&(e=n?r:r+"["+(a||"object"==i||"array"==i?e:"")+"]"),!r&&s?t.add(o.name,o.value):"array"==i||!n&&"object"==i?serialize(t,o,n,e):t.add(e,o)})}var key,name,jsonpID=0,document=window.document,rscript=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(t,e){if(!("type"in t))return $.ajax(t);var n,r,i=t.jsonpCallback,s=($.isFunction(i)?i():i)||"jsonp"+ ++jsonpID,a=document.createElement("script"),o=window[s],u=function(t){$(a).triggerHandler("error",t||"abort")},c={abort:u};return e&&e.promise(c),$(a).on("load error",function(i,u){clearTimeout(r),$(a).off().remove(),"error"!=i.type&&n?ajaxSuccess(n[0],c,t,e):ajaxError(null,u||"error",c,t,e),window[s]=o,n&&$.isFunction(o)&&o(n[0]),o=n=void 0}),ajaxBeforeSend(c,t)===!1?(u("abort"),c):(window[s]=function(){n=arguments},a.src=t.url.replace(/\?(.+)=\?/,"?$1="+s),document.head.appendChild(a),t.timeout>0&&(r=setTimeout(function(){u("timeout")},t.timeout)),c)},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},$.ajax=function(options){var settings=$.extend({},options||{}),deferred=$.Deferred&&$.Deferred();for(key in $.ajaxSettings)void 0===settings[key]&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host),settings.url||(settings.url=""+window.location),serializeData(settings),settings.cache===!1&&(settings.url=appendQuery(settings.url,"_="+Date.now()));var dataType=settings.dataType,hasPlaceholder=/\?.+=\?/.test(settings.url);if("jsonp"==dataType||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,settings.jsonp?settings.jsonp+"=?":settings.jsonp===!1?"":"callback=?")),$.ajaxJSONP(settings,deferred);var abortTimeout,mime=settings.accepts[dataType],headers={},setHeader=function(t,e){headers[t.toLowerCase()]=[t,e]},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=settings.xhr(),nativeSetHeader=xhr.setRequestHeader;if(deferred&&deferred.promise(xhr),settings.crossDomain||setHeader("X-Requested-With","XMLHttpRequest"),setHeader("Accept",mime||"*/*"),(mime=settings.mimeType||mime)&&(mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime)),(settings.contentType||settings.contentType!==!1&&settings.data&&"GET"!=settings.type.toUpperCase())&&setHeader("Content-Type",settings.contentType||"application/x-www-form-urlencoded"),settings.headers)for(name in settings.headers)setHeader(name,settings.headers[name]);if(xhr.setRequestHeader=setHeader,xhr.onreadystatechange=function(){if(4==xhr.readyState){xhr.onreadystatechange=empty,clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&300>xhr.status||304==xhr.status||0==xhr.status&&"file:"==protocol){dataType=dataType||mimeToDataType(settings.mimeType||xhr.getResponseHeader("content-type")),result=xhr.responseText;try{"script"==dataType?eval(result):"xml"==dataType?result=xhr.responseXML:"json"==dataType&&(result=blankRE.test(result)?null:$.parseJSON(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings,deferred):ajaxSuccess(result,xhr,settings,deferred)}else ajaxError(xhr.statusText||null,xhr.status?"error":"abort",xhr,settings,deferred)}},ajaxBeforeSend(xhr,settings)===!1)return xhr.abort(),ajaxError(null,"abort",xhr,settings,deferred),xhr;if(settings.xhrFields)for(name in settings.xhrFields)xhr[name]=settings.xhrFields[name];var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async,settings.username,settings.password);for(name in headers)nativeSetHeader.apply(xhr,headers[name]);return settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings,deferred)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr},$.get=function(){return $.ajax(parseArguments.apply(null,arguments))},$.post=function(){var t=parseArguments.apply(null,arguments);return t.type="POST",$.ajax(t)},$.getJSON=function(){var t=parseArguments.apply(null,arguments);return t.dataType="json",$.ajax(t)},$.fn.load=function(t,e,n){if(!this.length)return this;var r,i=this,s=t.split(/\s/),a=parseArguments(t,e,n),o=a.success;return s.length>1&&(a.url=s[0],r=s[1]),a.success=function(t){i.html(r?$("<div>").html(t.replace(rscript,"")).find(r):t),o&&o.apply(i,arguments)},$.ajax(a),this};var escape=encodeURIComponent;$.param=function(t,e){var n=[];return n.add=function(t,e){this.push(escape(t)+"="+escape(e))},serialize(n,t,e),n.join("&").replace(/%20/g,"+")}}(Zepto),function(t){t.fn.serializeArray=function(){var e,n=[];return t([].slice.call(this.get(0).elements)).each(function(){e=t(this);var r=e.attr("type");"fieldset"!=this.nodeName.toLowerCase()&&!this.disabled&&"submit"!=r&&"reset"!=r&&"button"!=r&&("radio"!=r&&"checkbox"!=r||this.checked)&&n.push({name:e.attr("name"),value:e.val()})}),n},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(e)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(t){"__proto__"in{}||t.extend(t.zepto,{Z:function(e,n){return e=e||[],t.extend(e,t.fn),e.selector=n||"",e.__Z=!0,e},isZ:function(e){return"array"===t.type(e)&&"__Z"in e}});try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;window.getComputedStyle=function(t){try{return n(t)}catch(e){return null}}}}(Zepto),$.fn.editable=function(t){var e=this,n=!1,r=$(e).text();$(e).on("mouseenter",function(){n||$(e).addClass("editable")}).on("mouseleave",function(){n||$(e).removeClass("editable")}).on("click",function(){if(!n){n=!0,$(e).empty().removeClass("editable");var i=$("<input/>").val(r).appendTo($(this)).focus().select(),s=function(){n&&(n=!1,$(e).text(r=i.val()),t&&t(r))};i.on("blur",s),i.on("keydown",function(t){13===t.keyCode?s():27===t.keyCode&&(n=!1,$(e).text(r))})}})},function(t){var e={};t.hasOwnProperty("getScript")||(t.getScript=function(n,r,i){if(e[n])return r();e[n]=!0;var s=document.createElement("script"),a=t(s);s.src=n,t("head").append(s),a.bind("load",r),a.bind("error",i)})}(Zepto),function(t){t.hasOwnProperty("getStyle")||(t.getStyle=function(e,n,r){var i=document.createElement("link"),s=t(i);i.href=e,i.type="text/css",i.rel="stylesheet",t("head").append(i),s.bind("load",function(){n(i)}),s.bind("error",r)})}(Zepto),$.fn.code=function(t,e){var n=this;e=e||{},_.defaults(e,{lines:!0,compress:!1,length:0});var r=Array(app.settings().tabsize+1).join(" "),i=t.get("text").replace(/\t/g,r),s=t.get("syntax");if(e.compress&&(i=i.replace(/\n\s*\n/g,"\n")),e.length&&i.length>e.length&&(i=i.substr(0,e.length)+"\n..."),!s||!app.styles[s])return n.text(i);var a=function(){var t=prettyPrintOne(_.escape(i),s,e.lines);n.html(t)},o=app.styles[s][1];o?$.getScript("syntax/"+o,a):a()},function(){var t=this,e=t._,n={},r=Array.prototype,i=Object.prototype,s=Function.prototype,a=r.push,o=r.slice,u=r.concat,c=i.toString,l=i.hasOwnProperty,h=r.forEach,p=r.map,f=r.reduce,d=r.reduceRight,g=r.filter,m=r.every,v=r.some,y=r.indexOf,x=r.lastIndexOf,b=Array.isArray,w=Object.keys,_=s.bind,j=function(t){return t instanceof j?t:this instanceof j?(this._wrapped=t,void 0):new j(t)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):t._=j,j.VERSION="1.5.2";var E=j.each=j.forEach=function(t,e,r){if(null!=t)if(h&&t.forEach===h)t.forEach(e,r);else if(t.length===+t.length){for(var i=0,s=t.length;s>i;i++)if(e.call(r,t[i],i,t)===n)return}else for(var a=j.keys(t),i=0,s=a.length;s>i;i++)if(e.call(r,t[a[i]],a[i],t)===n)return};j.map=j.collect=function(t,e,n){var r=[];return null==t?r:p&&t.map===p?t.map(e,n):(E(t,function(t,i,s){r.push(e.call(n,t,i,s))}),r)};var $="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),f&&t.reduce===f)return r&&(e=j.bind(e,r)),i?t.reduce(e,n):t.reduce(e);if(E(t,function(t,s,a){i?n=e.call(r,n,t,s,a):(n=t,i=!0)}),!i)throw new TypeError($);return n},j.reduceRight=j.foldr=function(t,e,n,r){var i=arguments.length>2;if(null==t&&(t=[]),d&&t.reduceRight===d)return r&&(e=j.bind(e,r)),i?t.reduceRight(e,n):t.reduceRight(e);var s=t.length;if(s!==+s){var a=j.keys(t);s=a.length}if(E(t,function(o,u,c){u=a?a[--s]:--s,i?n=e.call(r,n,t[u],u,c):(n=t[u],i=!0)}),!i)throw new TypeError($);return n},j.find=j.detect=function(t,e,n){var r;return S(t,function(t,i,s){return e.call(n,t,i,s)?(r=t,!0):void 0}),r},j.filter=j.select=function(t,e,n){var r=[];return null==t?r:g&&t.filter===g?t.filter(e,n):(E(t,function(t,i,s){e.call(n,t,i,s)&&r.push(t)}),r)},j.reject=function(t,e,n){return j.filter(t,function(t,r,i){return!e.call(n,t,r,i)},n)},j.every=j.all=function(t,e,r){e||(e=j.identity);var i=!0;return null==t?i:m&&t.every===m?t.every(e,r):(E(t,function(t,s,a){return(i=i&&e.call(r,t,s,a))?void 0:n}),!!i)};var S=j.some=j.any=function(t,e,r){e||(e=j.identity);var i=!1;return null==t?i:v&&t.some===v?t.some(e,r):(E(t,function(t,s,a){return i||(i=e.call(r,t,s,a))?n:void 0}),!!i)};j.contains=j.include=function(t,e){return null==t?!1:y&&t.indexOf===y?-1!=t.indexOf(e):S(t,function(t){return t===e})},j.invoke=function(t,e){var n=o.call(arguments,2),r=j.isFunction(e);return j.map(t,function(t){return(r?e:t[e]).apply(t,n)})},j.pluck=function(t,e){return j.map(t,function(t){return t[e]})},j.where=function(t,e,n){return j.isEmpty(e)?n?void 0:[]:j[n?"find":"filter"](t,function(t){for(var n in e)if(e[n]!==t[n])return!1;return!0})},j.findWhere=function(t,e){return j.where(t,e,!0)},j.max=function(t,e,n){if(!e&&j.isArray(t)&&t[0]===+t[0]&&65535>t.length)return Math.max.apply(Math,t);if(!e&&j.isEmpty(t))return-1/0;var r={computed:-1/0,value:-1/0};return E(t,function(t,i,s){var a=e?e.call(n,t,i,s):t;a>r.computed&&(r={value:t,computed:a})}),r.value},j.min=function(t,e,n){if(!e&&j.isArray(t)&&t[0]===+t[0]&&65535>t.length)return Math.min.apply(Math,t);if(!e&&j.isEmpty(t))return 1/0;var r={computed:1/0,value:1/0};return E(t,function(t,i,s){var a=e?e.call(n,t,i,s):t;r.computed>a&&(r={value:t,computed:a})}),r.value},j.shuffle=function(t){var e,n=0,r=[];return E(t,function(t){e=j.random(n++),r[n-1]=r[e],r[e]=t}),r},j.sample=function(t,e,n){return 2>arguments.length||n?t[j.random(t.length-1)]:j.shuffle(t).slice(0,Math.max(0,e))};var k=function(t){return j.isFunction(t)?t:function(e){return e[t]}};j.sortBy=function(t,e,n){var r=k(e);return j.pluck(j.map(t,function(t,e,i){return{value:t,index:e,criteria:r.call(n,t,e,i)}}).sort(function(t,e){var n=t.criteria,r=e.criteria;if(n!==r){if(n>r||void 0===n)return 1;if(r>n||void 0===r)return-1}return t.index-e.index}),"value")};var T=function(t){return function(e,n,r){var i={},s=null==n?j.identity:k(n);return E(e,function(n,a){var o=s.call(r,n,a,e);t(i,o,n)}),i}};j.groupBy=T(function(t,e,n){(j.has(t,e)?t[e]:t[e]=[]).push(n)}),j.indexBy=T(function(t,e,n){t[e]=n}),j.countBy=T(function(t,e){j.has(t,e)?t[e]++:t[e]=1}),j.sortedIndex=function(t,e,n,r){n=null==n?j.identity:k(n);for(var i=n.call(r,e),s=0,a=t.length;a>s;){var o=s+a>>>1;i>n.call(r,t[o])?s=o+1:a=o}return s},j.toArray=function(t){return t?j.isArray(t)?o.call(t):t.length===+t.length?j.map(t,j.identity):j.values(t):[]},j.size=function(t){return null==t?0:t.length===+t.length?t.length:j.keys(t).length},j.first=j.head=j.take=function(t,e,n){return null==t?void 0:null==e||n?t[0]:o.call(t,0,e)
},j.initial=function(t,e,n){return o.call(t,0,t.length-(null==e||n?1:e))},j.last=function(t,e,n){return null==t?void 0:null==e||n?t[t.length-1]:o.call(t,Math.max(t.length-e,0))},j.rest=j.tail=j.drop=function(t,e,n){return o.call(t,null==e||n?1:e)},j.compact=function(t){return j.filter(t,j.identity)};var O=function(t,e,n){return e&&j.every(t,j.isArray)?u.apply(n,t):(E(t,function(t){j.isArray(t)||j.isArguments(t)?e?a.apply(n,t):O(t,e,n):n.push(t)}),n)};j.flatten=function(t,e){return O(t,e,[])},j.without=function(t){return j.difference(t,o.call(arguments,1))},j.uniq=j.unique=function(t,e,n,r){j.isFunction(e)&&(r=n,n=e,e=!1);var i=n?j.map(t,n,r):t,s=[],a=[];return E(i,function(n,r){(e?r&&a[a.length-1]===n:j.contains(a,n))||(a.push(n),s.push(t[r]))}),s},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(t){var e=o.call(arguments,1);return j.filter(j.uniq(t),function(t){return j.every(e,function(e){return j.indexOf(e,t)>=0})})},j.difference=function(t){var e=u.apply(r,o.call(arguments,1));return j.filter(t,function(t){return!j.contains(e,t)})},j.zip=function(){for(var t=j.max(j.pluck(arguments,"length").concat(0)),e=Array(t),n=0;t>n;n++)e[n]=j.pluck(arguments,""+n);return e},j.object=function(t,e){if(null==t)return{};for(var n={},r=0,i=t.length;i>r;r++)e?n[t[r]]=e[r]:n[t[r][0]]=t[r][1];return n},j.indexOf=function(t,e,n){if(null==t)return-1;var r=0,i=t.length;if(n){if("number"!=typeof n)return r=j.sortedIndex(t,e),t[r]===e?r:-1;r=0>n?Math.max(0,i+n):n}if(y&&t.indexOf===y)return t.indexOf(e,n);for(;i>r;r++)if(t[r]===e)return r;return-1},j.lastIndexOf=function(t,e,n){if(null==t)return-1;var r=null!=n;if(x&&t.lastIndexOf===x)return r?t.lastIndexOf(e,n):t.lastIndexOf(e);for(var i=r?n:t.length;i--;)if(t[i]===e)return i;return-1},j.range=function(t,e,n){1>=arguments.length&&(e=t||0,t=0),n=arguments[2]||1;for(var r=Math.max(Math.ceil((e-t)/n),0),i=0,s=Array(r);r>i;)s[i++]=t,t+=n;return s};var C=function(){};j.bind=function(t,e){var n,r;if(_&&t.bind===_)return _.apply(t,o.call(arguments,1));if(!j.isFunction(t))throw new TypeError;return n=o.call(arguments,2),r=function(){if(!(this instanceof r))return t.apply(e,n.concat(o.call(arguments)));C.prototype=t.prototype;var i=new C;C.prototype=null;var s=t.apply(i,n.concat(o.call(arguments)));return Object(s)===s?s:i}},j.partial=function(t){var e=o.call(arguments,1);return function(){return t.apply(this,e.concat(o.call(arguments)))}},j.bindAll=function(t){var e=o.call(arguments,1);if(0===e.length)throw Error("bindAll must be passed function names");return E(e,function(e){t[e]=j.bind(t[e],t)}),t},j.memoize=function(t,e){var n={};return e||(e=j.identity),function(){var r=e.apply(this,arguments);return j.has(n,r)?n[r]:n[r]=t.apply(this,arguments)}},j.delay=function(t,e){var n=o.call(arguments,2);return setTimeout(function(){return t.apply(null,n)},e)},j.defer=function(t){return j.delay.apply(j,[t,1].concat(o.call(arguments,1)))},j.throttle=function(t,e,n){var r,i,s,a=null,o=0;n||(n={});var u=function(){o=n.leading===!1?0:new Date,a=null,s=t.apply(r,i)};return function(){var c=new Date;o||n.leading!==!1||(o=c);var l=e-(c-o);return r=this,i=arguments,0>=l?(clearTimeout(a),a=null,o=c,s=t.apply(r,i)):a||n.trailing===!1||(a=setTimeout(u,l)),s}},j.debounce=function(t,e,n){var r,i,s,a,o;return function(){s=this,i=arguments,a=new Date;var u=function(){var c=new Date-a;e>c?r=setTimeout(u,e-c):(r=null,n||(o=t.apply(s,i)))},c=n&&!r;return r||(r=setTimeout(u,e)),c&&(o=t.apply(s,i)),o}},j.once=function(t){var e,n=!1;return function(){return n?e:(n=!0,e=t.apply(this,arguments),t=null,e)}},j.wrap=function(t,e){return function(){var n=[t];return a.apply(n,arguments),e.apply(this,n)}},j.compose=function(){var t=arguments;return function(){for(var e=arguments,n=t.length-1;n>=0;n--)e=[t[n].apply(this,e)];return e[0]}},j.after=function(t,e){return function(){return 1>--t?e.apply(this,arguments):void 0}},j.keys=w||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var n in t)j.has(t,n)&&e.push(n);return e},j.values=function(t){for(var e=j.keys(t),n=e.length,r=Array(n),i=0;n>i;i++)r[i]=t[e[i]];return r},j.pairs=function(t){for(var e=j.keys(t),n=e.length,r=Array(n),i=0;n>i;i++)r[i]=[e[i],t[e[i]]];return r},j.invert=function(t){for(var e={},n=j.keys(t),r=0,i=n.length;i>r;r++)e[t[n[r]]]=n[r];return e},j.functions=j.methods=function(t){var e=[];for(var n in t)j.isFunction(t[n])&&e.push(n);return e.sort()},j.extend=function(t){return E(o.call(arguments,1),function(e){if(e)for(var n in e)t[n]=e[n]}),t},j.pick=function(t){var e={},n=u.apply(r,o.call(arguments,1));return E(n,function(n){n in t&&(e[n]=t[n])}),e},j.omit=function(t){var e={},n=u.apply(r,o.call(arguments,1));for(var i in t)j.contains(n,i)||(e[i]=t[i]);return e},j.defaults=function(t){return E(o.call(arguments,1),function(e){if(e)for(var n in e)void 0===t[n]&&(t[n]=e[n])}),t},j.clone=function(t){return j.isObject(t)?j.isArray(t)?t.slice():j.extend({},t):t},j.tap=function(t,e){return e(t),t};var N=function(t,e,n,r){if(t===e)return 0!==t||1/t==1/e;if(null==t||null==e)return t===e;t instanceof j&&(t=t._wrapped),e instanceof j&&(e=e._wrapped);var i=c.call(t);if(i!=c.call(e))return!1;switch(i){case"[object String]":return t==e+"";case"[object Number]":return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case"[object Date]":case"[object Boolean]":return+t==+e;case"[object RegExp]":return t.source==e.source&&t.global==e.global&&t.multiline==e.multiline&&t.ignoreCase==e.ignoreCase}if("object"!=typeof t||"object"!=typeof e)return!1;for(var s=n.length;s--;)if(n[s]==t)return r[s]==e;var a=t.constructor,o=e.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;n.push(t),r.push(e);var u=0,l=!0;if("[object Array]"==i){if(u=t.length,l=u==e.length)for(;u--&&(l=N(t[u],e[u],n,r)););}else{for(var h in t)if(j.has(t,h)&&(u++,!(l=j.has(e,h)&&N(t[h],e[h],n,r))))break;if(l){for(h in e)if(j.has(e,h)&&!u--)break;l=!u}}return n.pop(),r.pop(),l};j.isEqual=function(t,e){return N(t,e,[],[])},j.isEmpty=function(t){if(null==t)return!0;if(j.isArray(t)||j.isString(t))return 0===t.length;for(var e in t)if(j.has(t,e))return!1;return!0},j.isElement=function(t){return!(!t||1!==t.nodeType)},j.isArray=b||function(t){return"[object Array]"==c.call(t)},j.isObject=function(t){return t===Object(t)},E(["Arguments","Function","String","Number","Date","RegExp"],function(t){j["is"+t]=function(e){return c.call(e)=="[object "+t+"]"}}),j.isArguments(arguments)||(j.isArguments=function(t){return!(!t||!j.has(t,"callee"))}),j.isFunction=function(t){return"function"==typeof t},j.isFinite=function(t){return isFinite(t)&&!isNaN(parseFloat(t))},j.isNaN=function(t){return j.isNumber(t)&&t!=+t},j.isBoolean=function(t){return t===!0||t===!1||"[object Boolean]"==c.call(t)},j.isNull=function(t){return null===t},j.isUndefined=function(t){return void 0===t},j.has=function(t,e){return l.call(t,e)},j.noConflict=function(){return t._=e,this},j.identity=function(t){return t},j.times=function(t,e,n){for(var r=Array(Math.max(0,t)),i=0;t>i;i++)r[i]=e.call(n,i);return r},j.random=function(t,e){return null==e&&(e=t,t=0),t+Math.floor(Math.random()*(e-t+1))};var A={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};A.unescape=j.invert(A.escape);var P={escape:RegExp("["+j.keys(A.escape).join("")+"]","g"),unescape:RegExp("("+j.keys(A.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(t){j[t]=function(e){return null==e?"":(""+e).replace(P[t],function(e){return A[t][e]})}}),j.result=function(t,e){if(null==t)return void 0;var n=t[e];return j.isFunction(n)?n.call(t):n},j.mixin=function(t){E(j.functions(t),function(e){var n=j[e]=t[e];j.prototype[e]=function(){var t=[this._wrapped];return a.apply(t,arguments),H.call(this,n.apply(j,t))}})};var I=0;j.uniqueId=function(t){var e=++I+"";return t?t+e:e},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var M=/(.)^/,R={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},z=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(t,e,n){var r;n=j.defaults({},n,j.templateSettings);var i=RegExp([(n.escape||M).source,(n.interpolate||M).source,(n.evaluate||M).source].join("|")+"|$","g"),s=0,a="__p+='";t.replace(i,function(e,n,r,i,o){return a+=t.slice(s,o).replace(z,function(t){return"\\"+R[t]}),n&&(a+="'+\n((__t=("+n+"))==null?'':_.escape(__t))+\n'"),r&&(a+="'+\n((__t=("+r+"))==null?'':__t)+\n'"),i&&(a+="';\n"+i+"\n__p+='"),s=o+e.length,e}),a+="';\n",n.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{r=Function(n.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(e)return r(e,j);var u=function(t){return r.call(this,t,j)};return u.source="function("+(n.variable||"obj")+"){\n"+a+"}",u},j.chain=function(t){return j(t).chain()};var H=function(t){return this._chain?j(t).chain():t};j.mixin(j),E(["pop","push","reverse","shift","sort","splice","unshift"],function(t){var e=r[t];j.prototype[t]=function(){var n=this._wrapped;return e.apply(n,arguments),"shift"!=t&&"splice"!=t||0!==n.length||delete n[0],H.call(this,n)}}),E(["concat","join","slice"],function(t){var e=r[t];j.prototype[t]=function(){return H.call(this,e.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),function(){var t=this,e=t.Backbone,n=[];n.push;var r=n.slice;n.splice;var i;i="undefined"!=typeof exports?exports:t.Backbone={},i.VERSION="1.1.0";var s=t._;s||"undefined"==typeof require||(s=require("underscore")),i.$=t.jQuery||t.Zepto||t.ender||t.$,i.noConflict=function(){return t.Backbone=e,this},i.emulateHTTP=!1,i.emulateJSON=!1;var a=i.Events={on:function(t,e,n){if(!u(this,"on",t,[e,n])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);return r.push({callback:e,context:n,ctx:n||this}),this},once:function(t,e,n){if(!u(this,"once",t,[e,n])||!e)return this;var r=this,i=s.once(function(){r.off(t,i),e.apply(this,arguments)});return i._callback=e,this.on(t,i,n)},off:function(t,e,n){var r,i,a,o,c,l,h,p;if(!this._events||!u(this,"off",t,[e,n]))return this;if(!t&&!e&&!n)return this._events={},this;for(o=t?[t]:s.keys(this._events),c=0,l=o.length;l>c;c++)if(t=o[c],a=this._events[t]){if(this._events[t]=r=[],e||n)for(h=0,p=a.length;p>h;h++)i=a[h],(e&&e!==i.callback&&e!==i.callback._callback||n&&n!==i.context)&&r.push(i);r.length||delete this._events[t]}return this},trigger:function(t){if(!this._events)return this;var e=r.call(arguments,1);if(!u(this,"trigger",t,e))return this;var n=this._events[t],i=this._events.all;return n&&c(n,e),i&&c(i,arguments),this},stopListening:function(t,e,n){var r=this._listeningTo;if(!r)return this;var i=!e&&!n;n||"object"!=typeof e||(n=this),t&&((r={})[t._listenId]=t);for(var a in r)t=r[a],t.off(e,n,this),(i||s.isEmpty(t._events))&&delete this._listeningTo[a];return this}},o=/\s+/,u=function(t,e,n,r){if(!n)return!0;if("object"==typeof n){for(var i in n)t[e].apply(t,[i,n[i]].concat(r));return!1}if(o.test(n)){for(var s=n.split(o),a=0,u=s.length;u>a;a++)t[e].apply(t,[s[a]].concat(r));return!1}return!0},c=function(t,e){var n,r=-1,i=t.length,s=e[0],a=e[1],o=e[2];switch(e.length){case 0:for(;i>++r;)(n=t[r]).callback.call(n.ctx);return;case 1:for(;i>++r;)(n=t[r]).callback.call(n.ctx,s);return;case 2:for(;i>++r;)(n=t[r]).callback.call(n.ctx,s,a);return;case 3:for(;i>++r;)(n=t[r]).callback.call(n.ctx,s,a,o);return;default:for(;i>++r;)(n=t[r]).callback.apply(n.ctx,e)}},l={listenTo:"on",listenToOnce:"once"};s.each(l,function(t,e){a[e]=function(e,n,r){var i=this._listeningTo||(this._listeningTo={}),a=e._listenId||(e._listenId=s.uniqueId("l"));return i[a]=e,r||"object"!=typeof n||(r=this),e[t](n,r,this),this}}),a.bind=a.on,a.unbind=a.off,s.extend(i,a);var h=i.Model=function(t,e){var n=t||{};e||(e={}),this.cid=s.uniqueId("c"),this.attributes={},e.collection&&(this.collection=e.collection),e.parse&&(n=this.parse(n,e)||{}),n=s.defaults({},n,s.result(this,"defaults")),this.set(n,e),this.changed={},this.initialize.apply(this,arguments)};s.extend(h.prototype,a,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(){return s.clone(this.attributes)},sync:function(){return i.sync.apply(this,arguments)},get:function(t){return this.attributes[t]},escape:function(t){return s.escape(this.get(t))},has:function(t){return null!=this.get(t)},set:function(t,e,n){var r,i,a,o,u,c,l,h;if(null==t)return this;if("object"==typeof t?(i=t,n=e):(i={})[t]=e,n||(n={}),!this._validate(i,n))return!1;a=n.unset,u=n.silent,o=[],c=this._changing,this._changing=!0,c||(this._previousAttributes=s.clone(this.attributes),this.changed={}),h=this.attributes,l=this._previousAttributes,this.idAttribute in i&&(this.id=i[this.idAttribute]);for(r in i)e=i[r],s.isEqual(h[r],e)||o.push(r),s.isEqual(l[r],e)?delete this.changed[r]:this.changed[r]=e,a?delete h[r]:h[r]=e;if(!u){o.length&&(this._pending=!0);for(var p=0,f=o.length;f>p;p++)this.trigger("change:"+o[p],this,h[o[p]],n)}if(c)return this;if(!u)for(;this._pending;)this._pending=!1,this.trigger("change",this,n);return this._pending=!1,this._changing=!1,this},unset:function(t,e){return this.set(t,void 0,s.extend({},e,{unset:!0}))},clear:function(t){var e={};for(var n in this.attributes)e[n]=void 0;return this.set(e,s.extend({},t,{unset:!0}))},hasChanged:function(t){return null==t?!s.isEmpty(this.changed):s.has(this.changed,t)},changedAttributes:function(t){if(!t)return this.hasChanged()?s.clone(this.changed):!1;var e,n=!1,r=this._changing?this._previousAttributes:this.attributes;for(var i in t)s.isEqual(r[i],e=t[i])||((n||(n={}))[i]=e);return n},previous:function(t){return null!=t&&this._previousAttributes?this._previousAttributes[t]:null},previousAttributes:function(){return s.clone(this._previousAttributes)},fetch:function(t){t=t?s.clone(t):{},void 0===t.parse&&(t.parse=!0);var e=this,n=t.success;return t.success=function(r){return e.set(e.parse(r,t),t)?(n&&n(e,r,t),e.trigger("sync",e,r,t),void 0):!1},R(this,t),this.sync("read",this,t)},save:function(t,e,n){var r,i,a,o=this.attributes;if(null==t||"object"==typeof t?(r=t,n=e):(r={})[t]=e,n=s.extend({validate:!0},n),r&&!n.wait){if(!this.set(r,n))return!1}else if(!this._validate(r,n))return!1;r&&n.wait&&(this.attributes=s.extend({},o,r)),void 0===n.parse&&(n.parse=!0);var u=this,c=n.success;return n.success=function(t){u.attributes=o;var e=u.parse(t,n);return n.wait&&(e=s.extend(r||{},e)),s.isObject(e)&&!u.set(e,n)?!1:(c&&c(u,t,n),u.trigger("sync",u,t,n),void 0)},R(this,n),i=this.isNew()?"create":n.patch?"patch":"update","patch"===i&&(n.attrs=r),a=this.sync(i,this,n),r&&n.wait&&(this.attributes=o),a},destroy:function(t){t=t?s.clone(t):{};var e=this,n=t.success,r=function(){e.trigger("destroy",e,e.collection,t)};if(t.success=function(i){(t.wait||e.isNew())&&r(),n&&n(e,i,t),e.isNew()||e.trigger("sync",e,i,t)},this.isNew())return t.success(),!1;R(this,t);var i=this.sync("delete",this,t);return t.wait||r(),i},url:function(){var t=s.result(this,"urlRoot")||s.result(this.collection,"url")||M();return this.isNew()?t:t+("/"===t.charAt(t.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(t){return t},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},isValid:function(t){return this._validate({},s.extend(t||{},{validate:!0}))},_validate:function(t,e){if(!e.validate||!this.validate)return!0;t=s.extend({},this.attributes,t);var n=this.validationError=this.validate(t,e)||null;return n?(this.trigger("invalid",this,n,s.extend(e,{validationError:n})),!1):!0}});var p=["keys","values","pairs","invert","pick","omit"];s.each(p,function(t){h.prototype[t]=function(){var e=r.call(arguments);return e.unshift(this.attributes),s[t].apply(s,e)}});var f=i.Collection=function(t,e){e||(e={}),e.model&&(this.model=e.model),void 0!==e.comparator&&(this.comparator=e.comparator),this._reset(),this.initialize.apply(this,arguments),t&&this.reset(t,s.extend({silent:!0},e))},d={add:!0,remove:!0,merge:!0},g={add:!0,remove:!1};s.extend(f.prototype,a,{model:h,initialize:function(){},toJSON:function(t){return this.map(function(e){return e.toJSON(t)})},sync:function(){return i.sync.apply(this,arguments)},add:function(t,e){return this.set(t,s.extend({merge:!1},e,g))},remove:function(t,e){var n=!s.isArray(t);t=n?[t]:s.clone(t),e||(e={});var r,i,a,o;for(r=0,i=t.length;i>r;r++)o=t[r]=this.get(t[r]),o&&(delete this._byId[o.id],delete this._byId[o.cid],a=this.indexOf(o),this.models.splice(a,1),this.length--,e.silent||(e.index=a,o.trigger("remove",o,this,e)),this._removeReference(o));return n?t[0]:t},set:function(t,e){e=s.defaults({},e,d),e.parse&&(t=this.parse(t,e));var n=!s.isArray(t);t=n?t?[t]:[]:s.clone(t);var r,i,a,o,u,c,l,p=e.at,f=this.model,g=this.comparator&&null==p&&e.sort!==!1,m=s.isString(this.comparator)?this.comparator:null,v=[],y=[],x={},b=e.add,w=e.merge,_=e.remove,j=!g&&b&&_?[]:!1;for(r=0,i=t.length;i>r;r++){if(u=t[r],a=u instanceof h?o=u:u[f.prototype.idAttribute],c=this.get(a))_&&(x[c.cid]=!0),w&&(u=u===o?o.attributes:u,e.parse&&(u=c.parse(u,e)),c.set(u,e),g&&!l&&c.hasChanged(m)&&(l=!0)),t[r]=c;else if(b){if(o=t[r]=this._prepareModel(u,e),!o)continue;v.push(o),o.on("all",this._onModelEvent,this),this._byId[o.cid]=o,null!=o.id&&(this._byId[o.id]=o)}j&&j.push(c||o)}if(_){for(r=0,i=this.length;i>r;++r)x[(o=this.models[r]).cid]||y.push(o);y.length&&this.remove(y,e)}if(v.length||j&&j.length)if(g&&(l=!0),this.length+=v.length,null!=p)for(r=0,i=v.length;i>r;r++)this.models.splice(p+r,0,v[r]);else{j&&(this.models.length=0);var E=j||v;for(r=0,i=E.length;i>r;r++)this.models.push(E[r])}if(l&&this.sort({silent:!0}),!e.silent){for(r=0,i=v.length;i>r;r++)(o=v[r]).trigger("add",o,this,e);(l||j&&j.length)&&this.trigger("sort",this,e)}return n?t[0]:t},reset:function(t,e){e||(e={});for(var n=0,r=this.models.length;r>n;n++)this._removeReference(this.models[n]);return e.previousModels=this.models,this._reset(),t=this.add(t,s.extend({silent:!0},e)),e.silent||this.trigger("reset",this,e),t},push:function(t,e){return this.add(t,s.extend({at:this.length},e))},pop:function(t){var e=this.at(this.length-1);return this.remove(e,t),e},unshift:function(t,e){return this.add(t,s.extend({at:0},e))},shift:function(t){var e=this.at(0);return this.remove(e,t),e},slice:function(){return r.apply(this.models,arguments)},get:function(t){return null==t?void 0:this._byId[t.id]||this._byId[t.cid]||this._byId[t]},at:function(t){return this.models[t]},where:function(t,e){return s.isEmpty(t)?e?void 0:[]:this[e?"find":"filter"](function(e){for(var n in t)if(t[n]!==e.get(n))return!1;return!0})},findWhere:function(t){return this.where(t,!0)},sort:function(t){if(!this.comparator)throw Error("Cannot sort a set without a comparator");return t||(t={}),s.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(s.bind(this.comparator,this)),t.silent||this.trigger("sort",this,t),this},pluck:function(t){return s.invoke(this.models,"get",t)},fetch:function(t){t=t?s.clone(t):{},void 0===t.parse&&(t.parse=!0);var e=t.success,n=this;return t.success=function(r){var i=t.reset?"reset":"set";n[i](r,t),e&&e(n,r,t),n.trigger("sync",n,r,t)},R(this,t),this.sync("read",this,t)},create:function(t,e){if(e=e?s.clone(e):{},!(t=this._prepareModel(t,e)))return!1;e.wait||this.add(t,e);var n=this,r=e.success;return e.success=function(t,e,i){i.wait&&n.add(t,i),r&&r(t,e,i)},t.save(null,e),t},parse:function(t){return t},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(t,e){if(t instanceof h)return t.collection||(t.collection=this),t;e=e?s.clone(e):{},e.collection=this;var n=new this.model(t,e);return n.validationError?(this.trigger("invalid",this,n.validationError,e),!1):n},_removeReference:function(t){this===t.collection&&delete t.collection,t.off("all",this._onModelEvent,this)},_onModelEvent:function(t,e,n,r){("add"!==t&&"remove"!==t||n===this)&&("destroy"===t&&this.remove(e,r),e&&t==="change:"+e.idAttribute&&(delete this._byId[e.previous(e.idAttribute)],null!=e.id&&(this._byId[e.id]=e)),this.trigger.apply(this,arguments))}});var m=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain"];s.each(m,function(t){f.prototype[t]=function(){var e=r.call(arguments);return e.unshift(this.models),s[t].apply(s,e)}});var v=["groupBy","countBy","sortBy"];s.each(v,function(t){f.prototype[t]=function(e,n){var r=s.isFunction(e)?e:function(t){return t.get(e)};return s[t](this.models,r,n)}});var y=i.View=function(t){this.cid=s.uniqueId("view"),t||(t={}),s.extend(this,s.pick(t,b)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},x=/^(\S+)\s*(.*)$/,b=["model","collection","el","id","attributes","className","tagName","events"];s.extend(y.prototype,a,{tagName:"div",$:function(t){return this.$el.find(t)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(t,e){return this.$el&&this.undelegateEvents(),this.$el=t instanceof i.$?t:i.$(t),this.el=this.$el[0],e!==!1&&this.delegateEvents(),this},delegateEvents:function(t){if(!t&&!(t=s.result(this,"events")))return this;this.undelegateEvents();for(var e in t){var n=t[e];if(s.isFunction(n)||(n=this[t[e]]),n){var r=e.match(x),i=r[1],a=r[2];n=s.bind(n,this),i+=".delegateEvents"+this.cid,""===a?this.$el.on(i,n):this.$el.on(i,a,n)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(s.result(this,"el"),!1);else{var t=s.extend({},s.result(this,"attributes"));this.id&&(t.id=s.result(this,"id")),this.className&&(t["class"]=s.result(this,"className"));var e=i.$("<"+s.result(this,"tagName")+">").attr(t);this.setElement(e,!1)}}}),i.sync=function(t,e,n){var r=_[t];s.defaults(n||(n={}),{emulateHTTP:i.emulateHTTP,emulateJSON:i.emulateJSON});var a={type:r,dataType:"json"};if(n.url||(a.url=s.result(e,"url")||M()),null!=n.data||!e||"create"!==t&&"update"!==t&&"patch"!==t||(a.contentType="application/json",a.data=JSON.stringify(n.attrs||e.toJSON(n))),n.emulateJSON&&(a.contentType="application/x-www-form-urlencoded",a.data=a.data?{model:a.data}:{}),n.emulateHTTP&&("PUT"===r||"DELETE"===r||"PATCH"===r)){a.type="POST",n.emulateJSON&&(a.data._method=r);var o=n.beforeSend;n.beforeSend=function(t){return t.setRequestHeader("X-HTTP-Method-Override",r),o?o.apply(this,arguments):void 0}}"GET"===a.type||n.emulateJSON||(a.processData=!1),"PATCH"===a.type&&w&&(a.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var u=n.xhr=i.ajax(s.extend(a,n));return e.trigger("request",e,u,n),u};var w=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),_={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};i.ajax=function(){return i.$.ajax.apply(i.$,arguments)};var j=i.Router=function(t){t||(t={}),t.routes&&(this.routes=t.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},E=/\((.*?)\)/g,$=/(\(\?)?:\w+/g,S=/\*\w+/g,k=/[\-{}\[\]+?.,\\\^$|#\s]/g;s.extend(j.prototype,a,{initialize:function(){},route:function(t,e,n){s.isRegExp(t)||(t=this._routeToRegExp(t)),s.isFunction(e)&&(n=e,e=""),n||(n=this[e]);var r=this;return i.history.route(t,function(s){var a=r._extractParameters(t,s);n&&n.apply(r,a),r.trigger.apply(r,["route:"+e].concat(a)),r.trigger("route",e,a),i.history.trigger("route",r,e,a)}),this},navigate:function(t,e){return i.history.navigate(t,e),this},_bindRoutes:function(){if(this.routes){this.routes=s.result(this,"routes");for(var t,e=s.keys(this.routes);null!=(t=e.pop());)this.route(t,this.routes[t])}},_routeToRegExp:function(t){return t=t.replace(k,"\\$&").replace(E,"(?:$1)?").replace($,function(t,e){return e?t:"([^/]+)"}).replace(S,"(.*?)"),RegExp("^"+t+"$")},_extractParameters:function(t,e){var n=t.exec(e).slice(1);return s.map(n,function(t){return t?decodeURIComponent(t):null})}});var T=i.History=function(){this.handlers=[],s.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},O=/^[#\/]|\s+$/g,C=/^\/+|\/+$/g,N=/msie [\w.]+/,A=/\/$/,P=/[?#].*$/;T.started=!1,s.extend(T.prototype,a,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(null==t)if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var n=this.root.replace(A,"");t.indexOf(n)||(t=t.slice(n.length))}else t=this.getHash();return t.replace(O,"")},start:function(t){if(T.started)throw Error("Backbone.history has already been started");T.started=!0,this.options=s.extend({root:"/"},this.options,t),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment(),n=document.documentMode,r=N.exec(navigator.userAgent.toLowerCase())&&(!n||7>=n);this.root=("/"+this.root+"/").replace(C,"/"),r&&this._wantsHashChange&&(this.iframe=i.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(e)),this._hasPushState?i.$(window).on("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!r?i.$(window).on("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=e;var a=this.location,o=a.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!o)return this.fragment=this.getFragment(null,!0),this.location.replace(this.root+this.location.search+"#"+this.fragment),!0;this._hasPushState&&o&&a.hash&&(this.fragment=this.getHash().replace(O,""),this.history.replaceState({},document.title,this.root+this.fragment+a.search))}return this.options.silent?void 0:this.loadUrl()},stop:function(){i.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl),clearInterval(this._checkUrlInterval),T.started=!1},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(){var t=this.getFragment();return t===this.fragment&&this.iframe&&(t=this.getFragment(this.getHash(this.iframe))),t===this.fragment?!1:(this.iframe&&this.navigate(t),this.loadUrl(),void 0)},loadUrl:function(t){return t=this.fragment=this.getFragment(t),s.any(this.handlers,function(e){return e.route.test(t)?(e.callback(t),!0):void 0})},navigate:function(t,e){if(!T.started)return!1;e&&e!==!0||(e={trigger:!!e});var n=this.root+(t=this.getFragment(t||""));if(t=t.replace(P,""),this.fragment!==t){if(this.fragment=t,""===t&&"/"!==n&&(n=n.slice(0,-1)),this._hasPushState)this.history[e.replace?"replaceState":"pushState"]({},document.title,n);else{if(!this._wantsHashChange)return this.location.assign(n);this._updateHash(this.location,t,e.replace),this.iframe&&t!==this.getFragment(this.getHash(this.iframe))&&(e.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,t,e.replace))}return e.trigger?this.loadUrl(t):void 0}},_updateHash:function(t,e,n){if(n){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else t.hash="#"+e}}),i.history=new T;var I=function(t,e){var n,r=this;n=t&&s.has(t,"constructor")?t.constructor:function(){return r.apply(this,arguments)},s.extend(n,r,e);var i=function(){this.constructor=n};return i.prototype=r.prototype,n.prototype=new i,t&&s.extend(n.prototype,t),n.__super__=r.prototype,n};h.extend=f.extend=j.extend=y.extend=T.extend=I;var M=function(){throw Error('A "url" property or function must be specified')},R=function(t,e){var n=e.error;e.error=function(r){n&&n(t,r,e),t.trigger("error",t,r,e)}}}.call(this);var app={socketUrl:"wss://"+location.hostname+"/socket",identityKey:"name",storageKey:"mempes",storageIdKey:"id",settingsKey:"settings",panesEl:"#panes",snippetLen:300,settingsDefaults:{username:Math.floor((new Date).getTime()/1e3).toString(36),tabsize:2},styles:{c:["c/c++",null],cs:["c#",null],java:["java",null],bash:["bash",null],python:["python",null],perl:["perl",null],ruby:["ruby",null],js:["javascript",null],html:["html/xml",null],apollo:["apollo","lang-apollo.js"],basic:["basic","lang-basic.js"],coffee:["coffeescript",null],clj:["clojure","lang-clj.js"],css:["css","lang-css.js"],dart:["dart","lang-dart.js"],erlang:["erlang","lang-erlang.js"],go:["go","lang-go.js"],hs:["haskell","lang-hs.js"],lisp:["lisp","lang-lisp.js"],llvm:["llvm","lang-llvm.js"],lua:["lua","lang-lua.js"],matlab:["matlab","lang-matlab.js"],ml:["ml","lang-ml.js"],mumps:["mumps","lang-mumps.js"],n:["n","lang-n.js"],pascal:["pascal","lang-pascal.js"],proto:["proto","lang-proto.js"],r:["r","lang-r.js"],rust:["rust",null],scala:["scala","lang-scala.js"],sql:["sql","lang-sql.js"],tcl:["tcl","lang-tcl.js"],tex:["tex","lang-tex.js"],vb:["visual basic","lang-vb.js"],vhdl:["vhdl","lang-vhdl.js"],wiki:["wiki","lang-wiki.js"],xq:["xquery","lang-xq.js"],yaml:["yaml","lang-yaml.js"]},run:function(){$(app.panesEl).children().hide(),app.jst={},$("script[type='text/template']").each(function(){app.jst[$(this).prop("id")]=_.template($(this).text())}),app.settings(app.settings()),app.message=new app.MessageModel,new app.MessageView({model:app.message}),app.pasteCollection=new app.PasteCollection(app.storage.collection()),$(".logo").on("click",function(){app.router.navigate("",{trigger:!0})}),app.settings().dark&&app.toggleLights(),$("#dark").click(function(t){t.preventDefault(),app.toggleLights()}),app.connection=new app.Connection(function(){app.editView=new app.EditView,app.codeView=new app.CodeView,app.listView=new app.ListView({collection:app.pasteCollection}),app.settingsView=new app.SettingsView,Backbone.history.start()})},Pane:Backbone.View.extend({show:function(){var t=this;$(app.panesEl).children().each(function(){$(this).prop("id")!==t.$el.prop("id")&&$(this).hide()}),this.$el.show()}}),router:new(Backbone.Router.extend({routes:{"":"edit",":name/:id":"code",list:"list",settings:"settings",about:"about"},edit:function(){app.editView.show()},code:function(t,e){app.loadPaste(t,e,function(t){app.codeView.setModel(t).render().show()})},list:function(){return app.pasteCollection.length?(app.listView.rendered||app.listView.render(),app.listView.show(),void 0):(app.message.set({type:"info",name:"NO_PASTES"}).trigger("show"),void 0)},settings:function(){app.settingsView.render().show()},about:function(){app.message.set({type:"page",name:"ABOUT"}).trigger("show")}}))};app.fatal=function(t){return function(){app.message.set({type:"error",name:"CUSTOM",args:{message:t}}).trigger("show")}},app.formatText=function(t){for(var e=t.split(/\n/),n=65535,r=0;e.length>r;r++)if(e[r].match(/\S/)){var i=e[r].match(/^(\s+)/);if(!i){n=0;break}n=Math.min(n,i[1].length)}else e[r]="";var s=_(e).map(function(t){return t.substr(n,t.length-n)});return s.join("\n").replace(/^\n+/,"").replace(/\s*$/,"")},app.confirm=function(t){var e=$(t.el);_.defaults(t,{message:"Are you sure?",yes:"delete",cancel:"cancel",onYes:function(){},onCancel:function(){}});var n=e.html(),r=$("<button/>").text(t.yes).addClass("yes"),i=$("<button/>").text(t.cancel).addClass("cancel"),s=function(t){return function(r){r.stopPropagation(),e.html(n),t()}};r.on("click",s(t.onYes)),i.on("click",s(t.onCancel)),e.html(t.message).append(r).append(i)},app.loadPaste=function(t,e,n){function r(t){app.message.set({type:"error",name:t}).trigger("show")}if(t===app.identity()){var i=app.pasteCollection.findWhere({id:parseInt(e)});
i?n(i):r("LOCAL_NOT_FOUND")}else app.connection.request("fetch",{name:t,id:e},function(e){if(e.error)r(e.error);else{e.name=t;var i=new app.PasteModel(e);n(i)}})},app.identity=function(t){var e;return t!==void 0?localStorage.setItem(app.identityKey,e=t):e=localStorage.getItem(app.identityKey),e},app.settings=function(t){if("object"==typeof t)localStorage.setItem(app.settingsKey,JSON.stringify(t));else{t={};try{t=JSON.parse(localStorage.getItem(app.settingsKey))||{}}catch(e){console.error("Can't parse settings")}_.defaults(t,app.settingsDefaults)}return t},app.toggleLights=function(){var t=app.settings();app.darkness?($(app.darkness).remove(),app.darkness=null,t.dark=!1,app.settings(t)):$.getStyle("dark.css",function(e){app.darkness=e,t.dark=!0,app.settings(t)})},app.storage=function(){function t(t){for(var e=0;s.length>e;e++)if(s[e].id===t)return e;return-1}function e(){localStorage.setItem(r,JSON.stringify(s))}function n(){var t=localStorage.getItem(r);if(t)try{s=JSON.parse(t)}catch(e){console.error("Can not parse collection")}}var r=app.storageKey,i=app.storageIdKey,s=[];return n.prototype.nextId=function(){var t=parseInt(localStorage.getItem(i))||1;return localStorage.setItem(i,t+1),t},n.prototype.set=function(n){if(n.id===void 0){var r=this.nextId();n.id=r,s.push(n)}else{var i=t(n.id);i>=0&&(n.id=s[i].id,s[i]=n)}return e(),n.id},n.prototype.get=function(e){var n=t(parseInt(e));return 0>n?null:s[n]},n.prototype.remove=function(n){var r=t(n);r>=0&&(s.splice(r,1),e())},n.prototype.collection=function(){return s},n.prototype.count=function(){return s.length},n.prototype.stringify=function(){return JSON.stringify(this.collection(),void 0,app.settings().tabsize)},n.prototype.reset=function(t){var n=JSON.parse(t);if(!_.isArray(n))throw Error("Must be an array");for(var r={},i=0;n.length>i;i++){var a=n[i];if(!_.isObject(a))throw Error("Element "+i+" is not an object");if(_.each(["id","title","text"],function(t){if(!a.hasOwnProperty(t))throw Error("Element "+i+" doesn't have '"+t+"'")}),r[a.id])throw Error("ID "+a.id+" already used in element "+i);r[a.id]=!0}s=n,e()},new n}(),app.Connection=function(){function t(t){function n(){app.message.set({type:"error",name:"NO_WEBSOCKET"}).trigger("show")}var r=this;return _.extend(r,Backbone.Events),r.on("get",function(t){r.send("get",app.storage.get(t.id))}),window.WebSocket=window.WebSocket||window.MozWebSocket,window.WebSocket?(e=new WebSocket(app.socketUrl),e.onopen=function(){var e=app.settings().username;r.request("register",{name:e},function(e){app.identity(e.name),t&&t()})},e.onerror=n,e.onmessage=function(t){var e={};try{e=JSON.parse(t.data)}catch(n){_log("Bad JSON message ["+t.data+"]")()}r.trigger(e.action,e.args)},e.onclose=n,void 0):n()}var e;return t.prototype.send=function(t,n){var r=JSON.stringify({action:t,args:n});e.send(r)},t.prototype.request=function(t,e,n){this.once(t,n),this.send(t,e)},t}(),app.PasteModel=Backbone.Model.extend({defaults:{id:void 0,title:null,text:"",syntax:null,password:null,created:new Date},initialize:function(){this.on("change",this.store,this)},app:function(){return app},store:function(){this.isOwn()&&app.storage.set(this.toJSON())},title:function(t){var e=this.get("title");return t?e.length>t?e.substr(0,t)+"...":e:e},url:function(){return"#"+app.identity()+"/"+this.get("id")},syntax:function(){var t=this.get("syntax");return t&&app.styles[t]?app.styles[t][0]:null},created:function(){return new Date(this.get("created")).toLocaleString()},isOwn:function(){return!this.has("name")}}),app.MessageModel=Backbone.Model.extend({defaults:{type:"error",name:null,args:{}}}),app.MessageView=app.Pane.extend({el:"#message",initialize:function(){this.model.on("show",this.update,this)},update:function(){this.render().show()},render:function(){var t=this.model.toJSON();return this.$el.removeClass().addClass(t.type),this.$el.html(app.jst[t.type+"_"+t.name](t.args||{})),this}}),app.EditView=app.Pane.extend({el:"#edit",events:{"click button":"save"},initialize:function(){this.$textarea=this.$("textarea")},show:function(){app.Pane.prototype.show.call(this),this.$textarea.focus()},save:function(){var t=app.formatText(this.$textarea.val());if(""!==t){this.$textarea.val("");var e=new app.PasteModel({text:t});app.pasteCollection.add(e),app.router.navigate(e.url(),{trigger:!0})}}}),app.CodeView=app.Pane.extend({el:"#code",events:{"change select":"setSyntax","click .fork":"fork","click .raw":"raw","click .edit":"edit","click .save":"save","click .cancel":"render","click .remove":"askRemove"},setModel:function(t){if(app.connection.off("broadcast:change"),!t.isOwn()){var e=this;app.connection.on("broadcast:change",function(n){n.id===t.get("id")&&n.name===t.get("name")&&(e.model.set(n.changes),e.render())})}return this.model=t,this},renderText:function(){this.$("pre").code(this.model)},render:function(){if(this.$el.html(app.jst.codeView({m:this.model})),this.renderText(),this.model.isOwn()){var t=this;this.$(".title").editable(function(e){t.model.set("title",e),t.broadcastChange()}),this.$(".syntax").html(app.jst.syntaxView({m:this.model}))}return this},setSyntax:function(){this.model.set("syntax",this.$("select").val()),this.broadcastChange(),this.render()},fork:function(t){t.stopPropagation();var e=this.model.toJSON();delete e.id,delete e.created,delete e.name;var n=new app.PasteModel(e);app.pasteCollection.add(n),app.router.navigate(n.url(),{trigger:!0})},raw:function(t){if(t.stopPropagation(),this.rawDisplay)this.renderText(),this.rawDisplay=!1;else{var e=this.model.get("text");this.$("pre").text(e),this.rawDisplay=!0}},edit:function(t){t.stopPropagation(),this.$(".content").html(app.jst.editCodeView({m:this.model})),this.$("textarea").focus()},save:function(){this.model.set("text",this.$("textarea").val()),this.broadcastChange(),this.render()},askRemove:function(){var t=this;app.confirm({el:this.$(".remove"),message:"",onYes:function(){app.pasteCollection.remove(t.model),app.router.navigate("list",{trigger:!0})}})},broadcastChange:function(){var t=this.model.toJSON();app.connection.send("broadcast",{action:"change",id:t.id,name:app.identity(),changes:_(t).pick("title","syntax","text")})}}),app.PasteCollection=Backbone.Collection.extend({model:app.PasteModel,initialize:function(){this.on("remove",this._remove,this)},_remove:function(t){app.storage.remove(t.get("id")),t.view&&t.view.$el.remove()}}),app.ListPasteView=Backbone.View.extend({tagName:"li",className:"box",events:{"click .navigate":"navigate","click .remove":"askRemove"},initialize:function(){this.model.view=this,this.model.on("change",this.render,this)},render:function(){return this.$el.html(app.jst.pasteListView({m:this.model})),this.$("pre").code(this.model,{lines:!1,compress:!0,length:app.snippetLen}),this},navigate:function(){app.router.navigate(this.model.url(),{trigger:!0})},askRemove:function(){var t=this;app.confirm({el:this.$("strong"),onYes:function(){app.pasteCollection.remove(t.model)}})}}),app.ListView=app.Pane.extend({el:"#list",events:{"click .edit":"edit","click .save":"save","click .cancel":"cancel"},initialize:function(){this.rendered=!1,this.inEdit=!1,this.collection.on("add",this.add,this),this.collection.on("reset",this.render,this)},_addView:function(t){var e=new app.ListPasteView({model:t}).render();e.$el.appendTo(this.$(".boxen"))},render:function(){var t=this;return this.$el.html(app.jst.listView()),this.collection.each(function(e){t._addView(e)}),this.rendered=!0,this},add:function(t){var e=app.storage.set(t.toJSON());t.set({id:e}),null===t.get("title")&&t.set({title:"untitled"+e}),this.rendered&&this._addView(t)},edit:function(){this.inEdit?(this.$(".boxen").show(),this.$(".editor").hide()):(this.$(".boxen").hide(),this.$(".editor").show().find("textarea").val(app.storage.stringify())),this.inEdit=!this.inEdit},save:function(){if(this.$(".error").hide(),this.$("textarea").val()){try{app.storage.reset(this.$("textarea").val())}catch(t){return this.$(".error").text(t.message).show(),void 0}this.inEdit=!1,this.collection.reset(app.storage.collection())}},cancel:function(){this.$(".error").hide(),this.$("textarea").val(app.storage.stringify())}}),app.SettingsView=app.Pane.extend({el:"#settings",events:{"click button":"update"},render:function(){var t=app.settings();return this.$el.html(app.jst.settingsView(t)),this},error:function(t){t?this.$(".error").text(t).show():this.$(".error").hide()},update:function(){var t={username:this.$('input[name="username"]').val(),tabsize:parseInt(this.$('input[name="tabsize"]').val())};if(this.error(""),!t.username.match(/^\w{3,15}$/))return this.error("The username must be 3 - 15 alphanumeric"),void 0;if("number"!=typeof t.tabsize||1>t.tabsize||t.tabsize>8)return this.error("Tabsize must be 1 to 8"),void 0;var e=t.username!==app.settings().username;app.settings(t),e&&location.reload()}});