rpg-cards
rpg-cards copied to clipboard
Proper save file dialogue?
Hey, this is a great resource!
I was hoping to use it to create custom decks for my characters, having a different save file for each.
Currently, the file automatically gets download and there's no option to change the name of the file or where it's saved (if there is, what am I missing?).
I can always rename the file and move it straight after downloading - but then I have to do the same after loading up and editing that deck.
Any chance of building in a Save As menu so users can choose how they want to name the deck file, and where to save it?
I don't think it is possible to use the operating system Save As dialog from javascript.
I'll have to find out what other options there are to implement this.
This might be an option. http://en.wikipedia.org/wiki/Data_URI_scheme, though it is only compatible with more modern browsers.
The tool is already using data URIs (when you press the "Save to File" button, it generates a hidden link element with the data URI and triggers a click event on that link).
The problem is that if you open the data URI link, most browsers will download the file to your downloads folder. What I want is to trigger a "Save as" dialog, so that people can choose the file name and the folder where the file gets saved.
I'm not familiar with the JavaScript, but could you have a custom Dialog box pop up and ask the use for the file name then concatenate that onto a base URI string?
have a custom Dialog box pop up and ask the use for the file name then concatenate that onto a base URI string
Browsers don't have access to the local file system. As far as I know, there's really no way to write a file to a specific location (without using plugins).
I could use a completely different approach though, like saving the file to a server (cloud storage) or using one of the local storage APIs (localStorage, indexedDB).
I've been thinking about this and I realized that you can make your web browser default to ask you where to save a file. and in the process it prompts for a name of the file as well. its a bit of a work-around and i don't know if you can force a web browser to do this from inside your code, but it is an option to point people towards.
i know Chrome has it, and i believe Firefox does it by default. as far as the other browsers, i'm not sure
As far as I know, theres no way to force this from javascript code. The only thing you can set is the filename (but not the full path), what the browser does with the download is out of your control. But let me know if you find out a way to do this.
As a half-way measure, could you have a popup asking for a user inputted file name? It gets confusing quick when all the save files are named the same thing.