-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (32 loc) · 942 Bytes
/
index.js
File metadata and controls
35 lines (32 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* Name: Andrei Karavanov
* Date: October 16, 2019
* Section: CSE 154 AB
*
* This is a .js file that find a list of algorithms on every page and sets
* it to have a different color.
*/
"use strict";
(function() {
const ARRAY_OF_COLORS = ['red', 'blue', 'green'];
window.addEventListener("load", initializePage);
/** Set up things on load */
function initializePage() {
colorList();
}
/** This function colors the list of algorithms in different colors. */
function colorList() {
try {
let listOfAlgorithms = document
.getElementsByClassName("algorithmsList")[0]
.getElementsByTagName("a");
Array.from(listOfAlgorithms).map((elm, index) => {
elm.style.color = ARRAY_OF_COLORS[index % (ARRAY_OF_COLORS.length)];
return elm;
});
} catch (err) {
// Do something eles istead?
console.error(err);
}
}
})();