User:Majr/galleryList.js

$( function { 'use strict';

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

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

$list.css( {	position: 'fixed',	right: 0,	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 = $( 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( '+' );	} } );

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

} );