MediaWiki:Gadget-Prosesize.js: Difference between revisions
Content deleted Content added
fix |
fix |
||
Line 1:
// rewrite of [[User:Dr_pda/prosesize.js]]
( function () {
function sizeFormatter( size ) {
Line 26 ⟶ 25:
// Get size of text in edit box
// eslint-disable-next-line no-jquery/no-global-selector
appendResult( $( '#wpTextbox1' ).
} else if ( mw.config.get( 'wgIsArticle' ) ) {
// Get revision size from API
Line 90 ⟶ 89:
var proseValue, refValue, refHtmlValue, proseHtmlValue;
// eslint-disable-next-line no-jquery/no-global-selector
var
// eslint-disable-next-line no-jquery/no-global-selector
var prevStats = $( '#document-size-stats' );
Line 110 ⟶ 109:
.prop( 'id', 'document-size' )
.append( header, output );
if (
return;
}
Line 117 ⟶ 116:
prevStats.remove();
prevHeader.remove();
} else {
// Calculate prose size and size of reference markers ([1] etc)
$( this ).addClass( 'prosesize-highlight' );
proseSize += getLength( this );
Line 130 ⟶ 129:
// Calculate size of references (i.e. output of <references/>)
refSize = getLength( this );
refSizeHtml = this.innerHTML.length;
Line 140 ⟶ 139:
proseHtmlValue = sizeElement( 'prose-size-html', 'Prose size (including all HTML code):', proseSizeHtml - refmarkSizeHtml );
output.append( proseHtmlValue, refHtmlValue, proseValue, refValue );
getFileSize( proseHtmlValue );
getRevisionSize( proseValue );
Line 155 ⟶ 154:
* show the approppiate response upon clicking the portlet link
*/
var func, $portlet, notEnabled = false;
if (
if ( mw.config.get( 'wgAction' ) === 'edit' || ( mw.config.get( 'wgAction' ) === 'submit' && document.getElementById( 'wikiDiff' ) ) ) {▼
mw.config.get( 'wgAction' ) === 'edit' ||
▲
) {
notEnabled = true;
func = function () {
mw.notify( 'You need to preview the text for the prose size script to work in edit mode.' );
};
$portlet.addClass( 'prosesize-portlet-link-edit-mode' );▼
} else if ( [ 'view', 'submit', 'historysubmit', 'purge' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
func = main;
Line 166 ⟶ 168:
if ( func ) {
$portlet = $( mw.util.addPortletLink( 'p-tb', '#', 'Page size', 't-page-size', 'Calculate page and prose size' ) );
if ( notEnabled ) {
▲ $portlet.addClass( 'prosesize-portlet-link-edit-mode' );
}
$portlet.on( 'click', function ( e ) {
e.preventDefault();
if ( window.ve && ve.init && ve.init.target && ve.init.target.active ) {
func();▼
mw.notify( 'Prosesize does not work with the Visual Editor.' );
} else {
▲ func();
}
} );
}
|