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.addClass('suggestions-displayed'); suggestionsToggler.imgOff.hide(0); suggestionsToggler.imgOn.show(0); $.cookie('suggestionsToggler', 'true', {expires: 31, path: '/'}); } else { suggestionsToggler.nodes.removeClass('suggestions-displayed'); suggestionsToggler.imgOn.hide(0); suggestionsToggler.imgOff.show(0); $.cookie('suggestionsToggler', 'false', {expires: 31, path: '/'}); }	},	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); $('#searchform').append(toggleButton); /* monobook */ $('#simpleSearch').append(toggleButton); /* vector, timeless */ suggestionsToggler.set(!(!$.cookie('suggestionsToggler')) && $.cookie('suggestionsToggler') == 'true'); /* if cookie exists and it is "true", then on, otherwise off */ } }; $(suggestionsToggler.init);