MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* allow search autocomplete to be toggled (for spoiler reasons) */ /* doesn't work in Monobook yet */ /* inspired by/based on https://theportalwiki.com/wiki/MediaWiki:Common.js */ /* thanks AntiComposite and SuperHamster for help figuring out how to best do it */ var suggestionsToggler = { enabled: false, nodes: null, imgOn: null, imgOff: null, toggle: function { suggestionsToggler.set(!suggestionsToggler.enabled); },	set: function(enabled) { suggestionsToggler.enabled = enabled; if(enabled) { suggestionsToggler.nodes.removeClass('suggestions-hidden'); $.cookie('suggestionsToggler', 'true', {expires: 31, path: '/'}); suggestionsToggler.imgOff.hide(0); suggestionsToggler.imgOn.show(0); } else { suggestionsToggler.nodes.addClass('suggestions-hidden'); $.cookie('suggestionsToggler', 'false', {expires: 31, path: '/'}); suggestionsToggler.imgOn.hide(0); suggestionsToggler.imgOff.show(0); }	},	init: function { suggestionsToggler.nodes = $('.mediawiki'); /* target the page body */ suggestionsToggler.imgOn = $('').attr('src', 'https://www.xenoserieswiki.org/w/images/1/1a/Suggestions_on.svg'); suggestionsToggler.imgOff = $('').attr('src', 'https://www.xenoserieswiki.org/w/images/7/7f/Suggestions_off.svg'); var toggleButton = $('').append(suggestionsToggler.imgOn, suggestionsToggler.imgOff); toggleButton.click(suggestionsToggler.toggle); $('#simpleSearch').append(toggleButton); suggestionsToggler.set(!(!$.cookie('suggestionsToggler')) && $.cookie('suggestionsToggler') == 'true'); /* if cookie exists and it is "true", then on, otherwise off */ } }; $(suggestionsToggler.init);