Skip to content

Commit 8ffcbbb

Browse files
authored
feat: prevent losing data on user navigation (openscd#800)
1 parent 1aee731 commit 8ffcbbb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<head>
55
<meta charset="utf-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
7-
<meta name="Description" content="Open Substation Communication Designer is a bottom-up system configuration tool for projects described using IEC 61850-6 Edition 2 or greater.">
7+
<meta name="Description"
8+
content="Open Substation Communication Designer is a bottom-up system configuration tool for projects described using IEC 61850-6 Edition 2 or greater.">
89
<base href="/">
910

1011
<!-- Original URL from Google: https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300&family=Roboto:wght@300;400;500&display=swap -->
@@ -37,6 +38,15 @@
3738
if ('serviceWorker' in navigator)
3839
navigator.serviceWorker.register('/sw.js');
3940
</script>
41+
<script>
42+
const openScd = document.querySelector("open-scd");
43+
addEventListener("beforeunload", e => {
44+
if (openScd && openScd.doc) {
45+
e.preventDefault();
46+
return e.returnValue = "Are you sure you want to exit?";
47+
}
48+
});
49+
</script>
4050
</body>
4151

42-
</html>
52+
</html>

0 commit comments

Comments
 (0)