-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
67 lines (65 loc) · 1.89 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
<!doctype html>
<html>
<!--
DO NOT open this file locally. If you do it won't work.
Access it from a local HTTP server. For example,
$ python -m SimpleHTTPServer 8888
Then go to http://127.0.0.1:8888/index.html
-->
<head>
<meta charset="utf-8"/>
<title>tile viewer</title>
<style>
body {
background: #666;
font-family: sans-serif;
}
img {
image-rendering: pixelated;
}
#container {
max-height: 80vh;
overflow: scroll;
}
::-webkit-scrollbar {
-webkit-appearance: none;
width: 7px;
}
::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: rgba(0,0,0,.5);
}
</style>
</head>
<body>
<h3 id="title">(move the mouse over the tiles)</h3>
<div id="container">
<img id="image" src="rltiles-2d.png"/>
</div>
<h4>More info: <a href="https://github.com/statico/rltiles">https://github.com/statico/rltiles</a></h4>
<script>
if (/^file/.test(document.location.href)) {
alert("Don't run this page locally. View source for more info.");
document.body.innerHTML = 'error';
}
var title = document.getElementById('title');
var image = document.getElementById('image');
req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (req.readyState != 4) return;
init(JSON.parse(req.responseText));
};
req.open('GET', 'rltiles-2d.json', true);
req.send();
function init(data) {
image.addEventListener('mousemove', function(event) {
var x = Math.floor(event.offsetX / data.tileSize);
var y = Math.floor(event.offsetY / data.tileSize);
var i = x + y * data.width;
var key = data.tiles[i];
title.innerText = key + ' (i=' + i + ')';
});
}
</script>
</body>
</html>