MediaWiki discusión:Common.js

Contenido de la página no disponible en otros idiomas.
De Wikipedia, la enciclopedia libre

Broken scripts with stylepath change[editar]

The stylepath has been changed to an off-site URI:

var stylepath = "http://upload.wikimedia.org/skins";

However, this breaks some scripts here, the ones using .cssRules, which cannot be performed on off-domain sheets. Instead of using this, it should be possible to simply use the appendCSS function:

addOnloadHook ( function() {
     var n = Math.round(Math.random() * 9); //10 opciones
     var randrot = '.rotate_0 { display: none }\n.rotate_' + n + ' { display: block; }';
     appendCSS(randrot);
} );

and

addOnloadHook ( function() {
  if ( userInGroup('sysop') ) appendCSS('.para_biblios { display: inline; }')
} );
Splarka (discusión) 02:04 20 nov 2008 (UTC).[responder]

Ajuste WikiMiniAtlas[editar]

O código

var wma_settings =
{
buttonImage: "http://upload.wikimedia.org/wikipedia/commons/thumb/9/9a/Erioll_world.svg/15px-Erioll_world.svg.png"
}

deveria estar na mesma "seção" do "WikiMiniAtlas" em vez de estar no fim da página, certo? Helder (discusión) 13:13 7 ago 2009 (UTC)[responder]

Mejora para ordenar las fechas en las wikitable sortable[editar]

Tras investigar un poco he visto que las columnas con fechas en las wikitable sortable se ordenan correctamente... cuando se escriben con el formato inglés, pero no con el que hemos consensuado en nuestra Wikipedia. Con la ayuda de Sabbut (disc. · contr. · bloq.) "he" introducido aquí (Common.js) el código que extrae desde las fechas en español las claves AAAAMMDD con la ordenación correcta (función ts_dateToSortKey), pero falta modificar el código que reconoce un determinado patrón de regex como una fecha. Para ello, bastaría copiar desde http://es.wikipedia.org/skins-1.5/common/wikibits.js la function ts_resortTable(lnk) al completo (justo delante de la ts_dateToSortKey sería un buen sitio), y a continuación cambiar la línea del patrón en inglés que dice: if (/^\d\d[\/. -][a-zA-Z]{3}[\/. -]\d\d\d\d$/.test(itm)) { por el patrón en español: if (/\d\d? de [a-zA-Z]+ de \d+$/.test(itm)). Omito el ^ inicial para que se reconozcan rangos, p. ej. 4 al 5 o 4-5 de agosto de 2009, y admito años de entre una y cuatro cifras, pues son casos posibles.

Espero que podáis completar esa última fase del cambio. Decir también que Platonides (disc. · contr. · bloq.), informado del tema, ha abierto un bug para intentar que esto se resuelva desde la propia MediaWiki, pero dado que los bugs anteriores relacionados no han sido resueltos tras pasar años, soy absolutamente escéptico al respecto y entiendo que lo lógico es irlo resolviendo nosotros. Además, veo difícil que ellos vayan a implementar el reconocimiento de las fechas en todos los idiomas de los proyectos Wikimedia (siempre habrá quienes tengan palabras y no sólo cifras o símbolos, como en nuestro caso), por lo que es casi seguro que algún tipo de solución/función local va a ser necesaria siempre. No obstante, me comprometo a vigilar periódicamente la evolución de los bugs y el código de wikibits y avisar de nuevo para hacer los ajustes necesarios si desde MediaWiki hubiera finalmente una solución parcial o total del problema. Gracias. - José Emilio Mori (jem) Tú dirás... 20:51 30 ago 2009 (UTC)[responder]

¿Esto es lo que había que hacer? Muro de Aguas 13:52 31 ago 2009 (UTC)[responder]
Exactamente, muchas gracias. Objetivo conseguido, las wikitable sortable ya ordenan las fechas en español (y todo lo demás) perfectamente. Seguiré al tanto de la evolución de los bugs en todo caso. - José Emilio Mori (jem) Tú dirás... 15:44 31 ago 2009 (UTC)[responder]

LinkFA[editar]

Las funciones LinkFA y LinkGA son redundantes, por lo que propongo implementar este código y eliminar las funciones existentes:

function LinkFA() 
{
   hito("C LinkFA");
   for ( var i = 0; a = document.getElementsByTagName("span")[i]; i++ ) {
      if ( a.className == "destacado" ) {
         for ( var j = 0; b = document.getElementsByTagName("li")[j]; j++ ) {
            if ( b.className == "interwiki-" + a.id ) {
               b.className += " destacado";
               b.title = "Este es un artículo destacado en esta Wikipedia.";
            }
         }
      } else if ( a.className == "bueno" ) {
         for( var j = 0; b = document.getElementsByTagName("li")[j]; j++ ) {
            if ( b.className == "interwiki-" + a.id ) {
               b.className += " bueno";
               b.title = "Este es un artículo bueno en esta Wikipedia.";
            }
         }
      }
   }
   hito("F LinkFA");
}

--Bachinchi (discusión) aka Locos epraix 01:51 25 jul 2010 (UTC)[responder]

SVG images: adds links to rendered PNG images in different resolutions[editar]

Sorry for writing in English. Many users are not familiar with using SVG images available on Wikipedia/Commons in office applications, etc. This is particularly true, if the base size is small (example). Therefore, I suggest adding links to rendered PNG images in different resolutions to the file description page (see same example in en.wikipedia). The script was first implemented on Commons and in de-wikipedia, then in en.wikipedia. I originally had the idea, Commons:User:Slomox did the coding and en:User:TheDJ made some refinements. It is available at en:MediaWiki:Common.js/file.js. --Leyo (discusión) 00:44 13 nov 2010 (UTC)[responder]

anidar 'withJS' y getParamValue[editar]

Commons y wikipedia en ingles suportan los funcionas withJS y getParamValue en sus MediaWiki:Common.js lo voy a anidiar para que podemos probar subtitulo en paginas de es Wikipedia. --Mdale (discusión) 16:59 4 dic 2010 (UTC)[responder]

Gracias! --by Màñü飆¹5 talk 04:17 7 dic 2010 (UTC)[responder]

Inclopedia[editar]

Es una tontería, pero los créditos a Inciclopedia tienen mal puesto el nombre. Yo como "autor" del código inicial de dónde se copió también os doy el permiso para quitar ese crédito no vaya a ser que os contagie (porque de hecho eran 3 líneas de nada y tuvieron que ser corregidas) — Chixpy (disc) 14:52 11 feb 2011 (UTC)[responder]

Función Hito[editar]

Es la función hito, realmente necesaria? No le veo mucha utilidad. Locos epraix 01:48 15 sep 2011 (UTC)[responder]

Hay tantas cosas innecesarias en este código que una función que permite medir los tiempos de carga y ejecución no debe ser la que lo es más. --angus (msjs) 16:31 6 dic 2011 (UTC)[responder]

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");
}

--Nemo 01:47 13 dic 2013 (UTC) (comments, translations and last instructions)[responder]

✓ Done. Thanks, LlamaAl (discusión) 01:47 13 dic 2013 (UTC)[responder]
Great! :) --Nemo bis (discusión) 10:46 14 dic 2013 (UTC)[responder]

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* (discusión) 20:25 18 ago 2014 (UTC)[responder]

OSM.js y Wikiminiatlas.js[editar]

¿Por qué nos cargamos tanto OSM.js y Wikiminiatlas.js? Ambos hacen básicamente lo mismo, pero OSM.js es mucho mejor. MoreTomorrow (discusión) 00:54 14 feb 2015 (UTC)[responder]

URGENT: Exceptions thrown in IE11[editar]

The follow code is throwing an exception in IE11: document.attachEvent(...) as it is run whenever we detect a client of 'msie' regardless of version number. It is likely that these IE hacks are not needed in version 11. document.addEventListener is the method that needs to be use from version 11 onwards. ESanders (WMF) (discusión) 16:27 9 jul 2015 (UTC)[responder]

✓ Hecho --Krenair (WMF) (discusión) 16:47 9 jul 2015 (UTC)[responder]
Fwiw... .attachEvent() is deprecated not only in IE11 but in IE9 & IE10 as well. See...
* https://msdn.microsoft.com/en-us/library/bg182625(v=vs.85).aspx#legacyAPIs
* http://stackoverflow.com/questions/20180046/attachevent-doesnt-work-in-ie-8-0
* https://fr.wikisource.org/wiki/Discussion_MediaWiki:Common.js/IEFixes.js
-- George Orwell III (discusión) 21:52 10 jul 2015 (UTC)[responder]