Skip to content

Commit

Permalink
Use modern ES6 (const/let, for...of) in custom scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
CAM-Gerlach committed Feb 8, 2024
1 parent 1b99058 commit 8300511
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions assets/static/js/custom_scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"use strict";

/* Top-level variables */
var buttonData = {
const buttonData = {
win: {
text: "Download for Windows",
icon: ["fab", "fa-windows"],
Expand All @@ -31,7 +31,7 @@

// Get the key corresponding to the current desktop operating system
function getOSName() {
var platform = navigator.platform;
const platform = navigator.platform;
if (!platform) {
return "other";
}
Expand All @@ -53,30 +53,30 @@

// Get the button data corresponding to the current OS
function getButtonData() {
var osName = getOSName();
const osName = getOSName();
return buttonData[osName];
}

/* Main functions */

// Setup download button based on current OS
function setupDownloadButton(downloadButton) {
var buttonData = getButtonData();
const buttonData = getButtonData();
downloadButton.href = buttonData.url;
downloadButton.getElementsByClassName("download-text")[0].textContent =
buttonData.text;
for (var i = 0; i < buttonData.icon.length; i++) {
for (const icon of buttonData.icon) {
downloadButton
.getElementsByClassName("download-os-icon")[0]
.classList.add(buttonData.icon[i]);
.classList.add(icon);
}
}

/* Fire events */

// On initial DOM ready, set up the tour and the version dropdown
document.addEventListener("DOMContentLoaded", function () {
var downloadButton = document.getElementById("download-buttons-button");
const downloadButton = document.getElementById("download-buttons-button");
if (downloadButton) {
setupDownloadButton(downloadButton);
}
Expand Down

0 comments on commit 8300511

Please sign in to comment.