aboutsummaryrefslogtreecommitdiffstats
path: root/timer/templates/alarm.html
diff options
context:
space:
mode:
authorFilipp Lepalaan <f@0x00.co>2013-01-31 20:08:20 +0200
committerFilipp Lepalaan <f@0x00.co>2013-01-31 20:08:20 +0200
commitc0121b9b7f5041f6434a2e2dd24d3c68ed84b582 (patch)
treee3e8d0a05c45dabcc2a0399f902c6a59c92a9f4f /timer/templates/alarm.html
parente613dc2b8b17e6f58a9666bee03578bb7ffc4067 (diff)
downloadopus-c0121b9b7f5041f6434a2e2dd24d3c68ed84b582.tar.gz
opus-c0121b9b7f5041f6434a2e2dd24d3c68ed84b582.tar.bz2
opus-c0121b9b7f5041f6434a2e2dd24d3c68ed84b582.zip
Initial commit
Diffstat (limited to 'timer/templates/alarm.html')
-rw-r--r--timer/templates/alarm.html68
1 files changed, 68 insertions, 0 deletions
diff --git a/timer/templates/alarm.html b/timer/templates/alarm.html
new file mode 100644
index 0000000..a9a6b54
--- /dev/null
+++ b/timer/templates/alarm.html
@@ -0,0 +1,68 @@
+{% extends "default.html" %}
+
+{% block js %}
+ <script type="text/template" id="startViewTemplate">
+ <input type="text" value="<%= minutes %>" placeholder="M" id="minutes"/>:<input type="text" id="seconds" value="<%= seconds %>"/>
+ <a href="#runningView" data-role="button">Start</a>
+ </script>
+ <script type="text/template" id="runningViewTemplate">
+ <h1><%= minutes_remaining %>:<%= seconds_remaining %></h1>
+ <a href="#" data-role="button">Stop</a>
+ </script>
+ <script type="text/javascript">
+ var Alarm = Backbone.Model.extend({
+ start: function() {
+ var elapsed = 0;
+ var interval = parseInt(this.get('minutes'))*60 + parseInt(this.get('seconds'));
+ window.setInterval(function() {
+ elapsed += 1;
+ if(elapsed < interval) {
+ console.log(interval - elapsed, ' seconds to go');
+ }
+ }, 1000);
+ },
+ stop: function() {
+
+ },
+ pause: function() {
+
+ }
+ });
+
+ var RunningView = Backbone.View.extend({
+ initialize: function() {
+ this.template = _.template($('#runningViewTemplate').html());
+ this.modal.on('change', this.render);
+ },
+ render: function() {
+ console.log('render!!!');
+ return this;
+ }
+ });
+
+ var AppView = Backbone.View.extend({
+ initialize: function() {
+ var tpl = _.template($('#startViewTemplate').html());
+ alarm = new Alarm({minutes: 0, seconds: 15});
+ $('#startView').append(tpl(alarm.toJSON()));
+ //alarm.start();
+ //$('#startView a').button('refresh');
+ //$('#startView input').textinput('enable');
+ }
+ });
+
+ $(function() {
+ new AppView;
+ });
+
+ </script>
+{% endblock js %}
+
+{% block content %}
+ <div data-role="page">
+ <div data-role="content" id="startView"></div>
+ </div>
+ <div data-role="page">
+ <div data-role="content" id="runningView"></div>
+ </div>
+{% endblock content %}