MediaWiki:Regextool.js

Da Wikisource.

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
var rmf_globals = {};
 
if(mw.config.get("wgAction")=='edit' || mw.config.get("wgAction")=='submit') {
	/****************
	*** config tools
	****************/
	// function
	function regexTool(name,functionname, descrizione) {
		


                if (!descrizione) {
			descrizione = name;
		}
                if (skin=="monobook") {
                        var voce=$('<li><a href="javascript:'+functionname+'" title="'+descrizione+'">'+name+'</a></li>');
                        $("#p-regex").append(voce);
                        return;
                }
		var newline = document.createElement('li');
 
		var newlink = document.createElement('a');
		newlink.setAttribute('href','javascript:'+functionname);
		newlink.setAttribute('title', descrizione);
		newlink.setAttribute('class','sidebar-link');
		newlink.appendChild(document.createTextNode(name));
 
		newline.appendChild(newlink);
		toollist.appendChild(newline);
	}
 


	/*** create menu
	****************/
	function rfmenu(rfmconfig) {
		/* get elements */
		// note: these must be global.
		editbox = document.getElementById('wpTextbox1');
		editreason = document.getElementById('wpSummary');
                if (skin=='monobook') {$('<div class="portlet"><h5><a href="javascript:rmflinks()">Strumenti accessori</a></h5><div class="pBody"><ul id="p-regex"></ul></div>').insertAfter($("#p-tb"));
                return;

                       }
		try {
			sidebar = document.getElementById('p-navigation').parentNode;
		}
		catch(err) {
			console.log( 'Regex menu framework rfmenu() aborted due to unknown error. This (rare) issue will be fixed in the eventual rewrite.' );
			return;
		}
 
		/* add CSS */
		/*appendCSS('<style type="text/css">'
			+ '#p-regex li { list-style:none !important; }'
			+ '#p-regex a { color:gray !important; }')
			; */
 
		/* create menu */
		var container = document.createElement('div');
		if (skin=='vector') container.setAttribute('class','portal persistent');
                //if (skin=='monobook') container.setAttribute('class','pBody');
		container.setAttribute('id','p-regex');
                
		sidebar.appendChild(container);
 
		var header = document.createElement('h5');
                header.setAttribute('style','font-weight:bold');
                //if (skin=='monobook') container.setAttribute('class','portlet');
		header.appendChild(document.createTextNode('Attrezzi del rilettore'));
		container.appendChild(header);
 
		var toolbox = document.createElement('div');
		toolbox.setAttribute('class','body');
		container.appendChild(toolbox);
 
		toollist = document.createElement('ul');
		toolbox.appendChild(toollist);
 
 
		/* load user-defined sidebar links */
		if(self['gadget_rmflinks']) { gadget_rmflinks(); }
		if(self['rmflinks']) { rmflinks(); }
	}
 
	/* load script */
	$(rfmenu);
}