-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy path404.html
47 lines (43 loc) · 1.25 KB
/
404.html
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
37
38
39
40
41
42
43
44
45
46
47
---
layout: default
title: Page not found
---
<body onload="checkURL()">
<div class="row text-center "><h1><strong>Sorry!</strong>
The page you are looking for does not exist. :-(</h1></div>
<div class="row">
<img src="/img/pyrate.png" class="img-responsive center-block"
alt="Pyrate flag"/><br/>
</div>
<div class="row text-center"><p>(We're still working on some of the content. Come back again soon!)</p></div>
<script>
function urlExists(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(xhr.status < 400);
}
};
xhr.open("HEAD", url);
xhr.send();
}
function checkURL() {
const language_codes = ["en", "es", "de", "fr", "ja", "pt", "zh"];
const rel_path = window.location.pathname.split("/");
if (rel_path.len <= 1) {
return;
}
const code = rel_path[1];
if (language_codes.includes(code)) {
// check if english version exists, and redirect to it
rel_path[1] = "en";
const new_path = rel_path.join("/");
urlExists(new_path, function (exists) {
if (exists) {
window.location.replace(new_path);
}
});
}
}
</script>
</body>