MediaWiki talk:SearchIcons.js

From mediawiki.org
Latest comment: 7 months ago by Pppery in topic Legacy JavaScript

The iconMap cannot be easily overriden with the current code. Ideally, for allow local sites to override certain parts of the code, it should be coded like this:


// private variables with the default values
var _iconMap = [
		// URL to image, then one space, then the name of the article
		'http://upload.wikimedia.org/wikipedia/commons/9/94/Empty_search_icon.png Emptiness'
];

// Check for local customizations. Checks for global variable window.SearchIcons_iconMap first, then fallback to the default SearchIcons._iconMap
var lines = (window.SearchIcons_iconMap || SearchIcons._iconMap);

Then, for overriding on a local wiki, first declare the var window.SearchIcons_iconMap and then import the script:

window.SearchIcons_iconMap = [ /* whatever */ ];
importScriptURI('http://www.mediawiki.org/w/index.php?title=MediaWiki:SearchIcons.js&action=raw&ctype=text/javascript');

Note: variable names are just an example. The defaults don't need to be private, but prevent people from trying to override them the wrong way. --Ciencia Al Poder 20:49, 27 October 2011 (UTC)Reply

Legacy JavaScript[edit]

Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include addOnloadHook() needs to be replaced with $(); all wgGlobalVariables need to be properly gotten with mw.config.get( 'wgGlobalVariable' ); and addPortletLink needs to be called with mw.util.addPortletLink. Please see MW:ResourceLoader/Legacy JavaScript for details. Thank you. Technical 13 (talk) 18:13, 18 January 2015 (UTC)Reply

Was dealt with a while ago. * Pppery * it has begun 16:47, 16 September 2023 (UTC)Reply