From: Bartosz DziewoƄski Date: Wed, 14 Dec 2016 13:17:58 +0000 (+0100) Subject: mediawiki.page.watch: Avoid dynamic message keys X-Git-Tag: 1.31.0-rc.0~4597^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=31a1c4649ba06a9a4416a5e49f80f5214faa16cf;p=lhc%2Fweb%2Fwiklou.git mediawiki.page.watch: Avoid dynamic message keys Restructure the code to avoid constructing message names by adding strings together. Makes it easier to find the usages. Also, simplify a check for odd/even namespace numbers. Change-Id: I0b6794cc07ed2a600499632d240b71898715c5b0 --- diff --git a/resources/src/mediawiki/page/watch.js b/resources/src/mediawiki/page/watch.js index 0319c64550..f880e6a338 100644 --- a/resources/src/mediawiki/page/watch.js +++ b/resources/src/mediawiki/page/watch.js @@ -134,14 +134,11 @@ .done( function ( watchResponse ) { var mwTitle, message, otherAction = action === 'watch' ? 'unwatch' : 'watch'; - message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext'; mwTitle = mw.Title.newFromText( title ); - if ( mwTitle && mwTitle.getNamespaceId() > 0 && - /* eslint-disable no-bitwise */ - ( mwTitle.getNamespaceId() & 1 ) === 1 - /* eslint-enable no-bitwise */ - ) { - message += '-talk'; + if ( mwTitle && mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) { + message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk'; + } else { + message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext'; } mw.notify( mw.message( message, title ).parseDom(), {