Skip to content

Commit 55e67cf

Browse files
committed
Remove unused Contributor Card code
1 parent 0303c38 commit 55e67cf

File tree

8 files changed

+10
-210
lines changed

8 files changed

+10
-210
lines changed

layouts/css/page-modules/_jsfoundation.scss

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,6 @@
2424
margin-left: auto;
2525
}
2626

27-
.thanking-contributor {
28-
max-width: 300px;
29-
display: flex;
30-
align-items: center;
31-
padding: .5em 1em;
32-
margin-top: 1em;
33-
border: 1px solid $white;
34-
border-radius: 3px;
35-
36-
img {
37-
border-radius: 50%;
38-
margin-right: 1em;
39-
}
40-
}
41-
4227
.help {
4328
margin-top: 3em;
4429
width: 40%;

layouts/css/page-modules/spinner.scss

Lines changed: 0 additions & 18 deletions
This file was deleted.

layouts/css/styles.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
@import "page-modules/prev-next-navigation";
2323
@import "page-modules/release-schedule";
2424
@import "page-modules/resources";
25-
@import "page-modules/spinner";
2625
@import "vendor/prism-tomorrow";
2726

2827
article a {

layouts/partials/blm-html-head.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
66
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
7-
<link rel="dns-prefetch" href="https://api.github.com">
87

98
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600&amp;display=fallback">
109
<link rel="stylesheet" href="https://nodejs.org/static/css/styles.css">

layouts/partials/contributor-card.hbs

Lines changed: 0 additions & 15 deletions
This file was deleted.

layouts/partials/html-head.hbs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
<link rel="dns-prefetch" href="https://fonts.googleapis.com">
66
<link rel="dns-prefetch" href="https://fonts.gstatic.com">
7-
<link rel="dns-prefetch" href="https://api.github.com">
87

98
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600&display=fallback">
109
<link rel="stylesheet" href="/static/css/styles.css">

static/js/main.js

Lines changed: 8 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
langPickerElement.removeChild(currentLangElement.parentNode);
3535
}
3636

37-
const toggleFunction = function () {
37+
var toggleFunction = function () {
3838
langPickerElement.classList.toggle('hidden');
39-
const isAriaExpanded =
39+
var isAriaExpanded =
4040
langPickerTogglerElement.getAttribute('aria-expanded') === 'true';
4141
langPickerTogglerElement.setAttribute('aria-expanded', !isAriaExpanded);
4242
};
@@ -54,8 +54,8 @@
5454
}
5555
});
5656
})();
57+
5758
(function () {
58-
const themeAttr = 'data-theme';
5959
var darkThemeSwitcherElement = document.querySelector('.dark-theme-switcher');
6060

6161
darkThemeSwitcherElement.addEventListener('click', function () {
@@ -68,14 +68,15 @@
6868
});
6969

7070
function setTheme(theme) {
71-
document.querySelector('html').setAttribute(themeAttr, theme);
71+
document.documentElement.setAttribute('data-theme', theme);
7272
window.localStorage.setItem('theme', theme);
7373
}
7474

7575
function getTheme() {
7676
return window.localStorage.getItem('theme');
7777
}
7878
})();
79+
7980
(function () {
8081
var scrollToTop = document.querySelector('#scroll-to-top');
8182

@@ -91,158 +92,10 @@
9192
window.scrollTo(0, 0);
9293
});
9394
})();
94-
(function () {
95-
var contributorCard = document.querySelector('.contributor-card');
96-
97-
if (!contributorCard) {
98-
return;
99-
}
100-
101-
var contributorAvatar = contributorCard.querySelector('#contributor-avatar');
102-
var contributorUsername = contributorCard.querySelector(
103-
'#contributor-username'
104-
);
105-
var contributorContributions = contributorCard.querySelector(
106-
'#contributor-contributions'
107-
);
108-
var loadingSpinner = contributorCard.querySelector('.spinner-border');
109-
110-
if (window.IntersectionObserver) {
111-
var observer = new window.IntersectionObserver(
112-
function (entries) {
113-
entries.forEach(function (entry) {
114-
if (entry.intersectionRatio > 0.5) {
115-
// In viewport, fetch a random contributor
116-
fetchRandomContributor();
117-
118-
observer.unobserve(entry.target);
119-
}
120-
});
121-
},
122-
{ threshold: 0.5 }
123-
);
124-
125-
observer.observe(document.querySelector('footer'));
126-
} else {
127-
// Does not support IntersectionObserver
128-
fetchRandomContributor();
129-
}
130-
131-
function fetchRandomContributor() {
132-
var maxContributors;
133-
var fetchDate;
134-
var needToRefetch = false;
135-
136-
if (window.localStorage) {
137-
maxContributors = window.localStorage.getItem('max_contributors');
138-
fetchDate = parseInt(window.localStorage.getItem('fetch_date'), 10);
139-
}
140-
141-
// If fetch date is a month old (2592000000 ms === 30 days)
142-
if (Date.now() - fetchDate >= 2592000000) {
143-
needToRefetch = true;
144-
}
145-
146-
// If localStorage and data is less than 1 month old, fetch 1 time
147-
if (maxContributors && !needToRefetch) {
148-
getContributor(
149-
Math.floor(Math.random() * Math.floor(parseInt(maxContributors))) + 1
150-
);
151-
} else {
152-
getMaxContributors(function (randomPage, lastPage) {
153-
getContributor(randomPage);
154-
155-
if (window.localStorage) {
156-
window.localStorage.setItem('max_contributors', lastPage);
157-
}
158-
});
159-
}
160-
}
16195

162-
function getMaxContributors(callback) {
163-
var xhr = new window.XMLHttpRequest();
164-
xhr.open(
165-
'GET',
166-
'https://api.github.com/repos/nodejs/node/contributors?per_page=1',
167-
true
168-
);
169-
170-
xhr.onreadystatechange = function () {
171-
if (xhr.readyState === 4) {
172-
if (xhr.status === 200) {
173-
// Get Headers Links last page to generate a random contributor
174-
var links = linkParser(xhr.getResponseHeader('Link'));
175-
var randomPage =
176-
Math.floor(
177-
Math.random() * Math.floor(parseInt(links.last.page, 10))
178-
) + 1;
179-
180-
if (window.localStorage) {
181-
window.localStorage.setItem('fetch_date', Date.now());
182-
}
183-
callback(randomPage, links.last.page);
184-
} else {
185-
return contributorCard.parentNode.removeChild(contributorCard);
186-
}
187-
}
188-
};
189-
190-
xhr.send();
191-
}
192-
193-
function getContributor(randomPage) {
194-
var xhr = new window.XMLHttpRequest();
195-
xhr.open(
196-
'GET',
197-
'https://api.github.com/repos/nodejs/node/contributors?per_page=1&page=' +
198-
randomPage,
199-
true
200-
);
201-
202-
xhr.onreadystatechange = function () {
203-
if (xhr.readyState === 4) {
204-
if (xhr.status === 200) {
205-
var contributor = JSON.parse(xhr.responseText)[0];
206-
207-
// Remove loading spinner and show avatar
208-
loadingSpinner.parentNode.removeChild(loadingSpinner);
209-
contributorAvatar.classList.remove('hidden');
210-
// Set new values
211-
contributorAvatar.src = contributor.avatar_url + '&s=80';
212-
contributorAvatar.parentElement.href = contributor.html_url;
213-
contributorUsername.textContent = contributor.login;
214-
contributorUsername.href = contributor.html_url;
215-
contributorContributions.textContent =
216-
contributor.contributions + ' contributions';
217-
contributorContributions.parentElement.href =
218-
'https://github.com/nodejs/node/commits?author=' +
219-
contributor.login;
220-
} else {
221-
return contributorCard.parentNode.removeChild(contributorCard);
222-
}
223-
}
224-
};
225-
226-
xhr.send();
227-
}
228-
229-
function linkParser(linkHeader) {
230-
var regex = /<([^?]+\?per_page=1&[a-z]+=([\d]+))>;[\s]*rel="([a-z]+)"/g;
231-
var array = [];
232-
var object = {};
233-
234-
while ((array = regex.exec(linkHeader)) !== null) {
235-
object[array[3]] = {
236-
url: array[1],
237-
page: array[2]
238-
};
239-
}
240-
241-
return object;
242-
}
243-
})();
24496
(function () {
24597
'use strict';
98+
24699
var userAgent = navigator.userAgent;
247100
var osMatch = userAgent.match(/(Win|Mac|Linux)/);
248101
var os = (osMatch && osMatch[1]) || '';
@@ -298,10 +151,9 @@
298151
winText.textContent = winText.textContent.replace(/x(86|64)/, arch);
299152
}
300153
})();
301-
(function () {
302-
// This function is used to replace the anchor
303-
// link of Edit on GitHub
304154

155+
// This function is used to replace the anchor link of Edit on GitHub
156+
(function () {
305157
var editOnGitHubElement = document.getElementById('editOnGitHubLink');
306158
var editOnGitHubUrlElement = document.getElementById('editOnGitHubUrl');
307159

static/js/themeSwitcher.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(function () {
2-
const themeAttr = 'data-theme';
3-
const isInDarkMode =
2+
var isInDarkMode =
43
window.matchMedia &&
54
window.matchMedia('(prefers-color-scheme: dark)').matches;
65

@@ -11,7 +10,7 @@
1110
}
1211

1312
function setTheme(theme) {
14-
document.querySelector('html').setAttribute(themeAttr, theme);
13+
document.querySelector('html').setAttribute('data-theme', theme);
1514
window.localStorage.setItem('theme', theme);
1615
}
1716

0 commit comments

Comments
 (0)