-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathjavadoc-wrapper.html
More file actions
36 lines (32 loc) · 1.33 KB
/
javadoc-wrapper.html
File metadata and controls
36 lines (32 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
---
layout: default
---
<div class="container-fluid p-0">
<iframe id="javadoc-frame"
src="{{ page.raw_path | relative_url }}"
style="width: 100%; height: calc(100vh - 60px); border: none;"
title="Javadoc Content">
</iframe>
</div>
<script>
// This script forces links clicked inside the iframe to
// navigate the PARENT window to the correct Jekyll URI.
const iframe = document.getElementById('javadoc-frame');
iframe.onload = function() {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
const links = iframeDoc.getElementsByTagName('a');
for (let link of links) {
// Only intercept internal relative links
if (link.href && link.getAttribute('href').indexOf('http') !== 0) {
link.onclick = function(e) {
e.preventDefault();
const href = link.getAttribute('href');
// Construct the new URL by removing the '.raw' part of the path
const currentUrl = new URL(window.location.href);
const newUrl = new URL(href, iframe.src);
window.top.location.href = newUrl.href.replace('/{{ site.data.kroxylicious.javadocRawSubdir }}/', '/');
};
}
}
};
</script>