forked from Torvaney/elm-soccer-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
39 lines (30 loc) · 1.03 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
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="src/static/style/main.css">
</head>
<body>
<div id="elmApp" class="container"></div>
</body>
<script src="src/static/js/main.js"></script>
<script>
// var app = Elm.Main.fullscreen();
var node = document.getElementById("elmApp");
var app = Elm.Main.embed(node);
function getCanvasXY(canvas, event) {
var rect = canvas.getBoundingClientRect();
return {
x: event.clientX - rect.left,
y: event.clientY - rect.top
};
}
app.ports.addPitchListener.subscribe(function(placeholder) {
var pitch = document.getElementById("pitchSvg");
pitch.addEventListener('mousedown', function(evt) {
var xy = getCanvasXY(pitch, evt);
app.ports.pitchXY.send(xy)
}, false);
});
</script>
</html>