mirror of
https://github.com/LukeHagar/unicorn-utterances.git
synced 2025-12-09 21:07:49 +00:00
chore: apply automatic linting
This commit is contained in:
@@ -1,26 +1,26 @@
|
||||
/* AFTER CHANGING THIS FILE, PLEASE MANUALLY MINIFY IT AND PUT INTO backbtn.min.js */
|
||||
/* TODO: Add minifier to build script */
|
||||
window.onload = () => {
|
||||
const backBtn = document.querySelector('#backbtn');
|
||||
|
||||
let hasHistory = false;
|
||||
window.addEventListener('beforeunload', () => {
|
||||
hasHistory = true;
|
||||
})
|
||||
|
||||
backBtn.addEventListener('click', () => {
|
||||
if (!document.referrer) {
|
||||
// This is the first page the user has visited on the site in this session
|
||||
window.location.href = '/';
|
||||
return;
|
||||
}
|
||||
history.back();
|
||||
|
||||
// User cannot go back, meaning that we're at the first page of the site session
|
||||
setTimeout(() => {
|
||||
if (!hasHistory){
|
||||
window.location.href = "/";
|
||||
}
|
||||
}, 200);
|
||||
})
|
||||
}
|
||||
/* AFTER CHANGING THIS FILE, PLEASE MANUALLY MINIFY IT AND PUT INTO backbtn.min.js */
|
||||
/* TODO: Add minifier to build script */
|
||||
window.onload = () => {
|
||||
const backBtn = document.querySelector("#backbtn");
|
||||
|
||||
let hasHistory = false;
|
||||
window.addEventListener("beforeunload", () => {
|
||||
hasHistory = true;
|
||||
});
|
||||
|
||||
backBtn.addEventListener("click", () => {
|
||||
if (!document.referrer) {
|
||||
// This is the first page the user has visited on the site in this session
|
||||
window.location.href = "/";
|
||||
return;
|
||||
}
|
||||
history.back();
|
||||
|
||||
// User cannot go back, meaning that we're at the first page of the site session
|
||||
setTimeout(() => {
|
||||
if (!hasHistory) {
|
||||
window.location.href = "/";
|
||||
}
|
||||
}, 200);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user