Wiktionary:Gadgets
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.
General criteria for Gadgets
[edit]Gadgets should generally pass the following conditions:
- Gadgets must work if just included with no further configuration. They can be configurable via monobook.js, but must work unconfigured.
- Gadgets must be compatible with all major browsers, i.e. they must not terminate with errors.
- Gadgets should be functional in most major browsers (cross-browser compatibility). Exceptions must be clearly stated.
- Duplication of gadgets should only be made if it's reasonable.
- Gadgets requiring permissions must be marked, and must fail gracefully if the permissions aren't present.
- Gadgets only working in some skins must be marked as such, if that data is available.
Comments
[edit]Comments or warnings can be added to the gadget description templates in two ways:
- noinclude tag (visible on description page with links):
<noinclude> comment </noinclude>
- HTML comments (visible in source text only):
<!-- comment -->
Comments added in this way will be automatically discarded during the page creation process.
Installed gadgets
[edit]For currently installed gadgets, see Special:Gadgets.
Preferences
[edit]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
- add
ext.gadget.WiktGadgetPrefs
as a direct dependency of the gadget in MediaWiki:Gadgets-definition, or - use
mw.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.
See also
[edit]- WT:PREFS
- WT:TAT
- MediaWiki:Gadgets-definition List of gadgets and their used files
- Special:Gadgets, same list but with editable descriptions
- mw:Extension:Gadgets, the MediaWiki gadget extension page