Skip to content

Commit

Permalink
Merge branch 'master' into 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
daemontus committed Feb 6, 2023
2 parents 8446600 + cc32ee7 commit c7ca73c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ function init() {
);
}

// Warn user that there is an unsaved model.
window.onbeforeunload = function (e) {
if (LiveModel.isEmpty()) {
// Only warn when the model is not empty.
return;
}

e = e || window.event;

// In fact, most browsers will not display the text for security
// reasons, but we have to return some text anyway.

// For IE and Firefox prior to version 4
if (e) {
e.returnValue = Strings.closePrompt;
}

// For Safari
return Strings.closePrompt;
};

// Update version links and label to match expected engine version:
let version_string = "v"+EXPECTED_ENGINE_VERSION;
document.getElementById("version").innerHTML = version_string;
Expand Down Expand Up @@ -92,6 +113,7 @@ let Strings = {
},
modelEmpty: "Cannot export an empty model.",
modelWillBeErased: "This operation will overwrite your current model. Do you want to continue?",
closePrompt: "There may be unsaved changes. Close window?",
}

/* This can be used to properly show placeholder for content editable stuff */
Expand Down

0 comments on commit c7ca73c

Please sign in to comment.