A gadget is a JavaScript and/or a CSS snippet that can be enabled simply by checking an option in your Wiktionary preferences. The gadgets functionality is provided by the MediaWiki extension Extension:Gadgets.
Gadgets should generally pass the following conditions:
Comments or warnings can be added to the gadget description templates in two ways:
<noinclude> comment </noinclude>
<!-- comment -->
Comments added in this way will be automatically discarded during the page creation process.
For currently installed gadgets, see Special:Gadgets.
Gadgets may offer their own preferences to allow users to customize their behavior. This is done with the gadget WiktGadgetPrefs.js. To use it, you must either
ext.gadget.WiktGadgetPrefs
as a direct dependency of the gadget in MediaWiki:Gadgets-definition, ormw.loader.using("ext.gadget.WiktGadgetPrefs", ...)
to load it dynamically.After this, the preferences can be accessed through mw.wiktGadgetPrefs.get
. For example, to implement a check box (true/false) and a string enum (one of three options), the call could look like this:
var preferences = mw.wiktGadgetPrefs.get("gadgetfoobar",
{
"label": {
"en": "Example Gadget"
}
},
{
"frobulate": {
"type": "boolean",
"default": false,
"label": {
"en": "Whether this gadget should frobulate"
}
},
"favoriteColor": {
"type": "strenum",
"default": "red",
"label": {
"en": "Favorite color"
},
"choices": [
"red",
"green",
"blue"
],
"choiceLabels": {
"en": {
"red": "Red!",
"green": "Green!",
"blue": "Blue!"
}
}
}
});
var frobulate = preferences.frobulate;
Full documentation can be found in MediaWiki:Gadget-WiktGadgetPrefs.js.
Once implemented, the preferences should appear in Wiktionary:Gadget preferences.