MediaWiki:Gadget-Prosesize.js: Difference between revisions

Content deleted Content added
fix prose size calculation
fix
 
(2 intermediate revisions by the same user not shown)
Line 137:
// Use prosesize API to get a more accurate prose size account
// The calculations below are left in for the highlighting
prosePromise = $.getJSON( 'https://prosesize.toolforge.org/api/en' + mw.wikipediaconfig.orgget( 'wgServerName' ) + '/'
+ encodeURIComponent( mw.config.get( 'wgPageName' ) ) + '?revision=' + mw.config.get( 'wgRevisionId' ) );
 
Line 156:
} );
proseSize -= refmarksize;
// Add the relevant outputs once we have fetched the prose size.
prosePromise.then( function( data ) {
function show_output() {
if ( mw.config.get( 'wgIsArticle' ) ) {
// Tool doesn't work on previews
proseSize = data.prose_size;
wordCount = data.word_count;
} else {
proseSize -= refmarksize;
}
proseValue = sizeElement( 'prose-size', 'Prose size (text only):', proseSize, ' (' + wordCount + ' words) "readable prose size"' );
refValue = sizeElement( 'ref-size', 'References (text only):', refSize + refmarksize );
Line 173 ⟶ 167:
getFileSize( proseHtmlValue );
getRevisionSize( proseValue );
})
// Add the relevant outputs once we have fetched the prose size.
prosePromise.then( function( data ) {
function( data ) {
if ( mw.config.get( 'wgIsArticle' ) ) {
// Tool doesn't work on previews
proseSize = data.prose_size;
wordCount = data.word_count;
} else {
show_output();
},
// If tool is down fallback to our prose count
show_output
);
}
}