summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-28 18:05:58 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-28 18:05:58 (GMT)
commitc5b8ca5aebd6ebe9230a764b239b7bdaea8aaef7 (patch)
tree6916bf561422242a7d9d782eefe8b196db667656
parent7e3963d4a0ca528f041023146ba37810c9aef027 (diff)
readd jquery for clock callbacks
-rw-r--r--src/clock.js9
-rw-r--r--www/index.html8
-rw-r--r--www/js/bundle.js9
3 files changed, 18 insertions, 8 deletions
diff --git a/src/clock.js b/src/clock.js
index 59390d8..163f464 100644
--- a/src/clock.js
+++ b/src/clock.js
@@ -22,6 +22,8 @@
'use strict';
function Clock() {
+ this.draw_callbacks = $.Callbacks('unique');
+
this.last_message = { t1: 0, t2: 0, t3: 0, t4: 0, tz_offset: 3600 };
this.clock_offset = 0;
this.clock_rtt = 0;
@@ -46,7 +48,11 @@ function Clock() {
time_str += (rdtime.getUTCMinutes() > 9 ? ':' : ':0') + rdtime.getUTCMinutes();
time_str += (rdtime.getUTCSeconds() > 9 ? ':' : ':0') + rdtime.getUTCSeconds();
- console.log([date_str, time_str, get_rd_week(rdtime_ms)])
+ this.draw_callbacks.fireWith(window, [date_str, time_str, get_rd_week(rdtime_ms)]);
+ }
+
+ this.addCallback = function(cb) {
+ this.draw_callbacks.add(cb);
}
this.ntp_update = function(event) {
@@ -114,6 +120,7 @@ clock.start();
var ClockView = React.createClass({
+
render: function() {
return (
<p>
diff --git a/www/index.html b/www/index.html
index 63adbd2..01704e1 100644
--- a/www/index.html
+++ b/www/index.html
@@ -17,6 +17,7 @@
<script src="/javascript/react/react.min.js"></script>
<script src="/javascript/react/react-dom.min.js"></script>
-->
+ <script src="/javascript/jquery/jquery.min.js"></script>
<script src="/js/utils.js"></script>
</head>
<body>
@@ -27,11 +28,6 @@
<div id="clock"></div>
</div>
-
- <!-- <script type="text/javascript"> -->
- <!-- clock_init(); -->
- <!-- </script> -->
- <script src="/js/bundle.js"></script>
-
+ <script src="/js/bundle.js"></script>
</body>
</html>
diff --git a/www/js/bundle.js b/www/js/bundle.js
index 7aa4b78..02b7f7c 100644
--- a/www/js/bundle.js
+++ b/www/js/bundle.js
@@ -23,6 +23,8 @@
'use strict';
function Clock() {
+ this.draw_callbacks = $.Callbacks('unique');
+
this.last_message = { t1: 0, t2: 0, t3: 0, t4: 0, tz_offset: 3600 };
this.clock_offset = 0;
this.clock_rtt = 0;
@@ -47,7 +49,11 @@ function Clock() {
time_str += (rdtime.getUTCMinutes() > 9 ? ':' : ':0') + rdtime.getUTCMinutes();
time_str += (rdtime.getUTCSeconds() > 9 ? ':' : ':0') + rdtime.getUTCSeconds();
- console.log([date_str, time_str, get_rd_week(rdtime_ms)]);
+ this.draw_callbacks.fireWith(window, [date_str, time_str, get_rd_week(rdtime_ms)]);
+ };
+
+ this.addCallback = function (cb) {
+ this.draw_callbacks.add(cb);
};
this.ntp_update = function (event) {
@@ -115,6 +121,7 @@ clock.start();
var ClockView = React.createClass({
displayName: 'ClockView',
+
render: function () {
return React.createElement(
'p',