MediaWiki talk:Common.js

Page contents not supported in other languages.
From Simple English Wikipedia, the free encyclopedia

Undefined addEvent[change source]

Please be more careful when copying the code from other projects. In the current version the function addEvent() is undefined, causing JavaScript error on Preferences page. It should be replaced with addHandler() which is defined in wikibits.js. —AlexSm 13:56, 3 September 2008 (UTC)[reply]

Give search results even when page doesn't exist[change source]

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 19:33, 19 June 2023 (UTC) (comments, translations and last instructions)[reply]

Sounds like a good idea. --ShakespeareFan00 (talk) 19:33, 19 June 2023 (UTC)[reply]

Announced JavaScript change for badges implementation[change source]

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* (talk) 20:30, 18 August 2014 (UTC)[reply]

{{editprotected}} IE 7 and below no longer loads JavaScript, so please delete these:

/* IE 7 and below: Generate interpuncts and parentheses */
        if ( $.client.profile().versionNumber <= 7 ) {
            var hlists = $( '.hlist' );
            hlists.find( 'dt:not(:last-child)' )
                .append( ': ' );
            hlists.find( 'dd:not(:last-child)' )
                .append( '<b>·</b> ' );
            hlists.find( 'li:not(:last-child)' )
                .append( '<b>·</b> ' );
            hlists.find( 'dl dl, dl ol, dl ul, ol dl, ol ol, ol ul, ul dl, ul ol, ul ul' )
                .prepend( '( ' ).append( ') ' );
        }

Then merge the rest into MediaWiki:Common.js, like this change on English Wikipedia. Thanks! Chmarkine (talk) 04:01, 4 December 2014 (UTC)[reply]

Done --Chenzw  Talk  11:07, 4 December 2014 (UTC)[reply]