if("undefined"==typeofjQuery)thrownewError("Baby Buddy requires jQuery.");varBabyBuddy={};functionpreventDoubleSubmit(){return!1}BabyBuddy.PullToRefresh=function(e){return{init:function(){e.init({mainElement:"body",onRefresh:this.onRefresh})},onRefresh:function(){window.location.reload()}}}(PullToRefresh),$("form").off("submit",preventDoubleSubmit),$("form").on("submit",function(){$(this).on("submit",preventDoubleSubmit)}),BabyBuddy.Timer=function(e){varn=null,t=null,i=null,d=newDate,r=null,o={run:function(d,u){returnt=d,0===(i=e("#"+u)).length?(console.error("BBTimer: Timer element not found."),!1):0===i.find(".timer-seconds").length||0===i.find(".timer-minutes").length||0===i.find(".timer-hours").length?(console.error("BBTimer: Element does not contain expected children."),!1):(n=setInterval(this.tick,1e3),void0!==document.hidden?r="hidden":void0!==document.msHidden?r="msHidden":void0!==document.webkitHidden&&(r="webkitHidden"),voidwindow.addEventListener("focus",o.handleVisibilityChange,!1))},handleVisibilityChange:function(){!document[r]&&newDate-d>1&&o.update()},tick:function(){vare=i.find(".timer-seconds"),n=Number(e.text());if(n<59)e.text(n+1);else{e.text(0);vart=i.find(".timer-minutes"),d=Number(t.text());if(d<59)t.text(d+1);else{t.text(0);varr=i.find(".timer-hours"),o=Number(r.text());r.text(o+1)}}},update:function(){e.get("/api/timers/"+t+"/",function(e){if(e&&"duration"ine){clearInterval(n);vart=e.duration.split(/[\s:.]/);5===t.length&&(t[0]=24*parseInt(t[0])+parseInt(t[1]),t[1]=t[2],t[2]=t[3]),i.find(".timer-hours").text(parseInt(t[0])),i.find(".timer-minutes").text(parseInt(t[1])),i.find(".timer-seconds").text(parseInt(t[2])),d=newDate,n=setInterval(o.tick,1e3)}})}};returno}(jQuery),BabyBuddy.Dashboard=function(e){varn=null,t={watch:function(i,d){if(0==e("#"+i).length)returnconsole.error("Baby Buddy: Dashboard element not found."),!1;void0!==document.hidden?n="hidden":void0!==document.msHidden?n="msHidden":void0!==document.webkitHidden&&(n="webkitHidden"),void0===window.addEventListener||void0===document.hidden?d&&setInterval(this.update,d):(window.addEventListener("focus",t.handleVisibilityChange,!1),d&&setInterval(t.handleVisibilityChange,d))},handleVisibilityChange:function(){document[n]||t.update()},update:function(){location.reload()}};returnt}(jQuery);