From b77fb4c140c98a01ed4747c8e5ac70dad63e6d7c Mon Sep 17 00:00:00 2001 From: Manas Khurana Date: Mon, 12 Dec 2016 01:27:58 +0530 Subject: [PATCH] Update script.js --- js/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/script.js b/js/script.js index 61c2d3b..3c001f9 100644 --- a/js/script.js +++ b/js/script.js @@ -1 +1 @@ -function hide(e){var t=(e.id.toString(),window.getComputedStyle(e).getPropertyValue("display"));dispValue={prop:t},e.style.display="none"}function show(e){e.style.display&&"none"!=e.style.display||(dispValue[e.id.toString()]&&"none"!=dispValue[e.id.toString()]?e.style.display=dispValue[e.id.toString()]:e.style.display="block")}function css(e,t){for(var n in t)e.style[n]=t[n]}function arrowfunc(){var e,t;0===arrowvar?(window.innerWidth>800?(e="35vw",t="80%"):(e="88vw",t="98%"),Velocity(document.getElementById("extra"),{translateY:"0",width:t,height:e,borderRadius:"4px"},500),Velocity(document.getElementById("arrowCircle"),{rotateZ:"180deg"},500),setTimeout(function(){document.getElementById("extra").classList.add("extra"),menushrink(),Velocity(document.getElementById("extraContent"),{opacity:"1"},500),Velocity(document.body,"scroll",{offset:document.getElementById("extra").getBoundingClientRect().top.toString()+"px",mobileHA:!1,duration:500}),Velocity(document.getElementById("charts"),"fadeIn",500)},500),arrowvar=1):(menuswitch2=2,menushrink(),Velocity(document.body,"scroll",500),setTimeout(function(){menuswitch2=0,document.getElementById("extra").classList.remove("extra"),window.innerWidth>800?(e="4vw",t="4vw"):(e="10vw",t="10vw"),Velocity(document.getElementById("extra"),{translateY:"-4vw",width:t,height:e,borderRadius:"5vw"},500),1===chartswitch&&chartbutton(),hide(document.getElementById("charts")),Velocity(document.getElementById("arrowCircle"),{rotateZ:"0deg"},500),Velocity(document.getElementById("extraContent"),{opacity:"0"},500)},500),arrowvar=0)}function menubuttonfunc(){0===menuswitch1?showmenu():hidemenu()}function showmenu(){loc=window.pageYOffset,setTimeout(function(){css(document.getElementById("mainPage"),{overflow:"hidden"}),css(document.getElementById("contents"),{position:"absolute"}),menuswitch1=1},500),menuswitch2=1,menushrink(),Velocity(document.querySelector("#buttonBig hr:nth-child(1)"),{translateY:"7px"},{duration:250,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(1)"),{rotateZ:"45deg"},{duration:250,delay:260,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(2)"),{opacity:"0"},{duration:250,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(3)"),{translateY:"-7px"},{duration:250,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(3)"),{rotateZ:"-45deg"},{duration:250,delay:260,easing:"linear"}),css(document.getElementById("contents"),{position:"fixed"}),Velocity(document.getElementById("contents"),"fadeIn",750),Velocity(document.getElementById("bg1"),"slideDown",500),Velocity(document.getElementById("buttonBig"),{backgroundColor:"rgba(0,0,0,0.5)"},500),clearInterval(intervalId)}function hidemenu(){setTimeout(function(){menuswitch1=0},500),menuswitch2=0,Velocity(document.querySelector("#buttonBig hr:nth-child(1)"),{rotateZ:"0deg"},{duration:250,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(1)"),{translateX:"0",translateY:"0"},{duration:250,delay:260,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(2)"),{opacity:"1"},{duration:250,delay:260,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(3)"),{rotateZ:"0deg"},{duration:250,easing:"linear"}),Velocity(document.querySelector("#buttonBig hr:nth-child(3)"),{translateX:"0px",translateY:"0dpx"},{duration:250,delay:260,easing:"linear"}),Velocity(document.getElementById("contents"),"fadeOut",250);for(var e=0,t=document.querySelectorAll("#contents,#bg1");ee&&(e=60),window.pageYOffset>=e?css(document.getElementById("menu"),{position:"fixed",height:"10%"}):css(document.getElementById("menu"),{position:"absolute",height:"30%"}),css(document.getElementById("logo2"),{position:"fixed"}),window.pageYOffset>=logopos?(hide(document.getElementById("logo")),show(document.getElementById("logo2"))):(hide(document.getElementById("logo2")),show(document.getElementById("logo")))}else 1===menuswitch2?(css(document.getElementById("menu"),{position:"fixed",height:"10%"}),hide(document.getElementById("logo")),show(document.getElementById("logo2"))):2===menuswitch2&&(css(document.getElementById("menu"),{position:"absolute",height:"30%"}),hide(document.getElementById("logo2")),show(document.getElementById("logo")),css(document.getElementById("menu"),{transition:"height 0.5s linear"}),setTimeout(function(){css(document.getElementById("menu"),{transition:"all 0s"})}))}function nav(e,t){if("show"==e)"help"==t?0===help?(Velocity(document.getElementById("help"),"slideDown",1e3),Velocity(document.getElementById("menuHelp"),{color:"black",backgroundColor:"rgba(0,0,0,0.1)",fontWeight:"900"},1e3),help=1):(Velocity(document.getElementById("help"),"slideUp",1e3),Velocity(document.getElementById("menuHelp"),{color:"grey",backgroundColor:"white",fontWeight:"100"},1e3),setTimeout(function(){help=0},1e3)):"about"==t?0===about?(Velocity(document.getElementById("about"),"slideDown",1e3),Velocity(document.getElementById("menuAbout"),{color:"black",backgroundColor:"rgba(0,0,0,0.1)",fontWeight:"900"},1e3),about=1):(Velocity(document.getElementById("about"),"slideUp",1e3),Velocity(document.getElementById("menuAbout"),{color:"grey",backgroundColor:"white",fontWeight:"100"},1e3),setTimeout(function(){about=0},1e3)):0===embed?(Velocity(document.getElementById("embed"),"slideDown",1e3),Velocity(document.getElementById("menuEmbed"),{color:"black",backgroundColor:"rgba(0,0,0,0.1)",fontWeight:"900"},1e3),embed=1):(Velocity(document.getElementById("embed"),"slideUp",1e3),Velocity(document.getElementById("menuEmbed"),{color:"grey",backgroundColor:"white",fontWeight:"100"},1e3),setTimeout(function(){embed=0},1e3));else{for(var n=0,o=document.querySelectorAll("#about,#help,#embed");n800?1!==extraState&&(css(document.getElementById("extra"),{width:"4vw",height:"4vw"}),extraState=1):2!==extraState&&(css(document.getElementById("extra"),{width:"10vw",height:"10vw"}),extraState=2):window.innerWidth>800?3!==extraState&&(css(document.getElementById("extra"),{width:"80%",height:"35vw"}),extraState=3):4!==extraState&&(css(document.getElementById("extra"),{width:"98%",height:"88vw"}),extraState=4)}),document.getElementById("instruct").src="/images/instruct.png",(window.top!==window.self||window.top.location!=window.self.location||"youcount.github.io"!=window.location.hostname||"youcount.github.io"!=window.top.location.hostname)&&(window.top.location=window.self.location),"https:"!=window.location.protocol&&(window.location.href="https:"+window.location.href.substring(window.location.protocol.length));var emailParts=["manas.khurana20","gmail","com",".","@"];document.getElementById("email").innerHTML=emailParts[0]+emailParts[4]+emailParts[1]+emailParts[3]+emailParts[2],document.getElementById("email").href="mailto:"+document.getElementById("email").innerHTML,document.getElementById("buttonBig").addEventListener("click",function(){menubuttonfunc()}),document.getElementById("fb").addEventListener("click",function(){window.open("https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(document.querySelector("#pageUrl input").getAttribute("value")),"_blank")}),document.getElementById("tw").addEventListener("click",function(){window.open("https://twitter.com/share?text="+document.getElementById("username").value+" now has "+live.actualCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")+" subscribers!&url="+encodeURIComponent(document.querySelector("#pageUrl input").getAttribute("value"))+"&hashtags=YouCount","_blank")}),document.getElementById("lnkdIn").addEventListener("click",function(){window.open("https://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(document.querySelector("#pageUrl input").getAttribute("value"))+"&title="+encodeURIComponent(channelname)+"'s%20Live%20Subscriber%20Count&source=YouCount","_blank")}),document.getElementById("tb").addEventListener("click",function(){window.open("http://www.tumblr.com/share/link?url="+encodeURIComponent(document.querySelector("#pageUrl input").getAttribute("value")),"_blank")}),document.getElementById("rdit").addEventListener("click",function(){window.open("http://www.reddit.com/submit?url="+encodeURIComponent(document.querySelector("#pageUrl input").getAttribute("value"))+"&title="+encodeURIComponent(channelname)+"'s%20Live%20Subscriber%20Count","_blank")}),document.getElementById("link").addEventListener("click",function(){linkshare()});for(var i=0,x=document.querySelectorAll("#menuHelp,#menuAbout,#menuEmbed");in;n++)try{show(t[n]),t[n].dataset.id=e.items[n].snippet.channelId.trim(),document.querySelectorAll(".suggest div")[n].textContent=e.items[n].snippet.title,document.querySelectorAll(".suggestImg")[n].src=e.items[n].snippet.thumbnails["default"].url}catch(o){hide(t[n])}})):void hide(document.getElementById("suggest"))});var arrowvar=0,menuswitch1=0,menuswitch2=0,loc,menushrinkvar=0;setInterval(function(){1===menushrinkvar&&(menushrinkvar=0,menushrink())},100);var logopos=document.getElementById("logo").getBoundingClientRect().top;window.addEventListener("scroll",function(){menushrinkvar=1}),menushrink();var help=0,about=0,embed=0,chartswitch=0,firstload +function arrowfunc(){$("#extra").css({"-webkit-transition":"width 0.5s, height 0.5s, border-radius 0.5s, transform 0.5s",transition:"width 0.5s, height 0.5s, border-radius 0.5s, transform 0.5s"}),0===arrowvar?($("#extra").addClass("card"),$("#extra").removeClass("extra"),$("#arrowCircle").css({transform:"rotate(180deg)"}),setTimeout(function(){$("#extraContent").css({opacity:"1"}),$("html, body").animate({scrollTop:$("#extra").offset().top},500),$("#charts").fadeIn(500)},500),arrowvar=1):($("html, body").animate({scrollTop:0},500),setTimeout(function(){$("#extra").addClass("extra"),$("#extra").removeClass("card"),$("#charts").hide(),$("#arrowCircle").css({transform:"rotate(0deg)"}),$("#extraContent").css({opacity:"0"})}),arrowvar=0),setTimeout(function(){$("#extra").css({"-webkit-transition":"all 0s ease 0s",transition:"all 0s ease 0s"})},1e3)}function menubuttonfunc(){0===menuswitch1?showmenu():hidemenu()}function showmenu(){loc=$("#buttonBig").offset().top,setTimeout(function(){$("#mainPage").css({overflow:"hidden"}),$("#contents").css({position:"absolute"}),menuswitch1=1},500),menuswitch2=1,menushrink("smooth"),$("#buttonBig").addClass("cross"),$("#contents").css({position:"fixed"}),$("#contents").fadeIn(750),$("#bg1").slideDown(500),$("#buttonBig").css({"background-color":"rgba(0,0,0,0.5)"})}function hidemenu(){setTimeout(function(){menuswitch1=0},500),menuswitch2=0,$("#buttonBig").removeClass("cross"),$("#contents").fadeOut(250),$("#contents,#bg1").slideUp(500),$("#buttonBig").css({"background-color":"transparent"}),nav("hide",null),$("#mainPage").css({overflow:"visible"}),window.scrollTo(0,loc),menushrink()}function menushrink(a){if(0===menuswitch2){var b=window.innerHeight/5;window.pageYOffset>b?$("#menu").css({position:"fixed",height:"10%"}):$("#menu").css({position:"absolute",height:"30%"});var c=b/2;document.getElementById("logo2").style.position="fixed",window.pageYOffset>c?(document.getElementById("logo").style.display="none",document.getElementById("logo2").style.display="initial"):(document.getElementById("logo2").style.display="none",document.getElementById("logo").style.display="inherit")}else $("#menu").css({position:"fixed",height:"10%"}),document.getElementById("logo2").style.display="inherit",document.getElementById("logo").style.display="none";"smooth"==a&&($("#menu").css({transition:"height 0.5s linear"}),setTimeout(function(){$("#menu").css({transition:"all 0s"})}))}function nav(a,b){"show"==a?"help"==b?0===help?($("#help").slideDown(1e3),$("#menuHelp").css({color:"black","background-color":"rgba(0,0,0,0.1)","font-weight":"900"}),help=1):($("#help").slideUp(1e3),$("#menuHelp").css({color:"grey","background-color":"white","font-weight":"100"}),setTimeout(function(){help=0},1e3)):"about"==b?0===about?($("#about").slideDown(1e3),$("#menuAbout").css({color:"black","background-color":"rgba(0,0,0,0.1)","font-weight":"900"}),about=1):($("#about").slideUp(1e3),$("#menuAbout").css({color:"grey","background-color":"white","font-weight":"100"}),setTimeout(function(){about=0},1e3)):0===embed?($("#embed").slideDown(1e3),$("#menuEmbed").css({color:"black","background-color":"rgba(0,0,0,0.1)","font-weight":"900"}),embed=1):($("#embed").slideUp(1e3),$("#menuEmbed").css({color:"grey","background-color":"white","font-weight":"100"}),setTimeout(function(){embed=0},1e3)):($("#about,#help,#embed").hide(),$("#menuAbout,#menuHelp,#menuEmbed").css({color:"grey","background-color":"white","font-weight":"100"}),help=0,about=0,embed=0)}function trigenter(a){13===a.keyCode&&getValue()}function linkshare(){$("#pageUrl").fadeIn(),$("#bg2").fadeIn(),$("#bg2").on("click",function(){$("#pageUrl").fadeOut(),$("#bg2").hide(),$("bg2").off("click")})}function chartbutton(){$("#charts").css({"-webkit-transition":"all 0.5s",transition:"all 0.5s"}),0===firstload?($.getScript("/js/chart.js",function(){isChart=1,document.getElementById("charts").style.height="40vh",$("#showchart").fadeOut(),$("#hidechart").fadeIn(),chartswitch=1,setTimeout(function(){$("#charts").css({"-webkit-transition":"all 0s",transition:"all 0s"})},500)}),$("#showchart").html("LOADING..."),firstload=1):(setTimeout(function(){$("#charts").css({"-webkit-transition":"all 0s",transition:"all 0s"})},500),$("#showchart").html("SHOW TREND"),0===chartswitch?(isChart=1,document.getElementById("charts").style.height="40vh",$("#showchart").fadeOut(),$("#hidechart").fadeIn(),chartswitch=1):(myLineChart.destroy(),document.getElementById("charts").style.height="15vh",$("#showchart").fadeIn(),$("#hidechart").fadeOut(100),chartswitch=0,isChart=0))}for(var images=document.getElementsByTagName("img"),pl=0;pl'),changeText(document.querySelector("#pageUrl input"),"https://youcount.github.io/#!/"+d)})}popstatevar=1;var f="https://www.googleapis.com/youtube/v3/channels?part=statistics&id="+username+"&fields=items/statistics&key="+getKey();getText(f,function(a){changeText(document.getElementById("totalVideos"),a.items[0].statistics.videoCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")),changeText(document.getElementById("totalViews"),a.items[0].statistics.viewCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g,","))})})}),$("#arrowCircle").on("click",function(){arrowfunc()}),$("#logo,#logo2").on("click",function(){location.href="/"}),$("#showchart,#hidechart").on("click",function(){chartbutton()});var shareswitch=0;$("#share").on("click",function(){0===shareswitch?($("#sharebox").height("52.5%"),$("#share").height("14.2%"),$("#fb,#tw,#lnkdIn,#tb,#rdit,#link").fadeIn(200),shareswitch=3):($("#fb,#tw,#lnkdIn,#tb,#rdit,#link").fadeOut(200),setTimeout(function(){$("#sharebox").height("7.5%"),$("#share").height("100%"),shareswitch=0},200))}),$("body").on("click",function(){0!==shareswitch&&(--shareswitch,1==shareswitch&&($("#fb,#tw,#lnkdIn,#tb,#rdit,#link").fadeOut(200),setTimeout(function(){$("#sharebox").height("7.5%"),$("#share").height("100%"),shareswitch=0},200)))}),$("#username").focusin(function(){$("#input").css({"background-color":"rgba(255,0,0,0.4)"}),$("#input button").fadeIn(250),$("#username").select()}),$("#username").focusout(function(){$("#input").css({"background-color":"rgba(0,0,0,0.3)"}),$("#input button, #suggest").fadeOut(250)}),$("#username").on("keyup",function(){var a=document.getElementById("username").value;return a.trim()?($("#suggest").show(),void("Not Found!"!=a.trim()&&"Loading..."!=a.trim()&&getText("https://www.googleapis.com/youtube/v3/search?part=snippet&q="+encodeURIComponent(a)+"&type=channel&maxResults=5&relevanceLanguage=en&key="+getKey(),function(a){if(!(a.pageInfo.totalResults<1))for(var b=0;b<5;b++)try{document.querySelectorAll(".suggest")[b].style.display="block",document.querySelectorAll(".suggest")[b].dataset.id=a.items[b].snippet.channelId.trim(),document.querySelectorAll(".suggest div")[b].textContent=a.items[b].snippet.title,document.querySelectorAll(".suggestImg")[b].src=a.items[b].snippet.thumbnails.default.url}catch(a){document.querySelectorAll(".suggest")[b].style.display="none"}}))):void $("#suggest").hide()});var arrowvar=0,menuswitch1=0,menuswitch2=0,loc;window.onscroll=function(){menushrink()},menushrink();var help=0,about=0,embed=0,chartswitch=0,firstload=0;