MediaWiki:Gadget-Prosesize.js: Difference between revisions
Content deleted Content added
Update to get data from prosesize toolforge tool - is more accurate |
fix |
||
(7 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
+ encodeURIComponent( mw.config.get( 'wgPageName' ) ) + '?revision=' + mw.config.get( 'wgRevisionId' ) );
// Calculate prose size and size of reference markers ([1] etc)
Line 155 ⟶ 156:
} );
// Add the relevant outputs once we have fetched the prose size.▼
prosePromise.then( function( data ) {▼
function show_output() {
▲ proseSize = data.prose_size;
proseValue = sizeElement( 'prose-size', 'Prose size (text only):', proseSize
wordCount = data.word_count;▼
▲ proseValue = sizeElement( 'prose-size', 'Prose size (text only):', proseSize - refmarksize, ' (' + wordCount + ' words) "readable prose size"' );
refValue = sizeElement( 'ref-size', 'References (text only):', refSize + refmarksize );
refHtmlValue = sizeElement( 'ref-size-html', 'References (including all HTML code):', refSizeHtml + refmarkSizeHtml );
Line 167:
getFileSize( proseHtmlValue );
getRevisionSize( proseValue );
}
▲ // Add the relevant outputs once we have fetched the prose size.
function( data ) {
if ( mw.config.get( 'wgIsArticle' ) ) {
// Tool doesn't work on previews
proseSize = data.prose_size;
▲ wordCount = data.word_count;
}
show_output();
},
// If tool is down fallback to our prose count
show_output
);
}
}
|