MediaWiki

Difference between revisions of "Gadget-RecentNonAudio.js"

(
limit upgrade.)
(ModifySidebar( "add", "toolbox", "Recent (non-audio)", "https://lingualibre.org/wiki/Special:RecentChanges?limit=800&namespace=0&invert=1" );)
Line 64: Line 64:
  
 
function CustomizeModificationsOfSidebar() {
 
function CustomizeModificationsOfSidebar() {
ModifySidebar( "add", "toolbox", "Recent (non-audio)", "https://lingualibre.org/wiki/Special:RecentChanges?limit=5000&namespace=0&invert=1" );
+
ModifySidebar( "add", "toolbox", "Recent (non-audio)", "https://lingualibre.org/wiki/Special:RecentChanges?limit=800&namespace=0&invert=1" );
 
}
 
}
  
 
$( CustomizeModificationsOfSidebar );
 
$( CustomizeModificationsOfSidebar );

Revision as of 15:36, 17 October 2020

/* ************************************************************************** */
/* 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)", "https://lingualibre.org/wiki/Special:RecentChanges?limit=800&namespace=0&invert=1" );
}

$( CustomizeModificationsOfSidebar );