From 9689803b327c1401cd24de5e54330445c91964cc Mon Sep 17 00:00:00 2001 From: APerson Date: Mon, 23 Feb 2015 12:32:47 -0500 Subject: [PATCH] Disable cat link when cat empty to fix #52 --- src/modules/core.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/core.js b/src/modules/core.js index a21abc4..5a183de 100644 --- a/src/modules/core.js +++ b/src/modules/core.js @@ -1370,6 +1370,7 @@ return $( '' ) .attr( 'href', mw.util.getUrl( actualTitle ) ) + .attr( 'id', 'afch-cat-link-' + pagename.toLowerCase().replace( / /g, '-' ).replace( /\//g, '-' ) ) .attr( 'title', actualTitle ) .text( displayTitle || actualTitle ) .attr( 'target', newTab ? '_blank' : '_self' ); @@ -1403,6 +1404,9 @@ var pageKey = Object.keys( data.query.pages )[ 0 ], pagesCount = data.query.pages[ pageKey ].categoryinfo.pages; $( '#' + countSpanId ).text( ' (' + pagesCount + ')' ); + + // Disable link if there aren't any pages + $( '#afch-cat-link-' + pagename.toLowerCase().replace( / /g, '-' ).replace( /\//g, '-' ) ).replaceWith( displayTitle ); } } );