opendocs/index.html

84 lines
2.4 KiB
HTML
Raw Normal View History

2023-10-06 17:59:15 -04:00
<!DOCTYPE html>
<html>
<head>
<title>Rust Docs</title>
<meta charset="utf-8">
<!-- Make the device look good on phones -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" href="/favicon.ico" sizes="any">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<style>
body {
margin: 0;
background: black;
}
#links {
overflow-x: scroll;
white-space: nowrap;
padding-bottom: 20px;
}
a {
padding: 20px;
color: white;
}
#main {
position:fixed;
left: 0;
bottom: 0;right: 0;
width: 100%;
height: calc(100% - 2.5rem);
}
</style>
</head>
<body>
<div id="links">
2023-10-06 20:37:43 -04:00
<a href="global/std/" id="std-docs" target="main" onclick="focusFrame()">STD</a>
2023-10-06 20:58:08 -04:00
<a href="local-latest" id="local-docs" target="main" onclick="focusFrame()">Cargo</a>
2023-10-06 17:59:15 -04:00
</div>
2023-10-06 20:58:08 -04:00
<iframe name="main" id="main" src="local-latest"></iframe>
2023-10-06 17:59:15 -04:00
</body>
<script type="text/javascript">
let links = {
"std": document.getElementById("std-docs"),
"local": document.getElementById("local-docs"),
};
let frame = document.getElementById("main");
let lastLoaded = "local";
function toggleLastLoaded() {
if (lastLoaded === "std") {
lastLoaded = "local";
} else {
lastLoaded = "std";
}
links[lastLoaded].click();
}
function focusFrame() {
frame.contentWindow.focus();
frame.addEventListener("load", function() {
2023-10-06 20:37:43 -04:00
// if (this.contentWindow.window.searchState) {
// this.contentWindow.window.searchState.focus();
// }
2023-10-06 17:59:15 -04:00
frame.contentWindow.removeEventListener("keydown", cl);
frame.contentWindow.addEventListener("keydown", cl);
});
}
function cl(e) {
if ((e.which == 219 || e.which == 221) && !e.ctrlKey && e.shiftKey) {
e.preventDefault();
toggleLastLoaded();
}
}
focusFrame();
</script>
</html>