mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 13:43:26 +00:00
Added BaseLoader.save method.
Not really meant for production use, but super-handy for dev tools and prototypes.
This commit is contained in:
parent
8b7bf81637
commit
e15701da81
1 changed files with 24 additions and 0 deletions
|
@ -443,6 +443,30 @@ var BaseLoader = new Class({
|
|||
this.storage.clear();
|
||||
},
|
||||
|
||||
saveJSON: function (data, filename)
|
||||
{
|
||||
return this.save(JSON.stringify(data), filename);
|
||||
},
|
||||
|
||||
save: function (data, filename, filetype)
|
||||
{
|
||||
if (filename === undefined) { filename = 'file.json'; }
|
||||
if (filetype === undefined) { filetype = 'application/json'; }
|
||||
|
||||
var blob = new Blob([data], { type: filetype });
|
||||
|
||||
var url = URL.createObjectURL(blob);
|
||||
|
||||
var a = document.createElement('a');
|
||||
|
||||
a.download = filename;
|
||||
a.textContent = 'Download ' + filename;
|
||||
a.href = url;
|
||||
a.click();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
reset: function ()
|
||||
{
|
||||
this.list.clear();
|
||||
|
|
Loading…
Reference in a new issue