Merge pull request #305 from RDCH106/master
Added save dialog to example 4
This commit is contained in:
commit
45be754de8
|
@ -52,8 +52,21 @@
|
|||
|
||||
// Save a JSON document
|
||||
document.getElementById('saveDocument').onclick = function () {
|
||||
// Save Dialog
|
||||
fname = window.prompt("Save as...");
|
||||
|
||||
// Check json extension in file name
|
||||
if(fname.indexOf(".")==-1){
|
||||
fname = fname + ".json";
|
||||
}else{
|
||||
if(fname.split('.').pop().toLowerCase() == "json"){
|
||||
// Nothing to do
|
||||
}else{
|
||||
fname = fname.split('.')[0] + ".json";
|
||||
}
|
||||
}
|
||||
var blob = new Blob([editor.getText()], {type: 'application/json;charset=utf-8'});
|
||||
saveAs(blob, 'document.json');
|
||||
saveAs(blob, fname);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue