.done( function ( watchResponse ) {
var message, otherAction = action === 'watch' ? 'unwatch' : 'watch';
- if ( mwTitle.getNamespaceId() > 0 && mwTitle.getNamespaceId() % 2 === 1 ) {
+ if ( mwTitle.isTalkPage() ) {
message = action === 'watch' ? 'addedwatchtext-talk' : 'removedwatchtext-talk';
} else {
message = action === 'watch' ? 'addedwatchtext' : 'removedwatchtext';
label: label || mw.msg( 'blanknamespace' ),
description: '',
identifiers: [
- ( namespaceID < 0 || namespaceID % 2 === 0 ) ?
- 'subject' : 'talk'
+ mw.Title.isTalkNamespace( namespaceID ) ?
+ 'talk' : 'subject'
],
cssClass: 'mw-changeslist-ns-' + namespaceID
} );
$watchlistLine = $unwatchLink.closest( 'li, table' )
.find( '[data-target-page]' ),
pageTitle = $watchlistLine.data( 'targetPage' ),
- isTalk = mw.Title.newFromText( pageTitle ).getNamespaceId() % 2 === 1;
+ isTalk = mw.Title.newFromText( pageTitle ).isTalkPage();
// Utility function for looping through each watchlist line that matches
// a certain page or its associated page (e.g. Talk)
function forEachMatchingTitle( title, callback ) {
var titleObj = mw.Title.newFromText( title ),
- pageNamespaceId = titleObj.getNamespaceId(),
- isTalk = pageNamespaceId % 2 === 1,
- associatedTitle = mw.Title.makeTitle( isTalk ? pageNamespaceId - 1 : pageNamespaceId + 1,
- titleObj.getMainText() ).getPrefixedText();
+ associatedTitleObj = titleObj.isTalkPage() ? titleObj.getSubjectPage() : titleObj.getTalkPage(),
+ associatedTitle = associatedTitleObj.getPrefixedText();
$( '.mw-changeslist-line' ).each( function () {
var $this = $( this ), $row, $unwatchLink;