You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
724 B
JavaScript

3 years ago
const sentences = Array.from(document.querySelectorAll("span"));
3 years ago
const entries = Array.from(document.querySelectorAll("li"));
3 years ago
sentences.forEach((sentence) => {
3 years ago
capitals(sentence);
});
entries.forEach((entry) => {
capitals(entry);
});
function capitals(sentence) {
3 years ago
let content = sentence.textContent.trim();
if (content) {
3 years ago
let link = sentence.querySelector("a");
3 years ago
let first = content[0];
let rest = content.substring(1);
let capital = document.createElement("span");
capital.classList.add("first");
capital.innerHTML = first;
3 years ago
if (link) {
link.innerHTML = rest;
link.prepend(capital);
sentence.appendChild(link);
} else {
sentence.innerHTML = rest;
sentence.prepend(capital);
}
3 years ago
}
3 years ago
}