Jump to content

User:Terasail/ReferenceHider.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Terasail (talk | contribs) at 22:06, 16 May 2024 (Update for dark mode). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
let reflists = $('.reflist');
if (reflists.length > 0) {
	for (let i = 0; i < reflists.length; i++) {
		reflists[i].id = "CollapsibleSection" + i;
		let section = $('#CollapsibleSection' + i)[0];
		let sectionList = section.children[0];
		sectionList.style = "display:none;";
		$(section).prepend('<span style="font-size: 1.25rem; padding-left: 25px; background: url(/media/wikipedia/commons/3/34/OOjs_UI_icon_bookmark-rtl-progressive.svg) left center no-repeat;"></span><span style="font-size:1.25rem"><a href="" id="listToggle' + i + '">Open</a> reference list</span>');
		let toggleButton = $('#listToggle' + i)[0];
		$(toggleButton).on('click', function (e) {
			e.preventDefault();
			if (toggleButton.innerHTML == "Open") {
				sectionList.style = "";
				toggleButton.innerHTML = "Close";
			} else {
				sectionList.style = "display:none;";
				toggleButton.innerHTML = "Open";
			}
		});
	}
}