/* Mithril v0.1.24 http://github.com/lhorie/mithril.js (c) Leo Horie License: MIT */ Mithril=m=new function a(b,c){function d(a){D=a.document,E=a.location,G=a.cancelAnimationFrame||a.clearTimeout,F=a.requestAnimationFrame||a.setTimeout}function e(){for(var a,b=[].slice.call(arguments),c=(!(null==b[1]||L.call(b[1])!=H||"tag"in b[1]||"subtree"in b[1])),d=c?b[1]:{},e=("class"in d?"class":"className"),f={tag:"div",attrs:{}},g=[];a=M.exec(b[0]);)if(""==a[1]&&a[2])f.tag=a[2];else if("#"==a[1])f.attrs.id=a[2];else if("."==a[1])g.push(a[2]);else if("["==a[3][0]){var h=N.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" "));var i=c?b[2]:b[1];f.children=L.call(i)==I?i:b.slice(c?2:1);for(var j in d)f.attrs[j]=j==e?(f.attrs[j]||"")+" "+d[j]:d[j];return f}function f(a,d,e,i,l,m,n,o,p,q,r){if(null==l&&(l=""),"retain"===l.subtree)return m;var s=L.call(m),t=L.call(l);if(null==m||s!=t){if(null!=m)if(e&&e.nodes){var u=o-i,v=u+(t==I?l:m.nodes).length;h(e.nodes.slice(u,v),e.slice(u,v))}else m.nodes&&h(m.nodes,m);m=new l.constructor,m.tag&&(m={}),m.nodes=[]}if(t==I){l=k(l);for(var w=[],x=m.length===l.length,y=0,z=1,A=2,B=3,C={},E=[],F=!1,G=0;G\s*[^<]/g)||[]).length:L.call(V)==I?V.length:1,m[U++]=V)}if(!x){for(var G=0;G0?f(W,l.tag,c,c,l.children,m.children,!0,0,l.attrs.contenteditable?W:p,q,r):l.children,nodes:[W]},m.children&&!m.children.nodes&&(m.children.nodes=[]),"select"==l.tag&&l.attrs.value&&g(W,l.tag,{value:l.attrs.value},{},q),a.insertBefore(W,a.childNodes[o]||null)):(W=m.nodes[0],X.length&&g(W,l.tag,l.attrs,m.attrs,q),m.children=f(W,l.tag,c,c,l.children,m.children,!1,0,l.attrs.contenteditable?W:p,q,r),m.nodes.intact=!0,n===!0&&null!=W&&a.insertBefore(W,a.childNodes[o]||null)),typeof l.attrs.config==K){var Z=m.configContext=m.configContext||{},$=function(a,b){return function(){return a.attrs.config.apply(a,b)}};r.push($(l,[W,!Y,Z,m]))}}else if(typeof t!=K){var w;0===m.nodes.length?(l.$trusted?w=j(a,o,l):(w=[D.createTextNode(l)],a.nodeName.match(O)||a.insertBefore(w[0],a.childNodes[o]||null)),m="string number boolean".indexOf(typeof l)>-1?new l.constructor(l):l,m.nodes=w):m.valueOf()!==l.valueOf()||n===!0?(w=m.nodes,p&&p===D.activeElement||(l.$trusted?(h(w,m),w=j(a,o,l)):"textarea"===d?a.value=l:p?p.innerHTML=l:((1==w[0].nodeType||w.length>1)&&(h(m.nodes,m),w=[D.createTextNode(l)]),a.insertBefore(w[0],a.childNodes[o]||null),w[0].nodeValue=l)),m=new l.constructor(l),m.nodes=w):m.nodes.intact=!0}return m}function g(a,b,c,d,e){for(var f in c){var g=c[f],h=d[f];if(f in d&&h===g)"value"===f&&"input"===b&&a.value!==g&&(a.value=g);else{d[f]=g;try{if("config"===f)continue;if(typeof g==K&&0==f.indexOf("on"))a[f]=l(g,a);else if("style"===f&&null!=g&&L.call(g)==H){for(var i in g)(null==h||h[i]!==g[i])&&(a.style[i]=g[i]);for(var i in h)i in g||(a.style[i]="")}else null!=e?"href"===f?a.setAttributeNS("http://www.w3.org/1999/xlink","href",g):"className"===f?a.setAttribute("class",g):a.setAttribute(f,g):f in a&&"list"!=f&&"style"!=f&&"form"!=f?a[f]=g:a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}function h(a,b){for(var c=a.length-1;c>-1;c--)a[c]&&a[c].parentNode&&(a[c].parentNode.removeChild(a[c]),b=[].concat(b),b[c]&&i(b[c]));0!=a.length&&(a.length=0)}function i(a){if(a.configContext&&typeof a.configContext.onunload==K&&a.configContext.onunload(),a.children)if(L.call(a.children)==I)for(var b=0;bb?R.push(a)-1:b}function n(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function o(){for(var a=e.redraw.strategy(),b=0;b=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize==JSON.stringify&&a.data&&"GET"!=a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize==JSON.parse&&d.setRequestHeader("Accept","application/json, text/*"),typeof a.config==K){var e=a.config(d,a);null!=e&&(d=e)}if(a.data&&L.call(a.data)!=J&&a.data.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send("GET"!=a.method&&a.data?a.data:""),d}var f="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),g=D.createElement("script");b[f]=function(d){D.body.removeChild(g),a.onload({type:"load",target:{responseText:d}}),b[f]=c},g.onerror=function(){return D.body.removeChild(g),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[f]=c,!1},g.onload=function(){return!1},g.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+f+"&"+t(a.data||{}),D.body.appendChild(g)}function B(a,b,c){if("GET"==a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=t(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function C(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;dc&&(c=U.length);var d=!1;if(W[c]&&typeof W[c].onunload==K){var f={preventDefault:function(){d=!0}};W[c].onunload(f)}if(!d){e.redraw.strategy("all"),e.startComputation(),U[c]=a;var g=T=b,h=new b.controller;return g==T&&(W[c]=h,V[c]=b),e.endComputation(),W[c]}},e.redraw=function(a){X&&a!==!0?(new Date-Y>$||F==b.requestAnimationFrame)&&(X>0&&G(X),X=F(o,$)):(o(),X=F(function(){X=null},$))},e.redraw.strategy=e.prop();var _=0;e.startComputation=function(){_++},e.endComputation=function(){_=Math.max(_-1,0),0==_&&e.redraw()},e.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var ab,bb={pathname:"",hash:"#",search:"?"},cb=function(){},db={};return e.route=function(){if(0===arguments.length)return ab;if(3===arguments.length&&L.call(arguments[1])==J){var a=arguments[0],c=arguments[1],d=arguments[2];cb=function(b){var f=ab=p(b);q(a,d,f)||e.route(c,!0)};var f="hash"==e.route.mode?"onhashchange":"onpopstate";b[f]=function(){ab!=p(E[e.route.mode])&&cb(E[e.route.mode])},Z=s,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==e.route.mode?E.pathname:"")+bb[e.route.mode]+this.attrs.href,g.removeEventListener("click",r),g.addEventListener("click",r)}else if(L.call(arguments[0])==J){ab=arguments[0];var h=null!=arguments[1]&&L.call(arguments[1])==H?t(arguments[1]):null;h&&(ab+=(-1===ab.indexOf("?")?"?":"&")+h);var i=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(Z=function(){b.history[i?"replaceState":"pushState"](null,D.title,bb[e.route.mode]+ab),s()},cb(bb[e.route.mode]+ab)):E[e.route.mode]=ab}},e.route.param=function(a){return db[a]},e.route.mode="search",e.deferred=function(){var a=new y;return a.promise=x(a.promise),a},e.deferred.onerror=function(a){if("[object Error]"==L.call(a)&&!a.constructor.toString().match(/ Error/))throw a},e.sync=function(a){function b(a,b){return function(e){return g[a]=e,b||(c="reject"),0==--f&&(d.promise(g),d[c](g)),e}}var c="resolve",d=e.deferred(),f=a.length,g=new Array(f);if(a.length>0)for(var h=0;h