diff --git a/examples/demo.js b/examples/demo.js index ad512bb9..731b8603 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -2,7 +2,7 @@ document.addEventListener('DOMContentLoaded', function () { /*Scroll to top when arrow up clicked BEGIN*/ $(window).scroll(function() { - var height = $(window).scrollTop(); + let height = $(window).scrollTop(); if (height > 100) { $('#back2Top').fadeIn(); } else { @@ -28,16 +28,16 @@ document.addEventListener('DOMContentLoaded', function () { e.preventDefault(); }) - var toolbox; + let toolbox; (function() { - var org = urlHash().getUrlHashParameter('o') || 'publiclab'; - var repo = urlHash().getUrlHashParameter('r') || 'plots2'; - var ftoLabel = urlHash().getUrlHashParameter('f') || 'first-timers-only'; - var candidateLabel = urlHash().getUrlHashParameter('c') || 'fto-candidate'; - var recencyLabel = urlHash().getUrlHashParameter('l') || 'week'; - var leaderboardState = urlHash().getUrlHashParameter('s') || 'week'; + let org = urlHash().getUrlHashParameter('o') || 'publiclab'; + let repo = urlHash().getUrlHashParameter('r') || 'plots2'; + let ftoLabel = urlHash().getUrlHashParameter('f') || 'first-timers-only'; + let candidateLabel = urlHash().getUrlHashParameter('c') || 'fto-candidate'; + let recencyLabel = urlHash().getUrlHashParameter('l') || 'week'; + let leaderboardState = urlHash().getUrlHashParameter('s') || 'week'; toolbox = CommunityToolbox(org, repo); if (repo === 'all') { diff --git a/examples/themes.js b/examples/themes.js index fa60c993..7224ff24 100644 --- a/examples/themes.js +++ b/examples/themes.js @@ -2,9 +2,9 @@ // NIGHT MODE LOGIC //=============================================================== $(document).ready(() => { - var body=document.querySelector('body'); - var toggleButton=document.getElementById('myonoffswitch'); - var toggle = localStorage.getItem('currentToggle'); + let body=document.querySelector('body'); + let toggleButton=document.getElementById('myonoffswitch'); + let toggle = localStorage.getItem('currentToggle'); // Sets images' theme accordingly when the page is loaded setTimeout(()=> { @@ -105,7 +105,7 @@ buttonClickCallbackNightTheme = (e) => { e.preventDefault(); setTimeout(() => { - var recentContribsSectionImgs = document.getElementsByClassName('recent-contributors')[0].getElementsByTagName("img"); + let recentContribsSectionImgs = document.getElementsByClassName('recent-contributors')[0].getElementsByTagName("img"); let check=localStorage.getItem('currentToggle'); let images = [...recentContribsSectionImgs ]; if(check==="night") { diff --git a/examples/urlHash.js b/examples/urlHash.js index d926c449..f101bc9b 100644 --- a/examples/urlHash.js +++ b/examples/urlHash.js @@ -1,16 +1,16 @@ function urlHash() { function getUrlHashParameter(param) { - var params = getUrlHashParameters(); + let params = getUrlHashParameters(); return params[param]; } function getUrlHashParameters() { - var sPageURL = window.location.hash; + let sPageURL = window.location.hash; if (sPageURL) sPageURL = sPageURL.split('#')[1]; - var pairs = sPageURL.split('&'); - var object = {}; + let pairs = sPageURL.split('&'); + let object = {}; pairs.forEach(function(pair, i) { pair = pair.split('='); if (pair[0] != '') object[pair[0]] = pair[1]; @@ -22,19 +22,19 @@ function urlHash() { // and transforms to: url.com#paramName=value¶mName1=value function setUrlHashParameters(params) { - var keys = Object.keys(params); - var values = Object.values(params); - var pairs = []; + let keys = Object.keys(params); + let values = Object.values(params); + let pairs = []; keys.forEach(function(key, i) { if (key != '') pairs.push(keys[i] + '=' + values[i]); }); - var hash = pairs.join('&'); + let hash = pairs.join('&'); window.location.hash = hash; } function setUrlHashParameter(param, value) { - var params = getUrlHashParameters(); + let params = getUrlHashParameters(); params[param] = value; setUrlHashParameters(params); diff --git a/src/UI/contributorsUI.js b/src/UI/contributorsUI.js index fe0a97da..e1e79da2 100644 --- a/src/UI/contributorsUI.js +++ b/src/UI/contributorsUI.js @@ -6,10 +6,10 @@ function insertContributors(AllContributors){ document.getElementById("spinner-icon").style.display = "none"; let totalContributors = 0; - var usernames = AllContributors.map(function getContributorUsername(c) { + let usernames = AllContributors.map(function getContributorUsername(c) { return `@${c.login}`; }); - var avatars = AllContributors.map(function getContributorAvatarURL(c) { + let avatars = AllContributors.map(function getContributorAvatarURL(c) { return ``; }); totalContributors += AllContributors.length; diff --git a/src/UI/issuesUI.js b/src/UI/issuesUI.js index 4384117a..66dd5f1f 100644 --- a/src/UI/issuesUI.js +++ b/src/UI/issuesUI.js @@ -3,7 +3,7 @@ var moment = require('moment'); function generateIssueHtml(title, body, githubUrl, repo) { - var repoName = githubUrl.split('/')[4], + let repoName = githubUrl.split('/')[4], repoUrl = githubUrl.split('/').slice(0, 5).join('/'), html = '
\
\ @@ -18,7 +18,7 @@ function generateIssueHtml(title, body, githubUrl, repo) { } function insertIssue(issue, el) { - var body = ""; + let body = ""; body += "
" issue.labels.forEach(function(label) { body += "" + label.name + " "; diff --git a/src/scripts/chart.js b/src/scripts/chart.js index 99bf8304..c9ad7195 100644 --- a/src/scripts/chart.js +++ b/src/scripts/chart.js @@ -6,7 +6,7 @@ function generateChart(args) { args.label = args.label || ""; args.title = args.title || ""; - var colors = { + let colors = { "blue": "rgb(54, 162, 235)", "red": "rgb(255, 99, 132)", "green": "rgb(75, 192, 192)", @@ -15,9 +15,9 @@ function generateChart(args) { "purple": "rgb(153, 102, 255)", "yellow": "rgb(255, 205, 86)" } - var colorNames = Object.keys(colors); + let colorNames = Object.keys(colors); - var barChartData = { + let barChartData = { // labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [{ label: args.label, @@ -28,8 +28,8 @@ function generateChart(args) { }] } - var ctx = document.getElementById("canvas").getContext("2d"); - var chart = new Chart(ctx, { + let ctx = document.getElementById("canvas").getContext("2d"); + let chart = new Chart(ctx, { type: 'bar', data: barChartData, options: { diff --git a/src/utils/contribsUtil/fetchAllRepoContribs.js b/src/utils/contribsUtil/fetchAllRepoContribs.js index 6bbce2a1..11a6fa61 100644 --- a/src/utils/contribsUtil/fetchAllRepoContribs.js +++ b/src/utils/contribsUtil/fetchAllRepoContribs.js @@ -11,9 +11,9 @@ function fetchAllRepoContribs(org, repo) { return api.Repositories .getRepoContributors(org, repo, {method: "HEAD", qs: { sort: 'pushed', direction: 'desc', per_page: 100 } }) .then(function gotContribData(contribData) { - var headers = contribData; + let headers = contribData; if (headers.hasOwnProperty("link")) { - var parsed = parse(headers['link']); + let parsed = parse(headers['link']); if(parsed.last.page!=undefined) { totalPages = parseInt(parsed.last.page); } @@ -27,7 +27,7 @@ function fetchAllRepoContribs(org, repo) { let promises = []; for(let i = 1; i <= totalPages; i++) { - var currentPromise = api.Repositories + let currentPromise = api.Repositories .getRepoContributors(org, repo, { method:"GET", qs: { sort: 'pushed', direction: 'desc', per_page: 100, page:i } }) .then(function gotRepoContributors(contributors) { if (contributors!=undefined && (contributors != null || contributors.length > 0)) { diff --git a/src/utils/contribsUtil/storeAllContribsInDb.js b/src/utils/contribsUtil/storeAllContribsInDb.js index 8ebc0a2b..7311f00a 100644 --- a/src/utils/contribsUtil/storeAllContribsInDb.js +++ b/src/utils/contribsUtil/storeAllContribsInDb.js @@ -6,7 +6,7 @@ let model_utils = require('../../models/utils') function storeAllContribsInDb(org) { let AllContributors = []; let promises = []; - var contributorSet = new Set([]); + let contributorSet = new Set([]); return new Promise((resolve, reject) => { model_utils.getItem('allContributors').then((allContributors) => { // If all contributors list is not in the database, it makes a fresh call to Github API diff --git a/src/utils/getRepoContributors.js b/src/utils/getRepoContributors.js index 4e1bb606..fd38eb96 100644 --- a/src/utils/getRepoContributors.js +++ b/src/utils/getRepoContributors.js @@ -14,11 +14,11 @@ options = { // get list of contributors to a repo in a given time frame function getRepoContributors(username, repo, options){ commits = getCommitsInRange(username, repo, options); - var result = []; - var lookup = {}; - for (var i=0; i