aboutsummaryrefslogtreecommitdiff
path: root/src/view/index.html
blob: 0b66bc8901ac018bd70fda828f1fcaf67eb6c35d (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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>FreqTimer Web (Beta)</title>
    <!-- Bootstrap -->
    <link
        href="/freqtimer/css/bootstrap.min.css"
        rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
    >
    <style>
        .container-sm-max {
            max-width: 650px;
            margin-right: auto;
            margin-left: auto;
            padding: 0 0 0 0;
        }

        .btn-llg {
            padding: 0.7rem 1.0rem;
            font-size: 1.6rem;
            border-radius: 0.3rem;
        }

        .btn-plus {
            padding: 1.3rem 1rem;
            font-size: 1.6rem;
            border-radius: 0.3rem;
        }

        a {
            text-decoration: none;
        }

        .copyright {
            text-align: center;
            font-size: 0.8rem;
        }

        html, body, main {
            height: 100%;
            touch-action: none;
        }
    </style>
    <script src="/freqtimer/js/bundle.min.js"></script>
    <!-- Controller Bindings -->
    <script>
        var timer_controller = null;
        var sound_handle = null;

        var Module = {
          onRuntimeInitialized: function() {
              timer_controller = new Module.TimerController;
          }
        };

        function attach_ios_audio() {
            if(sound_handle !== null) {
                return;
            }

            sound_handle = document.getElementById('sound-handle');

            if (sound_handle.canPlayType("audio/mpeg")) {
                sound_handle.setAttribute("src", "/freqtimer/media/alarm_sound.mp3");
            } else if (sound_handle.canPlayType("audio/ogg")) {
                sound_handle.setAttribute("src", "/freqtimer/media/alarm_sound.ogg");
            } else {
                alert('This browser does not support audio');
            }

            sound_handle.loop = true;
            sound_handle.pause();
        }

        setInterval(() => {
            if (timer_controller !== null) {
                timer_controller.handle_timer_update();
            }
        }, 10);

        window.addEventListener('load', function () {
            const copyrightYearEl = document.getElementById("copyright-year");
            copyrightYearEl.innerText = (new Date()).getUTCFullYear();
        })
    </script>
    <script src="/freqtimer/build/timer_view.js"></script>
</head>
<body>
    <audio id="sound-handle" style="display:none;"></audio>
    <main class="container-sm-max d-flex flex-column">
        <div class="container-fluid pt-2 pb-1 flex-fill d-flex flex-column justify-content-around">
            <div class="mt-1 mb-1">
                <div class="text-center py-1">
                    <h1 id="time-display">00 : 00 : 00.0</h1>
                    <p class="mb-1" style="font-size: 0.8rem;">
                        Record floor: <span id="record-floor">00.00</span>
                    </p>
                </div>
                <div class="row text-center">
                    <div class="col">
                        <p class="mb-1" style="font-size: 0.8rem;" >Counter 1</p>
                        <h2 class="mb-1"><span id="counter-0">0</span></h2>
                        <p class="mb-1"><span id="rate-0">00.00</span></p>
                    </div>
                    <div class="col">
                        <p class="mb-1" style="font-size: 0.8rem;" >Counter 2</p>
                        <h2 class="mb-1"><span id="counter-1">0</span></h2>
                        <p class="mb-1"><span id="rate-1">00.00</span></p>
                    </div>
                </div>
            </div>

            <div class="d-flex flex-wrap justify-content-md-center mb-1">
                <div class="col-6 p-1">
                    <button
                        class="btn btn-outline-primary w-100"
                        onclick="timer_controller.handle_inc_time(1);"
                    >1s</button>
                </div>
                <div class="col-6 p-1">
                    <button
                        class="btn btn-outline-primary w-100"
                        onclick="timer_controller.handle_inc_time(6);"
                    >6s</button>
                </div>
                <div class="col-6 p-1">
                    <button
                        class="btn btn-outline-primary w-100"
                        onclick="timer_controller.handle_inc_time(10);"
                    >10s</button>
                </div>
                <div class="col-6 p-1">
                    <button
                        class="btn btn-outline-primary w-100"
                        onclick="timer_controller.handle_inc_time(15);"
                    >15s</button>
                </div>
                <div class="col-6 p-1">
                    <button
                        class="btn btn-outline-primary w-100"
                        onclick="timer_controller.handle_inc_time(30);"
                    >30s</button>
                </div>
                <div class="col-6 p-1">
                    <button
                        class="btn btn-outline-primary w-100"
                        onclick="timer_controller.handle_inc_time(60);"
                    >60s</button>
                </div>
            </div>

            <div class="d-flex flex-wrap justify-content-md-center mb-3">
                <div class="col-6 p-1 mb-1">
                    <button
                        class="btn btn-secondary btn-plus w-100"
                        id="increment-counter-1-btn"
                        onclick="timer_controller.handle_inc_counter(0);"
                    >+1</button>
                </div>
                <div class="col-6 p-1 mb-1">
                    <button
                        class="btn btn-secondary btn-plus w-100"
                        id="increment-counter-2-btn"
                        onclick="timer_controller.handle_inc_counter(1);"
                    >+1</button>
                </div>
                <div class="col-12 p-1 mt-2">
                    <button
                        class="btn btn-success btn-llg w-100"
                        id="start-stop-btn"
                        onclick="timer_controller.handle_start_stop(); attach_ios_audio();"
                    >Start</button>
                </div>
                <div class="col-12 p-1">
                    <button
                        class="btn btn-danger btn-llg w-100"
                        id="clear-reset-btn"
                        onclick="timer_controller.handle_clear_reset();"
                    >Reset</button>
                </div>
            </div>
        </div>
        <p class="copyright mb-1">Made with ❤️ by <a href="/">Alex</a> • Copyright <span id="copyright-year"></span>-2016 • <a href="https://www.git.flu0r1ne.net/freqtimer-web/">Code</a></p>
    </main>
</body>
</html>