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