Permalink
Browse files

Added counter view.

  • Loading branch information...
1 parent 89aee7f commit 64cf19ddca0f27f78cd6e6ad4f471cf63b59bcbe @deviantbits deviantbits committed May 28, 2011
Showing with 28 additions and 9 deletions.
  1. +4 −0 app.js
  2. +22 −6 views/counter.jade
  3. +1 −1 views/index.jade
  4. +1 −2 views/layout.jade
View
4 app.js
@@ -51,6 +51,10 @@ app.listen(3000);
var everyone = require("now").initialize(app);
+everyone.now.getTime = function(){
+ everyone.now.receiveTime((new Date).getTime());
+};
+
everyone.now.distribute = function(message){
// this.now exposes caller's scope
everyone.now.receive(message);
View
@@ -5,12 +5,28 @@
h1#counter
script(type='text/javascript')
- var counter = 0;
+
+ var serverTime = 0;
+ var localTime = 0;
+ var timeDiff = 0;
+
$(document).ready(function() {
- inc = function() {
- counter++;
- $("#counter").html(counter);
+
+ now.receiveTime = function(time) {
+ serverTime = time;
+ localTime = (new Date).getTime();
+ timeDiff = localTime - serverTime;
+ };
+
+ now.ready(function() {
+ now.getTime();
+ });
+
+ increment = function() {
+ serverTime++;
+ localTime++;
+ $("#counter").html('' + serverTime + ' + ' + timeDiff);
}
- setInterval( inc, 100);
- });
+ setInterval(increment, 100);
+ });
View
@@ -4,7 +4,7 @@
#main-content-box
h2#song-title Nicolas Jaar: Waterfalls
#player
- a(href='http://soundcloud.com/jwagener/bla', class='sc-player')
+ a(href='http://soundcloud.com/dodus_afarensis/nicolas-jaar-live-fall-08', class='sc-player')
script
$('.sc-player').scPlayer({
View
@@ -3,8 +3,7 @@ html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
- link(rel='stylesheet', href='/stylesheets/soundcloud/sc-player-minimal.css')
- script(type='text/javascript', src='http://code.jquery.com/jquery-1.5.min.js')
+ script(type='text/javascript', src='http://code.jquery.com/jquery-1.4.2.min.js')
script(type='text/javascript', src='/nowjs/now.js')
body!= body
script(type='text/javascript', src='/javascripts/soundcloud.player.api.js')

0 comments on commit 64cf19d

Please sign in to comment.