From 31a1c4649ba06a9a4416a5e49f80f5214faa16cf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 14 Dec 2016 14:17:58 +0100 Subject: [PATCH] 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 --- resources/src/mediawiki/page/watch.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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(), { -- 2.20.1