✨ confirm to leave page
This commit is contained in:
@@ -162,8 +162,14 @@
|
|||||||
timer_res = seconds.toString();
|
timer_res = seconds.toString();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
const confirmUnload = () => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = '';
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:beforeunload={confirmUnload} />
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>ClassQuiz - Host</title>
|
<title>ClassQuiz - Host</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
@@ -86,11 +86,19 @@
|
|||||||
localStorage.setItem('create_game', JSON.stringify(data));
|
localStorage.setItem('create_game', JSON.stringify(data));
|
||||||
window.location.href = '/account/login';
|
window.location.href = '/account/login';
|
||||||
} else if (res.status === 200) {
|
} else if (res.status === 200) {
|
||||||
|
localStorage.removeItem('create_game');
|
||||||
responseData.open = true;
|
responseData.open = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const confirmUnload = () => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = '';
|
||||||
|
localStorage.setItem('create_game', JSON.stringify(data));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:beforeunload={confirmUnload} />
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>ClassQuiz - Create</title>
|
<title>ClassQuiz - Create</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
@@ -82,12 +82,20 @@
|
|||||||
} else if (res.status === 404) {
|
} else if (res.status === 404) {
|
||||||
throw new Error('Quiz not found');
|
throw new Error('Quiz not found');
|
||||||
} else if (res.status === 200) {
|
} else if (res.status === 200) {
|
||||||
|
localStorage.removeItem('edit_game');
|
||||||
responseData.data = '200';
|
responseData.data = '200';
|
||||||
responseData.open = true;
|
responseData.open = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const confirmUnload = () => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = '';
|
||||||
|
localStorage.setItem('edit_game', JSON.stringify(data));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:beforeunload={confirmUnload} />
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>ClassQuiz - Edit</title>
|
<title>ClassQuiz - Edit</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|||||||
@@ -56,6 +56,11 @@
|
|||||||
unique = {};
|
unique = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const confirmUnload = () => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.returnValue = '';
|
||||||
|
};
|
||||||
|
|
||||||
// Socket-events
|
// Socket-events
|
||||||
socket.on('joined_game', (data) => {
|
socket.on('joined_game', (data) => {
|
||||||
console.log('joined_game', data);
|
console.log('joined_game', data);
|
||||||
@@ -89,6 +94,7 @@
|
|||||||
// The rest
|
// The rest
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window on:beforeunload={confirmUnload} />
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>ClassQuiz - Play</title>
|
<title>ClassQuiz - Play</title>
|
||||||
{#if gameData !== undefined}
|
{#if gameData !== undefined}
|
||||||
|
|||||||
Reference in New Issue
Block a user