Conversa MediaWiki:Common.js

Último comentário: hai 9 anos de Bene* no tópico Announced JavaScript change for badges implementation

Atopei un problema que vén dado polos parámetros que hai ao final desta páxina. Hai algún tempo engadíronse un par de botóns á caixa de edición, e un deron algún pequeno problema, e ségueno a dar: se prememos no primeiro botón pola dereita (sección "Véxase tamén") engádese isto:

NaN<references/>
==Véxase tamén==
===Bibliografía===
*
===Outros artigos===
*
===Ligazóns externas===
*

Alguén sabería arranxar o que aparece ao principio, iso de "NaN", para que ao premer o botón saia ==Notas==, que é o que realmente debería aparecer? --Toliño Fala aquí comigo 15:48, 17 abril 2008 (UTC)

  • O caso é que non atopo o erro, e houbo un tempo no que o botón ía ben. De non atoparse supoño que haberá que mudar o botón, é dicir, suprimilo. A ver se alguén ten mellor ollo informático para atopar o erro. AlberteSi, digame? 16:42, 17 abril 2008 (UTC)
  • Xa arranxei o botón! Fun á wikipedia francesa e revisei como o teñen alí para corrixilo aquí. Está por ver se agora funciona tamén o das IP. --Toliño Fala aquí comigo 18:49, 4 xullo 2008 (UTC)

Adicionar getParamValue e withJS editar

Gostaria que fosse adicionado o seguinte código ao Common.js:

/**
* Escape all RegExp special characters such that the result can be safely used in a RegExp as a literal.
* @author [[User:Krinkle]] at [[commons:MediaWiki:Common.js]]
*/
if ( typeof String.prototype.escapeRE === 'undefined' ) {
        String.prototype.escapeRE = function() {
                return this.replace (/([\\{}()|.?*+^$\[\]])/g, "\\$1");
        };
}
/**
* Extract a URL parameter from the current URL
* @param {string} paramName The name of the parameter to extract
* @param {string=} url Optional URL to extract the parameter from, document.location.href if not given.
* @return {?string} The value of parameter or null if not found
* @author From [[en:User:Lupin/autoedit.js]], maintened by [[User:Dschwen]], [[User:Lupo]] & [[User:Krinkle]] at [[commons:MediaWiki:Common.js]]
*/
function getParamValue( paramName, url) {
	// Get last match, stop at hash
	var re = new RegExp( '[^#]*[&?]' + paramName.escapeRE() + '=([^&#]*)' ); 
	var m = re.exec( url );
	if ( m && m.length > 1 ) {
		return decodeURIComponent( m[1] );
	}
	return null;
}
/** &withJS= URL parameter
 * Allow to try custom scripts from MediaWiki space without editing [[Special:Mypage/vector.js]]
 * @author From [[en:w:MediaWiki:Common.js]]
 */
var withJS = getParamValue("withJS");
if ( withJS && withJS.match("^MediaWiki:[^&<>=%]*\.js$") ) {
	importScript(withJS);
}

A função getParamValue é útil em vários casos.

O withJS é bem útil (ver tópico onde foi proposto na Wikipédia inglesa), pois fornece-nos um meio de criar "links que carreguem scripts do espaço nominal MediaWiki", permitindo que usuários possam testar scripts que estão em fase experimental sem ter que editar suas subpáginas, entre outras coisas. Helder 23:25, 17 de novembro de 2010 (UTC)

Give search results even when page doesn't exist editar

 
Screenshot of the Earth test search, with this script adding links to Wikidata, Reasonator, Commons, and Wikipedia.

Hello, I propose to enable the tool created by Magnus Manske (creator of MediaWiki) to provide results from other languages and Commons (via Wikidata) when a page doesn't exist here: links are added to Special:Search and noarticletext. This helps to encourage translation and to make readers use your wiki more, because they can be sure to find something even if it's not local (rather than searching directly on the biggest wiki). The Italian and Polish Wikipedias, among others already enabled it by default.
Examples: [1] [2] [3]. More information: Magnus blog.
How to: just add the following line at the end of Common.js.

// Results from Wikidata
// [[File:Wdsearch_script_screenshot.png]]
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||  ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
	importScriptURI("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
--[[m:User:Nemo_bis|Nemo]] ~~~~~ ([[w:en:MediaWiki talk:Wdsearch.js|comments, translations and last instructions]])
</div>
<!-- EdwardsBot 0661 -->

Announced JavaScript change for badges implementation editar

Hi! I want to let you know that in near future badges will be deployed on Wikidata and the Wikipedias. They help us with displaying the good and featured article icons next to the sitelinks and will replace the javascript hack which is used at the moment together with the Link GA and Link FA templates. To avoid an overlap where the current system and the new feature conflict, I will add a minor fix to your Common.js which adds the class names to the interwiki links. This is part of my task as a global edit interface editor for the Wikidata team. Thanks, Bene* (conversa) 11 de agosto de 2014 ás 19:16 (UTC)Responder

Volver á páxina "Common.js".