MediaWiki:Gadget-pulsanti-FI.js

E Wikisource

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* inserimento  template FI standard */
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' && mw.config.get("wgCanonicalNamespace")==="Page") {$( function() {
    var nomeBase, numeroPagina, nomeImmagine, fi;
    
    // console.log(nomeImmagine);
    
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
      'section': 'advanced',
      'group': 'insert',
      'tools': {'FI': {
          label: 'Inserisci template FI',
          type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/6/68/Pulsante_img.png',
          action: {type: 'callback',
            execute: function() {
            	nomeBase=mw.config.get("wgTitle").match(/(.+)\./)[1].replace("Pagina:","");
			    numeroPagina=mw.config.get("wgTitle").match(/\/(\d+)$/)[1];
			    nomeImmagine=nomeBase+" (page #1 crop).jpg".replace("#1",numeroPagina);
			    fi="{{FI\n|file = #1\n| tsize = 400px\n| float = floating-center\n| caption = \n}}".replace("#1",nomeImmagine);
				ws.incapsula(fi,"");
            	} 
          }
       }
}});});}