diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..d7a6e24 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2d72a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.js \ No newline at end of file diff --git a/README.md b/README.md index 230ec53..fa54b0d 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,19 @@ -# 2018 Wrapped() +# YearInCode -A year in code - reviewed -
-Are you a GitHub user who already got their Spotify 2018 Wrapped? Fret not because YearInCode has your back! +๐ŸŽ‰๐ŸŽ‰Congratulations for getting through another year of coding!๐ŸŽ‰๐ŸŽ‰ ---- - -## What you can do - -Deck the code with **2018 Wrapped** - a fun way of finding out what you did this year to make your GitHub experience all the more merrier and joyful! +![Congrats](https://media.giphy.com/media/vmtxnxveVUodG/giphy.gif) -Go check out what made your 2018 at [YearInCode](https://YearInCode.github.io)! +This year on Github, you were part of a community of **31 million developers** from over **2.1 million organisations** who've created more than **96 million repositories**. -Login using your preferred GitHub account and kick back as you watch the past year unfold because we'll give you the best of what you've done this year from your contributions all the way to your user stats - all neatly bundled in one place! - ---- + ๐Ÿ’ป That's a lot of code! So to wrap up the year, we thought it would be cool to look back on your year- the repos you made, the languages you coded in, the skills you developed- so we made **YearInCode**. -## Share your 2018 with us +Inspired by spotify wrapped, YearInCode is a culmination of your development through the year, check it out! [YearInCode](https://YearInCode.github.io)! -Let's be honest...if you don't share it, did it really happen? -Tweet it, Blog about it on Medium, Share it on Facebook - spread the cheer for New Year's here! --- ## Acknowledgements -This fun app was made by fellow GitHub users [Rishabh Anand](https://twitter.com/rishabh16_) and [Sarvasv Kulpati](https://twitter.com/sarvasvkulpati). -It'd mean a lot if you could _Star_ this repo and, share and spread it amongst friends and family! +This app was made by fellow GitHub users [Sarvasv Kulpati](https://twitter.com/sarvasvkulpati) and [Malhar Kamat](https://twitter.com/malharkamat) in two days. +It'd mean a lot if you could ๐ŸŒŸ this repo and contribute if you have any suggestions! diff --git a/app.js b/app.js index ffb206f..270d0b4 100644 --- a/app.js +++ b/app.js @@ -1,12 +1,16 @@ -var config = { - apiKey: "AIzaSyC_ALjoUddvJVfVbKsWlD-FFK-jtyrg4PQ", - authDomain: "wrapped-21a29.firebaseapp.com", - databaseURL: "https://wrapped-21a29.firebaseio.com", - projectId: "wrapped-21a29", - storageBucket: "wrapped-21a29.appspot.com", - messagingSenderId: "606608835269" +var configFinal = { + apiKey: config.apiKey, + authDomain: config.authDomain, + databaseURL: config.databaseURL, + projectId: config.projectId, + storageBucket: "", + messagingSenderId: config.messagingSenderId }; -firebase.initializeApp(config); +firebase.initializeApp(configFinal); + +const serverURL = "https://yearincode.herokuapp.com"; + +var highestStars, highestStarredRepo, numRepos, recommendedRepos, recommendedContribRepos, tastebreakerRepos, favLanguages, bestStarred; document.addEventListener("DOMContentLoaded", () => { console.log("App loaded!"); @@ -16,12 +20,23 @@ document.addEventListener("DOMContentLoaded", () => { const clientID = "05d4f56f89ba1a91c3bd"; const clientSecret = "a9e53f438683513f1fd92d561cce3252af0504e9"; + const firstRepo = document.getElementById("first-repo-title"); + + var token = ""; + const hero = document.getElementById("hero"); const prepare = document.getElementById("prepare"); + const screen2 = document.getElementById("screen2"); + const screen3 = document.getElementById("screen3"); + const screen4 = document.getElementById("screen4"); + const screen5 = document.getElementById("screen5"); + const screen6 = document.getElementById("screen6"); + const screen7 = document.getElementById("screen7"); + const wrapScreen = document.getElementById("wrap-screen"); var provider = new firebase.auth.GithubAuthProvider(); - provider.addScope("repo"); - provider.addScope("user"); + // provider.addScope("repo"); + // provider.addScope("user"); provider.setCustomParameters({ allow_signup: true }); @@ -37,14 +52,27 @@ document.addEventListener("DOMContentLoaded", () => { } authButton.onclick = () => { + document.getElementById("spinner").style.display = "block"; + document.getElementById("overlay").style.display = "block"; firebase .auth() .signInWithPopup(provider) .then(function(result) { // This gives you a GitHub Access Token. You can use it to access the GitHub API. - var token = result.credential.accessToken; + token = result.credential.accessToken; // The signed-in user info. var user = result.user; + var username = user.displayName; + console.log(token); + // $.ajax({ + // async: false, + // url: serverURL+"/authenticate", + // type: "POST", + // data: {"token": token}, + // success: function(result){ + // console.log("done"); + // } + // }); // ... var promise = $.getJSON( `https://api.github.com/user?access_token=${token}` @@ -52,14 +80,134 @@ document.addEventListener("DOMContentLoaded", () => { promise.done(data => { console.log(data.name); + + // getting the individual data from the server + $.ajax({ + async: false, + url: serverURL+"/get_highest_starred_repo_created/"+token, + type: "GET", + success: function(result){ + result = result.slice(1, -1).split(","); + console.log("Most stars: " + result[0]); + document.getElementById("num-stars3").innerHTML = result[0]; + console.log("Highest starred repo: " + result[1].slice(3, -1)); + document.getElementById("most-starred-span3").innerHTML = result[1].slice(2, -1); + highestStars = result[0]; + highestStarredRepo = result[1].slice(2, -1); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_first_repo_created/"+token, + type: "GET", + success: function(result){ + firstRepo.innerHTML = ""+result+""; + console.log("First Repo: " + result); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_num_repos_created/"+token, + type: "GET", + success: function(result){ + console.log("Num repos: " + result); + numRepos = parseInt(result); + if (numRepos == 0){ + window.alert("You don't seem to have made any public repositories this year :("); + } + document.getElementById("num-repos-main").innerHTML = numRepos; + updateButtons(); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_favorite_languages/"+token, + type: "GET", + success: function(result){ + console.log("Fav langs: " + result); + favLanguages = result.slice(0, -1).split(","); + for(var i in favLanguages){ + favLanguages[i] = favLanguages[i].slice(2, -1); + } + updateLanguages(); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_recommended_repos/"+token, + type: "GET", + success: function(result){ + console.log("Recommended Repos: " + result); + recommendedRepos = JSON.parse(result); + // for(var i in recommendedRepos){ + // recommendedRepos[i] = recommendedRepos[i].slice(3, -1); + // } + console.log(recommendedRepos); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_tastebreaker_repos/"+token, + type: "GET", + success: function(result){ + console.log("Tastebreaker Repos: " + result); + tastebreakerRepos = JSON.parse(result); + // for(var i in tastebreakerRepos){ + // tastebreakerRepos[i] = tastebreakerRepos[i].slice(3, -1) + // } + console.log(tastebreakerRepos); + updateTastebreakers(); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_recommended_contribution_repos/"+token, + type: "GET", + success: function(result){ + console.log("Recommended Contrib Repos: " + result); + recommendedContribRepos = JSON.parse(result); + // for (var i in recommendedContribRepos){ + // recommendedContribRepos[i] = recommendedContribRepos[i].slice(3, -1); + // } + updateRecommendedRepos(); + } + }); + $.ajax({ + async: false, + url: serverURL+"/get_best_starred_repos/"+token, + type: "GET", + success: function(result){ + console.log("Best Starred Repos: " + result); + bestStarred = {}; + bestStarred = JSON.parse(result); + // for (var i in bestStarred){ + // bestStarred[i] = bestStarred[i].slice(3, -1); + // } + updateBestStarred(); + } + }); + + updateTwitterShare(); + + document.getElementById("spinner").style.display = "none"; + document.getElementById("overlay").style.display = "none"; + document.getElementById("auth-button").style.display = "none"; + // Animation begins hero.style.height = "100%"; prepare.style.display = "flex"; + screen2.style.display = "flex"; + screen3.style.display = "flex"; + screen4.style.display = "flex"; + screen5.style.display = "flex"; + screen6.style.display = "flex"; + screen7.style.display = "flex"; + wrapScreen.style.display = "flex"; new fullpage("#fullpage", { licenseKey: "LICENSE", navigation: true, - anchors: ["heroScreen", "prepareScreen"], + // anchors: ["heroScreen", "prepareScreen", "screen2"], parallax: true, onLeave: function(origin, destination, direction) { console.log("Leaving section" + origin.index); @@ -77,6 +225,175 @@ document.addEventListener("DOMContentLoaded", () => { var credential = error.credential; // ... console.log(email, errorMessage); + console.log(location.protocol); }); }; }); + + +function updateButtons(){ + // Logic to display the randomised numbers in each button choice + var buttonsDiv = document.getElementById("question-buttons3"); + var correctButtonPos = Math.floor(Math.random() * 3) + 1; + for (var i=1; i<=3; i++){ + var btn = document.createElement("button"); + btn.setAttribute("class", "selection-btn3 btn3"); + btn.setAttribute("onclick", "verifyNumRepos(event)"); + btn.setAttribute("id", i+"-element3"); + if (i == correctButtonPos){ + btn.innerHTML = numRepos; + } else{ + var min = numRepos - (Math.floor(numRepos/2)); + var max = numRepos + (Math.floor(numRepos/2)); + while (true){ + var value = Math.floor(Math.random() * (max - min + 1)) + min; + if (value != numRepos){ + btn.innerHTML = value; + break; + } + } + } + buttonsDiv.appendChild(btn); + } +} + +function verifyNumRepos(event){ + var btnId = event.target.id; + var btn = document.getElementById(btnId); + if (parseInt(btn.innerHTML) == numRepos) { + // proceed with next slide + // ... + $("#question-content3").animate({ height: "90%", opacity: 0},"5000", function(){ + $("#question-content3").remove(); + displayMainContent(); + }); + } else { + btn.style.backgroundColor = "#D3F9B5"; + btn.style.cursor = "default"; + btn.style.boxShadow = "none"; + } +} + +function displayMainContent(){ + $("#main-content3").fadeIn(1000, function(){ + // $("#num-repos").delay("500").animate({fontSize: "10vw"}, function(){ + // $("#first-line").delay("100").fadeIn("slow", function(){ + // $("#main-data").delay("500").fadeIn(); + // }); + // }); + console.log("lit") + }); +} + + +function updateLanguages(){ + var favouriteLang = favLanguages[0]; + var restLangs = favLanguages.slice(1); + var img = document.getElementById("language-img4"); + img.setAttribute("src", "images/languages/"+favouriteLang.toLowerCase()+".png"); + document.getElementById("fav-lang4").innerHTML = favouriteLang; + document.getElementById("language-span4").innerHTML = favouriteLang; + var langsOl = document.getElementById("list-languages4"); + for (var i in restLangs){ + console.log(i); + if (i >= 3){ + break; + } + var li = document.createElement("li"); + li.innerHTML = restLangs[i]; + langsOl.appendChild(li); + } +} + + +function updateRecommendedRepos(){ + var recommendedReposList = document.getElementById("recommended-repo5"); + var recommendedContribReposList = document.getElementById("recommended-contrib-repo5"); + var idx = 0; + + for (var i in recommendedRepos){ + if(idx>=6){ + break; + } + var li = document.createElement("li"); + var a = document.createElement("a"); + a.setAttribute("href", recommendedRepos[i]); + a.setAttribute("target", "_blank"); + a.innerHTML = i; + li.appendChild(a); + recommendedReposList.appendChild(li); + idx++; + } + + var idx = 0; + for (var i in recommendedContribRepos){ + if(idx>=6){ + break; + } + var li = document.createElement("li"); + var a = document.createElement("a"); + a.setAttribute("href", recommendedContribRepos[i]); + a.setAttribute("target", "_blank"); + a.innerHTML = i; + li.appendChild(a); + recommendedContribReposList.appendChild(li); + idx++; + } +} + + +function updateTastebreakers(){ + var tastebreakersList = document.getElementById("tastebreakers-list6"); + var idx = 0; + for (var i in tastebreakerRepos){ + if(idx>=6){ + break; + } + var li = document.createElement("li"); + var a = document.createElement("a"); + a.setAttribute("href", tastebreakerRepos[i]); + a.setAttribute("target", "_blank"); + a.innerHTML = i; + li.appendChild(a); + tastebreakersList.appendChild(li); + idx++ + } +} + +function updateBestStarred(){ + if (!isEmpty(bestStarred)){ + var bestStarredList = document.getElementById("best-starred-list7"); + var idx = 0 + for (var i in bestStarred){ + if(idx>=6){ + break; + } + var li = document.createElement("li"); + var a = document.createElement("a"); + a.setAttribute("href", bestStarred[i]); + a.setAttribute("target", "_blank"); + a.innerHTML = i; + li.appendChild(a); + bestStarredList.appendChild(li); + idx++ + } + } else{ + document.getElementById("subtitle7").innerHTML = "Looks like you haven't starred any repositories this year. Why not explore a few more for 2019?" + } +} + + + +function isEmpty(obj) { + for(var key in obj) { + if(obj.hasOwnProperty(key)) + return false; + } + return true; +} + +function updateTwitterShare(){ + var message = "My favourite programming language this year was '"+favLanguages[0]+"', and I made "+numRepos+" repositories, my most starred being '"+highestStarredRepo+"! Find out your year in code too!"; + var url = "https://twitter.com/share?url=https://yearincode.github.io/&text="+message+"&hashtags=yearincode2018" + document.getElementById("twitter-share-link").setAttribute("href", url); +} diff --git a/config.js b/config.js new file mode 100644 index 0000000..ff54c70 --- /dev/null +++ b/config.js @@ -0,0 +1,8 @@ +var config = { + apiKey: "AIzaSyDnY5vGhGekMtd_JZqXxRZp8CVJ4Exaj_E", + authDomain: "yearincode-b03f4.firebaseapp.com", + databaseURL: "https://yearincode-b03f4.firebaseio.com", + projectId: "yearincode-b03f4", + storageBucket: "", + messagingSenderId: "809927327037" +}; diff --git a/images/.DS_Store b/images/.DS_Store new file mode 100644 index 0000000..d749eff Binary files /dev/null and b/images/.DS_Store differ diff --git a/images/languages/.DS_Store b/images/languages/.DS_Store new file mode 100644 index 0000000..7611702 Binary files /dev/null and b/images/languages/.DS_Store differ diff --git a/images/languages/c#.png b/images/languages/c#.png new file mode 100644 index 0000000..2fcd26d Binary files /dev/null and b/images/languages/c#.png differ diff --git a/images/languages/c++.png b/images/languages/c++.png new file mode 100644 index 0000000..936741a Binary files /dev/null and b/images/languages/c++.png differ diff --git a/images/languages/c.png b/images/languages/c.png new file mode 100644 index 0000000..62aa527 Binary files /dev/null and b/images/languages/c.png differ diff --git a/images/languages/css.png b/images/languages/css.png new file mode 100644 index 0000000..221bf52 Binary files /dev/null and b/images/languages/css.png differ diff --git a/images/languages/html.png b/images/languages/html.png new file mode 100644 index 0000000..a11c195 Binary files /dev/null and b/images/languages/html.png differ diff --git a/images/languages/java.png b/images/languages/java.png new file mode 100644 index 0000000..a8a06c0 Binary files /dev/null and b/images/languages/java.png differ diff --git a/images/languages/javascript.png b/images/languages/javascript.png new file mode 100644 index 0000000..e545d9f Binary files /dev/null and b/images/languages/javascript.png differ diff --git a/images/languages/php.png b/images/languages/php.png new file mode 100644 index 0000000..ed111bc Binary files /dev/null and b/images/languages/php.png differ diff --git a/images/languages/python.png b/images/languages/python.png new file mode 100644 index 0000000..dbe1e15 Binary files /dev/null and b/images/languages/python.png differ diff --git a/images/languages/r.png b/images/languages/r.png new file mode 100644 index 0000000..ff7873e Binary files /dev/null and b/images/languages/r.png differ diff --git a/images/languages/ruby.png b/images/languages/ruby.png new file mode 100644 index 0000000..7eaf00e Binary files /dev/null and b/images/languages/ruby.png differ diff --git a/images/languages/swift.png b/images/languages/swift.png new file mode 100644 index 0000000..6dfae81 Binary files /dev/null and b/images/languages/swift.png differ diff --git a/images/share-logos/buffer.png b/images/share-logos/buffer.png new file mode 100644 index 0000000..01fdc78 Binary files /dev/null and b/images/share-logos/buffer.png differ diff --git a/images/share-logos/diggit.png b/images/share-logos/diggit.png new file mode 100644 index 0000000..17a7c3a Binary files /dev/null and b/images/share-logos/diggit.png differ diff --git a/images/share-logos/email.png b/images/share-logos/email.png new file mode 100644 index 0000000..ce7c980 Binary files /dev/null and b/images/share-logos/email.png differ diff --git a/images/share-logos/facebook.png b/images/share-logos/facebook.png new file mode 100644 index 0000000..2728f61 Binary files /dev/null and b/images/share-logos/facebook.png differ diff --git a/images/share-logos/flattr.png b/images/share-logos/flattr.png new file mode 100644 index 0000000..833985e Binary files /dev/null and b/images/share-logos/flattr.png differ diff --git a/images/share-logos/google.png b/images/share-logos/google.png new file mode 100644 index 0000000..42f4f7e Binary files /dev/null and b/images/share-logos/google.png differ diff --git a/images/share-logos/linkedin.png b/images/share-logos/linkedin.png new file mode 100644 index 0000000..7cf3a0b Binary files /dev/null and b/images/share-logos/linkedin.png differ diff --git a/images/share-logos/pinterest.png b/images/share-logos/pinterest.png new file mode 100644 index 0000000..8670208 Binary files /dev/null and b/images/share-logos/pinterest.png differ diff --git a/images/share-logos/print.png b/images/share-logos/print.png new file mode 100644 index 0000000..5f06fa8 Binary files /dev/null and b/images/share-logos/print.png differ diff --git a/images/share-logos/reddit.png b/images/share-logos/reddit.png new file mode 100644 index 0000000..f52ac86 Binary files /dev/null and b/images/share-logos/reddit.png differ diff --git a/images/share-logos/stumbleupon.png b/images/share-logos/stumbleupon.png new file mode 100644 index 0000000..9d48eb3 Binary files /dev/null and b/images/share-logos/stumbleupon.png differ diff --git a/images/share-logos/tumblr.png b/images/share-logos/tumblr.png new file mode 100644 index 0000000..80d8650 Binary files /dev/null and b/images/share-logos/tumblr.png differ diff --git a/images/share-logos/twitter.png b/images/share-logos/twitter.png new file mode 100644 index 0000000..b1394ec Binary files /dev/null and b/images/share-logos/twitter.png differ diff --git a/images/share-logos/vk.png b/images/share-logos/vk.png new file mode 100644 index 0000000..f248732 Binary files /dev/null and b/images/share-logos/vk.png differ diff --git a/images/share-logos/yummly.png b/images/share-logos/yummly.png new file mode 100644 index 0000000..e0db7c9 Binary files /dev/null and b/images/share-logos/yummly.png differ diff --git a/index.html b/index.html index 021c347..f5b9155 100644 --- a/index.html +++ b/index.html @@ -20,13 +20,26 @@ /> - + + + +
+ +