Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Eruda support for non-tab view #323

Merged
merged 7 commits into from Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion static/contact/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ self.__uv$config = {
bundle: '/contact/bundle.js',
config: '/contact/config.js',
sw: '/contact/sw.js',
};
};
154 changes: 86 additions & 68 deletions static/go.html
Original file line number Diff line number Diff line change
@@ -1,86 +1,104 @@
<html lang="en">
<head>

<head>
<link rel="shortcut icon" id="dynamic-favicon" href="favicon.png">
<title id="dynamic-title">Home</title>
<script src="https://kit.fontawesome.com/1237c86ba0.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/eruda"></script>

<!--- Style --->
<style>
body {
margin: 0;
}

iframe {
display: block;
background: #000;
border: none;
height: 100vh;
width: 100vw;
}
.navbtn {
float:right;
border-radius: 100%;
width:50px;
height:50px;
background-color: rgba(255,255,255, 0.2);
border:none;
position: fixed;
top:10px;
right: 10px;
}
.navbtn1 {
float:right;
border-radius: 100%;
width:50px;
height:50px;
background-color: rgba(255,255,255, 0.2);
border:none;
position: fixed;
top:70px;
right: 10px;
}
.navbtn2 {
float:right;
border-radius: 100%;
width:50px;
height:50px;
background-color: rgba(255,255,255, 0.2);
border:none;
position: fixed;
top:130px;
right: 10px;
}
body {
margin: 0;
}

iframe {
display: block;
background: #000;
border: none;
height: 100vh;
width: 100vw;
}

.navbtn {
float: right;
border-radius: 100%;
width: 50px;
height: 50px;
background-color: rgba(255, 255, 255, 0.2);
border: none;
position: fixed;
top: 10px;
right: 10px;
}

.navbtn1 {
float: right;
border-radius: 100%;
width: 50px;
height: 50px;
background-color: rgba(255, 255, 255, 0.2);
border: none;
position: fixed;
top: 70px;
right: 10px;
}

.navbtn2 {
float: right;
border-radius: 100%;
width: 50px;
height: 50px;
background-color: rgba(255, 255, 255, 0.2);
border: none;
position: fixed;
top: 130px;
right: 10px;
}
</style>
</head>
<body>
<script>window.addEventListener('resize', navigator.keyboard.lock(["Escape"]));</script>
</head>
<body>
<iframe src="" id="iframeId" style="bottom: 0" style="border: 0px #ffffff none" name="Iframe" scrolling="yes" frameborder="0" marginheight="0px" marginwidth="0px" height="100%" width="100%" allowfullscreen></iframe>

<button onclick="reload()" class="navbtn"> <i class="fa-solid fa-rotate-right"></i> </button>
<button id="home-page" class="navbtn1" onclick="reload()"> <i class="fa-solid fa-house"></i> </button>
<button id="fullscreen-button" class="navbtn2"><i class="fa-solid fa-expand"></i></button>

<script>
function reload() {
document.getElementById("iframeId").src=document.getElementById("iframeId").src;
}
const fullscreenButton = document.getElementById("fullscreen-button");
fullscreenButton.addEventListener("click", function () {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
document.exitFullscreen();
function reload() {
document.getElementById("iframeId").src = document.getElementById("iframeId").src;
}
});
const homeButton = document.getElementById("home-page");
homeButton.addEventListener("click", function () {
window.location.href = "./";
});
window.onload = function() {
let encodedUrl = sessionStorage.getItem("encodedUrl");
encodedUrl = "/reviews/" + encodedUrl;
console.log(encodedUrl);
document.querySelector("#iframeid").src = encodedUrl;
};
const fullscreenButton = document.getElementById("fullscreen-button");
fullscreenButton.addEventListener("click", function() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
document.exitFullscreen();
}
});
const homeButton = document.getElementById("home-page");
homeButton.addEventListener("click", function() {
window.location.href = "./";
});
window.onload = function() {
let encodedUrl = sessionStorage.getItem("encodedUrl");
encodedUrl = "/reviews/" + encodedUrl;
console.log(encodedUrl);
document.querySelector("#iframeid").src = encodedUrl;
let iframe = document.querySelector("#iframeId");
iframe.src = encodedUrl;

iframe.onload = function() {
IncognitoTGT marked this conversation as resolved.
Show resolved Hide resolved
let iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentDocument should be the fallback. contentWindow is more supported.
Additionally, use iframe.contentWindow?.document in case it throws and error.

let script = iframeDocument.createElement('script');
script.src = "https://cdn.jsdelivr.net/npm/eruda";
script.onload = function() {
iframe.contentWindow.eruda.init();
};
iframeDocument.head.appendChild(script);
IncognitoTGT marked this conversation as resolved.
Show resolved Hide resolved
};
};
</script>
<script src="/assets/scripts/global.js?v=1"></script>
</body>
</body>