-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
70 lines (63 loc) · 2.3 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
<html>
<head>
<title>TimeBlockClock</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="src/main.css"/>
</head>
<body class="setbgim">
<!-- Keep all styling in css, only geometry in svg. -->
<!-- Use 100 width -->
<div id="clockwrapper">
<div id="clockbg" class="setbgim"></div>
<svg id="clock" viewBox="0 0 100 100">
<circle class="ring" cx="50" cy="50" r="50"/>
<g id="marks"></g>
<g id="timeblocks"></g>
<text x="50" y="50"><tspan id="time" text-anchor="middle"></tspan></text>
<line id="needle" x1="50" y1="27" x2="50" y2="2" transform="rotate(0 50 50)"/>
<text x="50" y="60"><tspan id="timer" text-anchor="middle"></tspan></text>
</svg>
</div>
<script type="text/javascript">
// Draw all clock lines
for (var i=0; i<144; i++) {
var svgLine = document.createElementNS("http://www.w3.org/2000/svg", "line");
svgLine.setAttribute('x1', 50);
svgLine.setAttribute('y1', 17);
svgLine.setAttribute('x2', 50);
svgLine.setAttribute('y2', 0);
svgLine.setAttribute('transform', `rotate(${i*2.5} 50 50)`);
if (!(i%12)) {
svgLine.setAttribute('class', 'hourmark');
svgLine.setAttribute('y1', 22);
} else if (!(i%6)) {
svgLine.setAttribute('class', 'halfmark');
} else {
svgLine.setAttribute('class', 'minutemark');
}
document.getElementById("marks").appendChild(svgLine);
}
</script>
<script src="src/model.js"></script>
<script src="src/utils.js"></script>
<script src="src/main.js"></script>
<audio id="fanta">
<source src="sounds/fanta.mp3" type="audio/mp3">
</audio>
<!-- Set random background image on load -->
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
// Assume we have images with names in the range 1.jpg - n.jpg
var N = 4;
// Choose a random image
var imurl = "url('images/" + (Math.floor(Math.random()*N)+1) + ".jpg')";
// Set that as bg image for .setbgim
var bgelems = document.getElementsByClassName("setbgim");
for (var i=0; i<bgelems.length; i++) {
console.log("Setting to: "+imurl)
bgelems[i].style.backgroundImage = imurl;
}
});
</script>
</body>
</html>