<html>
<head>
<title>Pomo</title>
-<script src="/install.js"></script>
</head>
<body>
+<div id="pomo">
+</div>
<div id="status">
</div>
+<audio src="/media/alarm.ogg" id="alarm"></audio>
+<script src="/install.js"></script>
+<script src="/pomo.js"></script>
</body>
</html>
CACHE MANIFEST
-# v1
+# v2
http://pomo.cascardo.info/index.html
http://pomo.cascardo.info/install.js
http://pomo.cascardo.info/images/*.png
+http://pomo.cascardo.info/media/*
--- /dev/null
+MILS_PER_SECOND = 1000;
+MILS_PER_MINUTE = 60 * MILS_PER_SECOND;
+MILS_PER_HOUR = 60 * MILS_PER_MINUTE;
+
+function Pomo() {
+ var p = this;
+ this.pomo = document.getElementById("pomo");
+ this.start = function() {
+ this.date = new Date();
+ setTimeout(function() {
+ p.update();
+ }, 500);
+ };
+ this.prefix = function(i) {
+ if (i < 10) {
+ i = "0" + i;
+ }
+ return i;
+ }
+ this.update = function() {
+ var now = new Date();
+ var mils = this.date.getTime() + 25 * MILS_PER_MINUTE - now.getTime();
+ if (mils < 0) {
+ this.alarm();
+ mils = 0;
+ } else {
+ setTimeout(function() {
+ p.update();
+ }, 500);
+ }
+ var hours = Math.floor(mils / MILS_PER_HOUR);
+ mils -= hours * MILS_PER_HOUR;
+ var minutes = Math.floor(mils / MILS_PER_MINUTE);
+ mils -= minutes * MILS_PER_MINUTE;
+ var seconds = Math.floor(mils / MILS_PER_SECOND);
+ var s_date = this.prefix(hours) + ":" + this.prefix(minutes) + ":" + this.prefix(seconds);
+ this.pomo.innerHTML = s_date;
+ };
+ this.alarm = function() {
+ var audio = document.getElementById("alarm");
+ audio.play();
+ }
+}
+
+var pomo = new Pomo();
+pomo.start();