Skip to content

Commit

Permalink
Added a confirmation popup which will be triggered when user is closi…
Browse files Browse the repository at this point in the history
…ng the page while some tabs in Sshwifty is still open
  • Loading branch information
nirui committed Aug 12, 2022
1 parent d5badd1 commit 28ab19a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ui/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,20 +253,32 @@ export default {
this.$emit("navigate-to", "");
});
}

window.addEventListener("beforeunload", this.onBrowserClose);
},
beforeDestroy() {
window.removeEventListener("beforeunload", this.onBrowserClose);

if (this.ticker === null) {
clearInterval(this.ticker);
this.ticker = null;
}
},
methods: {
onBrowserClose(e) {
if (this.tab.current < 0) {
return undefined;
}
const msg = "Some tabs are still open, are you sure you want to exit?";
(e || window.event).returnValue = msg;
return msg;
},
tick() {
let now = new Date();

this.socket.update(now, this);
},
closeAllWindow() {
closeAllWindow(e) {
for (let i in this.windows) {
this.windows[i] = false;
}
Expand Down

0 comments on commit 28ab19a

Please sign in to comment.