diff --git a/examples/04_load_and_save.html b/examples/04_load_and_save.html index 7614fe7..d8be3c9 100644 --- a/examples/04_load_and_save.html +++ b/examples/04_load_and_save.html @@ -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); };