Skip to content

Commit b94d388

Browse files
authored
github-queries.js: declare constants as const (#857)
1 parent aa8d420 commit b94d388

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

js/github-queries.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
// Get the updated field of an entry of the feed and format it like "Jan 1, 1970"
1111
function formatDate(updated) {
1212
// Extract the date and create a Date object
13-
var date = new Date(updated);
13+
const date = new Date(updated);
1414

1515
// Names for the months (we do not need an external library just for this)
16-
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
16+
const monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1717

1818
// Returns e.g. "Jan 1, 1970"
1919
return monthNames[date.getMonth()] + ' ' + date.getDate() + ', ' + date.getFullYear();
@@ -22,14 +22,14 @@ function formatDate(updated) {
2222
// Wait until the complete page has loaded (so that the latest-release exists)
2323
document.addEventListener("DOMContentLoaded", function() {
2424

25-
var github_api_endpoint = 'https://api.github.com/repos/precice/precice/releases'
25+
const github_api_endpoint = 'https://api.github.com/repos/precice/precice/releases'
2626

2727
fetch(github_api_endpoint).then(function(response) {
2828
if (response.ok) {
2929
response.json().then(function(data) {
30-
var tag = data[0].name;
31-
var published_at = data[0].published_at;
32-
var url = data[0].html_url;
30+
const tag = data[0].name;
31+
const published_at = data[0].published_at;
32+
const url = data[0].html_url;
3333

3434
var link = document.createElement('a');
3535
link.setAttribute('href', url);
@@ -60,12 +60,12 @@ var github_api_endpoint = 'https://api.github.com/repos/precice/precice/releases
6060
// Exact copy of the script to get latest release, but this time we get the number of stars, or 'stargazers_count' in Github lingo
6161
document.addEventListener("DOMContentLoaded", function() {
6262

63-
var github_api_endpoint = 'https://api.github.com/repos/precice/precice'
63+
const github_api_endpoint = 'https://api.github.com/repos/precice/precice'
6464

6565
fetch(github_api_endpoint).then(function(response) {
6666
if (response.ok) {
6767
response.json().then(function(data) {
68-
var count = data.stargazers_count;
68+
const count = data.stargazers_count;
6969

7070
var link = document.createElement('a');
7171
link.setAttribute('href', 'https://github.com/precice/precice/');

0 commit comments

Comments
 (0)