Added save dialog
This commit is contained in:
parent
f084180730
commit
9bf3e37153
|
@ -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