MediaWiki
Difference between revisions of "Gadget-RecentNonAudio.js"
WikiLucas00 (talk | contribs) m (800 -> 2500) |
(utilisation de mw.util.getUrl, je met en commentaire les console.log qui servaient probablement pour du debug) |
||
Line 4: | Line 4: | ||
function ModifySidebar( action, section, name, link ) { | function ModifySidebar( action, section, name, link ) { | ||
− | console.log("1:", action,section, name, link); | + | //console.log("1:", action,section, name, link); |
try { | try { | ||
var target=''; | var target=''; | ||
Line 23: | Line 23: | ||
if ( action == 'add' ) { | if ( action == 'add' ) { | ||
− | console.log(action,section, name, link); | + | //console.log(action,section, name, link); |
var node = document.getElementById( target ); | var node = document.getElementById( target ); | ||
// .getElementsByTagName( 'div' )[0] | // .getElementsByTagName( 'div' )[0] | ||
Line 64: | Line 64: | ||
function CustomizeModificationsOfSidebar() { | function CustomizeModificationsOfSidebar() { | ||
− | ModifySidebar( "add", "toolbox", "Recent (non-audio)", | + | ModifySidebar( "add", "toolbox", "Recent (non-audio)", mw.util.getUrl( 'Special:RecentChanges', { limit: 2500, namespace: 0, invert: 1 } ) ); |
} | } | ||
$( CustomizeModificationsOfSidebar ); | $( CustomizeModificationsOfSidebar ); |
Revision as of 14:43, 16 April 2021
/* ************************************************************************** */
/* Edit toolbox ************************************************************ */
/* Sources: [[:mw:Manual:Interface/Sidebar#Add_or_remove_toolbox_sections_(JavaScript)]] */
function ModifySidebar( action, section, name, link ) {
//console.log("1:", action,section, name, link);
try {
var target='';
switch ( section ) {
case 'languages':
target = 'p-lang';
break;
case 'toolbox':
target = 'toolbox'; // mediawiki: "p-tb" ; wikibase: "toolbox" and then remove lines selecting children div and ul
break;
case 'navigation':
target = 'p-navigation';
break;
default:
target = 'p-' + section;
break;
}
if ( action == 'add' ) {
//console.log(action,section, name, link);
var node = document.getElementById( target );
// .getElementsByTagName( 'div' )[0]
// .getElementsByTagName( 'ul' )[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( name ) );
aNode.setAttribute( 'href', link );
liNode.appendChild( aNode );
liNode.className = 'plainlinks';
node.appendChild( liNode );
}
if ( action == 'remove' ) {
var list = document.getElementById( target );
// .getElementsByTagName( 'div' )[0]
// .getElementsByTagName( 'ul' )[0];
var listelements = list.getElementsByTagName( 'li' );
for ( var i = 0; i < listelements.length; i++ ) {
if (
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
listelements[i].getElementsByTagName( 'a' )[0].href == link
)
{
list.removeChild( listelements[i] );
}
}
}
} catch( e ) {
// let's just ignore what's happened
return;
}
}
function CustomizeModificationsOfSidebar() {
ModifySidebar( "add", "toolbox", "Recent (non-audio)", mw.util.getUrl( 'Special:RecentChanges', { limit: 2500, namespace: 0, invert: 1 } ) );
}
$( CustomizeModificationsOfSidebar );