").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
// End jQuery
!function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,v=e.reduce,h=e.reduceRight,d=e.filter,g=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,_=Object.keys,w=i.bind,j=function(n){return n instanceof j?n:this instanceof j?(this._wrapped=n,void 0):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.5.0";var A=j.each=j.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a in n)if(j.has(n,a)&&t.call(e,n[a],a,n)===r)return};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var E="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduce===v)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(E);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduceRight===h)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(E);return r},j.find=j.detect=function(n,t,r){var e;return O(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:d&&n.filter===d?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:g&&n.every===g?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var O=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:O(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,function(n){return n[t]})},j.where=function(n,t,r){return j.isEmpty(t)?r?void 0:[]:j[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},j.findWhere=function(n,t){return j.where(n,t,!0)},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&j.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&j.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a
e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.indexi;){var o=i+a>>>1;r.call(e,n[o])=0})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){return j.unzip.apply(j,o.call(arguments))},j.unzip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var M=function(){};j.bind=function(n,t){var r,e;if(w&&n.bind===w)return w.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));M.prototype=n.prototype;var u=new M;M.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u=null;return function(){var i=this,a=arguments,o=function(){u=null,r||(e=n.apply(i,a))},c=r&&!u;return clearTimeout(u),u=setTimeout(o,t),c&&(e=n.apply(i,a)),e}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=_||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){var t=[];for(var r in n)j.has(n,r)&&t.push(n[r]);return t},j.pairs=function(n){var t=[];for(var r in n)j.has(n,r)&&t.push([r,n[r]]);return t},j.invert=function(n){var t={};for(var r in n)j.has(n,r)&&(t[n[r]]=r);return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var I={escape:{"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"}};I.unescape=j.invert(I.escape);var T={escape:new RegExp("["+j.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(I.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return I[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),D.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},z=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(z,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.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{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var D=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],D.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return D.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this);
// End Underscore
(function(){var t=this;var e=t.Backbone;var i=[];var r=i.push;var s=i.slice;var n=i.splice;var a;if(typeof exports!=="undefined"){a=exports}else{a=t.Backbone={}}a.VERSION="1.0.0";var h=t._;if(!h&&typeof require!=="undefined")h=require("underscore");a.$=t.jQuery||t.Zepto||t.ender||t.$;a.noConflict=function(){t.Backbone=e;return this};a.emulateHTTP=false;a.emulateJSON=false;var o=a.Events={on:function(t,e,i){if(!l(this,"on",t,[e,i])||!e)return this;this._events||(this._events={});var r=this._events[t]||(this._events[t]=[]);r.push({callback:e,context:i,ctx:i||this});return this},once:function(t,e,i){if(!l(this,"once",t,[e,i])||!e)return this;var r=this;var s=h.once(function(){r.off(t,s);e.apply(this,arguments)});s._callback=e;return this.on(t,s,i)},off:function(t,e,i){var r,s,n,a,o,u,c,f;if(!this._events||!l(this,"off",t,[e,i]))return this;if(!t&&!e&&!i){this._events={};return this}a=t?[t]:h.keys(this._events);for(o=0,u=a.length;o").attr(t);this.setElement(e,false)}else{this.setElement(h.result(this,"el"),false)}}});a.sync=function(t,e,i){var r=k[t];h.defaults(i||(i={}),{emulateHTTP:a.emulateHTTP,emulateJSON:a.emulateJSON});var s={type:r,dataType:"json"};if(!i.url){s.url=h.result(e,"url")||U()}if(i.data==null&&e&&(t==="create"||t==="update"||t==="patch")){s.contentType="application/json";s.data=JSON.stringify(i.attrs||e.toJSON(i))}if(i.emulateJSON){s.contentType="application/x-www-form-urlencoded";s.data=s.data?{model:s.data}:{}}if(i.emulateHTTP&&(r==="PUT"||r==="DELETE"||r==="PATCH")){s.type="POST";if(i.emulateJSON)s.data._method=r;var n=i.beforeSend;i.beforeSend=function(t){t.setRequestHeader("X-HTTP-Method-Override",r);if(n)return n.apply(this,arguments)}}if(s.type!=="GET"&&!i.emulateJSON){s.processData=false}if(s.type==="PATCH"&&window.ActiveXObject&&!(window.external&&window.external.msActiveXFilteringEnabled)){s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")}}var o=i.xhr=a.ajax(h.extend(s,i));e.trigger("request",e,o,i);return o};var k={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};a.ajax=function(){return a.$.ajax.apply(a.$,arguments)};var S=a.Router=function(t){t||(t={});if(t.routes)this.routes=t.routes;this._bindRoutes();this.initialize.apply(this,arguments)};var $=/\((.*?)\)/g;var T=/(\(\?)?:\w+/g;var H=/\*\w+/g;var A=/[\-{}\[\]+?.,\\\^$|#\s]/g;h.extend(S.prototype,o,{initialize:function(){},route:function(t,e,i){if(!h.isRegExp(t))t=this._routeToRegExp(t);if(h.isFunction(e)){i=e;e=""}if(!i)i=this[e];var r=this;a.history.route(t,function(s){var n=r._extractParameters(t,s);i&&i.apply(r,n);r.trigger.apply(r,["route:"+e].concat(n));r.trigger("route",e,n);a.history.trigger("route",r,e,n)});return this},navigate:function(t,e){a.history.navigate(t,e);return this},_bindRoutes:function(){if(!this.routes)return;this.routes=h.result(this,"routes");var t,e=h.keys(this.routes);while((t=e.pop())!=null){this.route(t,this.routes[t])}},_routeToRegExp:function(t){t=t.replace(A,"\\$&").replace($,"(?:$1)?").replace(T,function(t,e){return e?t:"([^/]+)"}).replace(H,"(.*?)");return new RegExp("^"+t+"$")},_extractParameters:function(t,e){var i=t.exec(e).slice(1);return h.map(i,function(t){return t?decodeURIComponent(t):null})}});var I=a.History=function(){this.handlers=[];h.bindAll(this,"checkUrl");if(typeof window!=="undefined"){this.location=window.location;this.history=window.history}};var N=/^[#\/]|\s+$/g;var P=/^\/+|\/+$/g;var O=/msie [\w.]+/;var C=/\/$/;I.started=false;h.extend(I.prototype,o,{interval:50,getHash:function(t){var e=(t||this).location.href.match(/#(.*)$/);return e?e[1]:""},getFragment:function(t,e){if(t==null){if(this._hasPushState||!this._wantsHashChange||e){t=this.location.pathname;var i=this.root.replace(C,"");if(!t.indexOf(i))t=t.substr(i.length)}else{t=this.getHash()}}return t.replace(N,"")},start:function(t){if(I.started)throw new Error("Backbone.history has already been started");I.started=true;this.options=h.extend({},{root:"/"},this.options,t);this.root=this.options.root;this._wantsHashChange=this.options.hashChange!==false;this._wantsPushState=!!this.options.pushState;this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var e=this.getFragment();var i=document.documentMode;var r=O.exec(navigator.userAgent.toLowerCase())&&(!i||i<=7);this.root=("/"+this.root+"/").replace(P,"/");if(r&&this._wantsHashChange){this.iframe=a.$('').hide().appendTo("body")[0].contentWindow;this.navigate(e)}if(this._hasPushState){a.$(window).on("popstate",this.checkUrl)}else if(this._wantsHashChange&&"onhashchange"in window&&!r){a.$(window).on("hashchange",this.checkUrl)}else if(this._wantsHashChange){this._checkUrlInterval=setInterval(this.checkUrl,this.interval)}this.fragment=e;var s=this.location;var n=s.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!n){this.fragment=this.getFragment(null,true);this.location.replace(this.root+this.location.search+"#"+this.fragment);return true}else if(this._wantsPushState&&this._hasPushState&&n&&s.hash){this.fragment=this.getHash().replace(N,"");this.history.replaceState({},document.title,this.root+this.fragment+s.search)}if(!this.options.silent)return this.loadUrl()},stop:function(){a.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);I.started=false},route:function(t,e){this.handlers.unshift({route:t,callback:e})},checkUrl:function(t){var e=this.getFragment();if(e===this.fragment&&this.iframe){e=this.getFragment(this.getHash(this.iframe))}if(e===this.fragment)return false;if(this.iframe)this.navigate(e);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(t){var e=this.fragment=this.getFragment(t);var i=h.any(this.handlers,function(t){if(t.route.test(e)){t.callback(e);return true}});return i},navigate:function(t,e){if(!I.started)return false;if(!e||e===true)e={trigger:e};t=this.getFragment(t||"");if(this.fragment===t)return;this.fragment=t;var i=this.root+t;if(this._hasPushState){this.history[e.replace?"replaceState":"pushState"]({},document.title,i)}else if(this._wantsHashChange){this._updateHash(this.location,t,e.replace);if(this.iframe&&t!==this.getFragment(this.getHash(this.iframe))){if(!e.replace)this.iframe.document.open().close();this._updateHash(this.iframe.location,t,e.replace)}}else{return this.location.assign(i)}if(e.trigger)this.loadUrl(t)},_updateHash:function(t,e,i){if(i){var r=t.href.replace(/(javascript:|#).*$/,"");t.replace(r+"#"+e)}else{t.hash="#"+e}}});a.history=new I;var j=function(t,e){var i=this;var r;if(t&&h.has(t,"constructor")){r=t.constructor}else{r=function(){return i.apply(this,arguments)}}h.extend(r,i,e);var s=function(){this.constructor=r};s.prototype=i.prototype;r.prototype=new s;if(t)h.extend(r.prototype,t);r.__super__=i.prototype;return r};d.extend=g.extend=S.extend=b.extend=I.extend=j;var U=function(){throw new Error('A "url" property or function must be specified')};var R=function(t,e){var i=e.error;e.error=function(r){if(i)i(t,r,e);t.trigger("error",t,r,e)}}}).call(this);
// End Backbone
(function(e,t){if(typeof define==="function"&&define.amd){define(["underscore","backbone"],function(n,r){return t(n||e._,r||e.Backbone)})}else{t(_,Backbone)}})(this,function(e,t){function n(){return((1+Math.random())*65536|0).toString(16).substring(1)}function r(){return n()+n()+"-"+n()+"-"+n()+"-"+n()+"-"+n()+n()+n()}t.LocalStorage=window.Store=function(e){this.name=e;var t=this.localStorage().getItem(this.name);this.records=t&&t.split(",")||[]};e.extend(t.LocalStorage.prototype,{save:function(){this.localStorage().setItem(this.name,this.records.join(","))},create:function(e){if(!e.id){e.id=r();e.set(e.idAttribute,e.id)}this.localStorage().setItem(this.name+"-"+e.id,JSON.stringify(e));this.records.push(e.id.toString());this.save();return this.find(e)},update:function(t){this.localStorage().setItem(this.name+"-"+t.id,JSON.stringify(t));if(!e.include(this.records,t.id.toString()))this.records.push(t.id.toString());this.save();return this.find(t)},find:function(e){return this.jsonData(this.localStorage().getItem(this.name+"-"+e.id))},findAll:function(){return e(this.records).chain().map(function(e){return this.jsonData(this.localStorage().getItem(this.name+"-"+e))},this).compact().value()},destroy:function(t){if(t.isNew())return false;this.localStorage().removeItem(this.name+"-"+t.id);this.records=e.reject(this.records,function(e){return e===t.id.toString()});this.save();return t},localStorage:function(){return localStorage},jsonData:function(e){return e&&JSON.parse(e)}});t.LocalStorage.sync=window.Store.sync=t.localSync=function(e,t,n){var r=t.localStorage||t.collection.localStorage;var i,s,o=$.Deferred&&$.Deferred();try{switch(e){case"read":i=t.id!=undefined?r.find(t):r.findAll();break;case"create":i=r.create(t);break;case"update":i=r.update(t);break;case"delete":i=r.destroy(t);break}}catch(u){if(u.code===DOMException.QUOTA_EXCEEDED_ERR&&window.localStorage.length===0)s="Private browsing is unsupported";else s=u.message}if(i){t.trigger("sync",t,i,n);if(n&&n.success)n.success(i);if(o)o.resolve(i)}else{s=s?s:"Record Not Found";if(n&&n.error)n.error(s);if(o)o.reject(s)}if(n&&n.complete)n.complete(i);return o&&o.promise()};t.ajaxSync=t.sync;t.getSyncMethod=function(e){if(e.localStorage||e.collection&&e.collection.localStorage){return t.localSync}return t.ajaxSync};t.sync=function(e,n,r){return t.getSyncMethod(n).apply(this,[e,n,r])};return t.LocalStorage})
//End locakStorage
// ------ End libraries ------
var cssText = "" +
"";
var buildingTemplate = ' State : ON /OFF ' +
'';
var upgradeTemplate = ' State : ON /OFF ' +
'';
var saveTemplate = ' ' +
'';
var specialTemplate = '';
var newGame = "MS4wMzZ8fDEzODAwNTgxMzE5MjV8MTExMTExfDA7MDswOzA7MDswOy0xOy0xOzA7MDs" +
"wOzA7MDswfDAsMCwwLDA7MCwwLDAsMDswLDAsMCwwOzAsMCwwLDA7MCwwLDAsMDswLDAsMCwwOzAsMCwwL" +
"DA7MCwwLDAsMDswLDAsMCwwOzAsMCwwLDA7fDIyNTE3OTk4MTM2ODUyNDk7MjI1MTc5OTgxMzY4NTI0OTsyMj" +
"UxNzk5ODEzNjg1MjQ5OzIyNTE3OTk4MTM2ODUyNDk7NTI0Mjg5fDIyNTE3OTk4MTM2ODUyNDk7ODc5NjA5MzAyMj" +
"IwOQ%3D%3D%21END%21";
$ = jQuery;
$("head").append(cssText);
var Tools = {
models: {},
views: {},
collections: {},
cookieToKeep: 0
};
Tools.Models = {
AutoClickModel: Backbone.Model.extend({
initialize: function() {
if (this.get("count") !== 0)
this.set({count: 0});
if (this.get("running") !== false)
this.set({running:false});
if (/CookieCheatNinetainedoAutoClick=\{([\s\S]+?)\};/.test(document.cookie)) {
this.set(JSON.parse(RegExp.$1));
}
this.save();
this.set({
intervalId: 0
});
if (typeof this.get("timeOut") === "undefined")
this.set({timeOut: 50});
if (this.get("running"))
this.go();
},
save: function () {
document.cookie = "CookieCheatNinetainedoAutoClick={" + JSON.stringify(this.toJSON()) + "};";
},
go: function() {
var that = this;
var t = function () {
Game.ClickCookie();
that.set({
count: that.get("count") + 1
});
var tmp = setTimeout(t, that.get("timeOut"));
that.set({intervalId:tmp});
};
var tmp = setTimeout(t, that.get("timeOut"));
this.set({intervalId:tmp, running:true});
this.save();
},
stop: function() {
var that = this;
if (typeof that.get("intervalId") !== "undefined")
clearTimeout(that.get("intervalId"));
that.set({running:false});
this.save();
}
}),
GoldenSpawnModel: Backbone.Model.extend({
initialize: function() {
if (this.get("count") !== 0)
this.set({count: 0});
},
incr: function() {
this.set({
count: this.get("count") + 1
});
}
}),
AutoGoldenClickModel: Backbone.Model.extend({
save: function () {
document.cookie = "CookieCheatNinetainedoAutoGoldenClick={" + JSON.stringify(this.toJSON()) + "};";
},
initialize: function() {
if (this.get("count") !== 0)
this.set({count: 0});
if (this.get("running") !== false)
this.set({running:false});
if (/CookieCheatNinetainedoAutoGoldenClick=\{([\s\S]+?)\};/.test(document.cookie)) {
this.set(JSON.parse(RegExp.$1));
}
this.save();
this.set({intervalId:0});
if (this.get("running"))
this.go();
},
go: function() {
var that = this;
var tmp = setInterval(function() {
if (Game.goldenCookie.life > 0) {
Game.goldenCookie.click();
that.set({
count: that.get("count") + 1
});
}
}, 1000);
this.set({intervalId:tmp, running:true});
this.save();
},
stop: function() {
var that = this;
if (typeof that.get("intervalId") !== "undefined")
clearInterval(that.get("intervalId"));
that.set({running:false});
this.save();
}
}),
AutoBuyBuilding: Backbone.Model.extend({
initialize: function() {
if (typeof this.get("maxAmount") === "undefined" || this.get("maxAmount") < 1)
this.set({maxAmount:1});
if (this.get("count") !== 0)
this.set({count: 0});
if (this.get("running") !== false && this.get("running") !== true)
this.set({running:false});
if (this.get("bought") !== 0)
this.set({bought:0});
this.set({count: Game.ObjectsById[this.get("buildingId")].amount});
this.set({maxBought:this.get("maxAmount") - this.get("count")});
if (this.get("running") === true) {
this.toJSON().first = true;
this.go();
}
this.set({intervalId:0, first:true});
},
validate: function(attrs, options) {
if (typeof Game.ObjectsById[this.get("buildingId")] === "undefined") {
return "Invalid buildingId specified.";
}
if (this.get("count") >= this.get("maxAmount")) {
return "Your current amount is above your maxAmount. Sorry, I delete myself !";
}
},
functionToDo: function () {
if (__DEBUG__)
console.log("In");
var that = this;
var running = that.get("running");
var buildingId = that.get("buildingId");
if (running && Game.ObjectsById[buildingId].amount < that.get("maxAmount")) {
if (Game.cookies - Game.ObjectsById[buildingId].price >= Tools.cookieToKeep) {
Game.ObjectsById[buildingId].buy();
if (that.get("count") !== Game.ObjectsById[buildingId].amount) {
that.set({bought: that.get("bought") + 1});
that.save();
}
that.set({count: Game.ObjectsById[buildingId].amount});
}
}
else if (Game.ObjectsById[buildingId].amount >= that.get("maxAmount")) {
that.stop();
}
if (this.get("again"))
setTimeout(_.bind(this.functionToDo, this), (running ? 100 : 2000));
else if (__DEBUG__)
console.log("Finished for real");
},
go: function() {
var that = this;
if (typeof this.toJSON().first === "undefined" || this.toJSON().first === true) {
setTimeout(_.bind(this.functionToDo, this), 200);
this.toJSON().first = false;
}
this.set({running:true, again: true});
this.save();
},
stop: function() {
var that = this;
that.set({running:false});
that.save();
}
}),
AutoBuyUpgrade: Backbone.Model.extend({
initialize: function() {
if (this.get("running") !== false && this.get("running") !== true)
this.set({running:false});
if (this.get("running") === true)
this.go();
this.set({intervalId:0});
},
validate: function(attrs, options) {
if (typeof Game.UpgradesById[this.get("upgradeId")] === "undefined") {
return "Invalid upgradeId specified.";
}
},
go: function() {
var that = this;
var tmp = setInterval(function() {
if (Game.UpgradesById[that.get("upgradeId")].unlocked === 1) {
if (Game.cookies - Game.UpgradesById[that.get("upgradeId")].basePrice >= Tools.cookieToKeep) {
Game.UpgradesById[that.get("upgradeId")].buy();
that.save();
}
}
}, 100);
this.set({intervalId:tmp, running:true});
that.save();
},
stop: function() {
var that = this;
if (typeof that.get("intervalId") !== "undefined")
clearInterval(that.get("intervalId"));
that.set({running:false});
that.save();
}
}),
SaveModel: Backbone.Model.extend({
initialize: function () {
if (typeof this.get("name") === "undefined")
this.set({name: "NoName"});
if (typeof this.get("date") === "undefined")
this.set({date: new Date()});
if (typeof this.get("code") === "undefined")
this.set({code: ""});
},
validate: function(attrs, options) {
var str = unescape(this.get("code")).split('!END!')[0];
str = b64_to_utf8(str);
if (str === "")
return ("Bad save")
},
saveGame: function (save) {
this.set({backUp: this.get("code"), code: save});
},
loadGame: function () {
Game.LoadSave(this.get("code"));
},
loadBackup: function () {
Game.LoadSave(this.get("backUp"));
},
generateSavePreview: function (save) {
var preview = {
prefs: {},
upgrades: {},
achievements: {},
objects: {}
};
var str = unescape(save);
var version = 0;
var oldstr = str.split('|');
if (oldstr[0] < 1) {} else {
str = str.split('!END!')[0];
str = b64_to_utf8(str);
}
if (str != '') {
var spl = '';
str = str.split('|');
preview.version = version = parseFloat(str[0]);
if (version >= 1 && version > Game.version) {
alert('Error : you are attempting to load a save from a later version (v.' + version + '; you are using v.' + Game.version + ').');
return;
}
else if (version >= 1) {
spl = str[2].split(';'); //save stats
preview.startDate = parseInt(spl[0]);
spl = str[3].split(''); //prefs
preview.prefs.particles = parseInt(spl[0]);
preview.prefs.numbers = parseInt(spl[1]);
preview.prefs.autosave = parseInt(spl[2]);
preview.prefs.autoupdate = spl[3] ? parseInt(spl[3]) : 1;
preview.prefs.milk = spl[4] ? parseInt(spl[4]) : 1;
preview.prefs.fancy = parseInt(spl[5]);
spl = str[4].split(';'); //cookies
preview.cookies = parseFloat(spl[0]);
preview.cookiesEarned = parseFloat(spl[1]);
preview.cookieClicks = spl[2] ? parseInt(spl[2]) : 0;
preview.goldenClicks = spl[3] ? parseInt(spl[3]) : 0;
preview.handmadeCookies = spl[4] ? parseFloat(spl[4]) : 0;
preview.missedGoldenClicks = spl[5] ? parseInt(spl[5]) : 0;
preview.backgroundType = spl[6] ? parseInt(spl[6]) : 0;
preview.milkType = spl[7] ? parseInt(spl[7]) : 0;
preview.cookiesReset = spl[8] ? parseFloat(spl[8]) : 0;
preview.elderWrath = spl[9] ? parseInt(spl[9]) : 0;
preview.pledges = spl[10] ? parseInt(spl[10]) : 0;
preview.pledgeT = spl[11] ? parseInt(spl[11]) : 0;
preview.nextResearch = spl[12] ? parseInt(spl[12]) : 0;
preview.researchT = spl[13] ? parseInt(spl[13]) : 0;
spl = str[5].split(';'); //buildings
preview.BuildingsOwned = 0;
for (var i in Game.ObjectsById) {
var me = Game.ObjectsById[i];
preview.objects[me.name] = {};
me = preview.objects[me.name];
if (spl[i]) {
var mestr = spl[i].toString().split(',');
me.amount = parseInt(mestr[0]);
me.bought = parseInt(mestr[1]);
me.totalCookies = parseInt(mestr[2]);
me.specialUnlocked = parseInt(mestr[3]);
preview.BuildingsOwned += me.amount;
} else {
me.unlocked = 0;
me.bought = 0;
me.totalCookies = 0;
}
}
if (version < 1.035) //old non-binary algorithm
{
spl = str[6].split(';'); //upgrades
preview.UpgradesOwned = 0;
for (var i in Game.UpgradesById) {
var me = Game.UpgradesById[i];
preview.upgrades[me.name] = {};
me = preview.upgrades[me.name];
if (spl[i]) {
var mestr = spl[i].split(',');
me.unlocked = parseInt(mestr[0]);
me.bought = parseInt(mestr[1]);
if (me.bought) preview.UpgradesOwned++;
} else {
me.unlocked = 0;
me.bought = 0;
}
}
if (str[7]) spl = str[7].split(';');
else spl = []; //achievements
preview.AchievementsOwned = 0;
for (var i in Game.AchievementsById) {
var me = Game.AchievementsById[i];
preview.achievements[me.name] = {};
me = preview.achievements[me.name];
if (spl[i]) {
var mestr = spl[i].split(',');
me.won = parseInt(mestr[0]);
} else {
me.won = 0;
}
if (me.won && me.hide != 3) preview.AchievementsOwned++;
}
} else {
if (str[6]) spl = str[6];
else spl = []; //upgrades
spl = UncompressLargeBin(spl);
preview.UpgradesOwned = 0;
for (var i in Game.UpgradesById) {
var me = Game.UpgradesById[i];
preview.upgrades[me.name] = {};
me = preview.upgrades[me.name];
if (spl[i * 2]) {
var mestr = [spl[i * 2], spl[i * 2 + 1]];
me.unlocked = parseInt(mestr[0]);
me.bought = parseInt(mestr[1]);
if (me.bought) preview.UpgradesOwned++;
} else {
me.unlocked = 0;
me.bought = 0;
}
}
if (str[7]) spl = str[7];
else spl = []; //achievements
spl = UncompressLargeBin(spl);
preview.AchievementsOwned = 0;
for (var i in Game.AchievementsById) {
var me = Game.AchievementsById[i];
preview.achievements[me.name] = {};
me = preview.achievements[me.name];
if (spl[i]) {
var mestr = [spl[i]];
me.won = parseInt(mestr[0]);
} else {
me.won = 0;
}
if (me.won && me.hide != 3) preview.AchievementsOwned++;
}
}
}
}
return preview;
}
}),
ChoiceModel: Backbone.Model.extend({})
};
Tools.Collections = {
BuildingsCollection: Backbone.Collection.extend({
model: Tools.Models.AutoBuyBuilding,
localStorage: new Store("CookieCheatNinetainedoBuildings"),
initialize: function () {
return this;
}
}),
UpgradesCollection: Backbone.Collection.extend({
model: Tools.Models.AutoBuyUpgrade,
localStorage: new Store("CookieCheatNinetainedoUpgrades"),
initialize: function () {
return this;
}
}),
ChoicesCollection: Backbone.Collection.extend({
model: Tools.Models.ChoiceModel,
localStorage: new Store("CookieCheatNinetainedoChoices"),
initialize: function () {
return this;
},
computeAndApply: function () {
var that = this;
var out = _.map(this.models, function (item) {return item.toJSON();});
Game.goldenCookie.choose = Tools.generateChooseFunc(out);
}
}),
SavesCollection: Backbone.Collection.extend({
model: Tools.Models.SaveModel,
localStorage: new Store("CookieCheatNinetainedoSaves"),
initialize: function () {
return this;
},
getModelByName: function (name) {
var res = "";
_.each(this.models, function (model) {
if (model.get("name") === name)
res = model;
});
return (res);
}
})
};
Tools.Views = {
SafeCookiesView: Backbone.View.extend({
elName: '#safeCookieDiv',
initialize: function() {
/CookieCheatNinetainedoSafeAmount=([\s\S]+?);/.exec(document.cookie);
Tools.cookieToKeep = parseInt(RegExp.$1, 10) || 0;
document.cookie = "CookieCheatNinetainedoSafeAmount=" + Tools.cookieToKeep + ";";
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).find('.numberToKeep').off("change");
$(toChange).find('.numberToKeep').change(function() {that.changed.apply(that)});
$(toChange).find('.numberToKeep').val(Tools.cookieToKeep);
$(toChange).find(".infoToDisplay").text((Tools.cookieToKeep <= 0) ? "Your cookies aren't safe !" : (Tools.cookieToKeep === 1) ? "One cookie is safe !" : Beautify(Tools.cookieToKeep) + " cookies are safe !");
$(toChange).find(".infoToDisplay").toggleClass("superGood", Tools.cookieToKeep > 0);
$(toChange).find(".infoToDisplay").toggleClass("superBad", Tools.cookieToKeep <= 0);
return (this);
},
changed: function() {
Tools.cookieToKeep = parseInt($(this.elName).find(".numberToKeep").val(), 10);
document.cookie = "CookieCheatNinetainedoSafeAmount=" + Tools.cookieToKeep + ";";
this.render();
}
}),
GoldenSpawnView: Backbone.View.extend({
elName: '#goldenSpawnDiv',
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).find('#goldenSpawnButton').off("click");
$(toChange).find('#goldenSpawnButton').click(function() {that.clicked.apply(that)});
$(toChange).find("#goldenSpawnedAmount").text(this.model.get("count") + " golden cookie" + (this.model.get("count") > 1 ? "s spawned.":" spawned."));
return (this);
},
clicked: function() {
Game.goldenCookie.life = Game.goldenCookie.delay = 0;
Game.goldenCookie.spawn();
this.model.incr();
}
}),
AutoClickView: Backbone.View.extend({
elName: '#autoClickDiv',
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
var perSecond = 1000 / this.model.get("timeOut");
$(toChange).find('#autoClickButton').off("click");
$(toChange).find('#clickingSpeed').off("change");
$(toChange).find('#autoClickButton').click(function() {that.clicked.apply(that)});
$(toChange).find('#clickingSpeed').change(function() {that.changed.apply(that)});
$(toChange).find('#clickingSpeed').val(perSecond);
$(toChange).find('#autoClickButton').toggleClass("superGood", this.model.get("running"));
$(toChange).find('#autoClickButton').toggleClass("superBad", !this.model.get("running"));
$(toChange).find("#clickAmount").text("Clicked " + this.model.get("count") + " time" + (this.model.get("count") > 1 ? "s.":"."));
$(toChange).find(".goodState").toggleClass("currentState", this.model.get("running"));
$(toChange).find(".badState").toggleClass("currentState", !this.model.get("running"));
$(toChange).find("#clickingSpeedText").text("Clicking speed : " + perSecond.toPrecision(5));
return (this);
},
clicked: function() {
if (this.model.get("running"))
this.model.stop();
else
this.model.go();
},
changed: function() {
var t = (1000 / parseInt($(this.elName).find('#clickingSpeed').val(), 10));
this.model.set({
timeOut: t
});
this.model.save();
}
}),
AutoGoldenClickView: Backbone.View.extend({
elName: '#autoGoldenClickDiv',
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).find('#autoGoldenClickButton').off("click");
$(toChange).find('#autoGoldenClickButton').click(function() {that.clicked.apply(that)});
$(toChange).find('#autoGoldenClickButton').toggleClass("superGood", this.model.get("running"));
$(toChange).find('#autoGoldenClickButton').toggleClass("superBad", !this.model.get("running"));
$(toChange).find("#goldenClickAmount").text("Clicked " + this.model.get("count") + " golden cookie" + (this.model.get("count") > 1 ? "s.":"."));
$(toChange).find(".goodState").toggleClass("currentState", this.model.get("running"));
$(toChange).find(".badState").toggleClass("currentState", !this.model.get("running"));
return (this);
},
clicked: function() {
if (this.model.get("running"))
this.model.stop();
else
this.model.go();
}
}),
BuildingFormView: Backbone.View.extend({
elName: '#newForm',
initialize: function() {
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).find('#newAutoBuyBuildingsButton').off("click");
$(toChange).find('#newAutoBuyBuildingsButton').click(function(e) {that.clicked.call(that, e);});
for (var i in Game.ObjectsById) {
$(toChange).find("#selectBuilding").append('' + Game.ObjectsById[i].name + ' ');
}
return (this);
},
clicked: function(e) {
e.preventDefault();
var toChange = $(this.elName);
var m = new Tools.Models.AutoBuyBuilding({
maxAmount: parseInt($(toChange).find(".number").val(), 10),
buildingId: $(toChange).find("#selectBuilding").val()
});
if (!m.isValid())
alert(m.validationError);
else {
Tools.collections.buildingsCollection.add(m);
$(toChange).find(".number").val("0");
$(toChange).find("#selectBuilding").val("0");
m.save();
}
}
}),
BuildingListView: Backbone.View.extend({
elName: '#buildingsListContainer',
initialize: function() {
var that = this;
this.template = _.template(specialTemplate);
this.listenTo(this.collection, "add", function() {that.update(); that.render();});
this.listenTo(this.collection, "remove", function() {that.update(); that.render();});
this.update();
this.render();
return (this);
},
update: function() {
Tools.views.buildingViews = [];
_.each(this.collection.models, function (item) {
Tools.views.buildingViews.push(new Tools.Views.BuildingView({model:item}));
});
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).toggleClass("superHidden", Tools.views.buildingViews.length === 0);
$(toChange).html("");
if (Tools.views.buildingViews.length > 0) {
$(toChange).append(this.template());
$(toChange).find('.myPauseAllBtn').off("click");
$(toChange).find('.myPauseAllBtn').click(function(e) {that.pauseAll.call(that, e);});
$(toChange).find('.myRemoveAllBtn').off("click");
$(toChange).find('.myRemoveAllBtn').click(function(e) {that.removeAll.call(that, e);});
$(toChange).find('.myGoAllBtn').off("click");
$(toChange).find('.myGoAllBtn').click(function(e) {that.goAll.call(that, e);});
}
_.each(Tools.views.buildingViews, function (item) {
$(toChange).append(item.render().$el);
});
return (this);
},
goAll: function () {
_.each(Tools.views.buildingViews, function (view) {view.model.go();});
},
pauseAll: function () {
_.each(Tools.views.buildingViews, function (view) {view.model.stop();});
},
removeAll: function () {
_.each(Tools.views.buildingViews, function (view) {
view.model.stop();
view.model.destroy();
Tools.collections.buildingsCollection.remove(view.model);
view.remove();
});
}
}),
BuildingView: Backbone.View.extend({
tagName: "div",
className: "tabElem",
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.template = _.template(buildingTemplate);
return (this);
},
render: function() {
this.$el.html(this.template());
var toChange = this.$el;
$(toChange).find('.myGoBtn').off("click");
$(toChange).find('.myPauseBtn').off("click");
$(toChange).find('.myRemoveBtn').off("click");
var that = this;
$(toChange).find('.myRemoveBtn').click(function() {that.removed.apply(that)});
$(toChange).find('.myGoBtn').click(function() {that.went.apply(that)});
$(toChange).find('.myPauseBtn').click(function() {that.paused.apply(that)});
$(toChange).find(".goodState").toggleClass("currentState", this.model.get("running"));
$(toChange).find(".badState").toggleClass("currentState", !this.model.get("running"));
$(toChange).find(".howManyBought").text("Bought : " + this.model.get("bought") + ' (' + this.model.get("count") + "/" + this.model.get("maxAmount") + ')');
$(toChange).find(".buildingName").text(Game.ObjectsById[this.model.get("buildingId")].name);
$(toChange).find(".buildingName").toggleClass("superGood", this.model.get("running"));
$(toChange).find(".buildingName").toggleClass("superBad", !this.model.get("running"));
$(toChange).toggleClass("tabElemDone", this.model.get("count") === this.model.get("maxAmount"));
return (this);
},
removed: function() {
var that = this;
this.$el.fadeOut("fast", function () {
that.model.stop();
that.model.set({again: false});
that.model.destroy();
Tools.collections.buildingsCollection.remove(that.model);
that.remove();
});
},
went: function() {
this.model.go();
},
paused: function() {
this.model.stop();
}
}),
UpgradeFormView: Backbone.View.extend({
elName: '#newUpgradeForm',
initialize: function() {
Tools.upgradeNames = {};
_.each(_.pluck(Game.UpgradesById, "name"), function (item) {
Tools.upgradeNames[item.toLowerCase()] = item;
});
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).find('#newAutoBuyUpgradesButton').off("click");
$(toChange).find('#newAutoBuyUpgradesButton').click(function(e) {that.clicked.call(that, e);});
for (var i in Game.UpgradesById) {
if (!Game.UpgradesById[i].bought && ['Gold hoard', "Neuromancy", "Ultrascience"].indexOf(Game.UpgradesById[i].name) === -1)
$(toChange).find("#selectUpgrade").append('' + Game.UpgradesById[i].name + ' ');
}
return (this);
},
clicked: function(e) {
e.preventDefault();
var toChange = $(this.elName);
var id;
if ($(toChange).find("#enterNameUpgrade").val().length > 0) {
var tmp = Tools.upgradeNames[$(toChange).find("#enterNameUpgrade").val().toLowerCase()];
id = (tmp) ? Game.Upgrades[tmp].id : -1;
}
else
id = $(toChange).find("#selectUpgrade").val();
var m = new Tools.Models.AutoBuyUpgrade({
upgradeId: id
});
if (!m.isValid())
alert(m.validationError);
else {
Tools.collections.upgradesCollection.add(m);
$(toChange).find(".number").val("0");
$(toChange).find("#selectUpgrade").val("0");
m.save();
this.render();
}
}
}),
UpgradeListView: Backbone.View.extend({
elName: '#upgradesListContainer',
initialize: function() {
var that = this;
this.listenTo(this.collection, "add", function() {that.update(); that.render();});
this.listenTo(this.collection, "remove", function() {that.update(); that.render();});
this.update();
this.render();
return (this);
},
update: function() {
Tools.views.upgradeViews = [];
_.each(this.collection.models, function (item) {
Tools.views.upgradeViews.push(new Tools.Views.UpgradeView({model:item}));
});
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).toggleClass("superHidden", Tools.views.upgradeViews.length === 0);
$(toChange).html("");
_.each(Tools.views.upgradeViews, function (item) {
$(toChange).append(item.render().$el);
});
return (this);
}
}),
UpgradeView: Backbone.View.extend({
tagName: "div",
className: "tabElem",
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.template = _.template(upgradeTemplate);
return (this);
},
render: function() {
this.$el.html(this.template());
var toChange = this.$el;
$(toChange).find('.myGoBtn').off("click");
$(toChange).find('.myPauseBtn').off("click");
$(toChange).find('.myRemoveBtn').off("click");
var that = this;
$(toChange).find('.myRemoveBtn').click(function() {that.removed.apply(that)});
$(toChange).find('.myGoBtn').click(function() {that.went.apply(that)});
$(toChange).find('.myPauseBtn').click(function() {that.paused.apply(that)});
$(toChange).find(".goodState").toggleClass("currentState", this.model.get("running"));
$(toChange).find(".badState").toggleClass("currentState", !this.model.get("running"));
$(toChange).find(".unlockedOrNot").text((Game.UpgradesById[that.model.get("upgradeId")].unlocked ? "Unlocked" : "Locked"));
$(toChange).find(".unlockedOrNot").toggleClass("superGood", Game.UpgradesById[that.model.get("upgradeId")].unlocked);
$(toChange).find(".unlockedOrNot").toggleClass("superBad", !Game.UpgradesById[that.model.get("upgradeId")].unlocked);
$(toChange).find(".upgradeName").text(Game.UpgradesById[this.model.get("upgradeId")].name);
$(toChange).find(".upgradeName").toggleClass("superGood", this.model.get("running"));
$(toChange).find(".upgradeName").toggleClass("superBad", !this.model.get("running"));
return (this);
},
removed: function() {
var that = this;
this.$el.fadeOut("slow", function () {
that.model.stop();
that.model.destroy();
Tools.collections.upgradesCollection.remove(that.model);
that.remove();
});
},
went: function() {
this.model.go();
},
paused: function() {
this.model.stop();
}
}),
SaveFormView: Backbone.View.extend({
elName: '#newSaveForm',
initialize: function() {
this.render();
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).find('#newSaveButton').off("click");
$(toChange).find('#newSaveButton').click(function(e) {that.clicked.call(that, e);});
$(toChange).find('#selectSaveCode').off("change");
$(toChange).find('#selectSaveCode').change(function(e) {that.changed.call(that, e);});
return (this);
},
clicked: function(e) {
e.preventDefault();
var toChange = $(this.elName);
var m = new Tools.Models.SaveModel({
name: ($(toChange).find("#enterNameSave").val().length > 0) ? $(toChange).find("#enterNameSave").val() : "noname",
code: ($(toChange).find("#saveCode").val().length > 0) ? $(toChange).find("#saveCode").val() : newGame,
asked: false
});
if (!m.isValid())
alert(m.validationError);
else {
Tools.collections.savesCollection.add(m);
$(toChange).find("#enterNameSave").val("");
m.save();
this.render();
}
},
changed: function (e) {
var toChange = $(this.elName);
var val = $(toChange).find("#selectSaveCode").val();
if (val === "manual") {
$(toChange).find("#saveCode").removeAttr("disabled");
$(toChange).find("#saveCode").val("");
$(toChange).find("#saveCode").attr("placeholder", "Paste your code here");
}
else if (val === "current") {
$(toChange).find("#saveCode").removeAttr("placeholder");
$(toChange).find("#saveCode").val(Game.WriteSave(1));
$(toChange).find("#saveCode").attr("disabled", "1");
}
else {
$(toChange).find("#saveCode").removeAttr("placeholder");
$(toChange).find("#saveCode").val($(toChange).find("#selectSaveCode").val());
$(toChange).find("#saveCode").attr("disabled", "1");
}
this.render();
}
}),
SaveListView: Backbone.View.extend({
elName: '#savesListContainer',
initialize: function() {
var that = this;
this.listenTo(this.collection, "add", function() {that.update(); that.render();});
this.listenTo(this.collection, "remove", function() {that.update(); that.render();});
this.noAsked();
this.update();
this.render();
return (this);
},
update: function() {
Tools.views.saveViews = [];
_.each(this.collection.models, function (item) {
Tools.views.saveViews.push(new Tools.Views.SaveView({model:item}));
});
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).toggleClass("superHidden", Tools.views.saveViews.length === 0);
$(toChange).html("");
_.each(Tools.views.saveViews, function (item) {
$(toChange).append(item.render().$el);
});
return (this);
},
noAsked: function () {
_.each(this.collection.models, function (model) {
model.set({asked: false});
});
}
}),
SaveView: Backbone.View.extend({
tagName: "div",
className: "tabElem",
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.template = _.template(saveTemplate);
return (this);
},
render: function() {
this.$el.html(this.template());
var toChange = this.$el;
$(toChange).find('.myLoadBtn').off("click");
$(toChange).find('.myRemoveBtn').off("click");
$(toChange).find('.saveName').off("dblclick");
$(toChange).find('.enterNameSave').off("blur");
$(toChange).find('.myExportBtn').off("click");
$(toChange).find('.mySaveHereBtn').off("click");
var that = this;
$(toChange).find('.mySaveHereBtn').click(function() {that.savedHere.apply(that)});
$(toChange).find('.myExportBtn').click(function() {that.exported.apply(that)});
$(toChange).find('.myLoadBtn').click(function() {that.loaded.apply(that)});
$(toChange).find('.myRemoveBtn').click(function() {that.removed.apply(that)});
$(toChange).find('.saveName').dblclick(function() {that.dblclicked.apply(that)});
$(toChange).find('.enterNameSave').blur(function() {that.blured.apply(that)});
$(toChange).find('.saveName').text(this.model.get("name"));
$(toChange).find('.saveDate').text("Created : " + new Date(this.model.get("date")).toUTCString());
return (this);
},
savedHere: function() {
var that = this;
if (this.model.get("asked") || confirm("Do you want to overwrite " + this.model.get("name") + " with your current save ? (You won't be asked again to save here !)")) {
this.model.saveGame(Game.WriteSave(1));
this.model.set({asked: false});
Tools.views.saveListView.noAsked();
this.model.save();
this.model.set({asked: true});
Tools.currentSave = this.model;
Game.Popup("Game succesfully saved in the cheat interface !");
}
},
removed: function() {
var that = this;
if (confirm("Do you really want to remove [" + this.model.get("name") + "] ?")) {
this.$el.fadeOut("fast", function () {
that.model.destroy();
Tools.collections.savesCollection.remove(that.model);
that.remove();
});
}
},
exported: function() {
prompt('Here is your exported save !', this.model.get("code"));
},
loaded: function() {
if (confirm("Do you want to save before loading another game ?")) {
if (typeof Tools.currentSave !== "undefined" && Tools.currentSave.get("asked") === true) {
Tools.currentSave.saveGame(Game.WriteSave(1));
Tools.currentSave.set({asked: false});
Tools.currentSave.save();
}
else {
m = new Tools.Models.SaveModel({
name: "Safe save",
code: Game.WriteSave(1),
});
Tools.collections.savesCollection.add(m);
m.save();
}
}
Tools.views.saveListView.noAsked();
Tools.currentSave = this.model;
Game.LoadSave(this.model.get("code"));
},
dblclicked: function() {
var toChange = this.$el;
$(toChange).find('.saveName').hide();
$(toChange).find('.enterNameSave').val(this.model.get("name"));
$(toChange).find('.enterNameSave').show();
$(toChange).find('.enterNameSave').select();
},
blured: function() {
var toChange = this.$el;
var newName = $(toChange).find('.enterNameSave').val() + "";
if ((newName).length < 1)
newName = "noname";
$(toChange).find('.enterNameSave').hide();
this.model.set({name: newName});
$(toChange).find('.saveName').val(this.model.get("name"));
$(toChange).find('.saveName').show();
this.model.save();
}
}),
ChoiceListView: Backbone.View.extend({
elName: '#choicesListContainer',
initialize: function() {
var that = this;
this.listenTo(this.collection, "add", function() {that.update(); that.render();});
this.listenTo(this.collection, "remove", function() {that.update(); that.render();});
this.update();
this.render();
return (this);
},
update: function() {
Tools.views.choiceViews = [];
_.each(this.collection.models, function (item) {
Tools.views.choiceViews.push(new Tools.Views.ChoiceView({model:item}));
});
return (this);
},
render: function() {
var toChange = $(this.elName);
var that = this;
$(toChange).toggleClass("superHidden", Tools.views.choiceViews.length === 0);
$(toChange).html("");
_.each(Tools.views.choiceViews, function (item) {
$(toChange).append(item.render().$el);
});
return (this);
}
}),
ChoiceView: Backbone.View.extend({
tagName: "div",
className: "tabElem",
initialize: function() {
this.listenTo(this.model, "change", this.render);
this.template = _.template(choiceTemplate);
return (this);
},
render: function() {
this.$el.html(this.template());
var toChange = this.$el;
$(toChange).find('.myGoBtn').off("click");
$(toChange).find('.myPauseBtn').off("click");
$(toChange).find('.myRemoveBtn').off("click");
var that = this;
$(toChange).find('.myRemoveBtn').click(function() {that.removed.apply(that)});
$(toChange).find('.myGoBtn').click(function() {that.went.apply(that)});
$(toChange).find('.myPauseBtn').click(function() {that.paused.apply(that)});
$(toChange).find(".goodState").toggleClass("currentState", this.model.get("running"));
$(toChange).find(".badState").toggleClass("currentState", !this.model.get("running"));
$(toChange).find(".unlockedOrNot").text((Game.ChoicesById[that.model.get("choiceId")].unlocked ? "Unlocked" : "Locked"));
$(toChange).find(".unlockedOrNot").toggleClass("superGood", Game.ChoicesById[that.model.get("choiceId")].unlocked);
$(toChange).find(".unlockedOrNot").toggleClass("superBad", !Game.ChoicesById[that.model.get("choiceId")].unlocked);
$(toChange).find(".choiceName").text(Game.ChoicesById[this.model.get("choiceId")].name);
$(toChange).find(".choiceName").toggleClass("superGood", this.model.get("running"));
$(toChange).find(".choiceName").toggleClass("superBad", !this.model.get("running"));
return (this);
},
spawnNow: function () {
},
toggle: function () {
}
})
};
$("#comments").append(' Cheat
');
l("cheatButton").onclick = function() {
Game.ShowMenu('cheat');
};
// Base hashs
Tools.howManyCookies = function (type, vals, fixAdd, ctx) {
if (!fixAdd)
fixAdd = 0;
if (!vals)
return 0;
if (!type)
type = "min";
if (typeof vals === "string" || !Array.isArray(vals))
vals = [vals];
if (!ctx)
ctx = this;
vals = _.map(vals, function (val) {
if (typeof val === "string")
val = new Function("return " + val)
return (typeof val === "function" ? val.call(ctx) : val);
});
if (typeof fixAdd === "function")
fixAdd = fixAdd.call(ctx);
var res = -1;
if (type === "min") {
vals.sort(function (a, b) {
return (a - b);
});
res = vals[0]
} else if (type === "max") {
vals.sort(function (a, b) {
return (b - a);
});
res = vals[0]
} else if (type === "random") {
res = vals[Math.floor(Math.random() * vals.length)];
} else if (type === "exact") {
res = vals[0] + fixAdd;
}
return (res < 0 ? 0 : res);
};
Tools.parseOrAnd = function (hash, cur) {
var res = '(';
var that = this;
var passed = false;
cur = cur || "and"; // De base, on est dans un "ET"
var separator = (cur === "or" ? " || " : " && ");
for (var key in hash) {
if (key === "or" || key === "and") {
if (passed)
res += separator;
res += Tools.parseOrAnd.call(this, hash[key], key);
passed = true;
}
else if (key === "vals") {
if (Array.isArray(hash[key])) {
_.each(hash[key], function (item, index) {
if (typeof item === "function") {
hash[key][index] = "(" + _.bind(item, that) + ")()";
}
});
}
if (passed)
res += separator;
if (Array.isArray(hash[key]))
res += hash[key].join(separator);
else
res += (typeof hash[key] === "function" ? "(" + _.bind(hash[key], that) + ")()" : hash[key]);
passed = true;
}
}
res += ')';
return (res);
};
Tools.clone = function (hash) {
var newObj;
if (hash === null || typeof hash === "undefined")
return hash;
else if (typeof hash !== "string" && Array.isArray(hash)) {
newObj = [];
for (var i = 0, n = hash.length; i < n; i++) {
newObj.push(Tools.clone(hash[i]));
}
}
else if (typeof hash === 'object' && hash.constructor === Object) {
newObj = {};
for (var key in hash) {
if (typeof hash[key] !== "string" && Array.isArray(hash[key])) {
newObj[key] = [];
for (var i = 0, n = hash[key].length; i < n; i++) {
newObj[key].push(Tools.clone(hash[key][i]));
}
}
else if (typeof hash[key] === 'object' && hash[key].constructor === Object) {
newObj[key] = Tools.clone(hash[key]);
}
else {
newObj[key] = hash[key];
}
}
}
else
newObj = hash;
return (newObj);
};
Tools.choices = {
"frenzy": {
active: true,
name: "frenzy",
condition: {
vals: "Game.goldenCookie.wrath == 0"
},
type: "cpsChange",
message: "'Frenzy : cookie production x' + this.params.frenzy + ' for ' + this.realTime + ' seconds !'",
recalculateGains: true,
params: {
frenzy: 7,
baseTime: 77,
}
},
"multiply cookies": {
active: true,
name: "multiply cookies",
condition: {
vals: "true"
},
type: "cookieModif",
message: "'Lucky ! +' + Beautify(this.cookies) + ' cookies !'",
recalculateGains: false,
params: {
modifType: "earn",
modifFunc: Game.Earn,
type: "min",
fixAdd: 13,
vals: [
"Game.cookies * 0.1",
"Game.cookiesPs * 60 * 20"
]
}
},
"ruin cookies": {
active: true,
name: "ruin cookies",
condition: {
vals: "Game.goldenCookie.wrath > 0"
},
type: "cookieModif",
message: "'Ruin ! Lost ' + Beautify(this.cookies) + ' cookies !'",
recalculateGains: false,
params: {
modifType: "lose",
modifFunc: Game.Spend,
type: "min",
fixAdd: 13,
vals: [
"Game.cookies * 0.05",
"Game.cookiesPs * 60 * 10"
]
}
},
"blood frenzy": {
active: true,
name: "blood frenzy",
condition: {
vals: [
"Game.goldenCookie.wrath > 0",
"Math.random() < 0.3"
]
},
type: "cpsChange",
message: "'Elder frenzy : cookie production x' + this.params.frenzy + ' for ' + this.realTime + ' seconds !'",
recalculateGains: true,
params: {
frenzy: 666,
baseTime: 6
}
},
"clot": {
active: true,
name: "clot",
condition: {
vals: "Game.goldenCookie.wrath > 0"
},
type: "cpsChange",
message: "'Clot : cookie production halved for ' + this.realTime + ' seconds !'",
recalculateGains: true,
params: {
frenzy: 0.5,
baseTime: 66
}
},
"click frenzy": {
active: true,
name: "click frenzy",
condition: {
vals: "Math.random() < 0.05"
},
type: "mouseChange",
message: "'Click frenzy ! Clicking power x' + this.params.frenzy + ' for ' + this.realTime + ' seconds !'",
recalculateGains: true,
params: {
frenzy: 777,
baseTime: 13
}
},
"chain cookie": {
active: true,
name: "chain cookie",
condition: {
vals: [
"Math.random() < 0.01",
"Game.cookiesEarned >= 100000"
]
},
type: "chain",
message: "'Cookie chain : +' + Beautify(this.cookies) + ' cookies !'",
recalculateGains: false,
params: {
chainNumber: "i", // i = Game.goldenCookie.chain
chainType: "cookieModif",
chainStop: {
or: {
vals: [
"Math.random() < 0.1",
"this.chainRealNumber > 12",
"this.cookies >= Game.cookies * 1"
]
},
vals: "this.chainRealNumber > 4"
},
// Basic cookieModif params below
modifType: "earn",
modifFunc: Game.Earn,
type: "exact",
fixAdd: 0,
vals: function () {
var max = this.chainRealNumber;
var moni = '';
for (var i = 0; i < max; i++)
moni += '6';
return parseInt(moni);
}
}
},
};
Game.mouseFrenzyPower = 1;
Game.mouseCps = function () {
var add = 0;
if (Game.Has('Thousand fingers')) add += 0.1;
if (Game.Has('Million fingers')) add += 0.5;
if (Game.Has('Billion fingers')) add += 2;
if (Game.Has('Trillion fingers')) add += 10;
if (Game.Has('Quadrillion fingers')) add += 20;
if (Game.Has('Quintillion fingers')) add += 100;
var num = 0;
for (var i in Game.Objects) {
if (Game.Objects[i].name != 'Cursor') num += Game.Objects[i].amount;
}
add = add * num;
if (Game.Has('Plastic mouse')) add += Game.cookiesPs * 0.01;
if (Game.Has('Iron mouse')) add += Game.cookiesPs * 0.01;
if (Game.Has('Titanium mouse')) add += Game.cookiesPs * 0.01;
if (Game.Has('Adamantium mouse')) add += Game.cookiesPs * 0.01;
var mult = 1;
if (Game.clickFrenzy > 0)
mult *= Game.mouseFrenzyPower;
else
Game.mouseFrenzyPower = 1;
return mult * Game.ComputeCps(1, Game.Has('Reinforced index finger'), Game.Has('Carpal tunnel prevention cream') + Game.Has('Ambidextrous'), add);
}
Tools.executeChoice = function (hash) {
var ctx = Tools.clone(hash);
var funcs = {
"cpsChange": function(ctx) {
var tmpTime = ctx.params.baseTime;
if (typeof ctx.params.baseTime === "string")
tmpTime = (new Function("return " + ctx.params.baseTime)).call(ctx);
ctx.realTime = tmpTime + tmpTime * Game.Has('Get lucky');
Game.frenzy = Game.fps * ctx.realTime;
if (typeof ctx.params.frenzy === "string")
ctx.params.frenzy = (new Function("return " + ctx.params.frenzy)).call(ctx);
Game.frenzyPower = ctx.params.frenzy;
funcs["finish"](ctx);
},
"cookieModif": function(ctx) {
ctx.cookies = Tools.howManyCookies(ctx.params.type, ctx.params.vals, ctx.params.fixAdd, ctx);
ctx.params.modifFunc(ctx.cookies);
funcs["finish"](ctx);
},
"chain": function(ctx) {
Game.goldenCookie.chainName = ctx.name;
Game.goldenCookie.chain++;
ctx.chainRealNumber = (new Function("i", "return " + ctx.params.chainNumber)).call(ctx, Game.goldenCookie.chain);
if ((new Function("return " + Tools.parseOrAnd(ctx.params.chainStop))).call(ctx))
Game.goldenCookie.chain = 0;
funcs[ctx.params.chainType](ctx);
},
"autoClick": function(ctx) {
var tmpTime = ctx.params.baseTime;
if (typeof ctx.params.baseTime === "string")
tmpTime = (new Function("return " + ctx.params.baseTime)).call(ctx);
ctx.realTime = tmpTime + tmpTime * Game.Has('Get lucky');
if (typeof ctx.params.clicksPerSecond === "string")
ctx.params.clicksPerSecond = (new Function("return " + ctx.params.clicksPerSecond)).call(ctx);
ctx.clickInterval = 1000 / ctx.params.clicksPerSecond;
var f = function (clicks) {
if (clicks > 0) {
Game.ClickCookie();
setTimeout(function() {f(clicks - 1);}, ctx.clickInterval);
}
};
f(ctx.realTime * ctx.params.clicksPerSecond);
funcs["finish"](ctx);
},
"mouseChange": function(ctx) {
var tmpTime = ctx.params.baseTime;
if (typeof ctx.params.baseTime === "string")
tmpTime = (new Function("return " + ctx.params.baseTime)).call(ctx);
ctx.realTime = tmpTime + tmpTime * Game.Has('Get lucky');
if (typeof ctx.params.frenzy === "string")
ctx.params.frenzy = (new Function("return " + ctx.params.frenzy)).call(ctx);
Game.mouseFrenzyPower = ctx.params.frenzy;
Game.clickFrenzy = Game.fps * ctx.realTime;
funcs["finish"](ctx);
},
"buildingSales": function(ctx) {
var tmpTime = ctx.params.baseTime;
if (typeof ctx.params.baseTime === "string")
tmpTime = (new Function("return " + ctx.params.baseTime)).call(ctx);
ctx.realTime = tmpTime + tmpTime * Game.Has('Get lucky');
if (typeof ctx.params.priceMultiplicator === "string")
ctx.params.priceMultiplicator = (new Function("return " + ctx.params.priceMultiplicator)).call(ctx);
if (typeof ctx.params.buildingName === "string")
ctx.params.buildingName = (new Function("return " + ctx.params.buildingName)).call(ctx);
if (typeof Game.Objects[ctx.params.buildingName].oldBasePrice === "undefined" || Game.Objects[ctx.params.buildingName].oldBasePrice === Game.Objects[ctx.params.buildingName].basePrice)
Game.Objects[ctx.params.buildingName].oldBasePrice = Game.Objects[ctx.params.buildingName].basePrice;
Game.Objects[ctx.params.buildingName].basePrice = Game.Objects[ctx.params.buildingName].oldBasePrice * ctx.params.priceMultiplicator;
Game.Objects[ctx.params.buildingName].currentTime = 0;
Game.Objects[ctx.params.buildingName].stopTime = ctx.realTime;
Game.Objects[ctx.params.buildingName].refresh();
Game.storeToRebuild = 1;
var f = function () {
if (Game.Objects[ctx.params.buildingName].currentTime == Game.Objects[ctx.params.buildingName].stopTime) {
Game.Objects[ctx.params.buildingName].basePrice = Game.Objects[ctx.params.buildingName].oldBasePrice;
Game.Objects[ctx.params.buildingName].refresh();
Game.storeToRebuild = 1;
}
else {
Game.Objects[ctx.params.buildingName].currentTime += 1;
setTimeout(f, 1000);
}
};
setTimeout(f, 1000);
funcs["finish"](ctx);
},
"finish": function(ctx) {
Game.Popup((new Function("return " + ctx.message)).call(ctx));
if (ctx.recalculateGains)
Game.recalculateGains = 1;
}
};
funcs[hash.type](ctx);
};
Tools.generateChooseFunc = function (choices) {
var func = "var list = [];";
for (var i in choices) {
if (choices[i].active === true) {
var tmp = 'if ' + Tools.parseOrAnd.call(choices[i], choices[i].condition) + 'list.push("' + choices[i].name + '");';
func += tmp;
}
}
func += 'if (list.length > 1 && Game.goldenCookie.last != \'\' && Math.random() < 0.8 && list.indexOf(Game.goldenCookie.last) != -1)list.splice(list.indexOf(Game.goldenCookie.last), 1);return choose(list);';
return (new Function(func));
};
Tools.computeChoose = function() {
Game.goldenCookie.choose = Tools.generateChooseFunc(Tools.choices);
};
Tools.computeChoose();
l('goldenCookie').onclick = Game.goldenCookie.click = function() {
if (Game.goldenCookie.life > 0) {
Game.goldenCookie.toDie = 1;
Game.goldenClicks++;
if (Game.goldenClicks >= 1)
Game.Win('Golden cookie');
if (Game.goldenClicks >= 7)
Game.Win('Lucky cookie');
if (Game.goldenClicks >= 27)
Game.Win('A stroke of luck');
if (Game.goldenClicks >= 77)
Game.Win('Fortune');
if (Game.goldenClicks >= 777)
Game.Win('Leprechaun');
if (Game.goldenClicks >= 7777)
Game.Win('Black cat\'s paw');
if (Game.goldenClicks >= 7)
Game.Unlock('Lucky day');
if (Game.goldenClicks >= 27)
Game.Unlock('Serendipity');
if (Game.goldenClicks >= 77)
Game.Unlock('Get lucky');
l('goldenCookie').style.display = 'none';
var choice = Game.goldenCookie.choose();
if (Game.goldenCookie.chain > 0)
choice = Game.goldenCookie.chainName;
if (typeof choice !== "undefined") {
Game.goldenCookie.last = choice;
if (Tools.choices[choice].type !== "chain")
Game.goldenCookie.chain = 0;
Tools.executeChoice(Tools.choices[choice]);
}
else
Game.Popup("Nothing happened...");
}
};
Game.oldUpdateMenu = Game.UpdateMenu;
Tools.views.safeCookiesView = new Tools.Views.SafeCookiesView();
Tools.models.autoClickModel = new Tools.Models.AutoClickModel();
Tools.views.autoClickView = new Tools.Views.AutoClickView({model: Tools.models.autoClickModel});
Tools.models.autoGoldenClickModel = new Tools.Models.AutoGoldenClickModel();
Tools.views.autoGoldenClickView = new Tools.Views.AutoGoldenClickView({model: Tools.models.autoGoldenClickModel});
Tools.models.goldenSpawnModel = new Tools.Models.GoldenSpawnModel();
Tools.views.goldenSpawnView = new Tools.Views.GoldenSpawnView({model: Tools.models.goldenSpawnModel});
Tools.collections.buildingsCollection = new Tools.Collections.BuildingsCollection();
Tools.collections.buildingsCollection.fetch();
Tools.views.buildingFormView = new Tools.Views.BuildingFormView();
Tools.views.buildingListView = new Tools.Views.BuildingListView({collection: Tools.collections.buildingsCollection});
Tools.collections.upgradesCollection = new Tools.Collections.UpgradesCollection();
Tools.collections.upgradesCollection.fetch();
Tools.views.upgradeFormView = new Tools.Views.UpgradeFormView();
Tools.views.upgradeListView = new Tools.Views.UpgradeListView({collection: Tools.collections.upgradesCollection});
Tools.collections.savesCollection = new Tools.Collections.SavesCollection();
Tools.collections.savesCollection.fetch();
Tools.views.saveFormView = new Tools.Views.SaveFormView();
Tools.views.saveListView = new Tools.Views.SaveListView({collection: Tools.collections.savesCollection});
Tools.collections.choicesCollection = new Tools.Collections.ChoicesCollection();
Tools.collections.choicesCollection.fetch();
Tools.views.choiceListView = new Tools.Views.ChoiceListView({collection: Tools.collections.choicesCollection});
Game.UpdateMenu=function()
{
if (Game.onMenu !== 'cheat') {
delete Tools.old;
return Game.oldUpdateMenu();
}
if (typeof Tools.old !== "undefined")
return;
else
Tools.old = "Used";
var str='';
if (Game.onMenu!='')
{
str+='X
';
}
if (Game.onMenu === "cheat") { // Cheat menu here
if (typeof tools === "undefined")
tools = {};
str+='Cheat (You bad boy !)
'+
'CookieCheat - v ' + __VERSION__ + ' - made by
Ninetainedo ' +
''+
'
' +
'
' +
'
' +
'
Save manager
'+ // Save manager
'
' +
'
' +
'
' +
'
' +
'
Cookie amount to keep safely (It\'s soooo safe)
'+ // Cookie to keep
'
' +
'
' +
'Amount to keep in safe place : ' +
' ' +
' ' +
'
' +
'
'+
'
' +
'
' +
'
' +
'
AutoClick Cookie
'+ // AutoClick Cookie
'
(Note : I can\'t guarantee that the cheat will click as fast as you want. It depends on your computer.)
'+
'
' +
'
AutoClick ' +
'
State : ON /
OFF ' +
'
' +
'
' +
'
'+
'
' +
'
' +
'
' +
'
AutoClick GoldenCookies
'+ // AutoClick GoldenCookies
'
'+
'
' +
'
' +
'
' +
'
Spawn GoldenCookies
'+ // Spawn GoldenCookie
'
'+
'
' +
'
' +
'
' +
'
AutoBuy Buildings
'+ // AutoBuy buildings
'
' +
'
' +
'
' +
'
' +
'
Golden cookie effects
'+ // Golden cookie choices
'
' +
'
' +
'
' +
'
' +
'
AutoBuy Upgrades
'+ // AutoBuy upgrades
'
';
}
l('menu').innerHTML=str;
Tools.views.autoClickView.render();
Tools.views.autoGoldenClickView.render();
Tools.views.goldenSpawnView.render();
Tools.views.buildingFormView.render();
Tools.views.buildingListView.render();
Tools.views.upgradeFormView.render();
Tools.views.upgradeListView.render();
Tools.views.safeCookiesView.render();
Tools.views.saveFormView.render();
Tools.views.saveListView.render();
Tools.views.choiceListView.render();
}