merge
commit
41cff2c374
@ -13,7 +13,7 @@
|
||||
<input type="file" id="import-input" accept="image/*" />
|
||||
<button id="export-button" class="button" title="save image to your computer">download image</button>
|
||||
<button id="imgur-button" class="button" title="share image via imgur.com"><span>share image</span></button>
|
||||
<a id="png-button" download="glitched-image.png" target="_blank" class="download-link">download bitmap file<span> (.png)</span></a>
|
||||
<a id="png-button" download="abrahamlincoln.png" target="_blank" class="download-link">download bitmap file<span> (.png)</span></a>
|
||||
<div id="imgur-url-container">
|
||||
<input id="imgur-url-input" type="text" readonly="readonly" />
|
||||
<a href id="imgur-url-link" class="button social-link" href="http://imgur.com" target="_blank">open</a>
|
||||
|
||||
@ -57,8 +57,8 @@ require(
|
||||
|
||||
process.init( shared );
|
||||
dragdrop.init( shared );
|
||||
controls.init( shared );
|
||||
export_button.init( shared );
|
||||
controls.init( shared );
|
||||
import_button.init( shared );
|
||||
random_button.init( shared );
|
||||
image.init( shared );
|
||||
|
||||
@ -7,21 +7,24 @@ define(
|
||||
var png_link;
|
||||
var default_file_name;
|
||||
var file_name;
|
||||
var download_file_name;
|
||||
var file_suffix = '.png';
|
||||
var file_suffix_regex = /(\.)(jpg|jpeg|png|gif|bmp)/ig;
|
||||
|
||||
function init( shared )
|
||||
{
|
||||
signals = shared.signals;
|
||||
export_button = document.getElementById( 'export-button' );
|
||||
png_link = document.getElementById( 'png-button' );
|
||||
|
||||
default_file_name = png_link.getAttribute( 'download' ).split( file_suffix )[0];
|
||||
file_name = default_file_name + file_suffix;
|
||||
default_file_name = png_link.getAttribute( 'download' ).replace( file_suffix_regex, '' );
|
||||
file_name = default_file_name;
|
||||
download_file_name = default_file_name;
|
||||
|
||||
export_button.addEventListener( 'click', exportButtonClicked, false );
|
||||
png_link.addEventListener( 'click', hidePNGLink, false );
|
||||
|
||||
signals['control-updated'].add( updateFileName );
|
||||
signals['load-file'].add( updateFileName );
|
||||
signals['control-updated'].add( updateDownloadFileName );
|
||||
}
|
||||
|
||||
function exportButtonClicked( event )
|
||||
@ -31,15 +34,26 @@ define(
|
||||
signals['image-data-url-requested'].dispatch( updatePNGLinkAddress );
|
||||
}
|
||||
|
||||
function updateFileName( options )
|
||||
function updateFileName( file )
|
||||
{
|
||||
file_name = default_file_name + '-' + objToString( options ) + '.png';
|
||||
if (
|
||||
file &&
|
||||
typeof file.name === 'string'
|
||||
)
|
||||
{
|
||||
file_name = file.name.replace( file_suffix_regex, '' );
|
||||
}
|
||||
}
|
||||
|
||||
function updateDownloadFileName( options )
|
||||
{
|
||||
download_file_name = file_name + '-glitched-' + objToString( options ) + file_suffix;
|
||||
}
|
||||
|
||||
function updatePNGLinkAddress( data_url )
|
||||
{
|
||||
png_link.href = data_url;
|
||||
png_link.setAttribute( 'download', file_name );
|
||||
png_link.setAttribute( 'download', download_file_name );
|
||||
png_link.classList.add( 'is-active' );
|
||||
}
|
||||
|
||||
@ -54,7 +68,7 @@ define(
|
||||
|
||||
for ( var key in obj )
|
||||
{
|
||||
result.push( key + '' + obj[key] );
|
||||
result.push( key[0] + '' + obj[key] );
|
||||
}
|
||||
|
||||
return result.join( '-' );
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user