Commit aa769863 authored by Tommy Chan's avatar Tommy Chan

save instead of save-as

parent 84b83fc2
......@@ -235,6 +235,7 @@
</div>
<input type="hidden" id="saveName" />
</body>
</html>
......@@ -6,6 +6,7 @@ const fs = require('fs');
let file;
let saved = false;
class File {
......@@ -32,8 +33,20 @@ class File {
const data = this.getDataFromEditor();
if (data !== null) {
if (data !== null && saved) {
//save
let fileName = document.getElementById("saveName").value;
fs.writeFile(fileName, data, function(err) {
if (err) {
dialog.err(err, window.lang.error);
}
else {
dialog.info(window.lang.saved);
}
});
} else if (data !== null) {
//Save-as
let fileName = "new.xml";
if (file && file.name) {
......@@ -61,6 +74,8 @@ class File {
dialog.info(window.lang.saved);
}
});
document.getElementById("saveName").value = fileName;
saved = true;
});
}
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment