-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
98 lines (88 loc) · 3.34 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WorkAdventure XCE - Map Starter Kit</title>
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet" />
<link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" />
<style>
body {
margin: 2rem 0.5rem;
max-width: 980px;
margin-left: auto;
margin-right: auto;
}
header, footer {
text-align: center;
margin-top: 2rem;
margin-bottom: 2rem;
}
.nes-container {
margin-top: 2rem;
}
</style>
</head>
<body>
<header style="display: flex; justify-content:center; align-items:center;">
<h2 style="margin-top: 1rem">Workadventure XCE - Map Starter Kit</h2>
</header>
<main>
<div class="nes-container with-title is-centered">
<p class="title">Test this map</p>
<p>You can test this map at:</p>
<p><a id="mapLink" href=""></a>.</p>
<p><a id="button" href="" class="nes-btn is-primary">Test this map</a></p>
</div>
<div class="nes-container with-title">
<p class="title">Custom server</p>
<i class="nes-logo" style="float: left; width: 10%"></i>
<div class="nes-field" style="display: inline-block; width: 89%">
<input type="text" placeholder="play.workadventu.re" id="server_input" class="nes-input">
</div>
</div>
<div style="display: flex; margin: 2rem">
<a href="https://github.com/workadventure-xce/">
<i class="nes-octocat animate" style="margin-top: 4rem"></i>
</a>
<p class="nes-balloon from-left" style="margin: 1rem; margin-bottom: 5rem">
Find us on <a href="https://github.com/workadventure-xce/">Github</a>!
</p>
</div>
</main>
<footer>
<p>Inspired by the <a href="https://github.com/thecodingmachine/workadventure-map-starter-kit">WorkAdventure Map Starter Kit</a> by <a href="https://www.thecodingmachine.com">TheCodingMachine</a></p>
</footer>
<script>
// default workadventure server
// let waServer = 'play.workadventu.re';
let waServer = 'play.wa.binary-kitchen.de';
// instance ID for this session
const instanceId = Math.random().toString(36).substring(2, 15);
// get location of local server
const host = window.location.host;
let path = window.location.pathname;
// strip filename, if necessary
if (path.endsWith('index.html')) {
path = path.substr(path, path.length - 'index.html'.length);
}
// build instance url
let url = `https://${waServer}/_/${instanceId}/${host}${path}main.json`;
const mapLink = document.getElementById('mapLink');
const button = document.getElementById('button');
// set links to instance url
mapLink.href = url;
mapLink.innerText = url;
button.href = url;
const serverInput = document.getElementById('server_input');
// update links on input
const inputHandler = function(e) {
waServer = e.target.value;
url = `https://${waServer}/_/${instanceId}/${host}${path}main.json`;
mapLink.href = url;
mapLink.innerText = url;
button.href = url;
}
serverInput.addEventListener('input', inputHandler);
</script>
</body>
</html>