MediaWiki talk:Centralnotice-template-wlm2018 template
Global variables[edit]
@Seddon (WMF): Can I recommend that the banner's JS not use unnecessary global variables so much? Replacing url = '';
with var url = '';
would remove one, and putting the contents of cn_rewrite_url
directly in the jQuery ready would remove the other. Also, the $( document ).ready
style is deprecated, and Mediawiki coding conventions require some changes, so that would be:
$( function () { var url = ''; switch ( Geo.country ) { case 'IE': url = 'http://wikimedia.ie/programme/wiki-loves-monuments-2017/?pk_campaign=Centralnotice'; break; case 'VE': url = 'https://wikimedia.org.ve/wiki/Wiki_Loves_Monuments'; break; } if ( url !== '' ) { $( 'div.wlm-banner a.wlm-mainlink' ).attr( 'href', url ); } } );
Thanks. --Yair rand (talk) 00:40, 28 August 2018 (UTC)
- Also, am I missing something with the repetition in the switch statement? The following two pieces of JS are identical:
case 'US': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break; case 'AS': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break; case 'GU': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break; case 'MP': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break; case 'PR': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break; case 'UM': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break; case 'VI': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break;
and
case 'US': case 'AS': case 'GU': case 'MP': case 'PR': case 'UM': case 'VI': url = '//commons.wikimedia.org/wiki/Commons:Wiki_Loves_Monuments_2018_in_the_United_States'; break;
- I don't understand the point of using the longer version? --Yair rand (talk) 21:44, 2 September 2018 (UTC)
There's also a specific central notice for Austria so this one isn't needed in AT :-) Braveheart (talk) 13:21, 3 September 2018 (UTC)
- Thanks for pointing to that. I've removed AT from this banner. —DerHexer (Talk) 13:29, 3 September 2018 (UTC)