Skip to content

Commit b25b7f3

Browse files
committed
deploy: 828ec4c
1 parent 0fe3977 commit b25b7f3

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

js/projects.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
var projectCards = Array.from(document.getElementsByClassName("project-card"))
7-
var searchBox = document.getElementById("search-box")
6+
const projectCards = Array.from(document.getElementsByClassName("project-card"))
7+
const searchBox = document.getElementById("search-box")
88

99
// parse cards to build project list
10-
var projects = []
10+
const projects = []
1111
projectCards.forEach(card => {
1212
projects.push({
1313
id: card.id,
@@ -18,7 +18,7 @@ projectCards.forEach(card => {
1818
})
1919

2020
// import fuse and initialize
21-
var fuse;
21+
let fuse;
2222
import("https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.esm.min.js")
2323
.then(module => {
2424
Fuse = module.default
@@ -48,7 +48,7 @@ import("https://cdnjs.cloudflare.com/ajax/libs/fuse.js/6.4.6/fuse.esm.min.js")
4848

4949
// perform search on search-box keyup and store in browser history.
5050
searchBox.addEventListener('keyup', function(event) {
51-
let query = this.value
51+
const query = this.value
5252
search(query)
5353

5454
// push new query onto history stack
@@ -65,7 +65,7 @@ searchBox.addEventListener('keyup', function(event) {
6565

6666
// debounce wraps a function so that calls will be delayed to prevent repeated
6767
// calls within the specified time window.
68-
var debounce = (fn, timeout = 500) => {
68+
const debounce = (fn, timeout = 500) => {
6969
let timer
7070
return (...args) => {
7171
clearTimeout(timer)
@@ -76,14 +76,14 @@ var debounce = (fn, timeout = 500) => {
7676
// pushState pushes the new search query onto the browser history on a slight
7777
// delay. This is to prevent every individual keystroke from being pushed onto
7878
// the history stack.
79-
var pushState = debounce((query, url) => {
79+
const pushState = debounce((query, url) => {
8080
window.history.pushState({}, `Projects search: ${query}`, url)
8181
})
8282

8383
// search the project list for the query string and display ranked results.
84-
var search = (query) => {
84+
const search = (query) => {
8585
searchBox.value = query
86-
let resultsBox = document.getElementById('results')
86+
const resultsBox = document.getElementById('results')
8787

8888
if (!query) {
8989
// reset all project cards
@@ -94,7 +94,7 @@ var search = (query) => {
9494
resultsBox.classList.add("hide")
9595
return
9696
}
97-
let results = fuse.search(query)
97+
const results = fuse.search(query)
9898

9999
// first, hide all the projects
100100
projectCards.forEach(card => {
@@ -105,7 +105,7 @@ var search = (query) => {
105105
// show results in ranked order
106106
let order = 1
107107
results.forEach(r => {
108-
var card = document.getElementById(r.item.id)
108+
const card = document.getElementById(r.item.id)
109109
card.classList.remove("hide")
110110
card.style.setProperty("order", order++)
111111
})

js/year-in-review.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@
55

66
// Insert top 10 repos
77
function renderTopRepos(reposList) {
8-
let topTenRepos = reposList.sort((a,b) => b.commitCount-a.commitCount).slice(0, 10);
9-
var topTenReposTable = document.getElementById("top-10-repos");
10-
var num = 1;
8+
const topTenRepos = reposList.sort((a,b) => b.commitCount-a.commitCount).slice(0, 10);
9+
const topTenReposTable = document.getElementById("top-10-repos");
10+
let num = 1;
1111

12-
for (var repo of topTenRepos) {
12+
topTenRepos.forEach(repo => {
1313
// Row
14-
var row = document.createElement('tr');
14+
const row = document.createElement('tr');
1515
row.className = "content";
1616

1717
// Number
18-
var numData = document.createElement('td');
18+
const numData = document.createElement('td');
1919
numData.className = "num";
2020
numData.innerHTML = num;
2121
num++;
2222
row.appendChild(numData);
2323

2424
// Repo name
25-
var repoData = document.createElement('td');
25+
const repoData = document.createElement('td');
2626
repoData.className = "repo";
2727

28-
var repoLink = document.createElement('a');
28+
const repoLink = document.createElement('a');
2929
repoLink.innerHTML = repo.name;
3030
repoLink.href = "https://github.com/twitter/" + repo.name;
3131
repoLink.target = "_blank";
@@ -35,13 +35,13 @@ function renderTopRepos(reposList) {
3535
row.appendChild(repoData);
3636

3737
// Commit count
38-
var commitCountData = document.createElement('td');
38+
const commitCountData = document.createElement('td');
3939
commitCountData.className = "commit-value";
4040
commitCountData.innerHTML = formatNum(repo.commitCount);
4141
row.appendChild(commitCountData);
4242

4343
topTenReposTable.appendChild(row);
44-
}
44+
})
4545
}
4646

4747
renderTopRepos(allRepos);

0 commit comments

Comments
 (0)