MediaWiki:Common.js: verschil tussen versies
Uit Klimaatwiki
Nieuwe pagina aangemaakt met '→JavaScript die hier wordt geplaatst heeft invloed op alle pagina's voor alle gebruikers: →---------- Reading progress bar script ----------: $(function () { // Create the bar element and insert it into the DOM const $bar = $('<div>', { id: 'readingProgress' }).appendTo('body'); // Function that updates the bar width based on scroll position const updateProgress = () => { const docHeight = $(document).height(); const…' |
Geen bewerkingssamenvatting |
||
| Regel 25: | Regel 25: | ||
$(window).on('scroll resize', updateProgress); | $(window).on('scroll resize', updateProgress); | ||
}); | }); | ||
mw.loader.load("https://deadlinkchecker.toolforge.org/static/script.js") | |||
Huidige versie van 27 okt 2026 20:59
/* JavaScript die hier wordt geplaatst heeft invloed op alle pagina's voor alle gebruikers */
/* ---------- Reading progress bar script ---------- */
$(function () {
// Create the bar element and insert it into the DOM
const $bar = $('<div>', { id: 'readingProgress' }).appendTo('body');
// Function that updates the bar width based on scroll position
const updateProgress = () => {
const docHeight = $(document).height();
const winHeight = $(window).height();
const scrollTop = $(window).scrollTop();
// Calculate percentage of page scrolled
const percent = ((scrollTop + winHeight) / docHeight) * 100;
// Set the bar width (capped at 100%)
$bar.css('width', Math.min(percent, 100) + '%');
};
// Run once on load (in case the page is short enough to be fully visible)
updateProgress();
// Update on scroll and on window resize (the latter can affect heights)
$(window).on('scroll resize', updateProgress);
});
mw.loader.load("https://deadlinkchecker.toolforge.org/static/script.js")
