29 lines
No EOL
587 B
JavaScript
29 lines
No EOL
587 B
JavaScript
window.onload = function(){
|
|
init();
|
|
};
|
|
|
|
|
|
function slugify(text) {
|
|
return text.trim()
|
|
.toLowerCase()
|
|
.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
|
|
.replace(/[^a-z0-9\s-]/g, '')
|
|
.replace(/\s+/g, '-')
|
|
.replace(/-+/g, '-');
|
|
}
|
|
|
|
function addHeadingIds(root) {
|
|
root.querySelectorAll('h3, h4').forEach(heading => {
|
|
if (!heading.id) {
|
|
heading.id = slugify(heading.textContent);
|
|
}
|
|
});
|
|
}
|
|
|
|
function init(){
|
|
let fadeEl = document.getElementById('fade');
|
|
if (fadeEl) {
|
|
fadeEl.classList.add('loaded');
|
|
}
|
|
addHeadingIds(document);
|
|
} |