(function(){var n=angular.module("hermitcraft",[])})(),function(){var n=function(n){var t=function(t,i,r){var u="/api/",f="",e=(new Date).toUTCString();return i==undefined&&(i="Latest"),r!=undefined?(u+="hermitvideos?type="+i+"&member="+r,gtag("event","GET",{API:"Hermit Videos"})):(u+="videos?type="+i,gtag("event","GET",{API:"Videos"})),t!=null?(t.forEach(function(n){n.uploaded>f&&(f=n.uploaded)}),u+="&id="+escape(f)):u+="&start="+escape(e),n.get(u).then(function(n){return n})},i=function(t){var i=[];return t.forEach(function(n){i.push(n.id)}),gtag("event","GET",{API:"Video Stats"}),n.get("/api/videostats?id="+escape(i.join(","))).then(function(n){return n})},r=function(t){var i="/api/hermit";return t!=undefined&&(i+="/"+t),n.get(i).then(function(n){return n})},u=function(t){var i="/api/inactivehermit";return t!=undefined&&(i+="/"+t),n.get(i).then(function(n){return n})},f=function(){return n.get("/api/streaming").then(function(n){return n})},e=function(t,i){var r="/api/videos";return t=="HermitCraft"?r+="?type=HermitCraft&start="+i:t=="All"&&(r+="?type=All&start="+i),gtag("event","GET",{Button:"More Videos"}),n.get(r).then(function(n){return n})};return{getVideos:t,getStats:i,getMemberList:r,getInactiveMemberList:u,getStreaming:f,getMoreVideos:e}},t=angular.module("hermitcraft");t.factory("api",["$http",n])}(),function(){angular.module("hermitcraft").filter("friendlyTime",function(){return function(n,t){var f=(Date.now()-Date.parse(n))/1e3,r=Math.floor(f/60),i=Math.floor(r/60),u=Math.floor(i/24);t==undefined&&(t=!1);var e=t?"d":" day"+(u>1?"s":"")+" ago",o=t?"m":" minute"+(r>1?"s":"")+" ago",s=t?"h":" hour"+(i>1?"s":"")+"  ago";return i>23?u+e:i==0?r+o:i+s}})}(),function(){var n=angular.module("hermitcraft"),t=function(n,t,i,r){var f=function(t){n.videos=t.data;e()},s=function(t){t.data.forEach(function(t){n.videos.push(t)});e()},u=function(t){t.status=="304"?c():n.error="Error retrieving data."},h=r.getVideos().then(f,u),e=function(){n.videos.forEach(function(n){n.friendlyTime=i("friendlyTime")(n.uploaded);n.friendlyTimeMobile=i("friendlyTime")(n.uploaded,!0)})},c=function(){n.videos&&r.getStats(n.videos).then(function(t){var r=t.data,i;n.videos.forEach(function(n){i=r[n.id];n.likeCount=i.likeCount;n.commentCount=i.commentCount;n.viewCount=i.viewCount})})},l=t(e,2e4),o=t(function(){r.getVideos(n.videos,"Latest").then(f,u)},3e5);n.btnLatest=!0;n.btnAll=!1;n.btnHermitCraft=!1;n.setView=function(i){i==undefined&&(i="Latest");t.cancel(o);o=t(function(){r.getVideos(n.videos,i).then(f,u)},3e5);h=r.getVideos(null,i).then(f,u);n.btnLatest=!1;n.btnAll=!1;n.btnHermitCraft=!1;switch(i){case"All":n.btnAll=!0;break;case"HermitCraft":n.btnHermitCraft=!0;break;default:n.btnLatest=!0}};n.getMoreVideos=function(){var t="",i=n.videos[n.videos.length-1].uploaded;n.btnHermitCraft?t="HermitCraft":n.btnAll&&(t="All");r.getMoreVideos(t,i).then(s,u)}};n.controller("HermitCraftController",["$scope","$interval","$filter","api",t])}(),function(){var n=angular.module("hermitcraft"),t=function(n,t,i,r){var u=_member,f=function(t){n.videos=t.data;o()},e=function(t){t.status=="304"?s():n.error="Error retrieving data."},h=r.getVideos(null,"Latest",u).then(f,e),o=function(){n.videos.forEach(function(n){n.friendlyTime=i("friendlyTime")(n.uploaded);n.friendlyTimeMobile=i("friendlyTime")(n.uploaded,!0)})},s=function(){var t;n.videos&&r.getStats(n.videos).then(function(i){var r=i.data;n.videos(function(n){t=r[n.id];n.likeCount=t.likeCount;n.commentCount=t.commentCount;n.viewCount=t.viewCount})})},c=t(o,2e4),l=t(function(){r.getVideos(n.videos,"Latest",u).then(f,e)},3e5)};n.controller("VideosController",["$scope","$interval","$filter","api",t])}(),function(){var n=angular.module("hermitcraft"),t=function(){};n.controller("HermitController",t)}(),function(){var n=angular.module("hermitcraft"),t=function(n,t,i,r){var u={ChannelName:_member,Streaming:!1,YTStreaming:!1},e=function(t){n.member=t.data},o=function(n){var t,i;n.data.twitch?(t=n.data.twitch.join(","),u.Streaming=t.indexOf(u.ChannelName)>-1?!0:!1):u.Streaming=!1;n.data.youtube?(i=n.data.youtube.join(","),u.YTStreaming=i.indexOf(u.ChannelName)>-1?!0:!1):u.YTStreaming=!1},f=function(){n.error="Error retrieving data."},s;r.getMemberList(u.ChannelName).then(e,f);s=t(function(){r.getStreaming().then(o,f)},3e5)};n.controller("LinksController",["$scope","$interval","$filter","api",t])}(),function(){var n=angular.module("hermitcraft"),t=function(n,t,i,r){var s;n.totalStreaming=0;var f=function(t){t.data.forEach(function(t){t.Streaming==!0&&(n.totalStreaming+=1);t.YTStreaming==!0&&(n.totalStreaming+=1)});n.members=t.data},e=function(t){n.inactiveMembers=t.data},o=function(t){var i,r;n.totalStreaming=0;t.data.twitch&&(n.totalStreaming+=t.data.twitch.length);t.data.youtube&&(n.totalStreaming+=t.data.youtube.length);t.data.twitch?(i=t.data.twitch.join(","),n.members.forEach(function(n){n.Streaming=i.indexOf(n.ChannelName)>-1?!0:!1})):n.members.forEach(function(n){n.Streaming=!1});t.data.youtube?(r=t.data.youtube.join(","),n.members.forEach(function(n){n.YTStreaming=r.indexOf(n.ChannelName)>-1?!0:!1})):n.members.forEach(function(n){n.YTStreaming=!1})},u=function(){n.error="Error retrieving data."};r.getMemberList().then(f,u);r.getInactiveMemberList().then(e,u);s=t(function(){r.getStreaming().then(o,u)},3e5)};n.controller("MemberListController",["$scope","$interval","$filter","api",t])}()