Skip to content
This repository was archived by the owner on Jul 5, 2025. It is now read-only.

Commit cdeb61b

Browse files
committed
onbeforeunload event if unsaved files
1 parent b6f4504 commit cdeb61b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/JS/fileContentManager.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ class fileContentManager {
99
throw new Error("No remote provided")
1010
} else if (typeof projectID == 'string') {
1111
this._data.projectID = projectID;
12+
window.onbeforeunload = function() {
13+
var temp = false;
14+
for (var i = 0; i < this._data.offloadedFiles.length; i++) {
15+
if (this._data.offloadedFiles[i].syncedWithRemote == false) {
16+
temp = true;
17+
}
18+
}
19+
if (temp) {
20+
return "You have unsaved changes. Are you sure you want to leave?";
21+
}
22+
}.bind(this);
1223
} else {
1324
throw new Error("Remote is not a string")
1425
}

0 commit comments

Comments
 (0)