|
1 | | -// initialize the header with the current directory name |
2 | | -var header = document.getElementById("header"); |
| 1 | +"use strict"; |
3 | 2 |
|
4 | | -// get the text of the header |
5 | | -header.textContent = header.textContent.slice(9, -1); |
| 3 | +// Get header element and trim the text content |
| 4 | +const header = document.getElementById("header"); |
| 5 | +header.textContent = header.textContent.trim(); |
6 | 6 |
|
7 | | -// if the title is empty, set it to ~ |
8 | | -if (header.textContent == "") { |
| 7 | +// Set the header text content to ~ if it is empty |
| 8 | +if (header.textContent === "") { |
9 | 9 | header.textContent = "~"; |
10 | 10 | } |
11 | 11 |
|
12 | | -// if there is something that has more then 40 characters, cut it off |
13 | | -var a = document.querySelectorAll("a"); |
14 | | -for (strings in a) { |
15 | | - if (a[strings].textContent.length > 40) { |
16 | | - a[strings].textContent = a[strings].textContent.slice(0, 40) + "..."; |
17 | | - } |
| 12 | +// Set the width of the header to 100% in order to fill the space |
| 13 | +header.style.width = "100%"; |
| 14 | + |
| 15 | +// Set the length of the header to 65 characters |
| 16 | +if (header.textContent.length > 65) { |
| 17 | + header.textContent = header.textContent.slice(0, 65) + "..."; |
18 | 18 | } |
| 19 | + |
| 20 | +// Shorten the text content of links that are too long |
| 21 | +const links = document.querySelectorAll("a"); |
| 22 | +links.forEach((link) => { |
| 23 | + if (link.textContent.length > 60) { |
| 24 | + link.textContent = link.textContent.slice(0, 60) + "..."; |
| 25 | + } |
| 26 | +}); |
0 commit comments