-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
65 lines (55 loc) · 1.68 KB
/
Copy pathindex.html
File metadata and controls
65 lines (55 loc) · 1.68 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Loading…</title>
<style>
body {
background: #000;
color: #0ff;
font-family: monospace;
text-align: center;
padding-top: 20vh;
}
</style>
</head>
<body>
<h2>Loading Repository…</h2>
<script>
// -----------------------------------------
// 1. DETECT THIS FILE'S REPO NAME
// -----------------------------------------
const path = window.location.pathname.split("/").filter(Boolean);
// Example paths:
// /Mercwar/index.html → repo = Mercwar
// /Constellation/index.html → repo = Constellation
// ../../Mercwar/index.html → repo = Mercwar
// Repo name is ALWAYS the folder BEFORE this file
const repo_name = path[path.length - 2] || "mercwar";
// -----------------------------------------
// 2. LOCAL MODE SWITCH
// -----------------------------------------
const LOCAL_MODE = false;
let git_url = LOCAL_MODE
? "../../"
: "https://mercwar.github.io/";
// -----------------------------------------
// 3. CLEAN URL JOINER (NO DOUBLE SLASHES)
// -----------------------------------------
function joinURL(base, path) {
return base.replace(/\/+$/, "") + "/" + path.replace(/^\/+/, "");
}
// -----------------------------------------
// 4. BUILD FINAL REDIRECT URL
// LIVE is ALWAYS inside Constellation
// -----------------------------------------
const clean_url =
joinURL(git_url, "Constellation/LIVE/index.html") +
`?index=${repo_name}`;
// -----------------------------------------
// 5. REDIRECT
// -----------------------------------------
window.location.href = clean_url;
</script>
</body>
</html>