User:Nw520/Gadgets

From Meta, a Wikimedia project coordination wiki

AutoReplace[edit]

Source code

Activation[edit]

This gadget can be enabled by appending the following line to either your global.js or your common.js on any Wikimedia-wiki:

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Nw520/AutoReplace.js&action=raw&ctype=text/javascript' );

Configuration[edit]

window.nw520_config = {
	autoReplace_replacements: [
		{
			find: / Open Street Maps?([ .,])/g,
			replace: ' OpenStreetMaps$1',
			comment: 'fixed spelling of OSM',
			trivial: false
		}
	]
};
Key Type Description
window.nw520_config.autoReplace_autoDiff boolean|String
  • If set to true, automatically reload editor page and display diff if automatic replacements were performed or if a manual rule was executed.
  • If set to auto, only display diff for automatic replacements.
window.nw520_config.autoReplace_replacements List<⟨refer to description⟩> List of replacements. Each replacement is defined by an object consisting of:
  • find: A string or regular expression (instance of RegExp) to look for.
  • replace: A string or function to replace the found match with. Regex group matching is supported. Refer to String.prototype.replace()'s replacement-parameter for more details.
  • comment (optional): String to append to the edit summary, if needed, separated by semicolons. If instead an array consisting of exactly two elements is specified, then both items are appended separated by : . The first parts acts as a group, i.e. if the groups was already present in the summary, only the second item is appended after the group's last item in the summary separated by a comma.
  • trivial (optional): If not set to true, users are required to preview or diff their wikitext before being able to submit it.
  • manual (optional): If set, instead of automatically executing the replacement it has to be manually triggered by pressing the corresponding button in the WikiEditor's toolbar. The value of this parameter determines the displayed label in the selection of rules to run. If multiple rules share the same value then all of those are executed when pressing the corresponding button.
  • iterative (optional): Maximum number of times the rule is to be re-run if the find-expression still has matches after execution of the rule.

Query parameters[edit]

Parameter Description
autoreplace If set to no, no automatic replacements are performed.

GadgetManager[edit]

Source code // de,en

Activation[edit]

This gadget can be enabled by appending the following line to either your global.js or your common.js on any Wikimedia-wiki:

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Nw520/GadgetManager.js&action=raw&ctype=text/javascript' );

Methods[edit]

Method Description
window.nw520.gadgetManager.addKeyboardListener()
window.nw520.gadgetManager.addLazyPortlet()
window.nw520.gadgetManager.loadLazyGadgets()
window.nw520.gadgetManager.registerGadget( displayName: String, URL: String, [lazy=false]: boolean, [method='using']: String )

Query parameters[edit]

Parameter Description
nogadget List of gadget slugs to not load separated by commas. If no value is defined, no gadgets will be loaded.

HashCheck[edit]

Source code // de,en

Activation[edit]

This gadget can be enabled by appending the following line to either your global.js or your common.js on any Wikimedia-wiki:

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Nw520/HashCheck.js&action=raw&ctype=text/javascript' );

Hooks[edit]

Hooks can be used to execute code once an event has occurred.

Hook Parameter Beschreibung
ext.hashCheck.loaded HashCheck-object Triggered, once HashCheck has been loaded and initialised.

Methods[edit]

Method Description
window.nw520.hashCheck.scan()


StraightToCommons[edit]

Source code

Replaces links to files on any Wikimedia-wiki to directly link to Wikimedia Commons saving you from having to wait for the on-wiki file page to load. Images and files hosted on Wikimedia Commons are highlighted with a green border to help distinguish between on-wiki files. Clicking on an image while holding down Ctrl copies the Commons file name to your clipboard.

Activation[edit]

This gadget can be enabled by appending the following line to either your global.js or your common.js on any Wikimedia-wiki:

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Nw520/StraightToCommons.js&action=raw&ctype=text/javascript' );


SummaryFloskeln[edit]

Source code

Activation[edit]

This gadget can be enabled by appending to following line to either your global.js or your common.js on any Wikimedia-wiki:

mw.loader.load( '//meta.wikimedia.org/w/index.php?title=User:Nw520/SummaryFloskeln.js&action=raw&ctype=text/javascript' );

Configuration[edit]

window.nw520_config = {
	summaryFloskeln_floskeln: [
		'Maintenance',
		[
			'Typo',
			[
				'OSM',
				'fixed spelling of OSM'
			]
		]
	]
};
Key Type Description
window.nw520_config.summaryFloskeln_floskeln List<[String, String|[String, String]]> List of summary strings to display. Summaries are grouped into groups which are modelled as tuples with the former component being a label to display in the interface and the latter being a list of summaries. Summaries can either be a string which is displayed and when chosen appended to the summary, or a tuple with the former component being the string that is displayed and the latter component being the string that is appended to the summary.


VoyageData[edit]

Source code // Only for German Wikivoyage (dewikivoyage)

Durchsucht den aktuellen Artikel nach Markern und vCards ohne Wikidata-ID und listet mögliche passende Wikidata-Datenobjekte auf.

Aktivierung[edit]

VoyageData kannst Du als Helferlein in deinen Einstellungen im Abschnitt „Beta-Funktionen“ aktivieren.

Dieses Gadget kann aktiviert werden, indem Du folgende Zeile deiner common.js in der Wikivoyage hinzufügst:

mw.loader.load( '//de.wikivoyage.org/w/index.php?title=User:Nw520/VoyageData.js&action=raw&ctype=text/javascript' );

Konfiguration[edit]

mw.hook( 'voy.voyagedata.loaded' ).add( function ( VoyageData ) {
	VoyageData.COORDINATES_MAX_LENGTH = 8;
	VoyageData.INITIAL_ZOOM = 12;
	VoyageData.SEARCH_LIMIT = 15;
	VoyageData.SPARQL_LIMIT = 1500;
    VoyageData.WIKIDATA_CLASS_SUGGESTIONS = [];
} );
Key Type Description
window.VoyageData.COORDINATES_MAX_LENGTH number Maximale Anzahl an Stellen von Koordinaten bei SPARQL-Anfragen.
window.VoyageData.INITIAL_ZOOM number Zoomstufe der Karte beim Öffnen von VoyageData.
window.VoyageData.SEARCH_LIMIT number Maximale Anzahl an Ergebnissen je Suchlauf bei der Namenssuche.
window.VoyageData.SPARQL_LIMIT number Maximale Anzahl an Ergebnissen für SPARQL-Anfragen.
window.VoyageData.WIKIDATA_CLASS_SUGGESTIONS [String, String][] In Autocomplete anzuzeigende Wikidata-Klassen (z. B. für Whitelist).

CSS[edit]

CSS-Klassen haben die Präfix voy-voyagedata-.

Hooks[edit]

Hooks können genutzt werden, um Code auszuführen, sobald bestimmte Ereignisse eintreten.

Hook Parameter Beschreibung
voy.voyagedata.loaded Klasse von VoyageData Ausgelöst, sobald VoyageData geladen und initialisiert wurde.

Zeichenketten[edit]

mw.messages-Zeichenketten haben die Präfix voy-voyagedata-.

globale Variablen[edit]

Variable Beschreibung
window.VoyageData Klasse von VoyageData