r73219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73218‎ | r73219 | r73220 >
Date:17:00, 17 September 2010
Author:kaldari
Status:ok (Comments)
Tags:
Comment:
allow banner forcing for testing
Modified paths:
  • /trunk/extensions/CentralNotice/SpecialBannerController.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/SpecialBannerController.php
@@ -124,8 +124,13 @@
125125 $( document ).ready( function () {
126126 // Initialize the query string vars
127127 $.centralNotice.fn.getQueryStringVariables();
128 - // Look for banners ready to go NOW
129 - $.centralNotice.fn.loadBannerList( );
 128+ if( $.centralNotice.data.getVars['cnbanner'] ) {
 129+ // if we're forcing one banner
 130+ $.centralNotice.fn.loadBanner( $.centralNotice.data.getVars['cnbanner'] );
 131+ } else {
 132+ // Look for banners ready to go NOW
 133+ $.centralNotice.fn.loadBannerList( );
 134+ }
130135 } ); //document ready
131136 } )( jQuery );
132137 EOT;

Comments

#Comment by Catrope (talk | contribs)   18:33, 27 September 2010

Since getVars['cnbanner'] is not necessarily defined, you need to do something like if ( typeof $.centralNotice.data.getVars['cnbanner'] != 'undefined' ) to avoid JS errors in most browsers.

#Comment by Kaldari (talk | contribs)   19:26, 27 September 2010

since centralNotice.data is defined, centralNotice.data.getVars['cnbanner'] should be OK actually.

#Comment by Catrope (talk | contribs)   19:29, 27 September 2010

You're right, JS lets you access undefined members up to one level deep.

Status & tagging log