ਵਰਤੋਂਕਾਰ:Gurlal Maan/common.js: ਰੀਵਿਜ਼ਨਾਂ ਵਿਚ ਫ਼ਰਕ

ਸਮੱਗਰੀ ਮਿਟਾਈ ਸਮੱਗਰੀ ਜੋੜੀ
Reverted to revision 22434 by Gurlal Maan (talk). (TW)
ਟੈਗ: ਅਣਕੀਤਾ
Get the old
ਲਾਈਨ 1:
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Dr pda/prosesize.js&action=raw&ctype=text/javascrpt');
//mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Harsh4101991/EditCount.js&action=raw&ctype=text/javascript');
//mw.loader.load('//bits.wikimedia.org/he.wikipedia.org/load.php?debug=false&lang=uk&modules=ext.gadget.autocomplete');
// Installation for Assessment Bar India
//$.getScript("//en.wikipedia.org/w/index.php?title=User:YuviPanda/AssessmentBar/WPIndia.js&action=raw&ctype=text/javascript").then(function() {
// mw.loader.load('//en.wikipedia.org/w/index.php?title=User:YuviPanda/AssessmentBar.js&action=raw&ctype=text/javascript');
//});
 
//mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hedonil/XTools/XTools.js&action=raw&ctype=text/javascript');
//importScript('User:Jackmcbarn/editProtectedHelper.js');
 
ਲਾਈਨ 15:
//importScript('User:Kephir/gadgets/rater.js'); // [[User:Kephir/gadgets/rater]]
 
//mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );
//importScript( 'User:Evad37/ToDoLister.js' ); // Backlink: [[User:Evad37/ToDoLister.js]]
// mw.loader.load('//he.wikipedia.org/w/load.php?modules=ext.gadget.autocomplete');
/*
@Author [[User:Jayprakash12345]]
@OwnBy [[meta:Indic-TechCom]]
*/
var IndicOCR = function () {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'IndicOCR': {
label: 'IndicOCR', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/4/43/Farm-Fresh_ocr_language_support.png/22px-Farm-Fresh_ocr_language_support.png',
action: {
type: 'callback',
execute: function () {
var toolUrl = "//tools.wmflabs.org/indic-ocr/getOCR";
lang = mw.config.get( 'wgContentLanguage' );
loadingGifUrl = '//upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif';
showLoadingMsg( 'OCR is in process.' );
if ( $( '.prp-page-image img' ).length === 0 ) {
mw.notify( 'Proofread Image not found.' );
}
var imageUrl = 'https:' + $( '.prp-page-image img' ).attr('src'),
requestUrl = toolUrl + "?imageurl=" + imageUrl + "&langcode="+lang+ "&api=True";
$.getJSON( requestUrl )
.done( processOcrResult )
.fail( processOcrResult ) // Same handler, for simplicity.
.always( function () { showLoadingMsg( '' ); } );
}
}
}
}
} );
 
function processOcrResult( response ) {
if ( response.responseJSON !== undefined && response.responseJSON.error ) {
mw.notify( mw.message( 'error' ) + ' ' + response.responseJSON.error.code + ' ' + response.responseJSON.error.message );
return;
}
if ( response.text === undefined || response.text.length === 0 ) {
mw.notify( "No OCR text." );
return;
}
$( '#wpTextbox1' ).val( response.text );
}
 
function showLoadingMsg( msgLabel ) {
var msg, loadingGif,
loadingId = 'GoogleOcrLoading';
 
// Always remove any existing message.
$( '#' + loadingId ).remove();
 
// Add the new message if required.
if ( msgLabel.length !== 0 ) {
msgBox = $( "<p>" )
.attr( "id", loadingId )
.css( "background-color", "#efefef" ).css( "border", "1px solid #ccc" )
.text( msgLabel );
loadingGif = $( "<img>" )
.attr( "src", loadingGifUrl )
.attr( "alt", "Animated loading indicator" )
.css( "display", "inline-block" ).css( "margin", "0.3em" );
msgBox.prepend( loadingGif );
$( '#wpTextbox1' ).before( msgBox );
}
}
};
 
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
if ( mw.config.get( 'wgCanonicalNamespace' ) === 'Page' ) {
$.when( mw.loader.using( 'ext.wikiEditor', 'mediawiki.notify' ), $.ready)
.then( IndicOCR );
}
}