Jump to content

User:Terasail/ReferenceHider.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Terasail (talk | contribs) at 19:07, 1 March 2023 (Update). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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;"><a id="listToggle' + i + '">Open</a> reference list<span>');
		let toggleButton = $('#listToggle' + i)[0];
		$(toggleButton).on('click', function (e) {
			if (toggleButton.innerHTML == "Open") {
				sectionList.style = "";
				toggleButton.innerHTML = "Close";
			} else {
				sectionList.style = "display:none;";
				toggleButton.innerHTML = "Open";
			}
		});
	}
}