Skip to content

Commit 48496c6

Browse files
authored
Merge pull request #34 from TristanCacqueray/file-name
Keep track of the current file name
2 parents 5795405 + d3f2ae9 commit 48496c6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

js/filePanel.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ besogo.makeFilePanel = function(container, editor) {
2424
container.appendChild(element);
2525

2626
// Save file button
27+
let currentName = 'export.sgf'; // Reference to the current file name.
2728
element = document.createElement('input');
2829
element.type = 'button';
2930
element.value = 'Save';
3031
element.title = 'Export SGF';
3132
element.onclick = function() {
32-
var fileName = prompt('Save file as', 'export.sgf');
33+
var fileName = prompt('Save file as', currentName);
3334
if (fileName) { // Canceled or empty string does nothing
3435
saveFile(fileName, besogo.composeSgf(editor));
36+
currentName = fileName;
3537
}
3638
};
3739
container.appendChild(element);
@@ -94,6 +96,7 @@ besogo.makeFilePanel = function(container, editor) {
9496
besogo.loadSgf(sgf, editor);
9597
};
9698
if (confirm("Load '" + file.name + "'?\n" + WARNING)) {
99+
currentName = file.name; // Use the file name for the next save
97100
reader.readAsText(file); // Initiate file read
98101
}
99102
}

0 commit comments

Comments
 (0)