aboutsummaryrefslogtreecommitdiff
path: root/index.html
blob: 7e3b489667cb741a0ae3662932d03b38dcbe9b9a (plain)
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
<!doctype HTML>

<html>

  <head>
    <title>Timer</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="design/reset.css">
    <link rel="stylesheet" href="design/design.css">
    <link rel="stylesheet" href="design/font-awesome/css/font-awesome.min.css">
    <link rel="icon" type="image/png" href="images/icon.png">
    <script src="elm.js"></script>
  </head>

  <body>
  </body>

  <script>
    var timer = Elm.fullscreen(Elm.Main, {
      initialTime: new Date().getTime(),
      clickAway: []
    });

    timer.ports.clickPosition.subscribe(function(pos) {
      const element = document.elementFromPoint(pos.x, pos.y);
      if(element.nodeName != 'BUTTON') {
        timer.ports.clickAway.send([]);
      }
    });

    const sound = new Audio('alarm.wav');
    sound.addEventListener('ended', function() {
      this.currentTime = 0;
      this.play();
    }, false);

    timer.ports.ringingTimers.subscribe(function(isRinging) {
      if(isRinging) {
        document.title = "~\\ Timer /~";
        sound.play();
      } else {
        document.title = "Timer";
        sound.pause();
        sound.currentTime = 0;
      }
    });

  </script>

</html>