Fix unspecified file extension when saving

File was saved without an extension in Firefox, and Edge even added a txt extension by default!

Also make some other extension handling hopefully more robust or at least consistent.
main
Isaiah Odhner 2017-10-30 01:27:25 -04:00
parent 2f7c985713
commit c3742cdad3
2 changed files with 4 additions and 5 deletions

View File

@ -47,7 +47,6 @@
### Issues
* Image is saved without `.png` file extension in Firefox, and Edge actually gives it a `.txt` extension!
* [Stretch/skew and rotate don't update the canvas size](https://github.com/1j01/jspaint/issues/8)
* ["Quick Undo" stopped working in Chrome](https://github.com/1j01/jspaint/issues/9)
* If you open an image it resets the zoom but if you're on the magnification tool it doesn't update the options

View File

@ -185,7 +185,7 @@ function file_open(){
function file_save(){
if(file_name.match(/\.svg$/)){
file_name += ".png";
file_name = file_name.replace(/\.svg$/, "") + ".png";
//update_title()?
return file_save_as();
}
@ -213,7 +213,7 @@ function file_save_as(){
});
}else{
canvas.toBlob(function(blob){
var file_saver = saveAs(blob, file_name);
var file_saver = saveAs(blob, file_name.replace(/\.(bmp|png|gif|jpe?g|tiff|webp)$/, "") + ".png");
file_saver.onwriteend = function(){
// this won't fire in chrome
saved = true;
@ -390,7 +390,7 @@ function render_history_as_gif(){
);
$win.$Button("Save", function(){
$win.close();
saveAs(blob, file_name + " history.gif");
saveAs(blob, file_name.replace(/\.(bmp|png|gif|jpe?g|tiff|webp)$/, "") + " history.gif");
});
$cancel.appendTo($win.$buttons);
$win.center();
@ -959,7 +959,7 @@ function set_as_wallpaper_centered(c){
});
}else{
c.toBlob(function(blob){
saveAs(blob, file_name.replace(/\.(bmp|png|gif|jpe?g|tiff|webp)/, "") + " wallpaper.png");
saveAs(blob, file_name.replace(/\.(bmp|png|gif|jpe?g|tiff|webp)$/, "") + " wallpaper.png");
});
}
}