Note – after saving, you may have to bypass your browser’s cache to see the changes.

  • Mozilla / Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Command-R on a Macintosh);
  • Konqueror and Chrome: click Reload or press F5;
  • Opera: clear the cache in Tools → Preferences;
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl-F5.

// [[WT:PREFS]]-specific cookie handling 
// {{documentation}}
// <nowiki>
// implicit dependencies : ext.gadget.StorageUtils
/* jshint maxerr:1048576, strict:true, undef:true, latedef:true, es5:true, sub:true */

/* global mw, $ */
/*
 * "checkbox" prefs can be used with getCookie() or wiktGetPrefCookie()
 * "externcheckbox" prefs can only be used with wiktGetPrefCookie()
 * wiktGetPrefCookie() is defined here in custom.js
 * so any prefs which need to work without custom.js enabled must use "externcheckbox"
 */
/* TODO OK and Cancel checkboxs. don't write the prefs to the actual cookie
 * TODO   until OK is clicked
 * TODO clearly and discoverably link between these prefs and the standard
 * TODO   MediaWiki prefs
 * TODO clearly indicate the differences between "cookie prefs" and real
 * TODO   (ie MediaWiki) prefs
 * TODO wrap everything in a class with as few globals as possible
 * TODO use cirwin's Preferences object from editor.js
 * TODO allow external and subprefs to have their own subprefs
 */
// TODO should not be global
var prefs = {
	// MASTER SWITCH
	WiktionaryUseJSPreferences: {
		num: 1,
		text: 'Use the preferences set on this page'
	},

	WiktionaryPreferencesHideSister: {
		num: 2,
		text: 'Hide the boxes that link to Wikipedia.',
		css: [{
			selector: '#bodyContent .sister-project',
			declarations: 'display: none;'
		}]
	},
	WiktionaryPreferencesSmallRC: {
		num: 3,
		text: 'Make the second half of the heading of Special:RecentChanges smaller',
		css: [{
			selector: '#bodyContent .minifont',
			declarations: 'font-size: 75%;'
		}]
	},
	WiktCustomTopToolbar: {
		num: 4,
		text: 'Add more script pages to the "Special characters" section of the enhanced editing toolbar',
		js: [{
			page: 'User:Bequw/CustomToolbar.js'
		}]
	},
	WiktionaryPreferencesHideRankings: {
		num: 5,
		text: 'Hide the boxes containing word frequency rankings.',
		css: [{
			selector: '#rank',
			declarations: 'display: none'
		}]
	},
	WiktRMTbotEntries: {
		num: 6,
		text: 'Add "[check]" buttons to the end of tbot entry boxes, to remove the template.',
		js: [{
			page: 'User:Yair rand/checktbotentries.js'
		}]
	},
	WiktionaryPreferencesHideLinesBetweenLanguages: {
		num: 7,
		text: 'Hide the horizontal separator between each language section.',
		css: [{
			selector: '.ns-0 #bodyContent hr',
			declarations: 'visibility: hidden'
		}]
	},
	WiktionaryPreferencesHideTranslations: {
		num: 8,
		text: 'Hide the translation sections entirely. [Instead of having them shown collapsed]',
		css: [{
			selector: '#bodyContent .translations',
			declarations: 'display:none'
		}]
	},
	WiktionaryPreferencesBoxedInflections: {
		num: 9,
		text: 'Highlight the inflection line of some entries',
		css: [{
			selector: '#bodyContent .infl-inline',
			declarations: 'background-color: #ADFFD6'
		}]
	},
	WiktionaryPreferencesIndentSeeAlso: {
		num: 10,
		text: 'Indent the “See also” lines more than usual.',
		css: [{
			selector: '#bodyContent .disambig-see-also, #bodyContent .disambig-see-also-2',
			declarations: 'text-indent: 4em'
		}]
	},
	WiktionaryPreferencesHideSiteNotice: {
		num: 11,
		text: 'Hide the display of site-wide notices at the top of the screen.',
		css: [{
			selector: '#siteNotice, #fundraiser, .fundraiser-box',
			declarations: 'display: none;'
		}]
	},
	WiktionaryPrefBoldCitedTerms: { // was CiteTab a long time ago
		num: 12,
		text: 'Display words in quotations that have been emboldened with {{q}} with a square box instead',
		css: [{
			selector: '.citedterm',
			declarations: 'border:#333 1px solid; padding: 1px 2px; margin: -2px 0px;font-weight: normal;'
		}]
	},
	WiktEditSectionWTEDIT: {
		num: 13,
		text: 'Edit sections without going to the edit screen.',
		js: [{
				page: 'User:Dixtosa/AjaxEdit.js'
			} //used to be this script User:Yair rand/editsection.js
		]
	},
	WiktionaryPreferencesKeyPad: {
		num: 16,
		text: 'Show a special character input (like the one beneath the edit field) for the search field. [Does not work in Vector or IE]',
		js: [{
			page: 'User:Connel_MacKenzie/keypad.js'
		}]
	},
	WiktPrefConnelReformat: {
		num: 17,
		text: 'Use [[User:Connel_MacKenzie/reformat.js]] to reformat pages semi-automatically. [Do NOT use this unless you know Wiktionary policy better than the back of your hand.]',
		js: [{
			page: 'User:Connel_MacKenzie/reformat.js'
		}]
	},
	WiktPrefPatrol: {
		num: 18
	},
	WiktPrefDelCmnt: {
		num: 19,
		text: 'Replace text in deletion log comment',
		js: [{
			page: 'User:Connel_MacKenzie/del-cmnt.js'
		}]
	},
	// was WiktIrc a very long time ago…
	WiktMakeRedLinksBlack: {
		num: 21,
		text: 'Make red-links on some inflection tables look black.',
		css: [{
			selector: '.inflection-table a.new',
			declarations: 'color: #000000;'
		}]
	},
	WiktAddStructure: {
		num: 23,
		text: 'Use [[User:Conrad.Irwin/parser.js]] to provide two different views of most pages.',
		js: [{
			page: 'User:Conrad.Irwin/parser.js'
		}]
	},
	WiktHideLogo: {
		num: 24,
		text: 'Hide the logo in the upper left corner.',
		css: [{
				selector: '#p-logo',
				declarations: 'display: none;'
			},
			{
				selector: '#column-one',
				declarations: 'padding-top: 0;'
			},
			{
				selector: '#mw-panel',
				declarations: 'top:0 !important;'
			}
		]
	},
	WiktFormOfPlain: {
		num: 25,
		text: 'Show “form of” definitions with a plain (only wikilinked) lemma. (Default is with a bold lemma.)',
		css: [{
			selector: '.use-with-mention .mention',
			declarations: 'font-weight: normal !important;'
		}]
	},
	WiktFormOfItalicQualifier: {
		num: 26,
		text: 'Show “form of” definitions with an italic definition (“qualifier”) and plain (only wikilinked) lemma. (Default is with a bold lemma.)',
		css: [{
			selector: '.use-with-mention',
			declarations: 'font-style: italic;'
		}, {
			selector: '.use-with-mention .mention',
			declarations: 'font-weight: normal !important;'
		}]
	},
	WiktFormOfItalicLemma: {
		num: 27,
		text: 'Show “form of” definitions with an italic lemma. (Default is with a bold lemma.)',
		css: [{
			selector: '.use-with-mention .mention',
			declarations: 'font-style: italic !important; font-weight: normal !important;'
		}]
	},
	WiktFormOfItalicQualifierBoldLemma: {
		num: 28,
		text: 'Show “form of” definitions with an italic definition (“qualifier”) and bold lemma. (Default is with a bold lemma.)',
		css: [{
			selector: '.use-with-mention',
			declarations: 'font-style: italic;'
		}]
	},
	WiktInterwikiWatchlists: {
		num: 29,
		text: 'Enable interwiki watchlists.',
		js: [{
			page: 'User:Yair rand/superwatchlist.js'
		}]
	},
	WiktDefEditOptions2: {
		num: 30,
		text: 'Enable definition editing options.',
		js: [{
			page: 'User:Yair rand/editor2.js'
		}]
	},
	WiktWatchlistNotifications: {
		num: 31,
		text: 'Enable watchlist notifications.',
		js: [{
			page: 'User:Yair rand/watchlistnotifications.js'
		}]
	},
	WiktLatnMentionBold: {
		text: 'Show other Latin (Roman) script mentions in bold. (Default is in italics.)',
		num: 32,
		css: [{
			selector: '.mention-Latn',
			declarations: 'font-style: normal !important; font-weight: bold;'
		}]
	},
	WiktMentionGlossSingleQuotes: {
		num: 33,
		text: 'Show English glosses for mentioned terms in single quotes. (Default is in double quotes.)',
		js: [{
			page: 'User:Bequw/singleQuote.js'
		}]
	},
	WiktionaryPreferencesHideQualifierParens: {
		num: 34,
		text: 'Hide the parentheses around list item qualifiers.',
		css: [{
			selector: '#bodyContent .qualifier-brac',
			declarations: 'display:none'
		}]
	},
	WiktionaryPreferencesItalicParens: {
		num: 35,
		text: 'Italicize the punctuation (parentheses and colon) around italic text.',
		css: [{
			selector: '.ib-brac, .ib-comma, .sense-qualifier-colon',
			declarations: 'font-style: italic'
		}]
	},
	WiktRTRC: {
		num: 36,
		text: 'Enable Real Time Recent Changes (Documentation at [[m:User:Krinkle/Tools/Real-Time Recent Changes]])',
		js: [ // [[File:Krinkle_RTRC.js]] (tracker)
			{
				page: 'User:Krinkle/RTRC.js',
				wiki: 'meta.wikimedia.org'
			}
		]
	},
	WiktHideTrGlossParens: {
		num: 37,
		text: 'Hide parentheses around transliterations and glosses.',
		css: [{
			selector: '.term-tr-gloss-paren, .term-tr-paren, .term-gloss-paren',
			declarations: 'display: none'
		}]
	},
	WiktHideAllParens: {
		num: 38,
		text: 'Hide the maximal amount of parentheses. [Can cause sentences to appear ungrammatical]',
		css: [{
			selector: '.ib-brac, .term-tr-gloss-paren, .term-gloss-paren',
			declarations: 'display:none'
		}]
	},
	WiktHideGlossParens: {
		num: 39,
		text: 'Hide parentheses around glosses.',
		js: [{
			page: 'User:Bequw/HideGlossParens.js'
		}]
	},
	WiktPlainTransliterations: {
		num: 40,
		text: 'Show parenthesized plain (non-italic) transliterations.',
		css: [{
			selector: '.mention-tr-paren, .mention-tr',
			declarations: 'font-style:normal !important'
		}]
	},
	WiktIrc2: {
		num: 41,
		text: 'Show a link to a web-based IRC client in the top right-hand corner.',
		js: [{
			page: 'User:Connel_MacKenzie/irc.js'
		}]
	},
	WiktFilterContributions: {
		num: 42,
		text: 'Filter out your own contributions from Special:Contributions',
		js: [{
			page: 'User:Hippietrail/filtercontribs.js'
		}]
	},
	WiktCIDRRangeContribs: {
		num: 43,
		text: 'Adds a CIDR Range Contributions check to Special:User contributions',
		js: [{
			page: 'MediaWiki:ContribsRange.js'
		}]
	},
	// This is just to allow people to test easily
	WiktAddProminentInterwikis: {
		num: 47,
		text: 'Show an interwiki link under the language heading when one exists in the sidebar.',
		js: [{
			page: 'User:Conrad.Irwin/iwiki.js'
		}]
	},
	WiktFloatNavToggleLeft: {
		num: 48,
		text: 'Put the [show] checkbox onto the left of the translation bars.',
		css: [{
			selector: '.NavToggle',
			declarations: 'float: left !important; position: static !important; right: inherit; margin-top: 0.1em; margin-right: 5px;'
		}]
	},
	WiktFastBrowse: {
		num: 49
	},
	WiktPreviewRightTOCs: {
		num: 50,
		text: 'Put the table of contents onto the right of entries.',
		css: [{
			selector: '.ns-0 #toc',
			declarations: 'float: right; clear: right; margin-left: 7px; margin-bottom: 6px; display: inline;'
		}]
	},
	// hide EditTools under search field
	WiktionaryPreferencesEditTools: {
		num: 53,
		text: 'Hide the special character input beneath the edit field.',
		css: [{
			selector: '.mw-editTools',
			declarations: 'display: none;'
		}]
	},
	// Show links to previous and next pages
	WiktNearbyPages: {
		num: 54,
		text: 'Add links to previous and next pages.',
		js: [{
			page: 'User:Dixtosa/nearby.js'
		}]
	},
	// Add some per-language toys
	WiktPerLanguage: {
		num: 55,
		text: 'For each language section add interwiki and random links.',
		js: [{
			page: 'User:Hippietrail/perlanguage.js'
		}]
	},
	WiktMoveWasWotdUp: {
		num: 56,
		text: 'Move the was-WOTD template back to the absolute top-right position (vector).',
		css: [{
			selector: '.was-wotd',
			declarations: 'float:none !important; clear:none !important; position:absolute !important; top: -35px !important; right: 0px !important; margin:0 0 0 0 !important;'
		}]
	},
	WiktSearchKeyboard: {
		num: 57,
		text: 'Add a button next to the search box to simplify inputting special characters.',
		js: [{
			page: 'User:Yair rand/keyboards.js'
		}]
	},
	// hide annoying copyright stuff
	WiktHideCopyrightWarning: {
		num: 58,
		text: 'Hide the copyright warning in the edit window.',
		css: [{
			selector: '#editpage-copywarn, .mw-tos-summary',
			declarations: 'display:none;'
		}]
	},
	WiktAllowDoubleClickLookup: {
		num: 59,
		text: 'Allow lookup of unlinked words on double click.',
		js: [{
			page: 'MediaWiki:Lookup.js'
		}]
	},
	WiktBeerParlourArchiver: {
		num: 60,
		text: 'Add Archive links to Beer parlour sections.',
		js: [{
			page: 'User:Conrad.Irwin/beerArchiver.js',
			condition: function() {
				return mw.config.get("wgPageName") == 'Wiktionary:Beer_parlour';
			}
		}]
	},
	WiktEtylAlwaysLink: {
		num: 61,
		text: 'Always linkify language-names in etymologies.',
		js: [{
			page: 'User:Ruakh/WiktEtylAlwaysLink.js'
		}]
	},
	WiktIPAConversion: {
		num: 63,
		text: 'Allow conversion of IPA to other formats.',
		js: [{
			page: 'User:Atelaes/pronunciationCustomization.js'
		}]
	},
	WiktRoundBullets4Lists: {
		num: 65,
		text: 'Change the bullets in unordered lists to be round.',
		css: [{
			selector: 'ul',
			declarations: 'list-style-image:none; list-style-type:disc;'
		}]
	},
	WiktMobile: {
		num: 66,
		text: 'Customize site for mobile browsers.',
		js: [{
			page: 'User:Bequw/mobile.js'
		}]
	},
	WiktUsexEditor: {
		num: 67,
		text: 'Enable example sentence editor.',
		js: [{
			page: 'User:Yair_rand/usexeditor.js'
		}]
	},
	// Converted to gadget!
	WiktBCAD: {
		num: 69,
		text: 'Switch BCE/CE to BC/AD.',
		js: [{
			page: 'User:Bequw/bc-ad.js'
		}]
	},
	WiktWSEdit: {
		num: 70,
		text: 'Enable Wikisaurus editor.',
		js: [{
			page: 'User:Yair_rand/wsedit.js'
		}]
	},
	WiktHeadersInline: {
		num: 72,
		text: 'Display headers inline.',
		css: [{
				selector: '.ns-0 h3, .ns-0 h4, .ns-0 #bodyContent h5',
				declarations: 'float:left;margin-top:8px;padding-right:5px;padding-top:0px;font-weight:normal;'
			},
			{
				selector: '.ns-0 h3:after, .ns-0 h4:after, .ns-0 #bodyContent h5:after',
				declarations: 'content:":";'
			},
			{
				selector: '.ns-0 h3 .editsection, .ns-0 h4 .editsection, .ns-0 h5 .editsection',
				declarations: 'position:absolute;right:0px;'
			},
			{
				selector: '.ns-0 h3+*, .ns-0 h4+*, .ns-0 h5+*',
				declarations: 'clear:left;'
			},
			{
				selector: '.ns-0 h3+p, .ns-0 h4+p, .ns-0 h5+p',
				declarations: 'clear:none;margin:0px;padding-top:8px;'
			},
			{
				selector: '.ns-0 h3+p+*, .ns-0 h4+p+*, .ns-0 h5+p+*',
				declarations: 'clear:left;'
			}
		]
	},
	WiktLangNameISOCodeConverter: {
		num: 74,
		text: 'Add a language name to ISO code converter to the sidebar.',
		js: [{
			page: 'User:Yair rand/languagenametocode.js'
		}]
	},
	WiktInterwikiWatchlists2: {
		num: 78,
		text: 'Interwiki watchlists, other version. (Only works with enhanced recent changes.)',
		js: [{
			page: 'User:Yair rand/superwatchlist2.js'
		}]
	},
	WiktXTE: {
		num: 79,
		text: 'Enable Experimental Translator\'s Extension.',
		js: [{
			page: 'User:Kephir/gadgets/xte.js'
		}]
	},
	WiktAddAudio: {
		num: 81,
		text: 'Enable audio recording tool. (Firefox only.)',
		js: [{
			page: 'User:Yair_rand/AddAudio.js'
		}]
	},
	WiktChangesByLang: {
		num: 82,
		text: 'Filter watchlist and recent changes to only show changes for certain languages.',
		js: [{
			page: 'User:Yair_rand/ChangesByLang.js'
		}]
	}
};

/* Warning: The numbers associated with each preference must not be changed.
 * (The cookie that stores preferences is written as a sequence of preference
 * values without the corresponding preference names.) */

// TODO should not be global
var wiktTempCookie = '';

// this function must be global. it is used from other scripts
// including User:Connel_MacKenzie/clock.js
function wiktGetPrefCookie(wiktPrefName) {
	var objectStorage = new ObjectStorage("WT:PREFS");
	var prefsObject = objectStorage.Get() || {};

	//When we have a few hundred prefs, I’ll have to do this in binary, instead of text "0" & "1"

	//if (jQuery.cookie(wiktPrefName) == 'true') return 'true';

	if (wiktPrefName in prefs) {
		if (prefsObject[prefs[wiktPrefName].num] == 1)
			return 'true';
		else
			return 'false';
	} else
		return jQuery.cookie(wiktPrefName) || "";
}

function wiktSetPrefCookie(prefName, boolValue) {
	var objectStorage = new ObjectStorage("WT:PREFS");
	var prefsObject = objectStorage.Get() || {};

	var intValue = 0;
	if (boolValue == 'true') intValue = 1;

	if (prefs[prefName]) {
		prefsObject[prefs[prefName].num] = intValue;
	}

	//for (var p in prefs) {
	//  prefsObject[prefs[p].num] = wiktGetPrefCookie(p);
	//}

	objectStorage.Set(prefsObject);

	// Log choices to http://toolserver.org/~enwikt/prefs_stats - please disable if you consider this a security concern.
	//if (wgPageName == "Wiktionary:Per-browser_preferences") {
	//  document.body.appendChild($('<img>').attr("src", 'http://toolserver.org/~enwikt/prefs_stats/?action=store&cookie=' + versi)[0]);
	//}
	return;
}

function ActivateChosenPrefs() {
	if (wiktGetPrefCookie('WiktionaryUseJSPreferences') == 'true') {

		//Start by refreshing the cookies, deleting the old format cookies.
		wiktSetPrefCookie('WiktionaryUseJSPreferences', 'true');

		for (var p in prefs) {
			var pref = prefs[p];
			if (wiktGetPrefCookie(p) == 'true') {
				if ('isdisabled' in pref && pref.isdisabled())
					continue;

				if ("css" in pref) {
					for (var c in pref.css) {
						var css = pref.css[c];
						mw.util.addCSS(css.selector + '{' + css.declarations + '}');
					}
				}
				if ("js" in pref) {
					for (var j in pref.js) {
						var js = pref.js[j];
						var ok = true;

						if ('condition' in js) {
							ok = false;
							if (typeof js.condition == typeof
								function() {}) {
								ok = js.condition();
							} else if ('othercookie' in js.condition && 'comp' in js.condition && 'value' in js.condition) {
								var oc = wiktGetPrefCookie(js.condition.othercookie);
								if (js.condition.comp == '!=' && oc != js.condition.value)
									ok = true;
							}
						}

						if (ok) importScript(js.page, js.wiki, js.rev);
					}
				}
			}
		}
	}
}

// TODO should not be global
enWiktPrefCheckboxs = [];

/* </pre>

== wiktAddCheckbox ==
<pre> */
// generate checkboxs 
function wiktAddCheckbox(cookieToToggle, speedTip, isDisabled) {
	var checkbox = document.createElement("input");
	checkbox.type = 'checkbox';
	checkbox.name = cookieToToggle;
	checkbox.id = 'wikt_pref_chk_' + cookieToToggle;
	checkbox.onclick = function() {
		if (wiktGetPrefCookie(this.name) != 'true') {
			wiktSetPrefCookie(this.name, 'true');
		} else {
			wiktSetPrefCookie(this.name, 'false');
		}
	};
	checkbox.disabled = isDisabled;
	if ('true' == wiktGetPrefCookie(cookieToToggle)) {
		checkbox.checked = true;
	}
	var isPreferencePage = document.getElementById('isPreferencePage');
	isPreferencePage.appendChild(checkbox);
	if ('true' == wiktGetPrefCookie(cookieToToggle)) {
		checkbox.checked = true;
	}
	var checkboxLabel = document.createElement('label');
	checkboxLabel.setAttribute('for', checkbox.id);
	checkboxLabel.appendChild(document.createTextNode(speedTip));
	isPreferencePage.appendChild(checkboxLabel);
	isPreferencePage.appendChild(document.createElement('br'));
	return checkbox;
}

function wiktAddSeparator(wiktSepText) {
	var pnod = document.createElement('p');
	var isPreferencePage = document.getElementById('isPreferencePage');
	pnod.appendChild(document.createTextNode(wiktSepText));
	pnod.appendChild(document.createElement('hr'));
	isPreferencePage.appendChild(pnod);
	return pnod;
}

//not used just yet
function wiktAddTextBox(cookieToInput, speedTip) {
	var textbox = document.createElement("input");
	textbox.type = 'text';
	textbox.width = 10;
	textbox.name = cookieToInput;
	textbox.onchange = function() {
		wiktSetPrefCookie(this.name, this.value);
	};
	textbox.value = wiktGetPrefCookie(cookieToInput);
	isPreferencePage.appendChild(textbox);
	var text = document.createTextNode(speedTip);
	isPreferencePage.appendChild(text);
	return textbox;
}


// == CustomizePreferencesPage==
//*Note that this needs to be re-written as a separate tab (or two or three) that appear when wgPageName=="Special:Preferences".
function CustomizePreferencesPage() {
	//If on [[Special:Preferences]], add reminder link
	if (mw.config.get("wgCanonicalSpecialPageName") === 'Preferences') {
		var wiktlink = document.createElement("a");
		wiktlink.setAttribute('href', '/wiki/Wiktionary:Per-browser preferences');
		var wiktltxt = document.createTextNode("See also: Wiktionary-specific preferences");
		wiktlink.appendChild(wiktltxt);
		document.getElementById('preferences').appendChild(wiktlink);
	}

	var isPreferencePage = document.getElementById('isPreferencePage');
	if (!isPreferencePage) return;

	//OK, so now we know we are on 
	//the Set EnglishWiktionary-specific Preferences page (or impersonation thereof)
	// Hide the "noscript" div and display the "hasscript" one
	var noscript = document.getElementById('wtprefs.noscript');
	var hasscript = document.getElementById('wtprefs.hasscript');

	if (noscript !== null && hasscript !== null) {
		noscript.style.display = 'none';
		hasscript.style.display = 'block';
	}

	// http://tools.wikimedia.de/~cmackenzie/make_checkboxs.html
	// crop image to 21 pixels vertical, whatever horizontal.
	var everyone = [{
			type: "checkbox",
			name: 'WiktionaryUseJSPreferences'
		},

		{
			type: "separator",
			text: '>IMPORTANT – If the above box is unchecked, EVERYTHING on this page is turned off'
		},

		{
			type: "separator",
			text: 'Preferences that change the display of the interface.'
		},

		// Hide special characters for edit field
		{
			type: "checkbox",
			name: 'WiktionaryPreferencesEditTools'
		},

		// Allow special characters in [Search] input
		{
			type: "checkbox",
			name: 'WiktionaryPreferencesKeyPad'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesHideSiteNotice'
		},

		{
			type: "checkbox",
			name: 'WiktHideLogo'
		},

		{
			type: "checkbox",
			name: 'WiktIrc2'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesSmallRC'
		},

		{
			type: "checkbox",
			name: 'WiktFloatNavToggleLeft'
		},

		{
			type: "checkbox",
			name: 'WiktPreviewRightTOCs'
		},

		{
			type: "checkbox",
			name: 'WiktHideCopyrightWarning'
		},

		{
			type: "checkbox",
			name: 'WiktCustomTopToolbar'
		},

		{
			type: "separator",
			text: 'Preferences that change the display of entries. [May only work with the Monobook skin]'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesHideLinesBetweenLanguages'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesHideQualifierParens'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesItalicParens'
		},

		{
			type: "checkbox",
			name: 'WiktHideAllParens'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesHideSister'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesHideRankings'
		},

		//there’s a typo somewhere here, but I’m not seeing it…
		//See [[MediaWiki:Monobook.js#Dynamic Navigation Bars (experimental)]]
		{
			type: "externcheckbox",
			name: 'WiktionaryPreferencesShowNav',
			text: 'Show the translation sections expanded, instead of having them collapsed.'
		},
		// MediaWiki:Monobook.js / getCookie

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesHideTranslations'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesBoxedInflections'
		},

		{
			type: "checkbox",
			name: 'WiktionaryPreferencesIndentSeeAlso'
		},

		{
			type: "checkbox",
			name: 'WiktFormOfPlain'
		},

		{
			type: "checkbox",
			name: 'WiktFormOfItalicQualifier'
		},

		{
			type: "checkbox",
			name: 'WiktFormOfItalicLemma'
		},
		{
			type: "checkbox",
			name: 'WiktFormOfItalicQualifierBoldLemma'
		},
		{
			type: "checkbox",
			name: 'WiktLatnMentionBold'
		},
		{
			type: "checkbox",
			name: 'WiktMentionGlossSingleQuotes'
		},
		{
			type: "checkbox",
			name: 'WiktHideTrGlossParens'
		},
		{
			type: "checkbox",
			name: 'WiktHideGlossParens'
		},
		{
			type: "checkbox",
			name: 'WiktPlainTransliterations'
		},
		{
			type: "checkbox",
			name: 'WiktRoundBullets4Lists'
		},
		{
			type: "checkbox",
			name: 'WiktMobile'
		},
		{
			type: "checkbox",
			name: 'WiktBCAD'
		},
		{
			type: "checkbox",
			name: 'WiktHeadersInline'
		},
		{
			type: "checkbox",
			name: 'WiktMoveWasWotdUp'
		},

		{
			type: "separator",
			text: 'Preferences relating to navigation and editing.'
		},

		{
			type: "externcheckbox",
			name: 'WiktionaryDisableAutoRedirect',
			text: 'Disable the javascript redirect between pages that differ only in case.'
		},
		// MediaWiki:Common.js / getCookie()

		{
			type: "checkbox",
			name: 'WiktPrefConnelReformat'
		},

		{
			type: "checkbox",
			name: 'WiktAllowDoubleClickLookup'
		},

		{
			type: "checkbox",
			name: 'WiktAddProminentInterwikis'
		},

		{
			type: "checkbox",
			name: 'WiktMakeRedLinksBlack'
		},

		{
			type: "separator",
			text: 'Experiments – these are likely to be buggy and may not work in very common browsers.'
		},

		{
			type: "checkbox",
			name: 'WiktAddStructure'
		},

		{
			type: "checkbox",
			name: 'WiktFilterContributions'
		},

		{
			type: "checkbox",
			name: 'WiktNearbyPages',
			suboptions: [
				"WiktNearbyPagesLangHeadings",
				"WiktNearbyPagesNavbar",
				"WiktNearbyAlwaysLTR"
			]
		},
		{
			type: "externcheckbox",
			name: 'WiktNearbyPagesNavbar',
			text: 'Add the links in the navigation bar.',
			isdisabled: function() {
				return wiktGetPrefCookie('WiktNearbyPages') != 'true';
			}
		},
		// User:Hippietrail/nearbypages.js / getCookie()
		// TODO disable LTR checkbox when nearby headings is off
		{
			type: "externcheckbox",
			name: 'WiktNearbyPagesLangHeadings',
			text: 'Add the links under the language headings.',
			isdisabled: function() {
				return wiktGetPrefCookie('WiktNearbyPages') != 'true';
			}
		},
		// User:Hippietrail/nearbypages.js / getCookie()
		// TODO only enable this when nearyby headings is also enabled
		{
			type: "externcheckbox",
			name: 'WiktNearbyAlwaysLTR',
			text: 'Make the links left-to-right for all languages.',
			isdisabled: function() {
				return wiktGetPrefCookie('WiktNearbyPages') != 'true';
			}
		},
		// User:Hippietrail/nearbypages.js / getCookie()

		{
			type: "checkbox",
			name: 'WiktPerLanguage'
		},

		{
			type: "checkbox",
			name: 'WiktEtylAlwaysLink'
		},

		{
			type: "checkbox",
			name: 'WiktIPAConversion'
		},

		{
			type: "checkbox",
			name: 'WiktUsexEditor'
		},

		{
			type: "checkbox",
			name: 'WiktWSEdit'
		},

		{
			type: "checkbox",
			name: 'WiktDefEditOptions2'
		},

		{
			type: "checkbox",
			name: 'WiktLangNameISOCodeConverter'
		},

		{
			type: "checkbox",
			name: 'WiktRMTbotEntries'
		},

		{
			type: "checkbox",
			name: 'WiktEditSectionWTEDIT'
		},

		{
			type: "checkbox",
			name: 'WiktInterwikiWatchlists'
		},

		{
			type: "checkbox",
			name: 'WiktInterwikiWatchlists2'
		},

		{
			type: "checkbox",
			name: 'WiktWatchlistNotifications'
		},

		{
			type: "checkbox",
			name: 'WiktRTRC'
		},

		{
			type: "checkbox",
			name: 'WiktAddAudio'
		},

		{
			type: "checkbox",
			name: 'WiktChangesByLang'
		},

		{
			type: "checkbox",
			name: 'WiktSearchKeyboard'
		},

		{
			type: "checkbox",
			name: 'WiktXTE'
		},
	];

	var sysops = [{
			type: "separator",
			text: 'Sysop-only functions: '
		},
		{
			type: "checkbox",
			name: 'WiktPrefDelCmnt'
		},

		{
			type: "externcheckbox",
			name: 'WiktPrefVOA',
			text: 'Use the Uber-Popups from VOA – WARNING – DANGEROUS',
			isdisabled: function() {
				return true;
			}
		},
		// Can't find where this is or was used

		{
			type: "checkbox",
			name: 'WiktCIDRRangeContribs'
		},
		{
			type: "checkbox",
			name: 'WiktBeerParlourArchiver'
		}
	];

	function masterOnclick() {
		var t = wiktGetPrefCookie('WiktionaryUseJSPreferences');

		wiktSetPrefCookie('WiktionaryUseJSPreferences', t == 'true' ? 'false' : 'true');

		updateGUI();
	}

	function groupOnclick(ev) {
		var ele = window.event ? window.event.srcElement : ev.target;
		var masterPref = ele.name;

		var t = wiktGetPrefCookie(masterPref);

		wiktSetPrefCookie(masterPref, t == 'true' ? 'false' : 'true');

		updateGUIGroup(masterPref);
	}

	function getGUIItemFromPrefName(prefName) {
		var lists = getGuiLists();

		for (var l in lists) {
			var list = lists[l];

			for (var i in list) {
				var item = list[i];

				if ("name" in item && item.name == prefName)
					return item;
			}
		}
		return undefined;
	}

	function updateGUIGroup(masterPrefName) {
		var masterPref = prefs[masterPrefName];
		var masterDisable = !masterPref.ele.checked;

		var master = getGUIItemFromPrefName(masterPrefName);

		var subPrefs = master.suboptions;

		for (var sp in subPrefs) {
			var subPrefName = subPrefs[sp];
			var item = getGUIItemFromPrefName(subPrefName);
			var isdisabled = masterDisable;

			switch (item.type) {
				case "checkbox":
					if (typeof pref.isdisabled !== "undefined")
						isdisabled |= pref.isdisabled();

					pref.ele.disabled = isdisabled;

					break;
				case "externcheckbox":
					if (typeof item.isdisabled !== "undefined")
						isdisabled |= item.isdisabled();

					item.ele.disabled = isdisabled;

					break;
			}
		}
	}

	function buildGUI() {
		var masterDisable = false;

		var lists = getGuiLists();

		for (var l in lists) {
			var list = lists[l];

			for (var i in list) {
				var item = list[i];
				var pref = prefs[item.name];

				var isdisabled = masterDisable;

				switch (item.type) {
					case "checkbox":
						if (pref === undefined) continue;
						if (typeof pref.isdisabled !== "undefined")
							isdisabled |= pref.isdisabled();

						pref.ele = item.ele = wiktAddCheckbox(item.name, pref.text, isdisabled);

						if (l == 0 && i == 0) {
							masterDisable = !pref.ele.checked;
							pref.ele.onclick = masterOnclick;
						} else if ("suboptions" in item) {
							pref.ele.onclick = groupOnclick;
						}

						break;
					case "separator":
						item.ele = wiktAddSeparator(item.text);
						break;
					case "externcheckbox":
						if (typeof item.isdisabled !== "undefined")
							isdisabled |= item.isdisabled();

						item.ele = wiktAddCheckbox(item.name, item.text, isdisabled);
				}
			}
		}
	}

	function updateGUI() {
		var masterDisable = false;

		var lists = getGuiLists();

		for (var l in lists) {
			var list = lists[l];

			for (var i in list) {
				var item = list[i];
				var pref = prefs[item.name];

				var isdisabled = masterDisable;

				switch (item.type) {
					case "checkbox":
						if (typeof pref.isdisabled !== "undefined")
							isdisabled |= pref.isdisabled();
						pref.ele.disabled = isdisabled;
						if (l == 0 && i == 0)
							masterDisable = !pref.ele.checked;
						break;
					case "externcheckbox":
						if (typeof item.isdisabled !== "undefined")
							isdisabled |= item.isdisabled();
						item.ele.disabled = isdisabled;
				}
			}
		}
	}

	function isSysop() {
		var wgUserGroups = mw.config.get("wgUserGroups");
		return wgUserGroups !== null && wgUserGroups.indexOf("sysop") != -1;
	}

	function getGuiLists() {
		var lists = [everyone];

		if (isSysop())
			lists.push(sysops);

		return lists;
	}

	buildGUI();
}

function wiktCustomPrefsLoad() {
	CustomizePreferencesPage();
	ActivateChosenPrefs();
}


mw.loader.using(["ext.gadget.StorageUtils"], function() {
	$(wiktCustomPrefsLoad);
});
//</nowiki>