From 36c05be1887d8bee686d8b3a6a021ed2cef0e6fa Mon Sep 17 00:00:00 2001 From: Matt Malone Date: Mon, 10 Mar 2014 09:02:21 +0000 Subject: [PATCH] Removed time-grunt, removed toolbar, added initial check for management when logging in --- assets/dist/EasyTimer.min.js | 4 ++-- assets/dist/src/EasyTimer_Production.js | 4 ++++ assets/js/procedural.js | 4 ++++ gruntfile.js | 1 - package.json | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/dist/EasyTimer.min.js b/assets/dist/EasyTimer.min.js index 5808e3d..e6287ef 100644 --- a/assets/dist/EasyTimer.min.js +++ b/assets/dist/EasyTimer.min.js @@ -5,5 +5,5 @@ }}function g(){var a=l.a.c(c());b.checked=j?0<=l.a.l(a,e()):h?a:e()===a}var h="checkbox"==b.type,i="radio"==b.type;if(h||i){var j=h&&l.a.c(c())instanceof Array,k=j?e():a,m=i||j;i&&!b.name&&l.d.uniqueName.init(b,function(){return!0}),l.ba(f,null,{G:b}),l.a.q(b,"click",f),l.ba(g,null,{G:b})}}},l.g.W.checked=!0,l.d.checkedValue={update:function(a,b){a.value=l.a.c(b())}}}(),l.d.css={update:function(a,b){var c=l.a.c(b());"object"==typeof c?l.a.A(c,function(b,c){c=l.a.c(c),l.a.ua(a,b,c)}):(c=String(c||""),l.a.ua(a,a.__ko__cssValue,!1),a.__ko__cssValue=c,l.a.ua(a,c,!0))}},l.d.enable={update:function(a,b){var c=l.a.c(b());c&&a.disabled?a.removeAttribute("disabled"):c||a.disabled||(a.disabled=!0)}},l.d.disable={update:function(a,b){l.d.enable.update(a,function(){return!l.a.c(b())})}},l.d.event={init:function(a,b,c,d,e){var f=b()||{};l.a.A(f,function(f){"string"==typeof f&&l.a.q(a,f,function(a){var g,h=b()[f];if(h){try{var i=l.a.R(arguments);d=e.$data,i.unshift(d),g=h.apply(d,i)}finally{!0!==g&&(a.preventDefault?a.preventDefault():a.returnValue=!1)}!1===c.get(f+"Bubble")&&(a.cancelBubble=!0,a.stopPropagation&&a.stopPropagation())}})})}},l.d.foreach={vb:function(a){return function(){var b=a(),c=l.a.Sa(b);return c&&"number"!=typeof c.length?(l.a.c(b),{foreach:c.data,as:c.as,includeDestroyed:c.includeDestroyed,afterAdd:c.afterAdd,beforeRemove:c.beforeRemove,afterRender:c.afterRender,beforeMove:c.beforeMove,afterMove:c.afterMove,templateEngine:l.K.Ja}):{foreach:b,templateEngine:l.K.Ja}}},init:function(a,b){return l.d.template.init(a,l.d.foreach.vb(b))},update:function(a,b,c,d,e){return l.d.template.update(a,l.d.foreach.vb(b),c,d,e)}},l.g.aa.foreach=!1,l.e.Q.foreach=!0,l.d.hasfocus={init:function(a,b,c){function d(d){a.__ko_hasfocusUpdating=!0;var e=a.ownerDocument;if("activeElement"in e){var f;try{f=e.activeElement}catch(g){f=e.body}d=f===a}e=b(),l.g.va(e,c,"hasfocus",d,!0),a.__ko_hasfocusLastValue=d,a.__ko_hasfocusUpdating=!1}var e=d.bind(null,!0),f=d.bind(null,!1);l.a.q(a,"focus",e),l.a.q(a,"focusin",e),l.a.q(a,"blur",f),l.a.q(a,"focusout",f)},update:function(a,b){var c=!!l.a.c(b());a.__ko_hasfocusUpdating||a.__ko_hasfocusLastValue===c||(c?a.focus():a.blur(),l.k.t(l.a.ha,null,[a,c?"focusin":"focusout"]))}},l.g.W.hasfocus=!0,l.d.hasFocus=l.d.hasfocus,l.g.W.hasFocus=!0,l.d.html={init:function(){return{controlsDescendantBindings:!0}},update:function(a,b){l.a.Va(a,b())}},k("if"),k("ifnot",!1,!0),k("with",!0,!1,function(a,b){return a.createChildContext(b)});var r={};l.d.options={init:function(a){if("select"!==l.a.B(a))throw Error("options binding applies only to SELECT elements");for(;0","#comment",e)})},Mb:function(a,b){return l.w.Na(function(c,d){var e=c.nextSibling;e&&e.nodeName.toLowerCase()===b&&l.xa(e,a,d)})}}}(),l.b("__tr_ambtns",l.Za.Mb),function(){l.n={},l.n.j=function(a){this.j=a},l.n.j.prototype.text=function(){var a=l.a.B(this.j),a="script"===a?"text":"textarea"===a?"value":"innerHTML";if(0==arguments.length)return this.j[a];var b=arguments[0];"innerHTML"===a?l.a.Va(this.j,b):this.j[a]=b};var b=l.a.f.L()+"_";l.n.j.prototype.data=function(a){return 1===arguments.length?l.a.f.get(this.j,b+a):void l.a.f.set(this.j,b+a,arguments[1])};var c=l.a.f.L();l.n.Z=function(a){this.j=a},l.n.Z.prototype=new l.n.j,l.n.Z.prototype.text=function(){if(0==arguments.length){var b=l.a.f.get(this.j,c)||{};return b.$a===a&&b.Ba&&(b.$a=b.Ba.innerHTML),b.$a}l.a.f.set(this.j,c,{$a:arguments[0]})},l.n.j.prototype.nodes=function(){return 0==arguments.length?(l.a.f.get(this.j,c)||{}).Ba:void l.a.f.set(this.j,c,{Ba:arguments[0]})},l.b("templateSources",l.n),l.b("templateSources.domElement",l.n.j),l.b("templateSources.anonymousTemplate",l.n.Z)}(),function(){function b(a,b,c){var d;for(b=l.e.nextSibling(b);a&&(d=a)!==b;)a=l.e.nextSibling(d),c(d,a)}function c(a,c){if(a.length){var d=a[0],e=a[a.length-1],f=d.parentNode,g=l.J.instance,h=g.preprocessNode;if(h){if(b(d,e,function(a,b){var c=a.previousSibling,f=h.call(g,a);f&&(a===d&&(d=f[0]||b),a===e&&(e=f[f.length-1]||c))}),a.length=0,!d)return;d===e?a.push(d):(a.push(d,e),l.a.ea(a,f))}b(d,e,function(a){1!==a.nodeType&&8!==a.nodeType||l.fb(c,a)}),b(d,e,function(a){1!==a.nodeType&&8!==a.nodeType||l.w.Ib(a,[c])}),l.a.ea(a,f)}}function d(a){return a.nodeType?a:0d)&&(g=a[e]);++e){for(f=0;h=b[f];++f)if(g.value===h.value){g.moved=h.index,h.moved=g.index,b.splice(f,1),d=f=0;break}d+=f}}},l.a.Aa=function(){function a(a,b,c,d,e){var f,g,h,i,j,k=Math.min,m=Math.max,n=[],o=a.length,p=b.length,q=p-o||1,r=o+p+1;for(f=0;o>=f;f++)for(i=h,n.push(h=[]),j=k(p,f+q),g=m(0,f-1);j>=g;g++)h[g]=g?f?a[f-1]===b[g-1]?i[g-1]:k(i[g]||r,h[g-1]||r)+1:g+1:f+1;for(k=[],m=[],q=[],f=o,g=p;f||g;)p=n[f][g]-1,g&&p===n[f][g-1]?m.push(k[k.length]={status:c,value:b[--g],index:g}):f&&p===n[f-1][g]?q.push(k[k.length]={status:d,value:a[--f],index:f}):(--g,--f,e.sparse||k.push({status:"retained",value:b[g]}));return l.a.nb(m,q,10*o),k.reverse()}return function(b,c,d){return d="boolean"==typeof d?{dontLimitMoves:d}:d||{},b=b||[],c=c||[],b.length<=c.length?a(b,c,"added","deleted",d):a(c,b,"deleted","added",d)}}(),l.b("utils.compareArrays",l.a.Aa),function(){function b(b,c,d,e,f){var g=[],h=l.h(function(){var a=c(d,f,l.a.ea(g,b))||[];0c;c++)b[c]&&l.a.r(b[c].S,function(d){a(d,c,b[c].ka)})}e=e||[],g=g||{};var k=l.a.f.get(d,c)===a,m=l.a.f.get(d,c)||[],n=l.a.ya(m,function(a){return a.ka}),o=l.a.Aa(n,e,g.dontLimitMoves),p=[],q=0,r=0,s=[],t=[];e=[];for(var u,v,w,x=[],n=[],y=0;v=o[y];y++)switch(w=v.moved,v.status){case"deleted":w===a&&(u=m[q],u.h&&u.h.F(),s.push.apply(s,l.a.ea(u.S,d)),g.beforeRemove&&(e[y]=u,t.push(u))),q++;break;case"retained":i(y,q++);break;case"added":w!==a?i(y,w):(u={ka:v.value,Ia:l.m(r++)},p.push(u),t.push(u),k||(n[y]=u))}j(g.beforeMove,x),l.a.r(s,g.beforeRemove?l.M:l.removeNode);for(var z,y=0,k=l.e.firstChild(d);u=t[y];y++){for(u.S||l.a.extend(u,b(d,f,u.ka,h,u.Ia)),q=0;o=u.S[q];k=o.nextSibling,z=o,q++)o!==k&&l.e.rb(d,o,z);!u.Zb&&h&&(h(u.ka,u.S,u.Ia),u.Zb=!0)}j(g.beforeRemove,e),j(g.afterMove,x),j(g.afterAdd,n),l.a.f.set(d,c,p)}}(),l.b("utils.setDomNodeChildrenFromArrayMapping",l.a.Ua),l.K=function(){this.allowTemplateRewriting=!1},l.K.prototype=new l.C,l.K.prototype.renderTemplateSource=function(a){var b=(9>l.a.oa?0:a.nodes)?a.nodes():null;return b?l.a.R(b.cloneNode(!0).childNodes):(a=a.text(),l.a.Qa(a))},l.K.Ja=new l.K,l.Wa(l.K.Ja),l.b("nativeTemplateEngine",l.K),function(){l.La=function(){var a=this.ac=function(){if(!e||!e.tmpl)return 0;try{if(0<=e.tmpl.tag.tmpl.open.toString().indexOf("__"))return 2}catch(a){}return 1}();this.renderTemplateSource=function(b,d,f){if(f=f||{},2>a)throw Error("Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.");var g=b.data("precompiled");return g||(g=b.text()||"",g=e.template(null,"{{ko_with $item.koBindingContext}}"+g+"{{/ko_with}}"),b.data("precompiled",g)),b=[d.$data],d=e.extend({koBindingContext:d},f.templateOptions),d=e.tmpl(g,b,d),d.appendTo(c.createElement("div")),e.fragments={},d},this.createJavaScriptEvaluatorBlock=function(a){return"{{ko_code ((function() { return "+a+" })()) }}"},this.addTemplate=function(a,b){c.write("")},a>0&&(e.tmpl.tag.ko_code={open:"__.push($1 || '');"},e.tmpl.tag.ko_with={open:"with($1) {",close:"} "})},l.La.prototype=new l.C;var a=new l.La;0d;d++)E[c[d]]=!!(c[d]in u);return E.list&&(E.list=!(!b.createElement("datalist")||!a.HTMLDataListElement)),E}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),o.inputtypes=function(a){for(var d,e,f,g=0,h=a.length;h>g;g++)u.setAttribute("type",e=a[g]),d="text"!==u.type,d&&(u.value=v,u.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(e)&&u.style.WebkitAppearance!==c?(q.appendChild(u),f=b.defaultView,d=f.getComputedStyle&&"textfield"!==f.getComputedStyle(u,null).WebkitAppearance&&0!==u.offsetHeight,q.removeChild(u)):/^(search|tel)$/.test(e)||(d=/^(url|email)$/.test(e)?u.checkValidity&&u.checkValidity()===!1:u.value!=v)),D[a[g]]=!!d;return D}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var l,m,n="2.7.1",o={},p=!0,q=b.documentElement,r="modernizr",s=b.createElement(r),t=s.style,u=b.createElement("input"),v=":)",w={}.toString,x=" -webkit- -moz- -o- -ms- ".split(" "),y="Webkit Moz O ms",z=y.split(" "),A=y.toLowerCase().split(" "),B={svg:"http://www.w3.org/2000/svg"},C={},D={},E={},F=[],G=F.slice,H=function(a,c,d,e){var f,g,h,i,j=b.createElement("div"),k=b.body,l=k||b.createElement("body");if(parseInt(d,10))for(;d--;)h=b.createElement("div"),h.id=e?e[d]:r+(d+1),j.appendChild(h);return f=["­",'"].join(""),j.id=r,(k?j:l).innerHTML+=f,l.appendChild(j),k||(l.style.background="",l.style.overflow="hidden",i=q.style.overflow,q.style.overflow="hidden",q.appendChild(l)),g=c(j,a),k?j.parentNode.removeChild(j):(l.parentNode.removeChild(l),q.style.overflow=i),!!g},I=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return H("@media "+b+" { #"+r+" { position: absolute; } }",function(b){d="absolute"==(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).position}),d},J=function(){function a(a,e){e=e||b.createElement(d[a]||"div"),a="on"+a;var g=a in e;return g||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(a,""),g=f(e[a],"function"),f(e[a],"undefined")||(e[a]=c),e.removeAttribute(a))),e=null,g}var d={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return a}(),K={}.hasOwnProperty;m=f(K,"undefined")||f(K.call,"undefined")?function(a,b){return b in a&&f(a.constructor.prototype[b],"undefined")}:function(a,b){return K.call(a,b)},Function.prototype.bind||(Function.prototype.bind=function(a){var b=this;if("function"!=typeof b)throw new TypeError;var c=G.call(arguments,1),d=function(){if(this instanceof d){var e=function(){};e.prototype=b.prototype;var f=new e,g=b.apply(f,c.concat(G.call(arguments)));return Object(g)===g?g:f}return b.apply(a,c.concat(G.call(arguments)))};return d}),C.flexbox=function(){return j("flexWrap")},C.flexboxlegacy=function(){return j("boxDirection")},C.canvas=function(){var a=b.createElement("canvas");return!(!a.getContext||!a.getContext("2d"))},C.canvastext=function(){return!(!o.canvas||!f(b.createElement("canvas").getContext("2d").fillText,"function"))},C.webgl=function(){return!!a.WebGLRenderingContext},C.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:H(["@media (",x.join("touch-enabled),("),r,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=9===a.offsetTop}),c},C.geolocation=function(){return"geolocation"in navigator},C.postmessage=function(){return!!a.postMessage},C.websqldatabase=function(){return!!a.openDatabase},C.indexedDB=function(){return!!j("indexedDB",a)},C.hashchange=function(){return J("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},C.history=function(){return!(!a.history||!history.pushState)},C.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},C.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},C.rgba=function(){return d("background-color:rgba(150,255,150,.5)"),g(t.backgroundColor,"rgba")},C.hsla=function(){return d("background-color:hsla(120,40%,100%,.5)"),g(t.backgroundColor,"rgba")||g(t.backgroundColor,"hsla")},C.multiplebgs=function(){return d("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(t.background)},C.backgroundsize=function(){return j("backgroundSize")},C.borderimage=function(){return j("borderImage")},C.borderradius=function(){return j("borderRadius")},C.boxshadow=function(){return j("boxShadow")},C.textshadow=function(){return""===b.createElement("div").style.textShadow},C.opacity=function(){return e("opacity:.55"),/^0.55$/.test(t.opacity)},C.cssanimations=function(){return j("animationName")},C.csscolumns=function(){return j("columnCount")},C.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return d((a+"-webkit- ".split(" ").join(b+a)+x.join(c+a)).slice(0,-a.length)),g(t.backgroundImage,"gradient")},C.cssreflections=function(){return j("boxReflect")},C.csstransforms=function(){return!!j("transform")},C.csstransforms3d=function(){var a=!!j("perspective");return a&&"webkitPerspective"in q.style&&H("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b){a=9===b.offsetLeft&&3===b.offsetHeight}),a},C.csstransitions=function(){return j("transition")},C.fontface=function(){var a;return H('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&0===g.indexOf(d.split(" ")[0])}),a},C.generatedcontent=function(){var a;return H(["#",r,"{font:0/0 a}#",r,':after{content:"',v,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},C.video=function(){var a=b.createElement("video"),c=!1;try{(c=!!a.canPlayType)&&(c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,""))}catch(d){}return c},C.audio=function(){var a=b.createElement("audio"),c=!1;try{(c=!!a.canPlayType)&&(c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,""))}catch(d){}return c},C.localstorage=function(){try{return localStorage.setItem(r,r),localStorage.removeItem(r),!0}catch(a){return!1}},C.sessionstorage=function(){try{return sessionStorage.setItem(r,r),sessionStorage.removeItem(r),!0}catch(a){return!1}},C.webworkers=function(){return!!a.Worker},C.applicationcache=function(){return!!a.applicationCache},C.svg=function(){return!!b.createElementNS&&!!b.createElementNS(B.svg,"svg").createSVGRect},C.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="",(a.firstChild&&a.firstChild.namespaceURI)==B.svg},C.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(w.call(b.createElementNS(B.svg,"animate")))},C.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(w.call(b.createElementNS(B.svg,"clipPath")))};for(var L in C)m(C,L)&&(l=L.toLowerCase(),o[l]=C[L](),F.push((o[l]?"":"no-")+l));return o.input||k(),o.addTest=function(a,b){if("object"==typeof a)for(var d in a)m(a,d)&&o.addTest(d,a[d]);else{if(a=a.toLowerCase(),o[a]!==c)return o;b="function"==typeof b?b():b,"undefined"!=typeof p&&p&&(q.className+=" "+(b?"":"no-")+a),o[a]=b}return o},d(""),s=u=null,function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=s.elements;return"string"==typeof a?a.split(" "):a}function e(a){var b=r[a[p]];return b||(b={},q++,a[p]=q,r[q]=b),b}function f(a,c,d){if(c||(c=b),k)return c.createElement(a);d||(d=e(c));var f;return f=d.cache[a]?d.cache[a].cloneNode():o.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!f.canHaveChildren||n.test(a)||f.tagUrn?f:d.frag.appendChild(f)}function g(a,c){if(a||(a=b),k)return a.createDocumentFragment();c=c||e(a);for(var f=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)f.createElement(h[g]);return f}function h(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return s.shivMethods?f(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(s,b.frag)}function i(a){a||(a=b);var d=e(a);return!s.shivCSS||j||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),k||h(a,d),a}var j,k,l="3.7.0",m=a.html5||{},n=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,o=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,p="_html5shiv",q=0,r={};!function(){try{var a=b.createElement("a");a.innerHTML="",j="hidden"in a,k=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){j=!0,k=!0}}();var s={elements:m.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:l,shivCSS:m.shivCSS!==!1,supportsUnknownElements:k,shivMethods:m.shivMethods!==!1,type:"default",shivDocument:i,createElement:f,createDocumentFragment:g};a.html5=s,i(b)}(this,b),o._version=n,o._prefixes=x,o._domPrefixes=A,o._cssomPrefixes=z,o.mq=I,o.hasEvent=J,o.testProp=function(a){return h([a])},o.testAllProps=j,o.testStyles=H,o.prefixed=function(a,b,c){return b?j(a,b,c):j(a,"pfx")},q.className=q.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(p?" js "+F.join(" "):""),o}(this,this.document),function(a,b,c,d){"use strict";function e(a){return("string"==typeof a||a instanceof String)&&(a=a.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g,"")),a}var f=function(b){for(var c=b.length;c--;)0===a("head").has("."+b[c]).length&&a("head").append('')};f(["foundation-mq-small","foundation-mq-medium","foundation-mq-large","foundation-mq-xlarge","foundation-mq-xxlarge","foundation-data-attribute-namespace"]),a(function(){"undefined"!=typeof FastClick&&"undefined"!=typeof c.body&&FastClick.attach(c.body)});var g=function(b,d){if("string"==typeof b){if(d){var e;return e=d.jquery?d[0]:d,a(e.querySelectorAll(b))}return a(c.querySelectorAll(b))}return a(b,d)},h=function(a){var b=[];return a||b.push("data"),this.namespace.length>0&&b.push(this.namespace),b.push(this.name),b.join("-")},f=function(b){for(var c=b.length;c--;)0===a("head").has("."+b[c]).length&&a("head").append('')},i=function(a){for(var b=a.split("-"),c=b.length,d=[];c--;)0!==c?d.push(b[c]):this.namespace.length>0?d.push(this.namespace,b[c]):d.push(b[c]);return d.reverse().join("-")},j=function(b,c){var d=this,e=!g(this).data(this.attr_name(!0));return"string"==typeof b?this[b].call(this,c):void(g(this.scope).is("["+this.attr_name()+"]")?(g(this.scope).data(this.attr_name(!0)+"-init",a.extend({},this.settings,c||b,this.data_options(g(this.scope)))),e&&this.events(this.scope)):g("["+this.attr_name()+"]",this.scope).each(function(){var e=!g(this).data(d.attr_name(!0)+"-init");g(this).data(d.attr_name(!0)+"-init",a.extend({},d.settings,c||b,d.data_options(g(this)))),e&&d.events(this)}))},k=function(a,b){function c(){b(a[0])}function d(){if(this.one("load",c),/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var a=this.attr("src"),b=a.match(/\?/)?"&":"?";b+="random="+(new Date).getTime(),this.attr("src",a+b)}}return a.attr("src")?void(a[0].complete||4===a[0].readyState?c():d.call(a)):void c()};b.matchMedia=b.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(c),function(){function a(){c&&(f(a),jQuery.fx.tick())}for(var c,d=0,e=["webkit","moz"],f=b.requestAnimationFrame,g=b.cancelAnimationFrame;d").appendTo("head")[0].sheet,global:{namespace:""},init:function(a,b,c,d,e){var f=[a,c,d,e],h=[];if(this.rtl=/rtl/i.test(g("html").attr("dir")),this.scope=a||this.scope,this.set_namespace(),b&&"string"==typeof b&&!/reflow/i.test(b))this.libs.hasOwnProperty(b)&&h.push(this.init_lib(b,f));else for(var i in this.libs)h.push(this.init_lib(i,b));return a},init_lib:function(a,b){return this.libs.hasOwnProperty(a)?(this.patch(this.libs[a]),b&&b.hasOwnProperty(a)?this.libs[a].init.apply(this.libs[a],[this.scope,b[a]]):(b=b instanceof Array?b:Array(b),this.libs[a].init.apply(this.libs[a],b))):function(){}},patch:function(a){a.scope=this.scope,a.namespace=this.global.namespace,a.rtl=this.rtl,a.data_options=this.utils.data_options,a.attr_name=h,a.add_namespace=i,a.bindings=j,a.S=this.utils.S},inherit:function(a,b){for(var c=b.split(" "),d=c.length;d--;)this.utils.hasOwnProperty(c[d])&&(a[c[d]]=this.utils[c[d]])},set_namespace:function(){var b=a(".foundation-data-attribute-namespace").css("font-family");/false/i.test(b)||(this.global.namespace=b)},libs:{},utils:{S:g,throttle:function(a,b){var c=null;return function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,e)},b)}},debounce:function(a,b,c){var d,e;return function(){var f=this,g=arguments,h=function(){d=null,c||(e=a.apply(f,g))},i=c&&!d;return clearTimeout(d),d=setTimeout(h,b),i&&(e=a.apply(f,g)),e}},data_options:function(b){function c(a){return!isNaN(a-0)&&null!==a&&""!==a&&a!==!1&&a!==!0}function d(b){return"string"==typeof b?a.trim(b):b}var e,f,g,h={},i=function(a){var b=Foundation.global.namespace;return a.data(b.length>0?b+"-options":"options") },j=i(b);if("object"==typeof j)return j;for(g=(j||":").split(";"),e=g.length;e--;)f=g[e].split(":"),/true/i.test(f[1])&&(f[1]=!0),/false/i.test(f[1])&&(f[1]=!1),c(f[1])&&(f[1]=parseInt(f[1],10)),2===f.length&&f[0].length>0&&(h[d(f[0])]=d(f[1]));return h},register_media:function(b,c){Foundation.media_queries[b]===d&&(a("head").append(''),Foundation.media_queries[b]=e(a("."+c).css("font-family")))},add_custom_rule:function(a,b){if(b===d)Foundation.stylesheet.insertRule(a,Foundation.stylesheet.cssRules.length);else{var c=Foundation.media_queries[b];c!==d&&Foundation.stylesheet.insertRule("@media "+Foundation.media_queries[b]+"{ "+a+" }")}},image_loaded:function(a,b){var c=this,d=a.length;a.each(function(){k(c.S(this),function(){d-=1,0==d&&b(a)})})},random_str:function(a){var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split("");a||(a=Math.floor(Math.random()*b.length));for(var c="";a--;)c+=b[Math.floor(Math.random()*b.length)];return c}}},a.fn.foundation=function(){var a=Array.prototype.slice.call(arguments,0);return this.each(function(){return Foundation.init.apply(Foundation,[this].concat(a)),this})}}(jQuery,this,this.document),function(a,b,c,d){"use strict";Foundation.libs.reveal={name:"reveal",version:"5.1.1",locked:!1,settings:{animation:"fadeAndPop",animation_speed:250,close_on_background_click:!0,close_on_esc:!0,dismiss_modal_class:"close-reveal-modal",bg_class:"reveal-modal-bg",open:function(){},opened:function(){},close:function(){},closed:function(){},bg:a(".reveal-modal-bg"),css:{open:{opacity:0,visibility:"visible",display:"block"},close:{opacity:1,visibility:"hidden",display:"none"}}},init:function(b,c,d){a.extend(!0,this.settings,c,d),this.bindings(c,d)},events:function(){var a=this,b=a.S;return b(this.scope).off(".reveal").on("click.fndtn.reveal","["+this.add_namespace("data-reveal-id")+"]",function(c){if(c.preventDefault(),!a.locked){var d=b(this),e=d.data(a.data_attr("reveal-ajax"));if(a.locked=!0,"undefined"==typeof e)a.open.call(a,d);else{var f=e===!0?d.attr("href"):e;a.open.call(a,d,{url:f})}}}),b(c).on("click.fndtn.reveal",this.close_targets(),function(c){if(c.preventDefault(),!a.locked){var d=b("["+a.attr_name()+"].open").data(a.attr_name(!0)+"-init"),e=b(c.target)[0]===b("."+d.bg_class)[0];if(e&&!d.close_on_background_click)return;a.locked=!0,a.close.call(a,e?b("["+a.attr_name()+"].open"):b(this).closest("["+a.attr_name()+"]"))}}),b("["+a.attr_name()+"]",this.scope).length>0?b(this.scope).on("open.fndtn.reveal",this.settings.open).on("opened.fndtn.reveal",this.settings.opened).on("opened.fndtn.reveal",this.open_video).on("close.fndtn.reveal",this.settings.close).on("closed.fndtn.reveal",this.settings.closed).on("closed.fndtn.reveal",this.close_video):b(this.scope).on("open.fndtn.reveal","["+a.attr_name()+"]",this.settings.open).on("opened.fndtn.reveal","["+a.attr_name()+"]",this.settings.opened).on("opened.fndtn.reveal","["+a.attr_name()+"]",this.open_video).on("close.fndtn.reveal","["+a.attr_name()+"]",this.settings.close).on("closed.fndtn.reveal","["+a.attr_name()+"]",this.settings.closed).on("closed.fndtn.reveal","["+a.attr_name()+"]",this.close_video),!0},key_up_on:function(){var a=this;return a.S("body").off("keyup.fndtn.reveal").on("keyup.fndtn.reveal",function(b){var c=a.S("["+a.attr_name()+"].open"),d=c.data(a.attr_name(!0)+"-init");d&&27===b.which&&d.close_on_esc&&!a.locked&&a.close.call(a,c)}),!0},key_up_off:function(){return this.S("body").off("keyup.fndtn.reveal"),!0},open:function(b,c){var d=this;if(b)if("undefined"!=typeof b.selector)var e=d.S("#"+b.data(d.data_attr("reveal-id")));else{var e=d.S(this.scope);c=b}else var e=d.S(this.scope);var f=e.data(d.attr_name(!0)+"-init");if(!e.hasClass("open")){var g=d.S("["+d.attr_name()+"].open");if("undefined"==typeof e.data("css-top")&&e.data("css-top",parseInt(e.css("top"),10)).data("offset",this.cache_offset(e)),this.key_up_on(e),e.trigger("open"),g.length<1&&this.toggle_bg(e),"string"==typeof c&&(c={url:c}),"undefined"!=typeof c&&c.url){var h="undefined"!=typeof c.success?c.success:null;a.extend(c,{success:function(b,c,i){if(a.isFunction(h)&&h(b,c,i),e.html(b),d.S(e).foundation("section","reflow"),g.length>0){var j=g.data(d.attr_name(!0));d.hide(g,j.css.close)}d.show(e,f.css.open)}}),a.ajax(c)}else{if(g.length>0){var i=g.data(d.attr_name(!0)+"-init");this.hide(g,i.css.close)}this.show(e,f.css.open)}}},close:function(a){var a=a&&a.length?a:this.S(this.scope),b=this.S("["+this.attr_name()+"].open"),c=a.data(this.attr_name(!0)+"-init");b.length>0&&(this.locked=!0,this.key_up_off(a),a.trigger("close"),this.toggle_bg(a),this.hide(b,c.css.close,c))},close_targets:function(){var a="."+this.settings.dismiss_modal_class;return this.settings.close_on_background_click?a+", ."+this.settings.bg_class:a},toggle_bg:function(b){b.data(this.attr_name(!0));0===this.S("."+this.settings.bg_class).length&&(this.settings.bg=a("
",{"class":this.settings.bg_class}).appendTo("body")),this.settings.bg.filter(":visible").length>0?this.hide(this.settings.bg):this.show(this.settings.bg)},show:function(c,d){if(d){var e=c.data(this.attr_name(!0)+"-init");if(0===c.parent("body").length){var f=c.wrap('
').parent(),g=this.settings.rootElement||"body";c.on("closed.fndtn.reveal.wrapped",function(){c.detach().appendTo(f),c.unwrap().unbind("closed.fndtn.reveal.wrapped")}),c.detach().appendTo(g)}if(/pop/i.test(e.animation)){d.top=a(b).scrollTop()-c.data("offset")+"px";var h={top:a(b).scrollTop()+c.data("css-top")+"px",opacity:1};return setTimeout(function(){return c.css(d).animate(h,e.animation_speed,"linear",function(){this.locked=!1,c.trigger("opened")}.bind(this)).addClass("open")}.bind(this),e.animation_speed/2)}if(/fade/i.test(e.animation)){var h={opacity:1};return setTimeout(function(){return c.css(d).animate(h,e.animation_speed,"linear",function(){this.locked=!1,c.trigger("opened")}.bind(this)).addClass("open")}.bind(this),e.animation_speed/2)}return c.css(d).show().css({opacity:1}).addClass("open").trigger("opened")}var e=this.settings;return/fade/i.test(e.animation)?c.fadeIn(e.animation_speed/2):(this.locked=!1,c.show())},hide:function(c,d){if(d){var e=c.data(this.attr_name(!0)+"-init");if(/pop/i.test(e.animation)){var f={top:-a(b).scrollTop()-c.data("offset")+"px",opacity:0};return setTimeout(function(){return c.animate(f,e.animation_speed,"linear",function(){this.locked=!1,c.css(d).trigger("closed")}.bind(this)).removeClass("open")}.bind(this),e.animation_speed/2)}if(/fade/i.test(e.animation)){var f={opacity:0};return setTimeout(function(){return c.animate(f,e.animation_speed,"linear",function(){this.locked=!1,c.css(d).trigger("closed")}.bind(this)).removeClass("open")}.bind(this),e.animation_speed/2)}return c.hide().css(d).removeClass("open").trigger("closed")}var e=this.settings;return/fade/i.test(e.animation)?c.fadeOut(e.animation_speed/2):c.hide()},close_video:function(b){var c=a(".flex-video",b.target),d=a("iframe",c);d.length>0&&(d.attr("data-src",d[0].src),d.attr("src","about:blank"),c.hide())},open_video:function(b){var c=a(".flex-video",b.target),e=c.find("iframe");if(e.length>0){var f=e.attr("data-src");if("string"==typeof f)e[0].src=e.attr("data-src");else{var g=e[0].src;e[0].src=d,e[0].src=g}c.show()}},data_attr:function(a){return this.namespace.length>0?this.namespace+"-"+a:a},cache_offset:function(a){var b=a.show().height()+parseInt(a.css("top"),10);return a.hide(),b},off:function(){a(this.scope).off(".fndtn.reveal")},reflow:function(){}}}(jQuery,this,this.document),function(a,b,c){"use strict";Foundation.libs.tooltip={name:"tooltip",version:"5.1.1",settings:{additional_inheritable_classes:[],tooltip_class:".tooltip",append_to:"body",touch_close_text:"Tap To Close",disable_for_touch:!1,hover_delay:200,tip_template:function(a,b){return''+b+''}},cache:{},init:function(a,b,c){Foundation.inherit(this,"random_str"),this.bindings(b,c)},events:function(){var b=this,d=b.S;Modernizr.touch?d(c).off(".tooltip").on("click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip","["+this.attr_name()+"]:not(a)",function(c){var e=a.extend({},b.settings,b.data_options(d(this)));e.disable_for_touch||(c.preventDefault(),d(e.tooltip_class).hide(),b.showOrCreateTip(d(this)))}).on("click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip",this.settings.tooltip_class,function(a){a.preventDefault(),d(this).fadeOut(150)}):d(c).off(".tooltip").on("mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip","["+this.attr_name()+"]",function(a){var c=d(this);/enter|over/i.test(a.type)?this.timer=setTimeout(function(){b.showOrCreateTip(c)}.bind(this),b.settings.hover_delay):("mouseout"===a.type||"mouseleave"===a.type)&&(clearTimeout(this.timer),b.hide(c))})},showOrCreateTip:function(a){var b=this.getTip(a);return b&&b.length>0?this.show(a):this.create(a)},getTip:function(a){var b=this.selector(a),c=null;return b&&(c=this.S('span[data-selector="'+b+'"]'+this.settings.tooltip_class)),"object"==typeof c?c:!1},selector:function(a){var b=a.attr("id"),c=a.attr(this.attr_name())||a.attr("data-selector");return(b&&b.length<1||!b)&&"string"!=typeof c&&(c="tooltip"+this.random_str(6),a.attr("data-selector",c)),b&&b.length>0?b:c},create:function(b){var c=a(this.settings.tip_template(this.selector(b),a("
").html(b.attr("title")).html())),d=this.inheritable_classes(b);c.addClass(d).appendTo(this.settings.append_to),Modernizr.touch&&c.append(''+this.settings.touch_close_text+""),b.removeAttr("title").attr("title",""),this.show(b)},reposition:function(a,b,c){var d,e,f,g,h;if(b.css("visibility","hidden").show(),d=a.data("width"),e=b.children(".nub"),f=e.outerHeight(),g=e.outerHeight(),b.css(this.small()?{width:"100%"}:{width:d?d:"auto"}),h=function(a,b,c,d,e){return a.css({top:b?b:"auto",bottom:d?d:"auto",left:e?e:"auto",right:c?c:"auto"}).end()},h(b,a.offset().top+a.outerHeight()+10,"auto","auto",a.offset().left),this.small())h(b,a.offset().top+a.outerHeight()+10,"auto","auto",12.5,this.S(this.scope).width()),b.addClass("tip-override"),h(e,-f,"auto","auto",a.offset().left+10);else{var i=a.offset().left;Foundation.rtl&&(i=a.offset().left+a.outerWidth()-b.outerWidth()),h(b,a.offset().top+a.outerHeight()+10,"auto","auto",i),b.removeClass("tip-override"),e.removeAttr("style"),c&&c.indexOf("tip-top")>-1?h(b,a.offset().top-b.outerHeight()-10,"auto","auto",i).removeClass("tip-override"):c&&c.indexOf("tip-left")>-1?h(b,a.offset().top+a.outerHeight()/2-b.outerHeight()/2,"auto","auto",a.offset().left-b.outerWidth()-f).removeClass("tip-override"):c&&c.indexOf("tip-right")>-1&&h(b,a.offset().top+a.outerHeight()/2-b.outerHeight()/2,"auto","auto",a.offset().left+a.outerWidth()+f).removeClass("tip-override")}b.css("visibility","visible").hide()},small:function(){return matchMedia(Foundation.media_queries.small).matches},inheritable_classes:function(b){var c=["tip-top","tip-left","tip-bottom","tip-right","radius","round"].concat(this.settings.additional_inheritable_classes),d=b.attr("class"),e=d?a.map(d.split(" "),function(b){return-1!==a.inArray(b,c)?b:void 0}).join(" "):"";return a.trim(e)},show:function(a){var b=this.getTip(a);return this.reposition(a,b,a.attr("class")),b.fadeIn(150)},hide:function(a){var b=this.getTip(a);return b.fadeOut(150)},reload:function(){var b=a(this);return b.data("fndtn-tooltips")?b.foundationTooltips("destroy").foundationTooltips("init"):b.foundationTooltips("init")},off:function(){this.S(this.scope).off(".fndtn.tooltip"),this.S(this.settings.tooltip_class).each(function(b){a("["+this.attr_name()+"]").get(b).attr("title",a(this).text())}).remove()},reflow:function(){}}}(jQuery,this,this.document),!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)k.push("exports"===i[l]?g={}:b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;jb?(c&&c(null),void d(null)):void a("readonly",function(a){var e=!1,f=a.openCursor();f.onsuccess=function(){var a=f.result;return a?void(0===b?(c&&c(a.key),d(a.key)):e?(c&&c(a.key),d(a.key)):(e=!0,a.advance(b))):(c&&c(null),void d(null))},f.onerror=function(){console.error("Error in asyncStorage.key(): ",f.error.name)}})})}var h="asyncStorage",i=1,j="keyvaluepairs",k=window.Promise,l=null,m=m||window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB;if(m){var n={driver:"asyncStorage",getItem:b,setItem:c,removeItem:d,clear:e,length:f,key:g};"function"==typeof define&&define.amd?define("asyncStorage",function(){return n}):"undefined"!=typeof module&&module.exports?module.exports=n:this.asyncStorage=n}}.call(this),!function(){"use strict";function a(a){return new g(function(b){h.clear(),a&&a(),b()})}function b(a,b){return new g(function(c,d){try{var e=h.getItem(a);e&&(e=JSON.parse(e)),b&&b(e),c(e)}catch(f){d(f)}})}function c(a,b){return new g(function(c){var d=h.key(a);b&&b(d),c(d)})}function d(a){return new g(function(b){var c=h.length;a&&a(c),b(c)})}function e(a,b){return new g(function(c){h.removeItem(a),b&&b(),c()})}function f(a,b,c){return new g(function(d,e){void 0===b&&(b=null);var f=b;try{b=JSON.stringify(b)}catch(g){console.error("Couldn't convert value into a JSON string: ",b),e(g)}h.setItem(a,b),c&&c(f),d(f)})}var g=window.Promise;if(!window.chrome||!window.chrome.runtime){var h=window.localStorage,i={driver:"localStorageWrapper",getItem:b,setItem:f,removeItem:e,clear:a,length:d,key:c};"function"==typeof define&&define.amd?define("localStorageWrapper",function(){return i}):"undefined"!=typeof module&&module.exports?module.exports=i:this.localStorageWrapper=i}}.call(this),!function(){"use strict";function a(a,b){return new m(function(c,d){n.transaction(function(e){e.executeSql("SELECT * FROM localforage WHERE key = ? LIMIT 1",[a],function(a,e){var f=e.rows.length?e.rows.item(0).value:null;if(f&&f.substr(0,k)===j)try{f=JSON.parse(f.slice(k))}catch(g){d(g)}b&&b(f),c(f)},null)})})}function b(a,b,c){return new m(function(d){void 0===b&&(b=null);var e;e="boolean"==typeof b||"number"==typeof b||"object"==typeof b?j+JSON.stringify(b):b,n.transaction(function(f){f.executeSql("INSERT OR REPLACE INTO localforage (key, value) VALUES (?, ?)",[a,e],function(){c&&c(b),d(b)},null)})})}function c(a,b){return new m(function(c){n.transaction(function(d){d.executeSql("DELETE FROM localforage WHERE key = ? LIMIT 1",[a],function(){b&&b(),c()},null)})})}function d(a){return new m(function(b){n.transaction(function(c){c.executeSql("DELETE FROM localforage",[],function(){a&&a(),b()},null)})})}function e(a){return new m(function(b){n.transaction(function(c){c.executeSql("SELECT COUNT(key) as c FROM localforage",[],function(c,d){var e=d.rows.item(0).c;a&&a(e),b(e)},null)})})}function f(a,b){return new m(function(c){n.transaction(function(d){d.executeSql("SELECT key FROM localforage WHERE id = ? LIMIT 1",[a+1],function(a,d){var e=d.rows.length?d.rows.item(0).key:null;b&&b(e),c(e)},null)})})}var g="localforage",h=5242880,i="1.0",j="__lfsc__:",k=j.length,l="keyvaluepairs",m=window.Promise;if(window.openDatabase){var n=window.openDatabase(g,i,l,h);n.transaction(function(a){a.executeSql("CREATE TABLE IF NOT EXISTS localforage (id INTEGER PRIMARY KEY, key unique, value)")});var o={driver:"webSQLStorage",getItem:a,setItem:b,removeItem:c,clear:d,length:e,key:f};"function"==typeof define&&define.amd?define("webSQLStorage",function(){return o}):"undefined"!=typeof module&&module.exports?module.exports=o:this.webSQLStorage=o}}.call(this),!function(){"use strict";var a=window.Promise,b=1,c=2,d=3,e=d;"function"==typeof define&&define.amd?e=b:"undefined"!=typeof module&&module.exports&&(e=c);var f,g=g||window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,h=this,i={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage",setDriver:function(d,f){return new a(function(a,j){return!g&&d===i.INDEXEDDB||!window.openDatabase&&d===i.WEBSQL?(f&&f(i),void j(i)):void(e===b?require([d],function(b){i._extend(b),f&&f(i),a(i)}):e===c?(i._extend(require("./"+d)),f&&f(i),a(i)):(i._extend(h[d]),f&&f(i),a(i)))})},_extend:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b])}};f=g?i.INDEXEDDB:window.openDatabase?i.WEBSQL:i.LOCALSTORAGE,i.setDriver(f),e===b?define(function(){return i}):e===c?module.exports=i:this.localforage=i}.call(this);var Base=function(){};Base.extend=function(a,b){"use strict";var c=Base.prototype.extend;Base._prototyping=!0;var d=new this;c.call(d,a),d.base=function(){},delete Base._prototyping;var e=d.constructor,f=d.constructor=function(){if(!Base._prototyping)if(this._constructing||this.constructor==f)this._constructing=!0,e.apply(this,arguments),delete this._constructing;else if(null!==arguments[0])return(arguments[0].extend||c).call(arguments[0],d)};return f.ancestor=this,f.extend=this.extend,f.forEach=this.forEach,f.implement=this.implement,f.prototype=d,f.toString=this.toString,f.valueOf=function(a){return"object"==a?f:e.valueOf()},c.call(f,b),"function"==typeof f.init&&f.init(),f},Base.prototype={extend:function(a,b){if(arguments.length>1){var c=this[a];if(c&&"function"==typeof b&&(!c.valueOf||c.valueOf()!=b.valueOf())&&/\bbase\b/.test(b)){var d=b.valueOf();b=function(){var a=this.base||Base.prototype.base;this.base=c;var b=d.apply(this,arguments);return this.base=a,b},b.valueOf=function(a){return"object"==a?b:d},b.toString=Base.toString}this[a]=b}else if(a){var e=Base.prototype.extend;Base._prototyping||"function"==typeof this||(e=this.extend||e);for(var f={toSource:null},g=["constructor","toString","valueOf"],h=Base._prototyping?0:1;i=g[h++];)a[i]!=f[i]&&e.call(this,i,a[i]);for(var i in a)f[i]||e.call(this,i,a[i])}return this}},Base=Base.extend({constructor:function(){this.extend(arguments[0])}},{ancestor:Object,version:"1.1",forEach:function(a,b,c){for(var d in a)void 0===this.prototype[d]&&b.call(c,a[d],d,a)},implement:function(){for(var a=0;a0)?b.log("Trying to start timer when countdown already at 0"):(b.face.start(b.time),b.timer.start(function(){b.flip(),"function"==typeof a&&a()}))},stop:function(a){this.face.stop(),this.timer.stop(a);for(var b in this.lists)this.lists[b].stop()},reset:function(a){this.timer.reset(a),this.face.reset()},setTime:function(a){this.time.time=a,this.face.setTime(a)},getTime:function(){return this.time},setCountdown:function(a){var b=this.running;this.countdown=a?!0:!1,b&&(this.stop(),this.start())},flip:function(){this.face.flip()}}),FlipClock.Face=FlipClock.Base.extend({dividers:[],factory:!1,lists:[],constructor:function(a,b){this.base(b),this.factory=a,this.dividers=[]},build:function(){},createDivider:function(b,c,d){"boolean"!=typeof c&&c||(d=c,c=b);var e=['',''].join("");d&&(e=""),b=this.factory.localize(b);var f=['',''+(b?b:"")+"",e,""];return a(f.join(""))},createList:function(a,b){"object"==typeof a&&(b=a,a=0);var c=new FlipClock.List(this.factory,a,b);return c},reset:function(){},setTime:function(a){this.flip(a)},addDigit:function(a){var b=this.createList(a,{classes:{active:this.factory.classes.active,before:this.factory.classes.before,flip:this.factory.classes.flip}});b.$obj.insertBefore(this.factory.lists[0].$obj),this.factory.lists.unshift(b)},start:function(){},stop:function(){},flip:function(b,c){var d=this;c||(d.factory.countdown?(d.factory.time.time<=0&&d.factory.stop(),d.factory.time.time--):d.factory.time.time++);var e=d.factory.lists.length-b.length;0>e&&(e=0);var f=!1;a.each(b,function(a,b){a+=e;var g=d.factory.lists[a];if(g){var h=g.digit;g.select(b),b==h||c||g.play()}else d.addDigit(b),f=!0});for(var g=0;g=e&&d.factory.lists[g].digit!=b[g]&&d.factory.lists[g].select(b[g])}}),FlipClock.List=FlipClock.Base.extend({digit:0,classes:{active:"flip-clock-active",before:"flip-clock-before",flip:"flip"},factory:!1,$obj:!1,items:[],constructor:function(a,b){this.factory=a,this.digit=b,this.$obj=this.createList(),b>0&&this.select(b),this.factory.$wrapper.append(this.$obj)},select:function(a){"undefined"==typeof a?a=this.digit:this.digit=a;{var b=this.$obj.find('[data-digit="'+a+'"]');this.$obj.find("."+this.classes.active).removeClass(this.classes.active),this.$obj.find("."+this.classes.before).removeClass(this.classes.before)}this.factory.countdown?b.is(":last-child")?this.$obj.find(":first-child").addClass(this.classes.before):b.next().addClass(this.classes.before):b.is(":first-child")?this.$obj.find(":last-child").addClass(this.classes.before):b.prev().addClass(this.classes.before),b.addClass(this.classes.active)},play:function(){this.$obj.addClass(this.factory.classes.play)},stop:function(){var a=this;setTimeout(function(){a.$obj.removeClass(a.factory.classes.play)},this.factory.timer.interval)},createList:function(){for(var b=a('
    '),c=0;10>c;c++){var d=a(['
  • ','','
    ','
    ','
    '+c+"
    ","
    ",'
    ','
    ','
    '+c+"
    ","
    ","
    ","
  • "].join(""));this.items.push(d),b.append(d)}return b}}),FlipClock.Time=FlipClock.Base.extend({minimumDigits:0,time:0,factory:!1,constructor:function(a,b,c){this.base(c),this.factory=a,b&&(this.time=b)},convertDigitsToArray:function(a){var b=[];a=a.toString();for(var c=0;cthis.minimumDigits&&(this.minimumDigits=c.length),this.minimumDigits>c.length&&c.unshift("0"),c},getDayCounter:function(a){var b=[this.getDays(),this.getHours(!0),this.getMinutes(!0)];return a&&b.push(this.getSeconds(!0)),this.digitize(b)},getDays:function(a){var b=this.time/60/60/24;return a&&(b%=7),Math.floor(b)},getHourCounter:function(){var a=this.digitize([this.getHours(),this.getMinutes(!0),this.getSeconds(!0)]);return a},getHourly:function(){return this.getHourCounter()},getHours:function(a){var b=this.time/60/60;return a&&(b%=24),Math.floor(b)},getMilitaryTime:function(){var a=new Date,b=this.digitize([a.getHours(),a.getMinutes(),a.getSeconds()]);return b},getMinutes:function(a){var b=this.time/60;return a&&(b%=60),Math.floor(b)},getMinuteCounter:function(){var a=this.digitize([this.getMinutes(),this.getSeconds(!0)]);return a},getSeconds:function(a){var b=this.time;return a&&(60==b?b=0:b%=60),Math.ceil(b)},getTime:function(){var a=new Date,b=a.getHours(),c=this.digitize([b>12?b-12:0===b?12:b,a.getMinutes(),a.getSeconds()]);return c},getWeeks:function(){var a=this.time/60/60/24/7;return mod&&(a%=52),Math.floor(a) },removeLeadingZeros:function(b,c){var d=0,e=[];return a.each(c,function(a){b>a?d+=parseInt(c[a],10):e.push(c[a])}),0===d?e:c},toString:function(){return this.time.toString()}}),FlipClock.Timer=FlipClock.Base.extend({callbacks:{destroy:!1,create:!1,init:!1,interval:!1,start:!1,stop:!1,reset:!1},count:0,factory:!1,interval:1e3,constructor:function(a,b){this.base(b),this.factory=a,this.callback(this.callbacks.init),this.callback(this.callbacks.create)},getElapsed:function(){return this.count*this.interval},getElapsedTime:function(){return new Date(this.time+this.getElapsed())},reset:function(a){clearInterval(this.timer),this.count=0,this._setInterval(a),this.callback(this.callbacks.reset)},start:function(a){this.factory.running=!0,this._createTimer(a),this.callback(this.callbacks.start)},stop:function(a){this.factory.running=!1,this._clearInterval(a),this.callback(this.callbacks.stop),this.callback(a)},_clearInterval:function(){clearInterval(this.timer)},_createTimer:function(a){this._setInterval(a)},_destroyTimer:function(a){this._clearInterval(),this.timer=!1,this.callback(a),this.callback(this.callbacks.destroy)},_interval:function(a){this.callback(this.callbacks.interval),this.callback(a),this.count++},_setInterval:function(a){var b=this;b.timer=setInterval(function(){b._interval(a)},this.interval)}}),String.prototype.ucfirst=function(){return this.substr(0,1).toUpperCase()+this.substr(1)},a.fn.FlipClock=function(b,c){return"object"==typeof b&&(c=b,b=0),new FlipClock(a(this),b,c)},a.fn.flipClock=function(b,c){return a.fn.FlipClock(b,c)}}(jQuery),function(a){FlipClock.TwentyFourHourClockFace=FlipClock.Face.extend({constructor:function(a,b){a.countdown=!1,this.base(a,b)},build:function(b){var c=this,d=this.factory.$wrapper.find("ul");b=b?b:this.factory.time.time||this.factory.time.getMilitaryTime(),b.length>d.length&&a.each(b,function(a,b){c.factory.lists.push(c.createList(b))}),this.dividers.push(this.createDivider()),this.dividers.push(this.createDivider()),a(this.dividers[0]).insertBefore(this.factory.lists[this.factory.lists.length-2].$obj),a(this.dividers[1]).insertBefore(this.factory.lists[this.factory.lists.length-4].$obj),this._clearExcessDigits(),this.autoStart&&this.start()},flip:function(a){a=a?a:this.factory.time.getMilitaryTime(),this.base(a)},_clearExcessDigits:function(){for(var a=this.factory.lists[this.factory.lists.length-2],b=this.factory.lists[this.factory.lists.length-4],c=6;10>c;c++)a.$obj.find("li:last-child").remove(),b.$obj.find("li:last-child").remove()}})}(jQuery),function(a){FlipClock.CounterFace=FlipClock.Face.extend({autoStart:!1,constructor:function(a,b){a.timer.interval=0,a.autoStart=!1,a.running=!0,a.increment=function(){a.countdown=!1,a.setTime(a.getTime().time+1)},a.decrement=function(){a.countdown=!0,a.setTime(a.getTime().time-1)},a.setValue=function(b){a.setTime(b)},a.setCounter=function(b){a.setTime(b)},this.base(a,b)},build:function(){var b=this,c=this.factory.$wrapper.find("ul"),d=[],e=this.factory.getTime().digitize([this.factory.getTime().time]);e.length>c.length&&a.each(e,function(a,c){var e=b.createList(c);e.select(c),d.push(e)}),a.each(d,function(a,b){b.play()}),this.factory.lists=d},flip:function(a){var b=this.factory.getTime().digitize([this.factory.getTime().time]);this.base(b,a)}})}(jQuery),function(a){FlipClock.DailyCounterFace=FlipClock.Face.extend({showSeconds:!0,constructor:function(a,b){this.base(a,b)},build:function(b,c){var d=this,e=this.factory.$wrapper.find("ul"),f=[],g=0;c=c?c:this.factory.time.getDayCounter(this.showSeconds),c.length>e.length&&a.each(c,function(a,b){f.push(d.createList(b))}),this.factory.lists=f,this.showSeconds?a(this.createDivider("Seconds")).insertBefore(this.factory.lists[this.factory.lists.length-2].$obj):g=2,a(this.createDivider("Minutes")).insertBefore(this.factory.lists[this.factory.lists.length-4+g].$obj),a(this.createDivider("Hours")).insertBefore(this.factory.lists[this.factory.lists.length-6+g].$obj),a(this.createDivider("Days",!0)).insertBefore(this.factory.lists[0].$obj),this._clearExcessDigits(),this.autoStart&&this.start()},flip:function(a,b){b||(b=this.factory.time.getDayCounter(this.showSeconds)),this.base(b,a)},_clearExcessDigits:function(){for(var a=this.factory.lists[this.factory.lists.length-2],b=this.factory.lists[this.factory.lists.length-4],c=6;10>c;c++)a.$obj.find("li:last-child").remove(),b.$obj.find("li:last-child").remove()}})}(jQuery),function(a){FlipClock.HourlyCounterFace=FlipClock.Face.extend({clearExcessDigits:!0,constructor:function(a,b){this.base(a,b)},build:function(b,c){var d=this,e=this.factory.$wrapper.find("ul"),f=[];c=c?c:this.factory.time.getHourCounter(),c.length>e.length&&a.each(c,function(a,b){f.push(d.createList(b))}),this.factory.lists=f,a(this.createDivider("Seconds")).insertBefore(this.factory.lists[this.factory.lists.length-2].$obj),a(this.createDivider("Minutes")).insertBefore(this.factory.lists[this.factory.lists.length-4].$obj),b||a(this.createDivider("Hours",!0)).insertBefore(this.factory.lists[0].$obj),this.clearExcessDigits&&this._clearExcessDigits(),this.autoStart&&this.start()},flip:function(a,b){b||(b=this.factory.time.getHourCounter()),this.base(b,a)},_clearExcessDigits:function(){for(var a=this.factory.lists[this.factory.lists.length-2],b=this.factory.lists[this.factory.lists.length-4],c=6;10>c;c++)a.$obj.find("li:last-child").remove(),b.$obj.find("li:last-child").remove()}})}(jQuery),function(){FlipClock.MinuteCounterFace=FlipClock.HourlyCounterFace.extend({clearExcessDigits:!1,constructor:function(a,b){this.base(a,b)},build:function(){this.base(!0,this.factory.time.getMinuteCounter())},flip:function(a){this.base(a,this.factory.time.getMinuteCounter())}})}(jQuery),function(a){FlipClock.TwelveHourClockFace=FlipClock.TwentyFourHourClockFace.extend({meridium:!1,meridiumText:"AM",build:function(b){b=b?b:this.factory.time.time?this.factory.time.time:this.factory.time.getTime(),this.base(b),this.meridiumText=this._isPM()?"PM":"AM",this.meridium=a(['"].join("")),this.meridium.insertAfter(this.factory.lists[this.factory.lists.length-1].$obj)},flip:function(){this.meridiumText!=this._getMeridium()&&(this.meridiumText=this._getMeridium(),this.meridium.find("a").html(this.meridiumText)),this.base(this.factory.time.getTime())},_getMeridium:function(){return(new Date).getHours()>=12?"PM":"AM"},_isPM:function(){return"PM"==this._getMeridium()?!0:!1},_clearExcessDigits:function(){for(var a=this.factory.lists[this.factory.lists.length-2],b=this.factory.lists[this.factory.lists.length-4],c=6;10>c;c++)a.$obj.find("li:last-child").remove(),b.$obj.find("li:last-child").remove()}})}(jQuery),function(){FlipClock.Lang.German={years:"Jahre",months:"Monate",days:"Tage",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden"},FlipClock.Lang.de=FlipClock.Lang.German,FlipClock.Lang["de-de"]=FlipClock.Lang.German,FlipClock.Lang.german=FlipClock.Lang.German}(jQuery),function(){FlipClock.Lang.English={years:"Years",months:"Months",days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},FlipClock.Lang.en=FlipClock.Lang.English,FlipClock.Lang["en-us"]=FlipClock.Lang.English,FlipClock.Lang.english=FlipClock.Lang.English}(jQuery),function(){FlipClock.Lang.Spanish={years:"Años",months:"Meses",days:"DÍas",hours:"Horas",minutes:"Minutos",seconds:"Segundo"},FlipClock.Lang.es=FlipClock.Lang.Spanish,FlipClock.Lang["es-es"]=FlipClock.Lang.Spanish,FlipClock.Lang.spanish=FlipClock.Lang.Spanish}(jQuery),function(){FlipClock.Lang.French={years:"ans",months:"mois",days:"jours",hours:"heures",minutes:"minutes",seconds:"secondes"},FlipClock.Lang.fr=FlipClock.Lang.French,FlipClock.Lang["fr-ca"]=FlipClock.Lang.French,FlipClock.Lang.french=FlipClock.Lang.French}(jQuery),function(a){function b(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function c(a,b){return function(c){return k(a.call(this,c),b)}}function d(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function e(){}function f(a){w(a),h(this,a)}function g(a){var b=q(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function h(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function i(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&qb.hasOwnProperty(b)&&(c[b]=a[b]);return c}function j(a){return 0>a?Math.ceil(a):Math.floor(a)}function k(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.lengthd;d++)(c&&a[d]!==b[d]||!c&&s(a[d])!==s(b[d]))&&g++;return g+f}function p(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Tb[a]||Ub[b]||b}return a}function q(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=p(c),b&&(d[b]=a[c]));return d}function r(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}db[b]=function(e,f){var g,h,i=db.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=db().utc().set(d,a);return i.call(db.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function s(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function t(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function u(a){return v(a)?366:365}function v(a){return a%4===0&&a%100!==0||a%400===0}function w(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[jb]<0||a._a[jb]>11?jb:a._a[kb]<1||a._a[kb]>t(a._a[ib],a._a[jb])?kb:a._a[lb]<0||a._a[lb]>23?lb:a._a[mb]<0||a._a[mb]>59?mb:a._a[nb]<0||a._a[nb]>59?nb:a._a[ob]<0||a._a[ob]>999?ob:-1,a._pf._overflowDayOfYear&&(ib>b||b>kb)&&(b=kb),a._pf.overflow=b)}function x(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function y(a){return a?a.toLowerCase().replace("_","-"):a}function z(a,b){return b._isUTC?db(a).zone(b._offset||0):db(a).local()}function A(a,b){return b.abbr=a,pb[a]||(pb[a]=new e),pb[a].set(b),pb[a]}function B(a){delete pb[a]}function C(a){var b,c,d,e,f=0,g=function(a){if(!pb[a]&&rb)try{require("./lang/"+a)}catch(b){}return pb[a]};if(!a)return db.fn._lang;if(!m(a)){if(c=g(a))return c;a=[a]}for(;f0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&o(e,d,!0)>=b-1)break;b--}f++}return db.fn._lang}function D(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function E(a){var b,c,d=a.match(vb);for(b=0,c=d.length;c>b;b++)d[b]=Yb[d[b]]?Yb[d[b]]:D(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function F(a,b){return a.isValid()?(b=G(b,a.lang()),Vb[b]||(Vb[b]=E(b)),Vb[b](a)):a.lang().invalidDate()}function G(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(wb.lastIndex=0;d>=0&&wb.test(a);)a=a.replace(wb,c),wb.lastIndex=0,d-=1;return a}function H(a,b){var c,d=b._strict;switch(a){case"DDDD":return Ib;case"YYYY":case"GGGG":case"gggg":return d?Jb:zb;case"Y":case"G":case"g":return Lb;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Kb:Ab;case"S":if(d)return Gb;case"SS":if(d)return Hb;case"SSS":if(d)return Ib;case"DDD":return yb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Cb;case"a":case"A":return C(b._l)._meridiemParse;case"X":return Fb;case"Z":case"ZZ":return Db;case"T":return Eb;case"SSSS":return Bb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Hb:xb;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return xb;default:return c=new RegExp(P(O(a.replace("\\","")),"i"))}}function I(a){a=a||"";var b=a.match(Db)||[],c=b[b.length-1]||[],d=(c+"").match(Qb)||["-",0,0],e=+(60*d[1])+s(d[2]);return"+"===d[0]?-e:e}function J(a,b,c){var d,e=c._a;switch(a){case"M":case"MM":null!=b&&(e[jb]=s(b)-1);break;case"MMM":case"MMMM":d=C(c._l).monthsParse(b),null!=d?e[jb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[kb]=s(b));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=s(b));break;case"YY":e[ib]=s(b)+(s(b)>68?1900:2e3);break;case"YYYY":case"YYYYY":case"YYYYYY":e[ib]=s(b);break;case"a":case"A":c._isPm=C(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[lb]=s(b);break;case"m":case"mm":e[mb]=s(b);break;case"s":case"ss":e[nb]=s(b);break;case"S":case"SS":case"SSS":case"SSSS":e[ob]=s(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=I(b);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":a=a.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=b)}}function K(a){var b,c,d,e,f,g,h,i,j,k,l=[];if(!a._d){for(d=M(a),a._w&&null==a._a[kb]&&null==a._a[jb]&&(f=function(b){var c=parseInt(b,10);return b?b.length<3?c>68?1900+c:2e3+c:c:null==a._a[ib]?db().weekYear():a._a[ib]},g=a._w,null!=g.GG||null!=g.W||null!=g.E?h=Z(f(g.GG),g.W||1,g.E,4,1):(i=C(a._l),j=null!=g.d?V(g.d,i):null!=g.e?parseInt(g.e,10)+i._week.dow:0,k=parseInt(g.w,10)||1,null!=g.d&&ju(e)&&(a._pf._overflowDayOfYear=!0),c=U(e,0,a._dayOfYear),a._a[jb]=c.getUTCMonth(),a._a[kb]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=l[b]=d[b];for(;7>b;b++)a._a[b]=l[b]=null==a._a[b]?2===b?1:0:a._a[b];l[lb]+=s((a._tzm||0)/60),l[mb]+=s((a._tzm||0)%60),a._d=(a._useUTC?U:T).apply(null,l)}}function L(a){var b;a._d||(b=q(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],K(a))}function M(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function N(a){a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=C(a._l),h=""+a._i,i=h.length,j=0;for(d=G(a._f,g).match(vb)||[],b=0;b0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),Yb[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),J(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[lb]<12&&(a._a[lb]+=12),a._isPm===!1&&12===a._a[lb]&&(a._a[lb]=0),K(a),w(a)}function O(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function P(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function Q(a){var c,d,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;fg)&&(e=g,d=c));h(a,d||c)}function R(a){var b,c,d=a._i,e=Mb.exec(d);if(e){for(a._pf.iso=!0,b=0,c=Ob.length;c>b;b++)if(Ob[b][1].exec(d)){a._f=Ob[b][0]+(e[6]||" ");break}for(b=0,c=Pb.length;c>b;b++)if(Pb[b][1].exec(d)){a._f+=Pb[b][0];break}d.match(Db)&&(a._f+="Z"),N(a)}else a._d=new Date(d)}function S(b){var c=b._i,d=sb.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?R(b):m(c)?(b._a=c.slice(0),K(b)):n(c)?b._d=new Date(+c):"object"==typeof c?L(b):b._d=new Date(c)}function T(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function U(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function V(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function W(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function X(a,b,c){var d=hb(Math.abs(a)/1e3),e=hb(d/60),f=hb(e/60),g=hb(f/24),h=hb(g/365),i=45>d&&["s",d]||1===e&&["m"]||45>e&&["mm",e]||1===f&&["h"]||22>f&&["hh",f]||1===g&&["d"]||25>=g&&["dd",g]||45>=g&&["M"]||345>g&&["MM",hb(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,W.apply({},i)}function Y(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=db(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function Z(a,b,c,d,e){var f,g,h=U(a,0,1).getUTCDay();return c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:u(a-1)+g}}function $(a){var b=a._i,c=a._f;return null===b?db.invalid({nullInput:!0}):("string"==typeof b&&(a._i=b=C().preparse(b)),db.isMoment(b)?(a=i(b),a._d=new Date(+b._d)):c?m(c)?Q(a):N(a):S(a),new f(a))}function _(a,b){db.fn[a]=db.fn[a+"s"]=function(a){var c=this._isUTC?"UTC":"";return null!=a?(this._d["set"+c+b](a),db.updateOffset(this),this):this._d["get"+c+b]()}}function ab(a){db.duration.fn[a]=function(){return this._data[a]}}function bb(a,b){db.duration.fn["as"+a]=function(){return+this/b}}function cb(a){var b=!1,c=db;"undefined"==typeof ender&&(a?(gb.moment=function(){return!b&&console&&console.warn&&(b=!0,console.warn("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.")),c.apply(null,arguments)},h(gb.moment,c)):gb.moment=db)}for(var db,eb,fb="2.5.1",gb=this,hb=Math.round,ib=0,jb=1,kb=2,lb=3,mb=4,nb=5,ob=6,pb={},qb={_isAMomentObject:null,_i:null,_f:null,_l:null,_strict:null,_isUTC:null,_offset:null,_pf:null,_lang:null},rb="undefined"!=typeof module&&module.exports&&"undefined"!=typeof require,sb=/^\/?Date\((\-?\d+)/i,tb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,ub=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,vb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,wb=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,xb=/\d\d?/,yb=/\d{1,3}/,zb=/\d{1,4}/,Ab=/[+\-]?\d{1,6}/,Bb=/\d+/,Cb=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Db=/Z|[\+\-]\d\d:?\d\d/gi,Eb=/T/i,Fb=/[\+\-]?\d+(\.\d{1,3})?/,Gb=/\d/,Hb=/\d\d/,Ib=/\d{3}/,Jb=/\d{4}/,Kb=/[+-]?\d{6}/,Lb=/[+-]?\d+/,Mb=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Nb="YYYY-MM-DDTHH:mm:ssZ",Ob=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],Pb=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d{1,3}/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Qb=/([\+\-]|\d\d)/gi,Rb="Date|Hours|Minutes|Seconds|Milliseconds".split("|"),Sb={Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6},Tb={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},Ub={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},Vb={},Wb="DDD w W M D d".split(" "),Xb="M D H h m s w W".split(" "),Yb={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return k(this.year()%100,2)},YYYY:function(){return k(this.year(),4)},YYYYY:function(){return k(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+k(Math.abs(a),6)},gg:function(){return k(this.weekYear()%100,2)},gggg:function(){return k(this.weekYear(),4)},ggggg:function(){return k(this.weekYear(),5)},GG:function(){return k(this.isoWeekYear()%100,2)},GGGG:function(){return k(this.isoWeekYear(),4)},GGGGG:function(){return k(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return s(this.milliseconds()/100)},SS:function(){return k(s(this.milliseconds()/10),2)},SSS:function(){return k(this.milliseconds(),3)},SSSS:function(){return k(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+k(s(a/60),2)+":"+k(s(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+k(s(a/60),2)+k(s(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},Zb=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];Wb.length;)eb=Wb.pop(),Yb[eb+"o"]=d(Yb[eb],eb);for(;Xb.length;)eb=Xb.pop(),Yb[eb+eb]=c(Yb[eb],2);for(Yb.DDDD=c(Yb.DDD,3),h(e.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=db.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=db([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return Y(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),db=function(c,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=c,g._f=d,g._l=e,g._strict=f,g._isUTC=!1,g._pf=b(),$(g)},db.utc=function(c,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=c,g._f=d,g._strict=f,g._pf=b(),$(g).utc()},db.unix=function(a){return db(1e3*a)},db.duration=function(a,b){var c,d,e,f=a,h=null;return db.isDuration(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(f={},b?f[b]=a:f.milliseconds=a):(h=tb.exec(a))?(c="-"===h[1]?-1:1,f={y:0,d:s(h[kb])*c,h:s(h[lb])*c,m:s(h[mb])*c,s:s(h[nb])*c,ms:s(h[ob])*c}):(h=ub.exec(a))&&(c="-"===h[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},f={y:e(h[2]),M:e(h[3]),d:e(h[4]),h:e(h[5]),m:e(h[6]),s:e(h[7]),w:e(h[8])}),d=new g(f),db.isDuration(a)&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},db.version=fb,db.defaultFormat=Nb,db.updateOffset=function(){},db.lang=function(a,b){var c;return a?(b?A(y(a),b):null===b?(B(a),a="en"):pb[a]||C(a),c=db.duration.fn._lang=db.fn._lang=C(a),c._abbr):db.fn._lang._abbr},db.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),C(a)},db.isMoment=function(a){return a instanceof f||null!=a&&a.hasOwnProperty("_isAMomentObject")},db.isDuration=function(a){return a instanceof g},eb=Zb.length-1;eb>=0;--eb)r(Zb[eb]);for(db.normalizeUnits=function(a){return p(a)},db.invalid=function(a){var b=db.utc(0/0);return null!=a?h(b._pf,a):b._pf.userInvalidated=!0,b},db.parseZone=function(a){return db(a).parseZone()},h(db.fn=f.prototype,{clone:function(){return db(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=db(this).utc();return 00:!1},parsingFlags:function(){return h({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=F(this,a||db.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?db.duration(+b,a):db.duration(a,b),l(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?db.duration(+b,a):db.duration(a,b),l(this,c,-1),this},diff:function(a,b,c){var d,e,f=z(a,this),g=6e4*(this.zone()-f.zone());return b=p(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-db(this).startOf("month")-(f-db(f).startOf("month")))/d,e-=6e4*(this.zone()-db(this).startOf("month").zone()-(f.zone()-db(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:j(e)},from:function(a,b){return db.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(db(),a)},calendar:function(){var a=z(db(),this).startOf("day"),b=this.diff(a,"days",!0),c=-6>b?"sameElse":-1>b?"lastWeek":0>b?"lastDay":1>b?"sameDay":2>b?"nextDay":7>b?"nextWeek":"sameElse";return this.format(this.lang().calendar(c,this))},isLeapYear:function(){return v(this.year())},isDST:function(){return this.zone()+db(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+db(a).startOf(b)},isSame:function(a,b){return b=b||"ms",+this.clone().startOf(b)===+z(a,this).startOf(b)},min:function(a){return a=db.apply(null,arguments),this>a?this:a},max:function(a){return a=db.apply(null,arguments),a>this?this:a},zone:function(a){var b=this._offset||0;return null==a?this._isUTC?b:this._d.getTimezoneOffset():("string"==typeof a&&(a=I(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,b!==a&&l(this,db.duration(b-a,"m"),1,!0),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?db(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return t(this.year(),this.month())},dayOfYear:function(a){var b=hb((db(this).startOf("day")-db(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},quarter:function(){return Math.ceil((this.month()+1)/3)},weekYear:function(a){var b=Y(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=Y(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=Y(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},get:function(a){return a=p(a),this[a]()},set:function(a,b){return a=p(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=C(b),this)}}),eb=0;eb=7;)b-=7;return c?a.i18n.weekdaysShort[b]:a.i18n.weekdays[b]},v=function(a,b,c,d,e){if(e)return'';var f=[];return d&&f.push("is-disabled"),c&&f.push("is-today"),b&&f.push("is-selected"),'"},w=function(a,b){return""+(b?a.reverse():a).join("")+""},x=function(a){return""+a.join("")+""},y=function(a){var b,c=[];for(b=0;7>b;b++)c.push(''+u(a,b,!0)+"");return""+(a.isRTL?c.reverse():c).join("")+""},z=function(a){var b,c,d,e,f,g=a._o,h=a._m,i=a._y,j=i===g.minYear,k=i===g.maxYear,l='
    ',n=!0,o=!0;for(d=[],b=0;12>b;b++)d.push('");for(e='
    '+g.i18n.months[h]+'
    ",m(g.yearRange)?(b=g.yearRange[0],c=g.yearRange[1]+1):(b=i-g.yearRange,c=1+i+g.yearRange),d=[];c>b&&b<=g.maxYear;b++)b>=g.minYear&&d.push('");return f='
    '+i+g.yearSuffix+'
    ",l+=g.showMonthAfterYear?f+e:e+f,j&&(0===h||g.minMonth>=h)&&(n=!1),k&&(11===h||g.maxMonth<=h)&&(o=!1),l+='",l+='",l+="
    "},A=function(a,b){return''+y(a)+x(b)+"
    "},B=function(g){var h=this,i=h.config(g);h._onMouseDown=function(a){if(h._v){a=a||window.event;var b=a.target||a.srcElement;if(b){if(!j(b,"is-disabled")){if(j(b,"pika-button")&&!j(b,"is-empty"))return h.setDate(new Date(h._y,h._m,parseInt(b.innerHTML,10))),void(i.bound&&e(function(){h.hide()},100));j(b,"pika-prev")?h.prevMonth():j(b,"pika-next")&&h.nextMonth()}if(j(b,"pika-select"))h._c=!0;else{if(!a.preventDefault)return a.returnValue=!1,!1;a.preventDefault()}}}},h._onChange=function(a){a=a||window.event;var b=a.target||a.srcElement;b&&(j(b,"pika-select-month")?h.gotoMonth(b.value):j(b,"pika-select-year")&&h.gotoYear(b.value))},h._onInputChange=function(c){var d;c.firedBy!==h&&(b?(d=a(i.field.value,i.format),d=d&&d.isValid()?d.toDate():null):d=new Date(Date.parse(i.field.value)),h.setDate(n(d)?d:null),h._v||h.show())},h._onInputFocus=function(){h.show()},h._onInputClick=function(){h.show()},h._onInputBlur=function(){h._c||(h._b=e(function(){h.hide()},50)),h._c=!1},h._onClick=function(a){a=a||window.event;var b=a.target||a.srcElement,d=b;if(b){!c&&j(b,"pika-select")&&(b.onchange||(b.setAttribute("onchange","return;"),f(b,"change",h._onChange)));do if(j(d,"pika-single"))return;while(d=d.parentNode);h._v&&b!==i.trigger&&h.hide()}},h.el=d.createElement("div"),h.el.className="pika-single"+(i.isRTL?" is-rtl":""),f(h.el,"mousedown",h._onMouseDown,!0),f(h.el,"change",h._onChange),i.field&&(i.bound?d.body.appendChild(h.el):i.field.parentNode.insertBefore(h.el,i.field.nextSibling),f(i.field,"change",h._onInputChange),i.defaultDate||(i.defaultDate=b&&i.field.value?a(i.field.value,i.format).toDate():new Date(Date.parse(i.field.value)),i.setDefaultDate=!0));var k=i.defaultDate;n(k)?i.setDefaultDate?h.setDate(k,!0):h.gotoDate(k):h.gotoDate(new Date),i.bound?(this.hide(),h.el.className+=" is-bound",f(i.trigger,"click",h._onInputClick),f(i.trigger,"focus",h._onInputFocus),f(i.trigger,"blur",h._onInputBlur)):this.show()};return B.prototype={config:function(a){this._o||(this._o=s({},t,!0));var b=s(this._o,a,!0);b.isRTL=!!b.isRTL,b.field=b.field&&b.field.nodeName?b.field:null,b.bound=!!(void 0!==b.bound?b.field&&b.bound:b.field),b.trigger=b.trigger&&b.trigger.nodeName?b.trigger:b.field;var c=parseInt(b.numberOfMonths,10)||1;if(b.numberOfMonths=c>4?4:c,n(b.minDate)||(b.minDate=!1),n(b.maxDate)||(b.maxDate=!1),b.minDate&&b.maxDate&&b.maxDate100&&(b.yearRange=100);return b},toString:function(c){return n(this._d)?b?a(this._d).format(c||this._o.format):this._d.toDateString():""},getMoment:function(){return b?a(this._d):null},setMoment:function(c,d){b&&a.isMoment(c)&&this.setDate(c.toDate(),d)},getDate:function(){return n(this._d)?new Date(this._d.getTime()):null},setDate:function(a,b){if(!a)return this._d=null,this.draw();if("string"==typeof a&&(a=new Date(Date.parse(a))),n(a)){var c=this._o.minDate,d=this._o.maxDate;n(c)&&c>a?a=c:n(d)&&a>d&&(a=d),this._d=new Date(a.getTime()),q(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),h(this._o.field,"change",{firedBy:this})),b||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},gotoDate:function(a){n(a)&&(this._y=a.getFullYear(),this._m=a.getMonth(),this.draw())},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(a){isNaN(a=parseInt(a,10))||(this._m=0>a?0:a>11?11:a,this.draw())},nextMonth:function(){++this._m>11&&(this._m=0,this._y++),this.draw()},prevMonth:function(){--this._m<0&&(this._m=11,this._y--),this.draw()},gotoYear:function(a){isNaN(a)||(this._y=parseInt(a,10),this.draw())},setMinDate:function(a){this._o.minDate=a},setMaxDate:function(a){this._o.maxDate=a},draw:function(a){if(this._v||a){var b=this._o,c=b.minYear,d=b.maxYear,f=b.minMonth,g=b.maxMonth;if(this._y<=c&&(this._y=c,!isNaN(f)&&this._m=d&&(this._y=d,!isNaN(g)&&this._m>g&&(this._m=g)),this.el.innerHTML=z(this)+this.render(this._y,this._m),b.bound&&(this.adjustPosition(),"hidden"!==b.field.type&&e(function(){b.trigger.focus()},1)),"function"==typeof this._o.onDraw){var h=this;e(function(){h._o.onDraw.call(h)},0)}}},adjustPosition:function(){var a,b,c,e=this._o.trigger,f=e,g=this.el.offsetWidth,h=this.el.offsetHeight,i=window.innerWidth||d.documentElement.clientWidth,j=window.innerHeight||d.documentElement.clientHeight,k=window.pageYOffset||d.body.scrollTop||d.documentElement.scrollTop;if("function"==typeof e.getBoundingClientRect)c=e.getBoundingClientRect(),a=c.left+window.pageXOffset,b=c.bottom+window.pageYOffset;else for(a=f.offsetLeft,b=f.offsetTop+f.offsetHeight;f=f.offsetParent;)a+=f.offsetLeft,b+=f.offsetTop;(a+g>i||this._o.position.indexOf("right")>-1&&a-g+e.offsetWidth>0)&&(a=a-g+e.offsetWidth),(b+h>j+k||this._o.position.indexOf("top")>-1&&b-h-e.offsetHeight>0)&&(b=b-h-e.offsetHeight),this.el.style.cssText=["position: absolute","left: "+a+"px","top: "+b+"px"].join(";")},render:function(a,b){var c=this._o,d=new Date,e=p(a,b),f=new Date(a,b,1).getDay(),g=[],h=[];q(d),c.firstDay>0&&(f-=c.firstDay,0>f&&(f+=7));for(var i=e+f,j=i;j>7;)j-=7;i+=7-j;for(var k=0,l=0;i>k;k++){var m=new Date(a,b,1+(k-f)),o=c.minDate&&mc.maxDate,s=n(this._d)?r(m,this._d):!1,t=r(m,d),u=f>k||k>=e+f;h.push(v(1+(k-f),s,t,o,u)),7===++l&&(g.push(w(h,c.isRTL)),h=[],l=0)}return A(c,g)},isVisible:function(){return this._v},show:function(){this._v||(this._o.bound&&f(d,"click",this._onClick),l(this.el,"is-hidden"),this._v=!0,this.draw(),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var a=this._v;a!==!1&&(this._o.bound&&g(d,"click",this._onClick),this.el.style.cssText="",k(this.el,"is-hidden"),this._v=!1,void 0!==a&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){this.hide(),g(this.el,"mousedown",this._onMouseDown,!0),g(this.el,"change",this._onChange),this._o.field&&(g(this._o.field,"change",this._onInputChange),this._o.bound&&(g(this._o.trigger,"click",this._onInputClick),g(this._o.trigger,"focus",this._onInputFocus),g(this._o.trigger,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},B}),"object"!=typeof XIGENTIMER&&(XIGENTIMER={}),function(a){"use strict";var b,c,d=require("restler");a.API={base:function(a,e,f,g){var h,i,j,k,l,m,n,o={};"delete"===a.toLowerCase()&&(a="del"),h=function(){localforage.getItem("user",function(a){m=a.UserID,c=a.Name,o.headers={Authorization:i,"Content-Type":"application/json"},Object.keys(f)&&0!==Object.keys(f).length&&(o.data="object"==typeof f?JSON.stringify(f):f)}).then(j)},j=function(){d[a.toLowerCase()](b+e,o).on("complete",function(a,b){a&&(k="object"!=typeof a?JSON.parse(a):a,"object"!=typeof a&&(a=JSON.parse(a)),a.length||(a=[a]),n=a.filter(a[0].UserID?function(a){return a.UserID===m}:a[0].Members?function(a){return a.Members.split("\n").indexOf(c)>-1}:function(a){return a.CanCreateTimeEntries})),"function"==typeof g&&(200===b.statusCode||201===b.statusCode?g(!0,n,k):(g(!1),console.log(o.data,a)))}).on("error",function(a){alert("Network Error: "+JSON.stringify(a.request.options))})},l=function(){localforage.getItem("userToken",function(a){i=a}).then(h)},b?l():localforage.getItem("baseURL",function(a){b=a.indexOf("/rest/v1/")>-1?a:a+"/rest/v1/"}).then(l)},authoriseAPI:function(a,c){var e,f,g;g=function(){d.get(b+"users",{headers:{Authorization:e,"Content-Type":"application/json","Content-Length":2}}).on("complete",function(b){return b?(localforage.setItem("userCache",b),b=b.filter(function(b){return b.Login===a})[0],void c(!0,b)):(c(!1),!1)})},f=function(){e?localforage.getItem("baseURL",function(a){b=a.indexOf("/rest/v1/")>-1?a:a+"/rest/v1/"}).then(g):c(!1)},localforage.getItem("userToken",function(a){e=a}).then(f)},getHierachy:function(b,c){var d,e,f,g=[],h=[],i=[],j={},k=0;c||(c=b,b=!1),d=function(a,b){var c,d=[],e=[],g=[];return a=a.filter(function(a){return f.indexOf(a.TaskID)>-1}),a=a.filter(b?b:function(a){return a.EndDate&&(1===a.TaskStatusID||4===a.TaskStatusID)}),a=a.filter(function(a){return a.CanCreateTimeEntries===!0}),d=a.filter(function(a){return a.HasChild>0}),e=a.filter(function(a){return a.ParentID}),g=a.filter(function(a){return!a.ParentID&&!a.HasChild}),d.length>0?($.each(d,function(a,b){c=b.EntityBaseID,d[a].Activities||(d[a].Activities=[]),d[a].Activities=e.filter(function(a){return a.ParentID===c})}),g.length>0&&(d=d.concat(g)),d.filter(function(a){return a.Activities?!a.ParentID&&a.Activities.length>0:!a.ParentID})):a},e=function(){a.API.base("GET","projects",{},function(e,l){g=l,localforage.setItem("projectCache",l),$.each(l,function(e,l){l.Activities=[],j[l.EntityBaseID]=this,a.API.base("GET","projects/"+l.EntityBaseID+"/activities",{},function(a,e){k+=1,h=h.concat(e.filter(function(a){return f.indexOf(a.TaskID)>-1})),i=i.concat(e),j[l.EntityBaseID].Activities=d(e,b),k===g.length&&"function"==typeof c&&localforage.setItem("activityCache",h,function(){localforage.setItem("rawActivityCache",i,function(){var a=[];$.each(j,function(){a.push(this)}),a=a.sort(function(a,b){return a.Nameb.Name?1:0}),c(a)})})})})})},a.API.base("GET","myactivities",{},function(a,b){f=b.map(function(a){return a.TaskID}),e()})},getTimelogs:function(b){a.API.base("GET","timelogs",{},function(a,c,d){localforage.setItem("timelogCache",d),"function"==typeof b&&b(c)})},getTimeForTask:function(a,b){var c;localforage.getItem("timelogCache",function(d){c=d.filter(function(b){return b.TaskID===a}).map(function(a){return a.Duration}),c=c.length?c.reduce(function(a,b){return a+b}):0,b(c)})},getProjectName:function(a,b){var c;localforage.getItem("projectCache",function(d){c=d.filter(function(b){return b.ProjectID===a})[0].Name,"function"==typeof b&&b(c)})},logTime:function(b,c,d,e,f,g){var h,i=new Date;h=[i.getFullYear(),"-",1===i.getMonth().toString().length?"0"+(i.getMonth()+1):i.getMonth()+1,"-",1===i.getDate().toString().length?"0"+i.getDate():i.getDate(),"T",1===i.getHours().toString().length?"0"+i.getHours():i.getHours(),":",1===i.getMinutes().toString().length?"0"+i.getMinutes():i.getMinutes(),":",1===i.getSeconds().toString().length?"0"+i.getSeconds():i.getSeconds()].join(""),a.API.base("POST","timelogs",{UserID:b,Duration:d,TaskID:c,Description:f,Billable:e,EntryDate:h},function(a){g(a)})},markForReview:function(b,c){var d=XIGENTIMER.VIEWMODEL.taskTypeID();a.API.base("PUT","activities/"+b,{EntityBaseID:b,TaskStatusID:1===d?18:8},function(a){c(a)})},updateTimeLog:function(a,c,e,f){var g,h,i,j,k=!1;i=function(){d.get(b+"timelogs/"+a,{headers:{Authorization:g,"Content-Type":"application/json"}}).on("complete",function(a){j=a,j.Duration!==c&&(k=!0,j.Duration=parseFloat(c)),j.Description!==e&&(k=!0,j.Description=e),delete j.LastModificationDate,k?h():f(!0)})},h=function(){d.put(b+"timelogs/"+a,{headers:{Authorization:g,"Content-Type":"application/json"},data:JSON.stringify(j)}).on("complete",function(a,b){"function"==typeof f&&f(200===b.statusCode)})},localforage.getItem("userToken",function(a){g=a}).then(i)},pulse:function(a){var b;XIGENTIMER.VIEWMODEL.isChecking(!0),localforage.getItem("baseURL",function(a){a?b(a):(XIGENTIMER.VIEWMODEL.isConnected(!1),XIGENTIMER.VIEWMODEL.isChecking(!1))}),b=function(b){d.get(b).on("complete",function(b,c){c.statusCode&&(XIGENTIMER.VIEWMODEL.isConnected(!0),XIGENTIMER.VIEWMODEL.isChecking(!1),"function"==typeof a&&a(!0))}).on("error",function(){XIGENTIMER.VIEWMODEL.isConnected(!1),XIGENTIMER.VIEWMODEL.isChecking(!1),"function"==typeof a&&a(!1)})}},getUserDetails:function(a,b){var c=[];localforage.getItem("userCache",function(d){c=d.filter(function(b){return a.indexOf(b.UserID)>-1}),"function"==typeof b&&b(c)})}}}(XIGENTIMER),function(){"use strict";var a=require("os");XIGENTIMER.ViewModel=function(){var b=this;this.isLoggedIn=ko.observable(!1),this.isLoggedOut=ko.computed(function(){return!b.isLoggedIn()}),this.selectedProject=ko.observable(!1),this.isTiming=ko.observable(!1),this.isProjectManager=ko.observable(!1),localforage.getItem("user",function(a){!a||1!==a.RoleID&&2!==a.RoleID||b.isProjectManager(!0)}),this.activityDesc=ko.observable(""),this.isEditingTime=ko.observable(!1),this.isRestoringTime=ko.observable(!1),this.isViewingTasks=ko.observable(!1),this.isManaging=ko.observable(!1),this.taskTypeID=ko.observable(1),this.isOverview=ko.computed(function(){return!b.isEditingTime()&&b.isLoggedIn()&&!b.isRestoringTime()&&!b.isViewingTasks()&&!b.isManaging()}),this.dummy=ko.observable(),this.hasProjectSelected=ko.computed(function(){return!!b.selectedProject()}),this.canEdit=ko.computed(function(){return!b.isTiming()}),this.canSendTime=ko.computed(function(){return b.dummy(),!!b.activityDesc()&&!b.isTiming()&&XIGENTIMER.TIMER.getTime().time-1>0&&b.hasProjectSelected()&&b.isConnected()}),this.markText=ko.computed(function(){switch(b.taskTypeID()){case 1:return"Send for internal review";case 2:return"Mark as fixed";default:return"Send for internal review"}}),this.showMarkComplete=ko.computed(function(){return 3!==b.taskTypeID()}),this.notOSX=!/darwin/.test(a.platform()),this.supressChangeOne=ko.observable(!0),this.supressChangeTwo=ko.observable(!0),this.showReviewItems=ko.observable(!1),localforage.getItem("showReviewItems",function(a){a&&b.showReviewItems(a),b.supressChangeOne(!1)}),this.showInfiniteItems=ko.observable(!1),localforage.getItem("showInfiniteItems",function(a){a&&b.showInfiniteItems(a),b.supressChangeTwo(!1)}),this.showReviewItems.subscribe(function(a){b.supressChangeOne()?b.supressChangeOne(!1):(a===!0?$("body").addClass("show-review"):$("body").removeClass("show-review"),localforage.setItem("showReviewItems",a),b.updateFromFilters())}),this.showInfiniteItems.subscribe(function(a){b.supressChangeTwo()?b.supressChangeTwo(!1):(a===!0?$("body").addClass("show-infinite"):$("body").removeClass("show-infinite"),localforage.setItem("showInfiniteItems",a),b.updateFromFilters())}),this.updateFromFilters=function(a){var c=b.showReviewItems(),d=b.showInfiniteItems();$(".do-refresh").addClass("is-refreshing").attr("disabled","disabled"),XIGENTIMER.drawProjects(function(){$(".do-refresh").removeClass("is-refreshing").removeAttr("disabled"),b.isProjectManager()&&XIGENTIMER.drawManagedTaskList(),XIGENTIMER.drawTaskList(),"function"==typeof a&&a()},c,d)},this.selectTiming=function(){b.isEditingTime(!0),b.isRestoringTime(!1),b.isViewingTasks(!1),b.isManaging(!1)},this.selectOverview=function(){b.isEditingTime(!1),b.isRestoringTime(!1),b.isViewingTasks(!1),b.isManaging(!1)},this.selectRestore=function(){b.isEditingTime(!1),b.isRestoringTime(!0),b.isViewingTasks(!1),b.isManaging(!1)},this.selectTasks=function(){b.isEditingTime(!1),b.isRestoringTime(!1),b.isViewingTasks(!0),b.isManaging(!1)},this.selectManagement=function(){b.isEditingTime(!1),b.isRestoringTime(!1),b.isViewingTasks(!1),b.isManaging(!0)},this.recalcCanSend=function(){b.dummy.notifySubscribers()},this.reset=function(a){a&&(b.isLoggedIn(!1),b.isEditingTime(!1)),b.activityDesc(""),b.isTiming(!1),b.recalcCanSend(),b.selectedProject(!1)},this.isConnected=ko.observable(!1),this.isChecking=ko.observable(!1),this.connectedText=ko.computed(function(){return b.isProjectManager()?b.isConnected()&&!b.isChecking()?"OK":b.isChecking()?"...":"!OK":b.isConnected()&&!b.isChecking()?"Connected to System":b.isChecking()?"Checking pulse...":"Not Connected."}),this.checkPulse=function(){XIGENTIMER.API.pulse()},this.savedStates=ko.observableArray([]),localforage.getItem("savedStates",function(a){a&&b.savedStates(a)}),this.saveState=function(){XIGENTIMER.STATE.save()},this.savedStates.subscribe(function(a){localforage.setItem("savedStates",a)}),this.canSaveState=ko.computed(function(){return!b.isTiming()&&b.hasProjectSelected()}),this.taskList=ko.observableArray([]),this.managedTaskList=ko.observableArray([]),this.managedShowOpen=ko.observable(!0),this.managedShowReview=ko.observable(!1),this.managedShowPending=ko.observable(!1),this.managedShowOpen.subscribe(function(){XIGENTIMER.drawManagedTaskList()}),this.managedShowReview.subscribe(function(){XIGENTIMER.drawManagedTaskList()}),this.managedShowPending.subscribe(function(){XIGENTIMER.drawManagedTaskList()}),this.priorities={5:"Mission Critical",4:"Urgent",3:"High",2:"Medium",1:"Low"},this.dateMagnitude=function(a){return 0===a?"today":0>a&&a>=-7?"overdue":-7>a?"super-overdue":a>0&&7>=a?"ontime":a>7?"super-ontime":"nodate"}},$(function(){XIGENTIMER.VIEWMODEL=new XIGENTIMER.ViewModel,ko.applyBindings(XIGENTIMER.VIEWMODEL)})}(XIGENTIMER),function(){"use strict";var a,b={TEXT_ELEMENT:"span",ACTIVE_CLASS:"is-open",BREADCRUMB_CLASS:".breadcrumbs",CLEAR_CLASS:".do-clearfilter"},c=require("nw.gui"),d=new c.Menu;d.append(new c.MenuItem({label:"Log time on this item"})),d.append(new c.MenuItem({label:"View in browser"})),a=function(a){localforage.getItem("baseURL",function(b){XIGENTIMER.launchExternal(b+"/TaskDetails.aspx?ID="+a)})},XIGENTIMER.ProjectFilter=function(a,b){return!this instanceof XIGENTIMER.ProjectFilter?new XIGENTIMER.ProjectFilter(arguments):(this.list=a.jquery?a:$(a),this.input=b.jquery?b:$(b),this.setup(),void this.addHandlers())},XIGENTIMER.ProjectFilter.prototype.setup=function(){var a=this;this.elements=[],$.each(this.list.children("li"),function(){a.elements.push({el:this,text:$(this).children("span").first().text()}),this.remove()}),this.showElements(this.matchText($(this.input).val()))},XIGENTIMER.ProjectFilter.prototype.refresh=function(a){this.setup(),this.draw(),$("span",this.list).each(function(){a.indexOf($(this).text())>-1&&($(this).addClass(b.ACTIVE_CLASS),$(this).parent("li").children("ul").toggle())})},XIGENTIMER.ProjectFilter.prototype.matchText=function(a){return a?this.elements.filter(function(b){return b.text.toLowerCase().indexOf(a.toLowerCase())>-1}):this.elements},XIGENTIMER.ProjectFilter.prototype.showElements=function(a){var c=this;c.list.empty(),$.each(a,function(){c.list.append(this.el)}),$("span",this.list).removeClass(b.ACTIVE_CLASS),this.draw()},XIGENTIMER.ProjectFilter.prototype.addHandlers=function(){var c=this;this.input.on("keyup",function(a){9!==a.which&&c.showElements(c.matchText($(this).val()))}),$(b.CLEAR_CLASS).on("click",function(){$(c.input).val(""),c.showElements(c.matchText($(c.input).val()))}),$(this.list).on("click","li span",function(){$(this).toggleClass(b.ACTIVE_CLASS),$(this).parent("li").children("ul").toggle()}),$(document).on("contextmenu",function(b){return $(b.target).parents("ul").length>1?(b.preventDefault(),d.items[1].click=function(){a($(b.target).closest("li").attr("data-id"))},d.items[0].click=function(){c.selectActivity(b.target)},d.popup(b.originalEvent.x,b.originalEvent.y),!1):void 0})},XIGENTIMER.ProjectFilter.prototype.draw=function(){$("li ul",this.list).hide();var a=$(b.BREADCRUMB_CLASS),c=this;XIGENTIMER.BREADCRUMB_EMPTY||(XIGENTIMER.BREADCRUMB_CONTAINER=a,XIGENTIMER.BREADCRUMB_EMPTY=a.contents()),$(this.list).on("click","a",function(a){a.preventDefault(),c.selectActivity(this)})},XIGENTIMER.ProjectFilter.prototype.selectActivity=function(a){{var b,c,d,e=parseInt($(a).parents("li").attr("data-id"),10),f=a,g=[],h=$(a).find(".label");XIGENTIMER.BREADCRUMB_CONTAINER}XIGENTIMER.VIEWMODEL.taskTypeID(h.hasClass("alert")?2:h.hasClass("success")?3:1),$(f).parents("li").each(function(){g.push($(this).find("span").first().text())}),g=g.filter(function(a){return""!==a}).reverse(),g=g.join(" » "),$(".is-projectText").text("Selected Task: "+g),Foundation.libs.tooltip.getTip($(".is-projectText")).remove(),$(".is-projectText").attr("title",g),$("[data-estimate]").text(b||"Working..."),$("[data-sofar]").text(c||"Working..."),XIGENTIMER.VIEWMODEL.selectedProject(e),localforage.getItem("activityCache",function(a){d=a.filter(function(a){return a.EntityBaseID===e})[0]||{},b=d.EstimatedHours?d.EstimatedHours.toFixed(2):!1,XIGENTIMER.API.getTimeForTask(e,function(a){c=a.toFixed(2),$("[data-estimate]").text(b||"0.00"),$("[data-sofar]").text(c||"---")})})}}(),function(){var a,b,c=require("nw.gui"),d=c.Window.get(),e=new c.Menu;e.append(new c.MenuItem({type:"normal",label:"Show Timer"})),XIGENTIMER.launchExternal=function(a){c.Shell.openExternal(a)},XIGENTIMER.close=function(){XIGENTIMER.VIEWMODEL.isLoggedIn()&&(XIGENTIMER.VIEWMODEL.isTiming()||XIGENTIMER.TIMER.getTime().time>1)?(XIGENTIMER.VIEWMODEL.isTiming()?b="Timer is running, are you sure you want to close?":XIGENTIMER.TIMER.getTime().time>1&&(b="There is time on the clock which hasn't been sent yet. Are you sure you want to close?"),confirm(b)&&d.close()):d.close()},XIGENTIMER.minimize=function(){d.minimize()},XIGENTIMER.goToTray=function(){d.once("minimize",function(){this.hide(),a=new c.Tray({icon:"assets/img/xigen_logo_whiteout.png"}),a.on("click",function(){d.show(),this.remove(),a=null}),a.menu=e,e.items[0].click=function(){d.show(),a.remove(),a=null}}),d.minimize()}}(),function(a){var b;b=function(a){var c,d,e,f,g=document.createDocumentFragment();return a.length||(a=[a]),$.each(a,function(){switch(f=!0,c=document.createElement("li"),c.setAttribute("data-id",this.EntityBaseID),this.CanCreateTimeEntries===!1&&(f=!1),this.TaskTypeID){case 2:e="
    Issue
    ";break;case 3:e="
    Request
    ";break;default:e="
    Task
    "}$(c).append(0===this.HasChild||this.HasChild>0&&0===this.Activities.length?""+e+""+this.Name+"":""+this.Name+""),this.Activities&&this.Activities.length>0?(d=$("
      "),$.each(this.Activities,function(){d.append(b(this))}),$(c).append(d)):f=!1,f&&g.appendChild(c)}),c},a.drawProjects=function(c,d,e){var f=document.createDocumentFragment(),g=[],h=!1;d&&!e?h=function(a){return a.EndDate&&(1===a.TaskStatusID||4===a.TaskStatusID||18===a.TaskStatusID)}:d&&e?h=function(a){return 1===a.TaskStatusID||4===a.TaskStatusID||18===a.TaskStatusID}:e&&!d&&(h=function(a){return 1===a.TaskStatusID||4===a.TaskStatusID}),$(".side-nav .is-open").each(function(){g.push($(this).text())}),a.API.getHierachy(h,function(a){$.each(a,function(){this.Activities.length>0&&$(f).append(b(this))}),$(".side-nav").empty().append(f),XIGENTIMER.SidebarFilter?(console.log(g),XIGENTIMER.SidebarFilter.refresh(g)):XIGENTIMER.SidebarFilter=new XIGENTIMER.ProjectFilter($(".side-nav"),$(".sidebar-filter-wrap input")),"function"==typeof c&&(c(),XIGENTIMER.updateDatePickers())})}}(XIGENTIMER),$(function(){"use strict";var a,b,c,d=require("nw.gui"),e=$(".login [type=submit]"),f=[];$(document).foundation(),$(".login").hide(),$(".datepicker").each(function(){b=new Pikaday({field:this,firstDay:1,defaultDate:new Date,setDefaultDate:!0,maxDate:new Date,format:"D MMM YYYY",onSelect:function(){XIGENTIMER.updateDatePickers()}}),$(this).data("picker",b),f.push(b)}),$("[data-logout]").on("click",function(a){return a.preventDefault(),XIGENTIMER.VIEWMODEL.savedStates().length>0&&!confirm("You have saved states which will be lost if you log out. Are you sure you want to continue?")?!1:(localforage.setItem("userToken",null),localforage.setItem("userName",null),localforage.setItem("baseURL",null),localforage.setItem("user",null),localforage.setItem("savedStates",null),XIGENTIMER.reset(),XIGENTIMER.VIEWMODEL.reset(!0),void $(".login").fadeIn(200))}),c=function(){e.text("Incorrect login, try again :)"),e.addClass("alert"),setTimeout(function(){e.text(a).removeClass("alert")},1500)},$("[data-login]").on("submit",function(b){b.preventDefault();var d=$("[name=password]",this).val(),f=$("[name=user]",this).val(),g=$("[name=baseURL]",this).val();a=e.text(),e.text("Logging in..."),f&&d&&g?localforage.setItem("baseURL",g).then(XIGENTIMER.authoriseUser(f,d,function(b,d){b?(e.text(a),localforage.setItem("userToken",d),localforage.setItem("userName",b.Login),localforage.setItem("baseURL",g),XIGENTIMER.VIEWMODEL.isLoggedIn(!0),localforage.setItem("user",b).then(function(){XIGENTIMER.VIEWMODEL.updateFromFilters(function(){XIGENTIMER.updateDatePickers()}),XIGENTIMER.API.pulse(),XIGENTIMER.drawTaskList(),setTimeout(function(){XIGENTIMER.API.pulse()},3e4)})):c()})):c()}),localforage.getItem("userToken",function(a){localforage.getItem("baseURL",function(b){a&&b?XIGENTIMER.authoriseUser(function(){XIGENTIMER.VIEWMODEL.isLoggedIn(!0),XIGENTIMER.VIEWMODEL.updateFromFilters(function(){XIGENTIMER.updateDatePickers()}),XIGENTIMER.API.pulse(),XIGENTIMER.drawTaskList(),setTimeout(function(){XIGENTIMER.API.pulse()},3e4)}):$(".login").fadeIn(200)})}),$(".do-reset").on("click",function(){XIGENTIMER.reset()}),$(".time-table-tasks").on("click",".do-selectTask",function(){XIGENTIMER.selectTask(this)}),$(".do-viewonline").on("click",function(){return $(this).attr("disabled")?!1:void d.Window.open("viewActivity.html?activityID="+$(this).attr("data-id"),{frame:!1,title:$(".breadcrumb li").last().text(),width:850,max_width:850,height:450,max_height:450,min_width:800,min_height:400,toolbar:!1})}),$("body").on("click","a",function(a){if("_system"===$(this).attr("target")&&(a.preventDefault(),XIGENTIMER.launchExternal($(this).attr("href"))),"_viewProject"===$(this).attr("target")){a.preventDefault();var b=$(this).text();d.Window.open("viewActivity.html?activityID="+$(this).attr("data-id"),{frame:!1,title:b,width:850,max_width:850,height:450,max_height:450,min_width:800,min_height:400,toolbar:!1})}if("_manageProject"===$(this).attr("target")){a.preventDefault();var b=$(this).text();d.Window.open("ManageActivity.html?activityID="+$(this).attr("data-id"),{frame:!1,title:b,width:850,max_width:850,height:450,max_height:450,min_width:800,min_height:450,toolbar:!1})}}),XIGENTIMER.BREADCRUMB_CONTAINER=$(".breadcrumbs"),XIGENTIMER.BREADCRUMB_EMPTY=$(".breadcrumbs").contents(),$(".time-table").on("click",".do-editTimeLog",function(){XIGENTIMER.editTimeLog($(this).parents("tr").attr("data-id"),this)}),$("#desc, .filter-text").on("keydown",function(a){(32===a.which||32===a.keyCode)&&a.stopPropagation()}),$(document).on("keyCombo",function(a,b){var c,e=b.combo; -"SUBMIT"===e&&XIGENTIMER.sendTime(),("REFRESH"===e||"REFRESH_ALT"===e)&&XIGENTIMER.VIEWMODEL.updateFromFilters(),("SETTINGS"===e||"SETTINGS_ALT"===e)&&$("#settingsMenu").foundation("reveal","open"),"EDIT"===e&&(XIGENTIMER.VIEWMODEL.isTiming()||$("#customTime").foundation("reveal","open")),"FIND"===e&&$(".filter-text").focus(),"PLAYPAUSE"===e&&$(".do-timestart").trigger("click"),"ONE"===e&&XIGENTIMER.VIEWMODEL.selectOverview(),"TWO"===e&&XIGENTIMER.VIEWMODEL.selectTasks(),"THREE"===e&&XIGENTIMER.VIEWMODEL.selectTiming(),"FOUR"===e&&XIGENTIMER.VIEWMODEL.selectRestore(),"DESC"===e&&$("#desc").focus(),"LOGOUT"===e&&(c=$(document.activeElement),"filter-text"===c[0].className&&$(".do-clearfilter").trigger("click")),"HELP"===e&&$("#shortcutMenu").foundation("reveal","open"),"VIEW"===e&&("TEXTAREA"!==document.activeElement.tagName?$(".do-viewonline").trigger("click"):$(document.activeElement).val($(document.activeElement).val()+d.Clipboard.get().get("text")))}),$(document).on("open","[data-reveal]",function(){var a=$(this);"customTime"===a[0].id&&setTimeout(function(){a.find("input").first().focus()},200)}),$(".icon-min").on("click",function(){XIGENTIMER.minimize()}),$(".icon-hide").on("click",function(){XIGENTIMER.goToTray()}),$(".icon-close").on("click",function(){XIGENTIMER.close()}),$(".do-refresh").on("click",function(){XIGENTIMER.VIEWMODEL.updateFromFilters(function(){$(".do-refresh").removeClass("is-refreshing").removeAttr("disabled")}),XIGENTIMER.updateDatePickers()})}),$(function(){"use strict";var a,b={ERROR_CLASS:"error",UPDATE_CLASS:"do-update",MODAL_ID:"customTime",CLOSE_CLASS:"do-close"};a=function(a){var c,d,e,f=$("#"+b.MODAL_ID),g=!0;a.preventDefault(),c=f.find("[name=hours]"),d=f.find("[name=minutes]"),e=f.find("[name=seconds]"),$.each([c,d,e],function(){$(this).val()?$(this).prev("label").removeClass(b.ERROR_CLASS):($(this).prev("label").addClass(b.ERROR_CLASS),$(this).on("keyup",function(){$(this).val()?$(this).prev("label").removeClass(b.ERROR_CLASS):$(this).prev("label").addClass(b.ERROR_CLASS)}),g=!1)}),g&&(c=60*parseInt(c.val(),10)*60,d=60*parseInt(d.val(),10),e=parseInt(e.val(),10),XIGENTIMER.TIMER.setTime(c+d+e),f.foundation("reveal","close"),XIGENTIMER.VIEWMODEL.recalcCanSend())},$("."+b.UPDATE_CLASS).on("click",function(b){a(b)}),$(document).on("keyup",function(b){13===b.which&&a(b)}),$("#"+b.MODAL_ID).on("click","."+b.CLOSE_CLASS,function(){$("#"+b.MODAL_ID).foundation("reveal","close")}),XIGENTIMER.UPDATEPOPUP=$("#"+b.MODAL_ID)}),$(function(){"use strict";var a,b,c,d={DO_STARTTIME:"do-timestart",DO_PAUSE:"do-timestop",TEXT_RUNNING:"Pause",TEXT_PAUSED:""},e=XIGENTIMER.UPDATEPOPUP,f=e.find("[name=hours]"),g=e.find("[name=minutes]"),h=e.find("[name=seconds]");d.TEXT_PAUSED=$("."+d.DO_STARTTIME).text(),XIGENTIMER.TIMER=$(".timer").FlipClock({autoStart:!1}),XIGENTIMER.VIEWMODEL.isTiming(!1),$("."+d.DO_STARTTIME).on("click",function(){return $(this).attr("disabled")?!1:void(XIGENTIMER.VIEWMODEL.isTiming()?(XIGENTIMER.TIMER.stop(function(){c=XIGENTIMER.TIMER.getTime()-1,a=Math.floor(c/3600),c-=3600*a,b=Math.floor(c/60),c-=60*b,f.val(a),g.val(b),h.val(c),XIGENTIMER.VIEWMODEL.isTiming(!1)}),$(this).text(d.TEXT_PAUSED)):(XIGENTIMER.TIMER.start(),XIGENTIMER.VIEWMODEL.isTiming(!0),$(this).text(d.TEXT_RUNNING)))})}),$(function(){"use strict";var a={SEND_CLASS:"do-send",PENDING_TEXT:"Sending...",MARKING_TEXT:"Marking for review...",SUCCESS_TEXT:"Done!",ERROR_TEXT:"Error :(",DESC_SEL:"[id=desc]"};a.DEFAULT_TEXT=$("."+a.SEND_CLASS).text(),$("."+a.SEND_CLASS).on("click",function(){XIGENTIMER.sendTime()}),XIGENTIMER.sendTime=function(){var b,c,d,e=$(a.DESC_SEL).val(),f=XIGENTIMER.VIEWMODEL.selectedProject(),g=$("#isBillable").prop("checked"),h=$("#markReview").prop("checked"),i=$("."+a.SEND_CLASS);return XIGENTIMER.VIEWMODEL.canSendTime()?(b=XIGENTIMER.TIMER.getTime()/3600,b=b.toFixed(2),d=function(){i.text(a.SUCCESS_TEXT),setTimeout(function(){i.text(a.DEFAULT_TEXT)},3e3)},i.text(a.PENDING_TEXT),void localforage.getItem("user",function(a){c=a.UserID}).then(function(){XIGENTIMER.API.logTime(c,f,b,g,e,function(b){b?(h?XIGENTIMER.API.markForReview(f,function(){d()}):d(),XIGENTIMER.reset()):(i.removeClass("info").addClass("alert").text(a.ERROR_TEXT),setTimeout(function(){i.text(a.DEFAULT_TEXT).addClass("info").removeClass("alert")},1500))})})):!1}}),function(){"use strict";function a(a,b){var c,d,e,f,g;localforage.getItem("activityCache",function(b){c=b.filter(function(b){return b.TaskID===a})[0],c&&(d=c.Name,f=c.EntityBaseID,g())}),g=function(){localforage.getItem("projectCache",function(a){c=a.filter(function(a){return a.ProjectID===c.ProjectID})[0],e=c.Name,b([d,e,f])})}}function b(){var a=new Date;return[a.getFullYear(),1===a.getMonth().toString().length?"0"+(a.getMonth()+1):a.getMonth()+1,1===a.getDate().toString().length?"0"+a.getDate():a.getDate()].join("-")}var c={TABLE_CLASS:".time-table-logs",TEXT_EDIT:"Edit",TEXT_SAVE:"Save",TEXT_SAVING:"Saving..."};XIGENTIMER.renderTimeLogs=function(d){XIGENTIMER.API.getTimelogs(function(e){var f,g,h,i,j=$(c.TABLE_CLASS+" tbody"),k=(b(),0),l=document.createDocumentFragment(),m=0;if(e=e.filter(function(a){return g=+moment(a.EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),"Locked"!==a.Locked&&a.Duration&&!a.Approved&&g>=d[0]&&g<=d[1]}).sort(function(a,b){return h=+moment(a.EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),i=+moment(b.EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),i>h?-1:h>i?1:0}).reverse(),$(e).each(function(){m+=this.Duration}),$("[data-totalHours]").val(m.toFixed(2)),e.length>0)$.each(e,function(b){a(this.TaskID,function(a){f=a;var d=document.createElement("tr");d.setAttribute("data-id",e[b].EntityBaseID),d.setAttribute("data-taskId",e[b].TaskID),g=moment(e[b].EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),$(d).append(""+g.calendar()+"
      ("+g.format("DD-MM-YYYY")+")"),$(d).append(""+f[1]+":
      "+f[0]+""),$(d).append(""+e[b].Duration.toFixed(2)+""),$(d).append(""+e[b].Description+""),$(d).append(""),l.appendChild(d),k+=1,k===e.length&&(j.empty(),j[0].appendChild(l),$.each(j.find("tr"),function(){ko.applyBindings(XIGENTIMER.VIEWMODEL,this)}))})});else{var n=document.createElement("tr");$(n).append("No time logged for these dates - Do some work!"),l.appendChild(n),j.empty(),j[0].appendChild(l)}})},XIGENTIMER.editTimeLog=function(a,b){var d=$(c.TABLE_CLASS+" tbody").find("[data-id='"+a+"']"),e=(d.attr("data-taskId"),d.find("td").eq(3)),f=d.find("td").eq(2),g=e.text(),h=f.text(),i=/[0-9]{1,2}\.[0-9]{1,2}/,j=!0;b.jquery||(b=$(b)),f.html(""),e.html(""),b.text(c.TEXT_SAVE),b.on("click",function(){g=e.find("textarea").val(),h=f.find("input").val(),i.test(h)||(f.find("input").addClass("error"),j=!1,f.find("input").on("keyup",function(){i.test($(this).val())?(f.find("input").removeClass("error"),j=!0):f.find("input").addClass("error")})),j&&(b.attr("disabled","disabled"),b.text(c.TEXT_SAVING),XIGENTIMER.API.updateTimeLog(a,h,g,function(){e.html(g),f.html(h),b.removeAttr("disabled"),b.text(c.TEXT_EDIT),b.off("click")}))})},XIGENTIMER.updateDatePickers=function(){var a=$("[data-start]").data("picker"),b=$("[data-end]").data("picker"),c=[];b.setMinDate(a.getDate()),a.setMaxDate(b.getDate()),c.push(+a.getDate()),c.push(+moment(b.getDate()).add("hours",24)),XIGENTIMER.renderTimeLogs(c)}}(),function(a){"use strict";var b,c,d,e,f,g;b=function(){console.log("Getting token"),localforage.getItem("userToken",function(a){e=a?a:!1}).then(d.apply(this,arguments))},d=function(a){localforage.getItem("userName",function(a){f=a}).then(a)},c=function(a,b){var c=arguments;!e||a&&b?(e="Basic "+new Buffer(a+":"+b).toString("base64"),localforage.setItem("userToken",e).then(function(){g.apply(this,c)})):g.apply(this,arguments)},g=function(a,b,c){b||c||(c=a,a=f),XIGENTIMER.API.authoriseAPI(a,function(a,b){c(b,e)})},a.authoriseUser=function(){var a=arguments,d=this;b(function(){c.apply(d,a)})}}(XIGENTIMER),function(a){"use strict";var b={DESC_SEL:"[id=desc]",BILLABLE_CHECKBOX:"#isBillable",REVIEW_CHECKBOX:"#markReview"};a.reset=function(){XIGENTIMER.TIMER.setTime(0),a.VIEWMODEL.isTiming()&&$(".do-timestart").trigger("click"),XIGENTIMER.UPDATEPOPUP.find("input").val(0),$(b.DESC_SEL).val("").trigger("change"),$(b.BILLABLE_CHECKBOX).prop("checked",!0),$(b.REVIEW_CHECKBOX).prop("checked",!1),XIGENTIMER.VIEWMODEL.reset(!1),$(".is-projectText").text("Select a task on the left to begin."),Foundation.libs.tooltip.getTip($(".is-projectText")).remove(),$(".is-projectText").attr("title","Select a task on the left to begin."),XIGENTIMER.updateDatePickers()}}(XIGENTIMER),function(a){"use strict";var b,c={CTRL:"modifier",ESC:27,ENT:13,SPACE:32,F5:116,E:69,F:70,L:76,S:83,R:82,T:84,D:68,COMMA:188,QM:191,V:86,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54};a.shortCuts={SUBMIT:[c.CTRL,c.ENT],PLAYPAUSE:[c.SPACE],LOGOUT:[c.ESC],FIND:[c.CTRL,c.F],REFRESH:[c.F5],REFRESH_ALT:[c.CTRL,c.R],EDIT:[c.CTRL,c.E],LOGS:[c.CTRL,c.L],TIMER:[c.CTRL,c.T],SETTINGS:[c.CTRL,c.S],SETTINGS_ALT:[c.CTRL,c.COMMA],DESC:[c.CTRL,c.D],HELP:[c.CTRL,c.QM],VIEW:[c.CTRL,c.V],ONE:[c.CTRL,c.ONE],TWO:[c.CTRL,c.TWO],THREE:[c.CTRL,c.THREE],FOUR:[c.CTRL,c.FOUR]},b=function(b){var c,d,e=b.ctrlKey||b.metaKey,f=[];return e&&f.push("modifier"),f.push(b.which),$.each(a.shortCuts,function(a,b){c=!0,f.length===b.length?$.each(b,function(a,b){b!==f[a]&&(c=!1)}):c=!1,c&&(d=a)}),d},$(document).on("keydown",function(a){b(a)&&(a.preventDefault(),$(document).trigger("keyCombo",{combo:b(a)}))}),$(document).on("keyCombo",function(a,b){console.log(b.combo)})}(XIGENTIMER),function(a){"use strict";var b,c={BILLABLE_SEL:"#isBillable",REVIEW_SEL:"#markReview",RESTORE_SEL:".do-restore",DELETE_SEL:".do-deleteState",STATE_TABLE:".time-table-state"};$(c.STATE_TABLE).on("click",c.RESTORE_SEL,function(){b=parseInt($(this).parents("tr").attr("data-id"),10),a.STATE.restore(b)}),$(c.STATE_TABLE).on("click",c.DELETE_SEL,function(){console.log("Delete state"),b=parseInt($(this).parents("tr").attr("data-id"),10),a.VIEWMODEL.savedStates.splice(b,1)}),a.STATE={save:function(){var b=$(".is-projectText").text().split("»");return a.VIEWMODEL.savedStates.push({TaskName:b[b.length-1].trim(),ProjectName:b[0].trim(),Breadcrumb:$(".is-projectText").text().split("Selected Task:")[1],TaskID:XIGENTIMER.VIEWMODEL.selectedProject(),TaskType:XIGENTIMER.VIEWMODEL.taskTypeID(),TimeLogged:[(XIGENTIMER.TIMER.getTime().time/3600).toFixed(2),XIGENTIMER.TIMER.getTime().time],Desc:XIGENTIMER.VIEWMODEL.activityDesc(),Billable:$(c.BILLABLE_SEL).is(":checked"),ForReview:$(c.REVIEW_SEL).is(":checked"),DateStored:moment().format("lll")}),a.reset(),a.savedStates},restore:function(d){var e,f,g,h="number"==typeof d?a.VIEWMODEL.savedStates()[d]:d;return XIGENTIMER.VIEWMODEL.isLoggedIn()&&(XIGENTIMER.VIEWMODEL.isTiming()||XIGENTIMER.TIMER.getTime().time>1)&&!confirm("You have a timer running, or time that hasn't been sent yet. Restoring this state will lose the current time. Are you sure you want to restore?")?!1:(XIGENTIMER.reset(),$(".is-projectText").text("Selected Task: "+h.Breadcrumb),Foundation.libs.tooltip.getTip($(".is-projectText")).remove(),$(".is-projectText").attr("title",h.Breadcrumb),XIGENTIMER.VIEWMODEL.selectedProject(h.TaskID),XIGENTIMER.VIEWMODEL.taskTypeID(h.TaskType),XIGENTIMER.TIMER.setTime(h.TimeLogged[1]),XIGENTIMER.VIEWMODEL.activityDesc(h.Desc),$(c.BILLABLE_SEL).prop("checked",h.Billable),$(c.REVIEW_SEL).prop("checked",h.ForReview),localforage.getItem("activityCache",function(a){g=a.filter(function(a){return a.EntityBaseID===h.TaskID})[0]||{},e=g.EstimatedHours?g.EstimatedHours.toFixed(2):!1,XIGENTIMER.API.getTimeForTask(h.TaskID,function(a){f=a.toFixed(2),$("[data-estimate]").text(e||"0.00"),$("[data-sofar]").text(f||"---")})}),"number"==typeof d&&a.VIEWMODEL.savedStates.splice(b,1),void XIGENTIMER.VIEWMODEL.selectOverview())}}}(XIGENTIMER),function(a){"use strict";var b,c;a.drawTaskList=function(){b()},a.drawManagedTaskList=function(){b(!0)},b=function(b){var d,e,f,g,h,i,j,k=b?"rawActivityCache":"activityCache";localforage.getItem(k,function(a){d=a,e=a,localforage.getItem("baseURL",function(a){j="/"===a.charAt(a.length-1)?a:a+"/",g()})}),g=function(){localforage.getItem("projectCache",function(a){c=a}).then(function(){localforage.getItem("user",function(a){h=a.UserID}).then(f)})},f=function(){b?d=d.filter(function(a){return a.CreatorID===h}):(d=d.filter(function(a){return a.CanEdit&&!a.HasChild}),d=d.filter(a.VIEWMODEL.showReviewItems()?function(a){return 18===a.TaskStatusID||1===a.TaskStatusID||4===a.TaskStatusID}:function(a){return 1===a.TaskStatusID||4===a.TaskStatusID}),a.VIEWMODEL.showInfiniteItems()||(d=d.filter(function(a){return a.EndDate}))),i()},i=function(){var a,e=0;a=function(){d=d.sort(function(a,b){return b.PriorityID===a.PriorityID?+a.moment-+b.moment:b.PriorityID-a.PriorityID}),b?XIGENTIMER.VIEWMODEL.managedTaskList([]):XIGENTIMER.VIEWMODEL.taskList([]),b?XIGENTIMER.VIEWMODEL.managedTaskList(d.filter(function(a){var b=[];return XIGENTIMER.VIEWMODEL.managedShowOpen()&&b.push(1),XIGENTIMER.VIEWMODEL.managedShowReview()&&b.push(18),XIGENTIMER.VIEWMODEL.managedShowPending()&&b.push(20),b.indexOf(a.TaskStatusID)>-1})):$.each(d,function(){XIGENTIMER.VIEWMODEL.taskList.push(this)})},$.each(d,function(f,g){switch(g.PriorityID){case 1:g.PriorityID=4;break;case 2:g.PriorityID=3;break;case 3:g.PriorityID=2;break;case 4:g.PriorityID=1}g.TaskURL=j+"TaskDetails.aspx?ID="+g.TaskID,g.ProjectURL=j+"ProjectDetails.aspx?ID="+g.ProjectID,g.DueDate=g.EndDate?moment(g.EndDate,"YYYY-MM-DD/HH:mm:ss.SS").startOf("day").add(17,"h").add(30,"m").fromNow():"--",g.moment=g.EndDate?moment(g.EndDate,"YYYY-MM-DD/HH:mm:ss.SS").startOf("day").add(17,"h").add(30,"m"):"--",g.daysDifference="string"!=typeof g.moment?g.moment.diff(moment(),"days"):null,g.EstimatedHours=g.EstimatedHours?parseFloat(g.EstimatedHours).toFixed(2):null,g.ProjectName=c.filter(function(a){return a.ProjectID===g.ProjectID})[0].Name,b?XIGENTIMER.API.getTimeForTask(g.TaskID,function(b){g.TotalHours=b.toFixed(2),e+=1,e===d.length&&a()}):(e+=1,e===d.length&&a())})}},a.selectTask=function(b){if(console.log("SelectingTask"),(a.VIEWMODEL.activityDesc()||a.TIMER.getTime().time>1)&&!confirm("There is time in the timer that hasn't been sent yet, or the timer is running. Are you sure you want to load this task?"))return!1;var d,e,f=parseInt($(b).parents("tr").attr("data-id"),10);localforage.getItem("activityCache",function(b){d=b.filter(function(a){return a.TaskID===f})[0],e=c.filter(function(a){return a.ProjectID===d.ProjectID})[0].Name,a.reset(),a.TIMER.stop(),a.STATE.restore({TaskName:d.Name,Breadcrumb:e+" » "+d.Name,TaskID:d.TaskID,TaskType:d.TaskTypeID,TimeLogged:[0,0],Desc:"",Billable:!0,ForReview:!1}),$(".do-timestart").trigger("click")})}}(XIGENTIMER),function(a){"use strict";var b=require("nw.gui"),c={WINDOW_WIDTH:290,WINDOW_HEIGHT:70,TARGET_X:screen.availWidth-290-10,TARGET_Y:screen.availHeight-70-10};a.notify=function(){var a,d=b.Window.open("notification.html",{frame:!1,title:"Notification Window",toolbar:!1,width:c.WINDOW_WIDTH,height:c.WINDOW_HEIGHT,x:screen.availWidth-c.WINDOW_WIDTH-10,y:screen.availHeight+100});d.setAlwaysOnTop(!0),a=setInterval(function(){d.y>c.TARGET_Y?d.moveTo(d.x,d.y-=5):clearInterval(a)},5),setTimeout(function(){a=setInterval(function(){d.y=7;)b-=7;return c?a.i18n.weekdaysShort[b]:a.i18n.weekdays[b]},v=function(a,b,c,d,e){if(e)return'';var f=[];return d&&f.push("is-disabled"),c&&f.push("is-today"),b&&f.push("is-selected"),'"},w=function(a,b){return""+(b?a.reverse():a).join("")+""},x=function(a){return""+a.join("")+""},y=function(a){var b,c=[];for(b=0;7>b;b++)c.push(''+u(a,b,!0)+"");return""+(a.isRTL?c.reverse():c).join("")+""},z=function(a){var b,c,d,e,f,g=a._o,h=a._m,i=a._y,j=i===g.minYear,k=i===g.maxYear,l='
      ',n=!0,o=!0;for(d=[],b=0;12>b;b++)d.push('");for(e='
      '+g.i18n.months[h]+'
      ",m(g.yearRange)?(b=g.yearRange[0],c=g.yearRange[1]+1):(b=i-g.yearRange,c=1+i+g.yearRange),d=[];c>b&&b<=g.maxYear;b++)b>=g.minYear&&d.push('");return f='
      '+i+g.yearSuffix+'
      ",l+=g.showMonthAfterYear?f+e:e+f,j&&(0===h||g.minMonth>=h)&&(n=!1),k&&(11===h||g.maxMonth<=h)&&(o=!1),l+='",l+='",l+="
      "},A=function(a,b){return''+y(a)+x(b)+"
      "},B=function(g){var h=this,i=h.config(g);h._onMouseDown=function(a){if(h._v){a=a||window.event;var b=a.target||a.srcElement;if(b){if(!j(b,"is-disabled")){if(j(b,"pika-button")&&!j(b,"is-empty"))return h.setDate(new Date(h._y,h._m,parseInt(b.innerHTML,10))),void(i.bound&&e(function(){h.hide()},100));j(b,"pika-prev")?h.prevMonth():j(b,"pika-next")&&h.nextMonth()}if(j(b,"pika-select"))h._c=!0;else{if(!a.preventDefault)return a.returnValue=!1,!1;a.preventDefault()}}}},h._onChange=function(a){a=a||window.event;var b=a.target||a.srcElement;b&&(j(b,"pika-select-month")?h.gotoMonth(b.value):j(b,"pika-select-year")&&h.gotoYear(b.value))},h._onInputChange=function(c){var d;c.firedBy!==h&&(b?(d=a(i.field.value,i.format),d=d&&d.isValid()?d.toDate():null):d=new Date(Date.parse(i.field.value)),h.setDate(n(d)?d:null),h._v||h.show())},h._onInputFocus=function(){h.show()},h._onInputClick=function(){h.show()},h._onInputBlur=function(){h._c||(h._b=e(function(){h.hide()},50)),h._c=!1},h._onClick=function(a){a=a||window.event;var b=a.target||a.srcElement,d=b;if(b){!c&&j(b,"pika-select")&&(b.onchange||(b.setAttribute("onchange","return;"),f(b,"change",h._onChange)));do if(j(d,"pika-single"))return;while(d=d.parentNode);h._v&&b!==i.trigger&&h.hide()}},h.el=d.createElement("div"),h.el.className="pika-single"+(i.isRTL?" is-rtl":""),f(h.el,"mousedown",h._onMouseDown,!0),f(h.el,"change",h._onChange),i.field&&(i.bound?d.body.appendChild(h.el):i.field.parentNode.insertBefore(h.el,i.field.nextSibling),f(i.field,"change",h._onInputChange),i.defaultDate||(i.defaultDate=b&&i.field.value?a(i.field.value,i.format).toDate():new Date(Date.parse(i.field.value)),i.setDefaultDate=!0));var k=i.defaultDate;n(k)?i.setDefaultDate?h.setDate(k,!0):h.gotoDate(k):h.gotoDate(new Date),i.bound?(this.hide(),h.el.className+=" is-bound",f(i.trigger,"click",h._onInputClick),f(i.trigger,"focus",h._onInputFocus),f(i.trigger,"blur",h._onInputBlur)):this.show()};return B.prototype={config:function(a){this._o||(this._o=s({},t,!0));var b=s(this._o,a,!0);b.isRTL=!!b.isRTL,b.field=b.field&&b.field.nodeName?b.field:null,b.bound=!!(void 0!==b.bound?b.field&&b.bound:b.field),b.trigger=b.trigger&&b.trigger.nodeName?b.trigger:b.field;var c=parseInt(b.numberOfMonths,10)||1;if(b.numberOfMonths=c>4?4:c,n(b.minDate)||(b.minDate=!1),n(b.maxDate)||(b.maxDate=!1),b.minDate&&b.maxDate&&b.maxDate100&&(b.yearRange=100);return b},toString:function(c){return n(this._d)?b?a(this._d).format(c||this._o.format):this._d.toDateString():""},getMoment:function(){return b?a(this._d):null},setMoment:function(c,d){b&&a.isMoment(c)&&this.setDate(c.toDate(),d)},getDate:function(){return n(this._d)?new Date(this._d.getTime()):null},setDate:function(a,b){if(!a)return this._d=null,this.draw();if("string"==typeof a&&(a=new Date(Date.parse(a))),n(a)){var c=this._o.minDate,d=this._o.maxDate;n(c)&&c>a?a=c:n(d)&&a>d&&(a=d),this._d=new Date(a.getTime()),q(this._d),this.gotoDate(this._d),this._o.field&&(this._o.field.value=this.toString(),h(this._o.field,"change",{firedBy:this})),b||"function"!=typeof this._o.onSelect||this._o.onSelect.call(this,this.getDate())}},gotoDate:function(a){n(a)&&(this._y=a.getFullYear(),this._m=a.getMonth(),this.draw())},gotoToday:function(){this.gotoDate(new Date)},gotoMonth:function(a){isNaN(a=parseInt(a,10))||(this._m=0>a?0:a>11?11:a,this.draw())},nextMonth:function(){++this._m>11&&(this._m=0,this._y++),this.draw()},prevMonth:function(){--this._m<0&&(this._m=11,this._y--),this.draw()},gotoYear:function(a){isNaN(a)||(this._y=parseInt(a,10),this.draw())},setMinDate:function(a){this._o.minDate=a},setMaxDate:function(a){this._o.maxDate=a},draw:function(a){if(this._v||a){var b=this._o,c=b.minYear,d=b.maxYear,f=b.minMonth,g=b.maxMonth;if(this._y<=c&&(this._y=c,!isNaN(f)&&this._m=d&&(this._y=d,!isNaN(g)&&this._m>g&&(this._m=g)),this.el.innerHTML=z(this)+this.render(this._y,this._m),b.bound&&(this.adjustPosition(),"hidden"!==b.field.type&&e(function(){b.trigger.focus()},1)),"function"==typeof this._o.onDraw){var h=this;e(function(){h._o.onDraw.call(h)},0)}}},adjustPosition:function(){var a,b,c,e=this._o.trigger,f=e,g=this.el.offsetWidth,h=this.el.offsetHeight,i=window.innerWidth||d.documentElement.clientWidth,j=window.innerHeight||d.documentElement.clientHeight,k=window.pageYOffset||d.body.scrollTop||d.documentElement.scrollTop;if("function"==typeof e.getBoundingClientRect)c=e.getBoundingClientRect(),a=c.left+window.pageXOffset,b=c.bottom+window.pageYOffset;else for(a=f.offsetLeft,b=f.offsetTop+f.offsetHeight;f=f.offsetParent;)a+=f.offsetLeft,b+=f.offsetTop;(a+g>i||this._o.position.indexOf("right")>-1&&a-g+e.offsetWidth>0)&&(a=a-g+e.offsetWidth),(b+h>j+k||this._o.position.indexOf("top")>-1&&b-h-e.offsetHeight>0)&&(b=b-h-e.offsetHeight),this.el.style.cssText=["position: absolute","left: "+a+"px","top: "+b+"px"].join(";")},render:function(a,b){var c=this._o,d=new Date,e=p(a,b),f=new Date(a,b,1).getDay(),g=[],h=[];q(d),c.firstDay>0&&(f-=c.firstDay,0>f&&(f+=7));for(var i=e+f,j=i;j>7;)j-=7;i+=7-j;for(var k=0,l=0;i>k;k++){var m=new Date(a,b,1+(k-f)),o=c.minDate&&mc.maxDate,s=n(this._d)?r(m,this._d):!1,t=r(m,d),u=f>k||k>=e+f;h.push(v(1+(k-f),s,t,o,u)),7===++l&&(g.push(w(h,c.isRTL)),h=[],l=0)}return A(c,g)},isVisible:function(){return this._v},show:function(){this._v||(this._o.bound&&f(d,"click",this._onClick),l(this.el,"is-hidden"),this._v=!0,this.draw(),"function"==typeof this._o.onOpen&&this._o.onOpen.call(this))},hide:function(){var a=this._v;a!==!1&&(this._o.bound&&g(d,"click",this._onClick),this.el.style.cssText="",k(this.el,"is-hidden"),this._v=!1,void 0!==a&&"function"==typeof this._o.onClose&&this._o.onClose.call(this))},destroy:function(){this.hide(),g(this.el,"mousedown",this._onMouseDown,!0),g(this.el,"change",this._onChange),this._o.field&&(g(this._o.field,"change",this._onInputChange),this._o.bound&&(g(this._o.trigger,"click",this._onInputClick),g(this._o.trigger,"focus",this._onInputFocus),g(this._o.trigger,"blur",this._onInputBlur))),this.el.parentNode&&this.el.parentNode.removeChild(this.el)}},B}),"object"!=typeof XIGENTIMER&&(XIGENTIMER={}),function(a){"use strict";var b,c,d=require("restler");a.API={base:function(a,e,f,g){var h,i,j,k,l,m,n,o={};"delete"===a.toLowerCase()&&(a="del"),h=function(){localforage.getItem("user",function(a){m=a.UserID,c=a.Name,o.headers={Authorization:i,"Content-Type":"application/json"},Object.keys(f)&&0!==Object.keys(f).length&&(o.data="object"==typeof f?JSON.stringify(f):f)}).then(j)},j=function(){d[a.toLowerCase()](b+e,o).on("complete",function(a,b){a&&(k="object"!=typeof a?JSON.parse(a):a,"object"!=typeof a&&(a=JSON.parse(a)),a.length||(a=[a]),n=a.filter(a[0].UserID?function(a){return a.UserID===m}:a[0].Members?function(a){return a.Members.split("\n").indexOf(c)>-1}:function(a){return a.CanCreateTimeEntries})),"function"==typeof g&&(200===b.statusCode||201===b.statusCode?g(!0,n,k):(g(!1),console.log(o.data,a)))}).on("error",function(a){alert("Network Error: "+JSON.stringify(a.request.options))})},l=function(){localforage.getItem("userToken",function(a){i=a}).then(h)},b?l():localforage.getItem("baseURL",function(a){b=a.indexOf("/rest/v1/")>-1?a:a+"/rest/v1/"}).then(l)},authoriseAPI:function(a,c){var e,f,g;g=function(){d.get(b+"users",{headers:{Authorization:e,"Content-Type":"application/json","Content-Length":2}}).on("complete",function(b){return b?(localforage.setItem("userCache",b),b=b.filter(function(b){return b.Login===a})[0],void c(!0,b)):(c(!1),!1)})},f=function(){e?localforage.getItem("baseURL",function(a){b=a.indexOf("/rest/v1/")>-1?a:a+"/rest/v1/"}).then(g):c(!1)},localforage.getItem("userToken",function(a){e=a}).then(f)},getHierachy:function(b,c){var d,e,f,g=[],h=[],i=[],j={},k=0;c||(c=b,b=!1),d=function(a,b){var c,d=[],e=[],g=[];return a=a.filter(function(a){return f.indexOf(a.TaskID)>-1}),a=a.filter(b?b:function(a){return a.EndDate&&(1===a.TaskStatusID||4===a.TaskStatusID)}),a=a.filter(function(a){return a.CanCreateTimeEntries===!0}),d=a.filter(function(a){return a.HasChild>0}),e=a.filter(function(a){return a.ParentID}),g=a.filter(function(a){return!a.ParentID&&!a.HasChild}),d.length>0?($.each(d,function(a,b){c=b.EntityBaseID,d[a].Activities||(d[a].Activities=[]),d[a].Activities=e.filter(function(a){return a.ParentID===c})}),g.length>0&&(d=d.concat(g)),d.filter(function(a){return a.Activities?!a.ParentID&&a.Activities.length>0:!a.ParentID})):a},e=function(){a.API.base("GET","projects",{},function(e,l){g=l,localforage.setItem("projectCache",l),$.each(l,function(e,l){l.Activities=[],j[l.EntityBaseID]=this,a.API.base("GET","projects/"+l.EntityBaseID+"/activities",{},function(a,e){k+=1,h=h.concat(e.filter(function(a){return f.indexOf(a.TaskID)>-1})),i=i.concat(e),j[l.EntityBaseID].Activities=d(e,b),k===g.length&&"function"==typeof c&&localforage.setItem("activityCache",h,function(){localforage.setItem("rawActivityCache",i,function(){var a=[];$.each(j,function(){a.push(this)}),a=a.sort(function(a,b){return a.Nameb.Name?1:0}),c(a)})})})})})},a.API.base("GET","myactivities",{},function(a,b){f=b.map(function(a){return a.TaskID}),e()})},getTimelogs:function(b){a.API.base("GET","timelogs",{},function(a,c,d){localforage.setItem("timelogCache",d),"function"==typeof b&&b(c)})},getTimeForTask:function(a,b){var c;localforage.getItem("timelogCache",function(d){c=d.filter(function(b){return b.TaskID===a}).map(function(a){return a.Duration}),c=c.length?c.reduce(function(a,b){return a+b}):0,b(c)})},getProjectName:function(a,b){var c;localforage.getItem("projectCache",function(d){c=d.filter(function(b){return b.ProjectID===a})[0].Name,"function"==typeof b&&b(c)})},logTime:function(b,c,d,e,f,g){var h,i=new Date;h=[i.getFullYear(),"-",1===i.getMonth().toString().length?"0"+(i.getMonth()+1):i.getMonth()+1,"-",1===i.getDate().toString().length?"0"+i.getDate():i.getDate(),"T",1===i.getHours().toString().length?"0"+i.getHours():i.getHours(),":",1===i.getMinutes().toString().length?"0"+i.getMinutes():i.getMinutes(),":",1===i.getSeconds().toString().length?"0"+i.getSeconds():i.getSeconds()].join(""),a.API.base("POST","timelogs",{UserID:b,Duration:d,TaskID:c,Description:f,Billable:e,EntryDate:h},function(a){g(a)})},markForReview:function(b,c){var d=XIGENTIMER.VIEWMODEL.taskTypeID();a.API.base("PUT","activities/"+b,{EntityBaseID:b,TaskStatusID:1===d?18:8},function(a){c(a)})},updateTimeLog:function(a,c,e,f){var g,h,i,j,k=!1;i=function(){d.get(b+"timelogs/"+a,{headers:{Authorization:g,"Content-Type":"application/json"}}).on("complete",function(a){j=a,j.Duration!==c&&(k=!0,j.Duration=parseFloat(c)),j.Description!==e&&(k=!0,j.Description=e),delete j.LastModificationDate,k?h():f(!0)})},h=function(){d.put(b+"timelogs/"+a,{headers:{Authorization:g,"Content-Type":"application/json"},data:JSON.stringify(j)}).on("complete",function(a,b){"function"==typeof f&&f(200===b.statusCode)})},localforage.getItem("userToken",function(a){g=a}).then(i)},pulse:function(a){var b;XIGENTIMER.VIEWMODEL.isChecking(!0),localforage.getItem("baseURL",function(a){a?b(a):(XIGENTIMER.VIEWMODEL.isConnected(!1),XIGENTIMER.VIEWMODEL.isChecking(!1))}),b=function(b){d.get(b).on("complete",function(b,c){c.statusCode&&(XIGENTIMER.VIEWMODEL.isConnected(!0),XIGENTIMER.VIEWMODEL.isChecking(!1),"function"==typeof a&&a(!0))}).on("error",function(){XIGENTIMER.VIEWMODEL.isConnected(!1),XIGENTIMER.VIEWMODEL.isChecking(!1),"function"==typeof a&&a(!1)})}},getUserDetails:function(a,b){var c=[];localforage.getItem("userCache",function(d){c=d.filter(function(b){return a.indexOf(b.UserID)>-1}),"function"==typeof b&&b(c)})}}}(XIGENTIMER),function(){"use strict";var a=require("os");XIGENTIMER.ViewModel=function(){var b=this;this.isLoggedIn=ko.observable(!1),this.isLoggedOut=ko.computed(function(){return!b.isLoggedIn()}),this.selectedProject=ko.observable(!1),this.isTiming=ko.observable(!1),this.isProjectManager=ko.observable(!1),localforage.getItem("user",function(a){!a||1!==a.RoleID&&2!==a.RoleID||b.isProjectManager(!0)}),this.activityDesc=ko.observable(""),this.isEditingTime=ko.observable(!1),this.isRestoringTime=ko.observable(!1),this.isViewingTasks=ko.observable(!1),this.isManaging=ko.observable(!1),this.taskTypeID=ko.observable(1),this.isOverview=ko.computed(function(){return!b.isEditingTime()&&b.isLoggedIn()&&!b.isRestoringTime()&&!b.isViewingTasks()&&!b.isManaging()}),this.dummy=ko.observable(),this.hasProjectSelected=ko.computed(function(){return!!b.selectedProject()}),this.canEdit=ko.computed(function(){return!b.isTiming()}),this.canSendTime=ko.computed(function(){return b.dummy(),!!b.activityDesc()&&!b.isTiming()&&XIGENTIMER.TIMER.getTime().time-1>0&&b.hasProjectSelected()&&b.isConnected()}),this.markText=ko.computed(function(){switch(b.taskTypeID()){case 1:return"Send for internal review";case 2:return"Mark as fixed";default:return"Send for internal review"}}),this.showMarkComplete=ko.computed(function(){return 3!==b.taskTypeID()}),this.notOSX=!/darwin/.test(a.platform()),this.supressChangeOne=ko.observable(!0),this.supressChangeTwo=ko.observable(!0),this.showReviewItems=ko.observable(!1),localforage.getItem("showReviewItems",function(a){a&&b.showReviewItems(a),b.supressChangeOne(!1)}),this.showInfiniteItems=ko.observable(!1),localforage.getItem("showInfiniteItems",function(a){a&&b.showInfiniteItems(a),b.supressChangeTwo(!1)}),this.showReviewItems.subscribe(function(a){b.supressChangeOne()?b.supressChangeOne(!1):(a===!0?$("body").addClass("show-review"):$("body").removeClass("show-review"),localforage.setItem("showReviewItems",a),b.updateFromFilters())}),this.showInfiniteItems.subscribe(function(a){b.supressChangeTwo()?b.supressChangeTwo(!1):(a===!0?$("body").addClass("show-infinite"):$("body").removeClass("show-infinite"),localforage.setItem("showInfiniteItems",a),b.updateFromFilters())}),this.updateFromFilters=function(a){var c=b.showReviewItems(),d=b.showInfiniteItems();$(".do-refresh").addClass("is-refreshing").attr("disabled","disabled"),XIGENTIMER.drawProjects(function(){$(".do-refresh").removeClass("is-refreshing").removeAttr("disabled"),b.isProjectManager()&&XIGENTIMER.drawManagedTaskList(),XIGENTIMER.drawTaskList(),"function"==typeof a&&a()},c,d)},this.selectTiming=function(){b.isEditingTime(!0),b.isRestoringTime(!1),b.isViewingTasks(!1),b.isManaging(!1)},this.selectOverview=function(){b.isEditingTime(!1),b.isRestoringTime(!1),b.isViewingTasks(!1),b.isManaging(!1)},this.selectRestore=function(){b.isEditingTime(!1),b.isRestoringTime(!0),b.isViewingTasks(!1),b.isManaging(!1)},this.selectTasks=function(){b.isEditingTime(!1),b.isRestoringTime(!1),b.isViewingTasks(!0),b.isManaging(!1)},this.selectManagement=function(){b.isEditingTime(!1),b.isRestoringTime(!1),b.isViewingTasks(!1),b.isManaging(!0)},this.recalcCanSend=function(){b.dummy.notifySubscribers()},this.reset=function(a){a&&(b.isLoggedIn(!1),b.isEditingTime(!1)),b.activityDesc(""),b.isTiming(!1),b.recalcCanSend(),b.selectedProject(!1)},this.isConnected=ko.observable(!1),this.isChecking=ko.observable(!1),this.connectedText=ko.computed(function(){return b.isProjectManager()?b.isConnected()&&!b.isChecking()?"OK":b.isChecking()?"...":"!OK":b.isConnected()&&!b.isChecking()?"Connected to System":b.isChecking()?"Checking pulse...":"Not Connected."}),this.checkPulse=function(){XIGENTIMER.API.pulse()},this.savedStates=ko.observableArray([]),localforage.getItem("savedStates",function(a){a&&b.savedStates(a)}),this.saveState=function(){XIGENTIMER.STATE.save()},this.savedStates.subscribe(function(a){localforage.setItem("savedStates",a)}),this.canSaveState=ko.computed(function(){return!b.isTiming()&&b.hasProjectSelected()}),this.taskList=ko.observableArray([]),this.managedTaskList=ko.observableArray([]),this.managedShowOpen=ko.observable(!0),this.managedShowReview=ko.observable(!1),this.managedShowPending=ko.observable(!1),this.managedShowOpen.subscribe(function(){XIGENTIMER.drawManagedTaskList()}),this.managedShowReview.subscribe(function(){XIGENTIMER.drawManagedTaskList()}),this.managedShowPending.subscribe(function(){XIGENTIMER.drawManagedTaskList()}),this.priorities={5:"Mission Critical",4:"Urgent",3:"High",2:"Medium",1:"Low"},this.dateMagnitude=function(a){return 0===a?"today":0>a&&a>=-7?"overdue":-7>a?"super-overdue":a>0&&7>=a?"ontime":a>7?"super-ontime":"nodate"}},$(function(){XIGENTIMER.VIEWMODEL=new XIGENTIMER.ViewModel,ko.applyBindings(XIGENTIMER.VIEWMODEL)})}(XIGENTIMER),function(){"use strict";var a,b={TEXT_ELEMENT:"span",ACTIVE_CLASS:"is-open",BREADCRUMB_CLASS:".breadcrumbs",CLEAR_CLASS:".do-clearfilter"},c=require("nw.gui"),d=new c.Menu;d.append(new c.MenuItem({label:"Log time on this item"})),d.append(new c.MenuItem({label:"View in browser"})),a=function(a){localforage.getItem("baseURL",function(b){XIGENTIMER.launchExternal(b+"/TaskDetails.aspx?ID="+a)})},XIGENTIMER.ProjectFilter=function(a,b){return!this instanceof XIGENTIMER.ProjectFilter?new XIGENTIMER.ProjectFilter(arguments):(this.list=a.jquery?a:$(a),this.input=b.jquery?b:$(b),this.setup(),void this.addHandlers())},XIGENTIMER.ProjectFilter.prototype.setup=function(){var a=this;this.elements=[],$.each(this.list.children("li"),function(){a.elements.push({el:this,text:$(this).children("span").first().text()}),this.remove()}),this.showElements(this.matchText($(this.input).val()))},XIGENTIMER.ProjectFilter.prototype.refresh=function(a){this.setup(),this.draw(),$("span",this.list).each(function(){a.indexOf($(this).text())>-1&&($(this).addClass(b.ACTIVE_CLASS),$(this).parent("li").children("ul").toggle())})},XIGENTIMER.ProjectFilter.prototype.matchText=function(a){return a?this.elements.filter(function(b){return b.text.toLowerCase().indexOf(a.toLowerCase())>-1}):this.elements},XIGENTIMER.ProjectFilter.prototype.showElements=function(a){var c=this;c.list.empty(),$.each(a,function(){c.list.append(this.el)}),$("span",this.list).removeClass(b.ACTIVE_CLASS),this.draw()},XIGENTIMER.ProjectFilter.prototype.addHandlers=function(){var c=this;this.input.on("keyup",function(a){9!==a.which&&c.showElements(c.matchText($(this).val()))}),$(b.CLEAR_CLASS).on("click",function(){$(c.input).val(""),c.showElements(c.matchText($(c.input).val()))}),$(this.list).on("click","li span",function(){$(this).toggleClass(b.ACTIVE_CLASS),$(this).parent("li").children("ul").toggle()}),$(document).on("contextmenu",function(b){return $(b.target).parents("ul").length>1?(b.preventDefault(),d.items[1].click=function(){a($(b.target).closest("li").attr("data-id"))},d.items[0].click=function(){c.selectActivity(b.target)},d.popup(b.originalEvent.x,b.originalEvent.y),!1):void 0})},XIGENTIMER.ProjectFilter.prototype.draw=function(){$("li ul",this.list).hide();var a=$(b.BREADCRUMB_CLASS),c=this;XIGENTIMER.BREADCRUMB_EMPTY||(XIGENTIMER.BREADCRUMB_CONTAINER=a,XIGENTIMER.BREADCRUMB_EMPTY=a.contents()),$(this.list).on("click","a",function(a){a.preventDefault(),c.selectActivity(this)})},XIGENTIMER.ProjectFilter.prototype.selectActivity=function(a){{var b,c,d,e=parseInt($(a).parents("li").attr("data-id"),10),f=a,g=[],h=$(a).find(".label");XIGENTIMER.BREADCRUMB_CONTAINER}XIGENTIMER.VIEWMODEL.taskTypeID(h.hasClass("alert")?2:h.hasClass("success")?3:1),$(f).parents("li").each(function(){g.push($(this).find("span").first().text())}),g=g.filter(function(a){return""!==a}).reverse(),g=g.join(" » "),$(".is-projectText").text("Selected Task: "+g),Foundation.libs.tooltip.getTip($(".is-projectText")).remove(),$(".is-projectText").attr("title",g),$("[data-estimate]").text(b||"Working..."),$("[data-sofar]").text(c||"Working..."),XIGENTIMER.VIEWMODEL.selectedProject(e),localforage.getItem("activityCache",function(a){d=a.filter(function(a){return a.EntityBaseID===e})[0]||{},b=d.EstimatedHours?d.EstimatedHours.toFixed(2):!1,XIGENTIMER.API.getTimeForTask(e,function(a){c=a.toFixed(2),$("[data-estimate]").text(b||"0.00"),$("[data-sofar]").text(c||"---")})})}}(),function(){var a,b,c=require("nw.gui"),d=c.Window.get(),e=new c.Menu;e.append(new c.MenuItem({type:"normal",label:"Show Timer"})),XIGENTIMER.launchExternal=function(a){c.Shell.openExternal(a)},XIGENTIMER.close=function(){XIGENTIMER.VIEWMODEL.isLoggedIn()&&(XIGENTIMER.VIEWMODEL.isTiming()||XIGENTIMER.TIMER.getTime().time>1)?(XIGENTIMER.VIEWMODEL.isTiming()?b="Timer is running, are you sure you want to close?":XIGENTIMER.TIMER.getTime().time>1&&(b="There is time on the clock which hasn't been sent yet. Are you sure you want to close?"),confirm(b)&&d.close()):d.close()},XIGENTIMER.minimize=function(){d.minimize()},XIGENTIMER.goToTray=function(){d.once("minimize",function(){this.hide(),a=new c.Tray({icon:"assets/img/xigen_logo_whiteout.png"}),a.on("click",function(){d.show(),this.remove(),a=null}),a.menu=e,e.items[0].click=function(){d.show(),a.remove(),a=null}}),d.minimize()}}(),function(a){var b;b=function(a){var c,d,e,f,g=document.createDocumentFragment();return a.length||(a=[a]),$.each(a,function(){switch(f=!0,c=document.createElement("li"),c.setAttribute("data-id",this.EntityBaseID),this.CanCreateTimeEntries===!1&&(f=!1),this.TaskTypeID){case 2:e="
      Issue
      ";break;case 3:e="
      Request
      ";break;default:e="
      Task
      "}$(c).append(0===this.HasChild||this.HasChild>0&&0===this.Activities.length?""+e+""+this.Name+"":""+this.Name+""),this.Activities&&this.Activities.length>0?(d=$("
        "),$.each(this.Activities,function(){d.append(b(this))}),$(c).append(d)):f=!1,f&&g.appendChild(c)}),c},a.drawProjects=function(c,d,e){var f=document.createDocumentFragment(),g=[],h=!1;d&&!e?h=function(a){return a.EndDate&&(1===a.TaskStatusID||4===a.TaskStatusID||18===a.TaskStatusID)}:d&&e?h=function(a){return 1===a.TaskStatusID||4===a.TaskStatusID||18===a.TaskStatusID}:e&&!d&&(h=function(a){return 1===a.TaskStatusID||4===a.TaskStatusID}),$(".side-nav .is-open").each(function(){g.push($(this).text())}),a.API.getHierachy(h,function(a){$.each(a,function(){this.Activities.length>0&&$(f).append(b(this))}),$(".side-nav").empty().append(f),XIGENTIMER.SidebarFilter?(console.log(g),XIGENTIMER.SidebarFilter.refresh(g)):XIGENTIMER.SidebarFilter=new XIGENTIMER.ProjectFilter($(".side-nav"),$(".sidebar-filter-wrap input")),"function"==typeof c&&(c(),XIGENTIMER.updateDatePickers())})}}(XIGENTIMER),$(function(){"use strict";var a,b,c,d=require("nw.gui"),e=$(".login [type=submit]"),f=[];$(document).foundation(),$(".login").hide(),$(".datepicker").each(function(){b=new Pikaday({field:this,firstDay:1,defaultDate:new Date,setDefaultDate:!0,maxDate:new Date,format:"D MMM YYYY",onSelect:function(){XIGENTIMER.updateDatePickers()}}),$(this).data("picker",b),f.push(b)}),$("[data-logout]").on("click",function(a){return a.preventDefault(),XIGENTIMER.VIEWMODEL.savedStates().length>0&&!confirm("You have saved states which will be lost if you log out. Are you sure you want to continue?")?!1:(localforage.setItem("userToken",null),localforage.setItem("userName",null),localforage.setItem("baseURL",null),localforage.setItem("user",null),localforage.setItem("savedStates",null),XIGENTIMER.reset(),XIGENTIMER.VIEWMODEL.reset(!0),void $(".login").fadeIn(200))}),c=function(){e.text("Incorrect login, try again :)"),e.addClass("alert"),setTimeout(function(){e.text(a).removeClass("alert")},1500)},$("[data-login]").on("submit",function(b){b.preventDefault();var d=$("[name=password]",this).val(),f=$("[name=user]",this).val(),g=$("[name=baseURL]",this).val();a=e.text(),e.text("Logging in..."),f&&d&&g?localforage.setItem("baseURL",g).then(XIGENTIMER.authoriseUser(f,d,function(b,d){b?(e.text(a),localforage.setItem("userToken",d),localforage.setItem("userName",b.Login),localforage.setItem("baseURL",g),XIGENTIMER.VIEWMODEL.isLoggedIn(!0),localforage.setItem("user",b).then(function(){XIGENTIMER.VIEWMODEL.updateFromFilters(function(){XIGENTIMER.updateDatePickers()}),(1===b.RoleID||2===b.RoleID)&&XIGENTIMER.VIEWMODEL.isProjectManager(!0),XIGENTIMER.API.pulse(),XIGENTIMER.drawTaskList(),setTimeout(function(){XIGENTIMER.API.pulse()},3e4)})):c()})):c()}),localforage.getItem("userToken",function(a){localforage.getItem("baseURL",function(b){a&&b?XIGENTIMER.authoriseUser(function(){XIGENTIMER.VIEWMODEL.isLoggedIn(!0),XIGENTIMER.VIEWMODEL.updateFromFilters(function(){XIGENTIMER.updateDatePickers()}),XIGENTIMER.API.pulse(),XIGENTIMER.drawTaskList(),setTimeout(function(){XIGENTIMER.API.pulse()},3e4)}):$(".login").fadeIn(200)})}),$(".do-reset").on("click",function(){XIGENTIMER.reset()}),$(".time-table-tasks").on("click",".do-selectTask",function(){XIGENTIMER.selectTask(this)}),$(".do-viewonline").on("click",function(){return $(this).attr("disabled")?!1:void d.Window.open("viewActivity.html?activityID="+$(this).attr("data-id"),{frame:!1,title:$(".breadcrumb li").last().text(),width:850,max_width:850,height:450,max_height:450,min_width:800,min_height:400,toolbar:!1})}),$("body").on("click","a",function(a){if("_system"===$(this).attr("target")&&(a.preventDefault(),XIGENTIMER.launchExternal($(this).attr("href"))),"_viewProject"===$(this).attr("target")){a.preventDefault();var b=$(this).text();d.Window.open("viewActivity.html?activityID="+$(this).attr("data-id"),{frame:!1,title:b,width:850,max_width:850,height:450,max_height:450,min_width:800,min_height:400,toolbar:!1})}if("_manageProject"===$(this).attr("target")){a.preventDefault();var b=$(this).text();d.Window.open("ManageActivity.html?activityID="+$(this).attr("data-id"),{frame:!1,title:b,width:850,max_width:850,height:450,max_height:450,min_width:800,min_height:450,toolbar:!1})}}),XIGENTIMER.BREADCRUMB_CONTAINER=$(".breadcrumbs"),XIGENTIMER.BREADCRUMB_EMPTY=$(".breadcrumbs").contents(),$(".time-table").on("click",".do-editTimeLog",function(){XIGENTIMER.editTimeLog($(this).parents("tr").attr("data-id"),this)}),$("#desc, .filter-text").on("keydown",function(a){(32===a.which||32===a.keyCode)&&a.stopPropagation() +}),$(document).on("keyCombo",function(a,b){var c,e=b.combo;"SUBMIT"===e&&XIGENTIMER.sendTime(),("REFRESH"===e||"REFRESH_ALT"===e)&&XIGENTIMER.VIEWMODEL.updateFromFilters(),("SETTINGS"===e||"SETTINGS_ALT"===e)&&$("#settingsMenu").foundation("reveal","open"),"EDIT"===e&&(XIGENTIMER.VIEWMODEL.isTiming()||$("#customTime").foundation("reveal","open")),"FIND"===e&&$(".filter-text").focus(),"PLAYPAUSE"===e&&$(".do-timestart").trigger("click"),"ONE"===e&&XIGENTIMER.VIEWMODEL.selectOverview(),"TWO"===e&&XIGENTIMER.VIEWMODEL.selectTasks(),"THREE"===e&&XIGENTIMER.VIEWMODEL.selectTiming(),"FOUR"===e&&XIGENTIMER.VIEWMODEL.selectRestore(),"DESC"===e&&$("#desc").focus(),"LOGOUT"===e&&(c=$(document.activeElement),"filter-text"===c[0].className&&$(".do-clearfilter").trigger("click")),"HELP"===e&&$("#shortcutMenu").foundation("reveal","open"),"VIEW"===e&&("TEXTAREA"!==document.activeElement.tagName?$(".do-viewonline").trigger("click"):$(document.activeElement).val($(document.activeElement).val()+d.Clipboard.get().get("text")))}),$(document).on("open","[data-reveal]",function(){var a=$(this);"customTime"===a[0].id&&setTimeout(function(){a.find("input").first().focus()},200)}),$(".icon-min").on("click",function(){XIGENTIMER.minimize()}),$(".icon-hide").on("click",function(){XIGENTIMER.goToTray()}),$(".icon-close").on("click",function(){XIGENTIMER.close()}),$(".do-refresh").on("click",function(){XIGENTIMER.VIEWMODEL.updateFromFilters(function(){$(".do-refresh").removeClass("is-refreshing").removeAttr("disabled")}),XIGENTIMER.updateDatePickers()})}),$(function(){"use strict";var a,b={ERROR_CLASS:"error",UPDATE_CLASS:"do-update",MODAL_ID:"customTime",CLOSE_CLASS:"do-close"};a=function(a){var c,d,e,f=$("#"+b.MODAL_ID),g=!0;a.preventDefault(),c=f.find("[name=hours]"),d=f.find("[name=minutes]"),e=f.find("[name=seconds]"),$.each([c,d,e],function(){$(this).val()?$(this).prev("label").removeClass(b.ERROR_CLASS):($(this).prev("label").addClass(b.ERROR_CLASS),$(this).on("keyup",function(){$(this).val()?$(this).prev("label").removeClass(b.ERROR_CLASS):$(this).prev("label").addClass(b.ERROR_CLASS)}),g=!1)}),g&&(c=60*parseInt(c.val(),10)*60,d=60*parseInt(d.val(),10),e=parseInt(e.val(),10),XIGENTIMER.TIMER.setTime(c+d+e),f.foundation("reveal","close"),XIGENTIMER.VIEWMODEL.recalcCanSend())},$("."+b.UPDATE_CLASS).on("click",function(b){a(b)}),$(document).on("keyup",function(b){13===b.which&&a(b)}),$("#"+b.MODAL_ID).on("click","."+b.CLOSE_CLASS,function(){$("#"+b.MODAL_ID).foundation("reveal","close")}),XIGENTIMER.UPDATEPOPUP=$("#"+b.MODAL_ID)}),$(function(){"use strict";var a,b,c,d={DO_STARTTIME:"do-timestart",DO_PAUSE:"do-timestop",TEXT_RUNNING:"Pause",TEXT_PAUSED:""},e=XIGENTIMER.UPDATEPOPUP,f=e.find("[name=hours]"),g=e.find("[name=minutes]"),h=e.find("[name=seconds]");d.TEXT_PAUSED=$("."+d.DO_STARTTIME).text(),XIGENTIMER.TIMER=$(".timer").FlipClock({autoStart:!1}),XIGENTIMER.VIEWMODEL.isTiming(!1),$("."+d.DO_STARTTIME).on("click",function(){return $(this).attr("disabled")?!1:void(XIGENTIMER.VIEWMODEL.isTiming()?(XIGENTIMER.TIMER.stop(function(){c=XIGENTIMER.TIMER.getTime()-1,a=Math.floor(c/3600),c-=3600*a,b=Math.floor(c/60),c-=60*b,f.val(a),g.val(b),h.val(c),XIGENTIMER.VIEWMODEL.isTiming(!1)}),$(this).text(d.TEXT_PAUSED)):(XIGENTIMER.TIMER.start(),XIGENTIMER.VIEWMODEL.isTiming(!0),$(this).text(d.TEXT_RUNNING)))})}),$(function(){"use strict";var a={SEND_CLASS:"do-send",PENDING_TEXT:"Sending...",MARKING_TEXT:"Marking for review...",SUCCESS_TEXT:"Done!",ERROR_TEXT:"Error :(",DESC_SEL:"[id=desc]"};a.DEFAULT_TEXT=$("."+a.SEND_CLASS).text(),$("."+a.SEND_CLASS).on("click",function(){XIGENTIMER.sendTime()}),XIGENTIMER.sendTime=function(){var b,c,d,e=$(a.DESC_SEL).val(),f=XIGENTIMER.VIEWMODEL.selectedProject(),g=$("#isBillable").prop("checked"),h=$("#markReview").prop("checked"),i=$("."+a.SEND_CLASS);return XIGENTIMER.VIEWMODEL.canSendTime()?(b=XIGENTIMER.TIMER.getTime()/3600,b=b.toFixed(2),d=function(){i.text(a.SUCCESS_TEXT),setTimeout(function(){i.text(a.DEFAULT_TEXT)},3e3)},i.text(a.PENDING_TEXT),void localforage.getItem("user",function(a){c=a.UserID}).then(function(){XIGENTIMER.API.logTime(c,f,b,g,e,function(b){b?(h?XIGENTIMER.API.markForReview(f,function(){d()}):d(),XIGENTIMER.reset()):(i.removeClass("info").addClass("alert").text(a.ERROR_TEXT),setTimeout(function(){i.text(a.DEFAULT_TEXT).addClass("info").removeClass("alert")},1500))})})):!1}}),function(){"use strict";function a(a,b){var c,d,e,f,g;localforage.getItem("activityCache",function(b){c=b.filter(function(b){return b.TaskID===a})[0],c&&(d=c.Name,f=c.EntityBaseID,g())}),g=function(){localforage.getItem("projectCache",function(a){c=a.filter(function(a){return a.ProjectID===c.ProjectID})[0],e=c.Name,b([d,e,f])})}}function b(){var a=new Date;return[a.getFullYear(),1===a.getMonth().toString().length?"0"+(a.getMonth()+1):a.getMonth()+1,1===a.getDate().toString().length?"0"+a.getDate():a.getDate()].join("-")}var c={TABLE_CLASS:".time-table-logs",TEXT_EDIT:"Edit",TEXT_SAVE:"Save",TEXT_SAVING:"Saving..."};XIGENTIMER.renderTimeLogs=function(d){XIGENTIMER.API.getTimelogs(function(e){var f,g,h,i,j=$(c.TABLE_CLASS+" tbody"),k=(b(),0),l=document.createDocumentFragment(),m=0;if(e=e.filter(function(a){return g=+moment(a.EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),"Locked"!==a.Locked&&a.Duration&&!a.Approved&&g>=d[0]&&g<=d[1]}).sort(function(a,b){return h=+moment(a.EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),i=+moment(b.EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),i>h?-1:h>i?1:0}).reverse(),$(e).each(function(){m+=this.Duration}),$("[data-totalHours]").val(m.toFixed(2)),e.length>0)$.each(e,function(b){a(this.TaskID,function(a){f=a;var d=document.createElement("tr");d.setAttribute("data-id",e[b].EntityBaseID),d.setAttribute("data-taskId",e[b].TaskID),g=moment(e[b].EntryDate,"YYYY-MM-DD/HH:mm:ss.SS"),$(d).append(""+g.calendar()+"
        ("+g.format("DD-MM-YYYY")+")"),$(d).append(""+f[1]+":
        "+f[0]+""),$(d).append(""+e[b].Duration.toFixed(2)+""),$(d).append(""+e[b].Description+""),$(d).append(""),l.appendChild(d),k+=1,k===e.length&&(j.empty(),j[0].appendChild(l),$.each(j.find("tr"),function(){ko.applyBindings(XIGENTIMER.VIEWMODEL,this)}))})});else{var n=document.createElement("tr");$(n).append("No time logged for these dates - Do some work!"),l.appendChild(n),j.empty(),j[0].appendChild(l)}})},XIGENTIMER.editTimeLog=function(a,b){var d=$(c.TABLE_CLASS+" tbody").find("[data-id='"+a+"']"),e=(d.attr("data-taskId"),d.find("td").eq(3)),f=d.find("td").eq(2),g=e.text(),h=f.text(),i=/[0-9]{1,2}\.[0-9]{1,2}/,j=!0;b.jquery||(b=$(b)),f.html(""),e.html(""),b.text(c.TEXT_SAVE),b.on("click",function(){g=e.find("textarea").val(),h=f.find("input").val(),i.test(h)||(f.find("input").addClass("error"),j=!1,f.find("input").on("keyup",function(){i.test($(this).val())?(f.find("input").removeClass("error"),j=!0):f.find("input").addClass("error")})),j&&(b.attr("disabled","disabled"),b.text(c.TEXT_SAVING),XIGENTIMER.API.updateTimeLog(a,h,g,function(){e.html(g),f.html(h),b.removeAttr("disabled"),b.text(c.TEXT_EDIT),b.off("click")}))})},XIGENTIMER.updateDatePickers=function(){var a=$("[data-start]").data("picker"),b=$("[data-end]").data("picker"),c=[];b.setMinDate(a.getDate()),a.setMaxDate(b.getDate()),c.push(+a.getDate()),c.push(+moment(b.getDate()).add("hours",24)),XIGENTIMER.renderTimeLogs(c)}}(),function(a){"use strict";var b,c,d,e,f,g;b=function(){console.log("Getting token"),localforage.getItem("userToken",function(a){e=a?a:!1}).then(d.apply(this,arguments))},d=function(a){localforage.getItem("userName",function(a){f=a}).then(a)},c=function(a,b){var c=arguments;!e||a&&b?(e="Basic "+new Buffer(a+":"+b).toString("base64"),localforage.setItem("userToken",e).then(function(){g.apply(this,c)})):g.apply(this,arguments)},g=function(a,b,c){b||c||(c=a,a=f),XIGENTIMER.API.authoriseAPI(a,function(a,b){c(b,e)})},a.authoriseUser=function(){var a=arguments,d=this;b(function(){c.apply(d,a)})}}(XIGENTIMER),function(a){"use strict";var b={DESC_SEL:"[id=desc]",BILLABLE_CHECKBOX:"#isBillable",REVIEW_CHECKBOX:"#markReview"};a.reset=function(){XIGENTIMER.TIMER.setTime(0),a.VIEWMODEL.isTiming()&&$(".do-timestart").trigger("click"),XIGENTIMER.UPDATEPOPUP.find("input").val(0),$(b.DESC_SEL).val("").trigger("change"),$(b.BILLABLE_CHECKBOX).prop("checked",!0),$(b.REVIEW_CHECKBOX).prop("checked",!1),XIGENTIMER.VIEWMODEL.reset(!1),$(".is-projectText").text("Select a task on the left to begin."),Foundation.libs.tooltip.getTip($(".is-projectText")).remove(),$(".is-projectText").attr("title","Select a task on the left to begin."),XIGENTIMER.updateDatePickers()}}(XIGENTIMER),function(a){"use strict";var b,c={CTRL:"modifier",ESC:27,ENT:13,SPACE:32,F5:116,E:69,F:70,L:76,S:83,R:82,T:84,D:68,COMMA:188,QM:191,V:86,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54};a.shortCuts={SUBMIT:[c.CTRL,c.ENT],PLAYPAUSE:[c.SPACE],LOGOUT:[c.ESC],FIND:[c.CTRL,c.F],REFRESH:[c.F5],REFRESH_ALT:[c.CTRL,c.R],EDIT:[c.CTRL,c.E],LOGS:[c.CTRL,c.L],TIMER:[c.CTRL,c.T],SETTINGS:[c.CTRL,c.S],SETTINGS_ALT:[c.CTRL,c.COMMA],DESC:[c.CTRL,c.D],HELP:[c.CTRL,c.QM],VIEW:[c.CTRL,c.V],ONE:[c.CTRL,c.ONE],TWO:[c.CTRL,c.TWO],THREE:[c.CTRL,c.THREE],FOUR:[c.CTRL,c.FOUR]},b=function(b){var c,d,e=b.ctrlKey||b.metaKey,f=[];return e&&f.push("modifier"),f.push(b.which),$.each(a.shortCuts,function(a,b){c=!0,f.length===b.length?$.each(b,function(a,b){b!==f[a]&&(c=!1)}):c=!1,c&&(d=a)}),d},$(document).on("keydown",function(a){b(a)&&(a.preventDefault(),$(document).trigger("keyCombo",{combo:b(a)}))}),$(document).on("keyCombo",function(a,b){console.log(b.combo)})}(XIGENTIMER),function(a){"use strict";var b,c={BILLABLE_SEL:"#isBillable",REVIEW_SEL:"#markReview",RESTORE_SEL:".do-restore",DELETE_SEL:".do-deleteState",STATE_TABLE:".time-table-state"};$(c.STATE_TABLE).on("click",c.RESTORE_SEL,function(){b=parseInt($(this).parents("tr").attr("data-id"),10),a.STATE.restore(b)}),$(c.STATE_TABLE).on("click",c.DELETE_SEL,function(){console.log("Delete state"),b=parseInt($(this).parents("tr").attr("data-id"),10),a.VIEWMODEL.savedStates.splice(b,1)}),a.STATE={save:function(){var b=$(".is-projectText").text().split("»");return a.VIEWMODEL.savedStates.push({TaskName:b[b.length-1].trim(),ProjectName:b[0].trim(),Breadcrumb:$(".is-projectText").text().split("Selected Task:")[1],TaskID:XIGENTIMER.VIEWMODEL.selectedProject(),TaskType:XIGENTIMER.VIEWMODEL.taskTypeID(),TimeLogged:[(XIGENTIMER.TIMER.getTime().time/3600).toFixed(2),XIGENTIMER.TIMER.getTime().time],Desc:XIGENTIMER.VIEWMODEL.activityDesc(),Billable:$(c.BILLABLE_SEL).is(":checked"),ForReview:$(c.REVIEW_SEL).is(":checked"),DateStored:moment().format("lll")}),a.reset(),a.savedStates},restore:function(d){var e,f,g,h="number"==typeof d?a.VIEWMODEL.savedStates()[d]:d;return XIGENTIMER.VIEWMODEL.isLoggedIn()&&(XIGENTIMER.VIEWMODEL.isTiming()||XIGENTIMER.TIMER.getTime().time>1)&&!confirm("You have a timer running, or time that hasn't been sent yet. Restoring this state will lose the current time. Are you sure you want to restore?")?!1:(XIGENTIMER.reset(),$(".is-projectText").text("Selected Task: "+h.Breadcrumb),Foundation.libs.tooltip.getTip($(".is-projectText")).remove(),$(".is-projectText").attr("title",h.Breadcrumb),XIGENTIMER.VIEWMODEL.selectedProject(h.TaskID),XIGENTIMER.VIEWMODEL.taskTypeID(h.TaskType),XIGENTIMER.TIMER.setTime(h.TimeLogged[1]),XIGENTIMER.VIEWMODEL.activityDesc(h.Desc),$(c.BILLABLE_SEL).prop("checked",h.Billable),$(c.REVIEW_SEL).prop("checked",h.ForReview),localforage.getItem("activityCache",function(a){g=a.filter(function(a){return a.EntityBaseID===h.TaskID})[0]||{},e=g.EstimatedHours?g.EstimatedHours.toFixed(2):!1,XIGENTIMER.API.getTimeForTask(h.TaskID,function(a){f=a.toFixed(2),$("[data-estimate]").text(e||"0.00"),$("[data-sofar]").text(f||"---")})}),"number"==typeof d&&a.VIEWMODEL.savedStates.splice(b,1),void XIGENTIMER.VIEWMODEL.selectOverview())}}}(XIGENTIMER),function(a){"use strict";var b,c;a.drawTaskList=function(){b()},a.drawManagedTaskList=function(){b(!0)},b=function(b){var d,e,f,g,h,i,j,k=b?"rawActivityCache":"activityCache";localforage.getItem(k,function(a){d=a,e=a,localforage.getItem("baseURL",function(a){j="/"===a.charAt(a.length-1)?a:a+"/",g()})}),g=function(){localforage.getItem("projectCache",function(a){c=a}).then(function(){localforage.getItem("user",function(a){h=a.UserID}).then(f)})},f=function(){b?d=d.filter(function(a){return a.CreatorID===h}):(d=d.filter(function(a){return a.CanEdit&&!a.HasChild}),d=d.filter(a.VIEWMODEL.showReviewItems()?function(a){return 18===a.TaskStatusID||1===a.TaskStatusID||4===a.TaskStatusID}:function(a){return 1===a.TaskStatusID||4===a.TaskStatusID}),a.VIEWMODEL.showInfiniteItems()||(d=d.filter(function(a){return a.EndDate}))),i()},i=function(){var a,e=0;a=function(){d=d.sort(function(a,b){return b.PriorityID===a.PriorityID?+a.moment-+b.moment:b.PriorityID-a.PriorityID}),b?XIGENTIMER.VIEWMODEL.managedTaskList([]):XIGENTIMER.VIEWMODEL.taskList([]),b?XIGENTIMER.VIEWMODEL.managedTaskList(d.filter(function(a){var b=[];return XIGENTIMER.VIEWMODEL.managedShowOpen()&&b.push(1),XIGENTIMER.VIEWMODEL.managedShowReview()&&b.push(18),XIGENTIMER.VIEWMODEL.managedShowPending()&&b.push(20),b.indexOf(a.TaskStatusID)>-1})):$.each(d,function(){XIGENTIMER.VIEWMODEL.taskList.push(this)})},$.each(d,function(f,g){switch(g.PriorityID){case 1:g.PriorityID=4;break;case 2:g.PriorityID=3;break;case 3:g.PriorityID=2;break;case 4:g.PriorityID=1}g.TaskURL=j+"TaskDetails.aspx?ID="+g.TaskID,g.ProjectURL=j+"ProjectDetails.aspx?ID="+g.ProjectID,g.DueDate=g.EndDate?moment(g.EndDate,"YYYY-MM-DD/HH:mm:ss.SS").startOf("day").add(17,"h").add(30,"m").fromNow():"--",g.moment=g.EndDate?moment(g.EndDate,"YYYY-MM-DD/HH:mm:ss.SS").startOf("day").add(17,"h").add(30,"m"):"--",g.daysDifference="string"!=typeof g.moment?g.moment.diff(moment(),"days"):null,g.EstimatedHours=g.EstimatedHours?parseFloat(g.EstimatedHours).toFixed(2):null,g.ProjectName=c.filter(function(a){return a.ProjectID===g.ProjectID})[0].Name,b?XIGENTIMER.API.getTimeForTask(g.TaskID,function(b){g.TotalHours=b.toFixed(2),e+=1,e===d.length&&a()}):(e+=1,e===d.length&&a())})}},a.selectTask=function(b){if(console.log("SelectingTask"),(a.VIEWMODEL.activityDesc()||a.TIMER.getTime().time>1)&&!confirm("There is time in the timer that hasn't been sent yet, or the timer is running. Are you sure you want to load this task?"))return!1;var d,e,f=parseInt($(b).parents("tr").attr("data-id"),10);localforage.getItem("activityCache",function(b){d=b.filter(function(a){return a.TaskID===f})[0],e=c.filter(function(a){return a.ProjectID===d.ProjectID})[0].Name,a.reset(),a.TIMER.stop(),a.STATE.restore({TaskName:d.Name,Breadcrumb:e+" » "+d.Name,TaskID:d.TaskID,TaskType:d.TaskTypeID,TimeLogged:[0,0],Desc:"",Billable:!0,ForReview:!1}),$(".do-timestart").trigger("click")})}}(XIGENTIMER),function(a){"use strict";var b=require("nw.gui"),c={WINDOW_WIDTH:290,WINDOW_HEIGHT:70,TARGET_X:screen.availWidth-290-10,TARGET_Y:screen.availHeight-70-10};a.notify=function(){var a,d=b.Window.open("notification.html",{frame:!1,title:"Notification Window",toolbar:!1,width:c.WINDOW_WIDTH,height:c.WINDOW_HEIGHT,x:screen.availWidth-c.WINDOW_WIDTH-10,y:screen.availHeight+100});d.setAlwaysOnTop(!0),a=setInterval(function(){d.y>c.TARGET_Y?d.moveTo(d.x,d.y-=5):clearInterval(a)},5),setTimeout(function(){a=setInterval(function(){d.y