User:Majr/galleryList.js

$( function { 'use strict';

$( 'body' ).append( ' Select all  Clear selection ' ); $( '.gallerybox' ).css( 'position', 'relative' ).prepend( ' + ' );

var $list = $( '#gallery-list' ), $textbox = $list.find( '> textarea' ), $all = $list.find( '> .all' ), $clear = $list.find( '> .clear' );

$list.css( {	position: 'fixed',	right: '1px',	bottom: 0,	opacity: 0.9,	zIndex: 100,	textAlign: 'right' } ); $textbox.prop( 'readonly', true ).css( {	display: 'block',	width: '300px',	height: parseInt( $textbox.css( 'line-height' ) ) * 12,	resize: 'none' } ); $( '.gallerybox .add' ).css( {	position: 'absolute',	top: '3px',	right: '5px',	fontSize: '24px' } ).click( function {	var name = decodeURIComponent( $( this ).parent.find( '.thumb a' ).prop( 'href' ) )		.replace( /.*File:/, 'File:' ).replace( /_/g, ' ' );	if ( $( this ).text === '+' ) {		$textbox.prop( 'value', function( $, text ) { return ( text + '\n' + name ).trim; } );		$textbox[0].scrollTop = $textbox[0].scrollHeight;		$( this ).text( '−' );	} else {		$textbox.prop( 'value', function( $, text ) { return text.replace( name, '' ).replace( /\n+/g, '\n' ).trim; } );		$textbox[0].scrollTop = $textbox[0].scrollHeight;		$( this ).text( '+' );	} } );

$all.click( function {	var files = [];	$textbox.val( '' );	$( '.gallerybox .thumb a' ).each( function { files.push( decodeURIComponent( $( this ).prop( 'href' ) ).replace( /.*File:/, 'File:' ).replace( /_/g, ' ' ) ); } );	$textbox.val( files.join( '\n' ) );	$( '.gallerybox .add' ).text( '−' ); } );

$clear.click( function {	$textbox.val( '' );	$( '.gallerybox .add' ).text( '+' ); } );

} );