Skip to content
Open
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
506 changes: 491 additions & 15 deletions index.html

Large diffs are not rendered by default.

89 changes: 82 additions & 7 deletions static/datro/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -512,17 +512,92 @@ <h5 class="FooterNew-link-title FooterNew-link-title--hideMobile" style="margin-
</script> <!--// SystemJS -->
<script defer src="js/footer-accordion.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
var libraryLinks = document.querySelectorAll('a[href*="library"]');
var hostname = window.location.hostname;
if (!libraryLinks.length) {
return;
}

var remoteLibraryRoot = "https://library.datro.xyz";
var localLibraryRoot = "../library";
var hostname = window.location.hostname || "";
var protocol = window.location.protocol;
var offlineHosts = ["localhost", "127.0.0.1", "0.0.0.0", "::1", ""];
var isOffline = protocol === "file:" || offlineHosts.indexOf(hostname) > -1;
var parser = document.createElement("a");

function extractLibrarySuffix(href) {
if (!href) {
return null;
}

var lowerHref = href.toLowerCase();
var remoteIndex = lowerHref.indexOf(remoteLibraryRoot);
if (remoteIndex === 0) {
var remoteSuffix = href.substring(remoteLibraryRoot.length);
return remoteSuffix || "/";
}

parser.href = href;
var path = parser.pathname || "";
var lowerPath = path.toLowerCase();
var libraryPos = lowerPath.indexOf("/library");
var suffixPart;

if (libraryPos > -1) {
suffixPart = path.substring(libraryPos + "/library".length);
if (!suffixPart) {
suffixPart = "/";
}
} else {
var host = (parser.hostname || "").toLowerCase();
if (host.indexOf("library.datro.xyz") > -1) {
suffixPart = path || "/";
} else {
return null;
}
}

return suffixPart + (parser.search || "") + (parser.hash || "");
}

function normalizeSuffix(suffix) {
if (!suffix) {
return "/";
}

if (suffix.charAt(0) === "/") {
return "/" + suffix.replace(/^\/+/, "");
}

if (suffix.charAt(0) === "?" || suffix.charAt(0) === "#") {
return "/" + suffix;
}

return "/" + suffix.replace(/^\/+/, "");
}

function convertHref(href, useRemote) {
var suffix = extractLibrarySuffix(href);
if (suffix === null) {
return null;
}

var normalized = normalizeSuffix(suffix);
var base = useRemote ? remoteLibraryRoot : localLibraryRoot;
return base.replace(/\/+$/, "") + normalized;
}

for (var i = 0; i < libraryLinks.length; i++) {
var link = libraryLinks[i];
if (hostname === 'datro.xyz') {
var oldHref = link.getAttribute('href');
var newHref = oldHref.replace('../library/', 'https://library.datro.xyz/');
newHref = newHref.replace('/library/', 'https://library.datro.xyz/');
link.setAttribute('href', newHref);
var originalHref = link.getAttribute("href");
if (!originalHref) {
continue;
}

var targetHref = convertHref(originalHref, !isOffline);
if (targetHref) {
link.setAttribute("href", targetHref);
}
}
});
Expand Down
89 changes: 82 additions & 7 deletions static/datro/academy.html
Original file line number Diff line number Diff line change
Expand Up @@ -942,17 +942,92 @@ <h5 class="FooterNew-link-title FooterNew-link-title--hideMobile" style="margin-
</script>
<script defer src="js/footer-accordion.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
var libraryLinks = document.querySelectorAll('a[href*="library"]');
var hostname = window.location.hostname;
if (!libraryLinks.length) {
return;
}

var remoteLibraryRoot = "https://library.datro.xyz";
var localLibraryRoot = "../library";
var hostname = window.location.hostname || "";
var protocol = window.location.protocol;
var offlineHosts = ["localhost", "127.0.0.1", "0.0.0.0", "::1", ""];
var isOffline = protocol === "file:" || offlineHosts.indexOf(hostname) > -1;
var parser = document.createElement("a");

function extractLibrarySuffix(href) {
if (!href) {
return null;
}

var lowerHref = href.toLowerCase();
var remoteIndex = lowerHref.indexOf(remoteLibraryRoot);
if (remoteIndex === 0) {
var remoteSuffix = href.substring(remoteLibraryRoot.length);
return remoteSuffix || "/";
}

parser.href = href;
var path = parser.pathname || "";
var lowerPath = path.toLowerCase();
var libraryPos = lowerPath.indexOf("/library");
var suffixPart;

if (libraryPos > -1) {
suffixPart = path.substring(libraryPos + "/library".length);
if (!suffixPart) {
suffixPart = "/";
}
} else {
var host = (parser.hostname || "").toLowerCase();
if (host.indexOf("library.datro.xyz") > -1) {
suffixPart = path || "/";
} else {
return null;
}
}

return suffixPart + (parser.search || "") + (parser.hash || "");
}

function normalizeSuffix(suffix) {
if (!suffix) {
return "/";
}

if (suffix.charAt(0) === "/") {
return "/" + suffix.replace(/^\/+/, "");
}

if (suffix.charAt(0) === "?" || suffix.charAt(0) === "#") {
return "/" + suffix;
}

return "/" + suffix.replace(/^\/+/, "");
}

function convertHref(href, useRemote) {
var suffix = extractLibrarySuffix(href);
if (suffix === null) {
return null;
}

var normalized = normalizeSuffix(suffix);
var base = useRemote ? remoteLibraryRoot : localLibraryRoot;
return base.replace(/\/+$/, "") + normalized;
}

for (var i = 0; i < libraryLinks.length; i++) {
var link = libraryLinks[i];
if (hostname === 'datro.xyz') {
var oldHref = link.getAttribute('href');
var newHref = oldHref.replace('../library/', 'https://library.datro.xyz/');
newHref = newHref.replace('/library/', 'https://library.datro.xyz/');
link.setAttribute('href', newHref);
var originalHref = link.getAttribute("href");
if (!originalHref) {
continue;
}

var targetHref = convertHref(originalHref, !isOffline);
if (targetHref) {
link.setAttribute("href", targetHref);
}
}
});
Expand Down
89 changes: 82 additions & 7 deletions static/datro/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,92 @@
</script>
<!-- google tracking code end -->
<script>
document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
var libraryLinks = document.querySelectorAll('a[href*="library"]');
var hostname = window.location.hostname;
if (!libraryLinks.length) {
return;
}

var remoteLibraryRoot = "https://library.datro.xyz";
var localLibraryRoot = "../library";
var hostname = window.location.hostname || "";
var protocol = window.location.protocol;
var offlineHosts = ["localhost", "127.0.0.1", "0.0.0.0", "::1", ""];
var isOffline = protocol === "file:" || offlineHosts.indexOf(hostname) > -1;
var parser = document.createElement("a");

function extractLibrarySuffix(href) {
if (!href) {
return null;
}

var lowerHref = href.toLowerCase();
var remoteIndex = lowerHref.indexOf(remoteLibraryRoot);
if (remoteIndex === 0) {
var remoteSuffix = href.substring(remoteLibraryRoot.length);
return remoteSuffix || "/";
}

parser.href = href;
var path = parser.pathname || "";
var lowerPath = path.toLowerCase();
var libraryPos = lowerPath.indexOf("/library");
var suffixPart;

if (libraryPos > -1) {
suffixPart = path.substring(libraryPos + "/library".length);
if (!suffixPart) {
suffixPart = "/";
}
} else {
var host = (parser.hostname || "").toLowerCase();
if (host.indexOf("library.datro.xyz") > -1) {
suffixPart = path || "/";
} else {
return null;
}
}

return suffixPart + (parser.search || "") + (parser.hash || "");
}

function normalizeSuffix(suffix) {
if (!suffix) {
return "/";
}

if (suffix.charAt(0) === "/") {
return "/" + suffix.replace(/^\/+/, "");
}

if (suffix.charAt(0) === "?" || suffix.charAt(0) === "#") {
return "/" + suffix;
}

return "/" + suffix.replace(/^\/+/, "");
}

function convertHref(href, useRemote) {
var suffix = extractLibrarySuffix(href);
if (suffix === null) {
return null;
}

var normalized = normalizeSuffix(suffix);
var base = useRemote ? remoteLibraryRoot : localLibraryRoot;
return base.replace(/\/+$/, "") + normalized;
}

for (var i = 0; i < libraryLinks.length; i++) {
var link = libraryLinks[i];
if (hostname === 'datro.xyz') {
var oldHref = link.getAttribute('href');
var newHref = oldHref.replace('../library/', 'https://library.datro.xyz/');
newHref = newHref.replace('/library/', 'https://library.datro.xyz/');
link.setAttribute('href', newHref);
var originalHref = link.getAttribute("href");
if (!originalHref) {
continue;
}

var targetHref = convertHref(originalHref, !isOffline);
if (targetHref) {
link.setAttribute("href", targetHref);
}
}
});
Expand Down
Loading