From b3559746cf40fa2667fe6cf106811b1d0e966470 Mon Sep 17 00:00:00 2001 From: rishabh570 Date: Mon, 22 Jul 2019 20:42:55 +0530 Subject: [PATCH] some minor changes. --- dist/community-toolbox.js | 32 +++++------ examples/demo.js | 7 ++- examples/themes.js | 54 ++++++++++--------- index.html | 4 +- src/scripts/community-toolbox.js | 12 ++--- .../fetchAllRecentMonthContribs.js | 2 +- .../fetchRecentMonthContribs.js | 5 +- src/utils/recentContribsUtil/freshFetch.js | 1 - .../getContribsLastMonth.js | 2 - src/utils/recentContribsUtil/main.js | 2 +- src/utils/recentContribsUtil/queryTime.js | 2 +- ...ThisMonthOrNot.js => withinMonthsOrNot.js} | 4 +- 12 files changed, 62 insertions(+), 65 deletions(-) rename src/utils/recentContribsUtil/{withinThisMonthOrNot.js => withinMonthsOrNot.js} (82%) diff --git a/dist/community-toolbox.js b/dist/community-toolbox.js index 41b2d574..97979070 100644 --- a/dist/community-toolbox.js +++ b/dist/community-toolbox.js @@ -82160,23 +82160,23 @@ CommunityToolbox = function CommunityToolbox(org, repo) { // Function for fetching and showing recent contributors - function showRecentContributors(org, repo, recencyLabel, forMonths=1) { + function showRecentContributors(org, repo, recencyLabel, forMonths=6) { return recentContribsUtil.fetchAllRecentContribsInDb(org, repo).then((result)=>{ if(recencyLabel==="month") { return recentContribsUtil.fetchContribsLastMonth(org, repo, forMonths) - .then(function gotCommits(commits) { - // Stores the CURRENTLY ACTIVE recent contribs data + .then(function gotMonthlyContribs(monthContribs) { + // Stores the CURRENTLY ACTIVE recent contribs data which is utilized by filter model_utils.deleteItem('recent-contribs-data').then((res)=> { - model_utils.setItem('recent-contribs-data', commits); + model_utils.setItem('recent-contribs-data', monthContribs); }) // Push data to UI - recentContributorsUI.insertRecentContributors(commits); + recentContributorsUI.insertRecentContributors(monthContribs); return; }); } else { return recentContribsUtil.fetchContribsLastWeek(org, repo) .then((weekly_contribs) => { - // Stores the CURRENTLY ACTIVE recent contribs data + // Stores the CURRENTLY ACTIVE recent contribs data which is utilized by filter model_utils.deleteItem('recent-contribs-data').then((res)=> { model_utils.setItem('recent-contribs-data', weekly_contribs); }) @@ -82532,7 +82532,7 @@ function fetchAllRecentMonthContribs(org, repos, queryTime) { let monthInd = monthsQuery.findMonthInd(queryTime); // We take only 10 repos just for API quota reasons - let splicedRepos = repos.splice(0,1); + let splicedRepos = repos.splice(0,10); let promises = splicedRepos.map(function mapToEachRepo(repo, i) { return fetchRecentMonthContribs.fetchRecentMonthContribs(org, repo, queryTime) @@ -82576,8 +82576,7 @@ module.exports = { },{"../../models/utils":405,"./fetchRecentMonthContribs":416,"./queryTime":421}],416:[function(require,module,exports){ let model_utils = require('../../models/utils') let monthsQuery = require('./queryTime') -let withinThisWeekOrNot = require('./withinThisWeekOrNot') -let withinThisMonthOrNot = require('./withinThisMonthOrNot') +let withinMonthsOrNot = require('./withinMonthsOrNot') let freshFetch = require('./freshFetch') // Fetches recent month commits for a particular repository @@ -82596,7 +82595,7 @@ function fetchRecentMonthContribs(org, repo, queryTime) { if(wholeContribsList!=undefined && wholeContribsList!=null) { wholeContribsList.map((contributor, index) => { let commit_date = contributor['commit']['committer']['date']; - let check = withinThisMonthOrNot.within_this_month(commit_date, monthsInd); + let check = withinMonthsOrNot.within_months(commit_date, monthsInd); if(check) { contribs.push(contributor); } @@ -82630,7 +82629,7 @@ function fetchRecentMonthContribs(org, repo, queryTime) { module.exports = { fetchRecentMonthContribs: fetchRecentMonthContribs } -},{"../../models/utils":405,"./freshFetch":417,"./queryTime":421,"./withinThisMonthOrNot":423,"./withinThisWeekOrNot":424}],417:[function(require,module,exports){ +},{"../../models/utils":405,"./freshFetch":417,"./queryTime":421,"./withinMonthsOrNot":423}],417:[function(require,module,exports){ let model_utils = require('../../models/utils') let monthsQuery = require('./queryTime') @@ -82666,7 +82665,6 @@ function freshFetch(org, repo, queryTime) { return Promise.all(proms) .then(() => { - console.log("going in promise all of freshFetch"); // Save each repo's commits data to the database let currTime = (new Date).getTime(); model_utils.setItem(`recent-${repo}-${monthsInd}-month-commits`, result); @@ -82711,7 +82709,6 @@ function getContribsLastMonth(org, repo, forMonths) { // We make queryTime 1 month behind the current time, to pass it as query in the request let d = (new Date); let temp = forMonths*30; - console.log('temp: ', temp); d.setDate(d.getDate() - temp); let queryTime = d.toISOString(); if(repo==='all') { @@ -82723,7 +82720,6 @@ function getContribsLastMonth(org, repo, forMonths) { else { return fetchRecentMonthContribs.fetchRecentMonthContribs(org, repo, queryTime) .then(function gotRecentCommitsInStorage(month_commits) { - console.log("getContribsLastMonth = ", month_commits) return month_commits; }) } @@ -82806,7 +82802,7 @@ let storeAllRecentContribsInDb = require('./storeAllRecentContribsInDb') -function fetchContribsLastMonth(org, repo, forMonths=1) { +function fetchContribsLastMonth(org, repo, forMonths=6) { return getContribsLastMonth.getContribsLastMonth(org, repo, forMonths) .then((contribs) => { return contribs; @@ -82845,7 +82841,7 @@ function findMonthInd(queryTime) { if (diff > 60e3) { monthsBack = Math.floor((Math.floor(diff / 60e3))/(60*24*30)); } - console.log("monthsBack = ", monthsBack); + return monthsBack; } @@ -82903,7 +82899,7 @@ module.exports = { },{"../../models/utils":405,"../repoUtil/fetchRepoUtil":425,"./fetchAllRecentMonthContribs":415}],423:[function(require,module,exports){ // Utility function that checks if a given date is behind the current date // by 7 or less -function within_this_month(date, months) { +function within_months(date, months) { let current = (new Date).getTime(); let past_date = (new Date(`${date}`)).getTime(); let measure = Math.ceil(Math.abs(current - past_date) / (1000*3600*24)); @@ -82917,7 +82913,7 @@ function within_this_month(date, months) { // EXPORTS module.exports = { - within_this_month: within_this_month + within_months: within_months } },{}],424:[function(require,module,exports){ // Utility function that checks if a given date is behind the current date diff --git a/examples/demo.js b/examples/demo.js index 4cdfafea..71cd9545 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -50,6 +50,8 @@ document.addEventListener('DOMContentLoaded', function () { toolbox.initialize(org, repo).then((res)=> { if(res) { + // Fetches and shows recent contributors' list + toolbox.showRecentContributors(org, repo, recencyLabel); // compile and display all contributors for given org toolbox.showAllContributors(org, repo); toolbox.dropdownInit(); @@ -70,6 +72,7 @@ document.addEventListener('DOMContentLoaded', function () { toolbox.initialize(org, repo).then((res)=> { if(res) { + // Fetches and shows recent contributors' list toolbox.showRecentContributors(org, repo, recencyLabel); // compile and display all contributors for given repo toolbox.showRepoContributors(org, repo); @@ -115,11 +118,11 @@ document.addEventListener('DOMContentLoaded', function () { toolbox.filter(org, 'mostrecentfirst'); }) - $('.past').click((e) => { + $(".past").click((e) => { e.preventDefault(); let timeSpan = e.target.textContent; $('#dropdownMenuButtonRCS > #content').html(timeSpan); - let forMonths=1; + let forMonths = 6; if(timeSpan.includes('Week')) { timeSpan = 'week'; }else { diff --git a/examples/themes.js b/examples/themes.js index 97e3453f..fa60c993 100644 --- a/examples/themes.js +++ b/examples/themes.js @@ -47,7 +47,7 @@ switcher.style.removeProperty('right'); switcher.style.removeProperty('background-color'); } - }, 1000) + }, 2000) // Toggles the theme of the page @@ -98,35 +98,37 @@ switcher.style.backgroundColor = '#34A7C1'; } - }, 500); + }, 300); }); - // Converts images' theme inside recent contributors section according to the mode selected - // every time the toggle button is clicked - $('.past').click((e) => { - e.preventDefault(); - console.log("night mode adapt"); - setTimeout(() => { - var recentContribsSectionImgs = document.getElementsByClassName('recent-contributors')[0].getElementsByTagName("img"); - let check=localStorage.getItem('currentToggle'); - let images = [...recentContribsSectionImgs ]; - if(check==="night") { + buttonClickCallbackNightTheme = (e) => { + e.preventDefault(); + setTimeout(() => { + var recentContribsSectionImgs = document.getElementsByClassName('recent-contributors')[0].getElementsByTagName("img"); + let check=localStorage.getItem('currentToggle'); + let images = [...recentContribsSectionImgs ]; + if(check==="night") { + images.forEach((image) => { + image.style.filter = 'grayscale(1) invert(1)'; + image.style.transitionProperty = 'filter'; + image.style.transitionDuration = '0.5s'; + image.style.transitionTimingFunction = 'linear'; + }) + }else { images.forEach((image) => { - image.style.filter = 'grayscale(1) invert(1)'; - image.style.transitionProperty = 'filter'; - image.style.transitionDuration = '0.5s'; - image.style.transitionTimingFunction = 'linear'; + image.style.filter = 'grayscale(0) invert(0)'; + image.style.transitionProperty = 'filter'; + image.style.transitionDuration = '0.5s'; + image.style.transitionTimingFunction = 'linear'; }) - }else { - images.forEach((image) => { - image.style.filter = 'grayscale(0) invert(0)'; - image.style.transitionProperty = 'filter'; - image.style.transitionDuration = '0.5s'; - image.style.transitionTimingFunction = 'linear'; - }) - } - }, 500); - }) + } + }, 300); + } + + // Converts images' theme inside recent contributors section according to the mode selected + // every time the toggle button is clicked + $('.past').click((e) => buttonClickCallbackNightTheme(e)); + $('.sort-options').click((e) => buttonClickCallbackNightTheme(e)); }) \ No newline at end of file diff --git a/index.html b/index.html index e3e82bbc..ef344bf8 100644 --- a/index.html +++ b/index.html @@ -195,10 +195,10 @@

Recent Contributors

Sort