From 8ae0a6a621ccdf300287c6a30aedb863a3184852 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 24 Jan 2013 15:37:53 -0500 Subject: time on cursors --- public/javascripts/game.js | 9 +++++++-- public/javascripts/util.js | 2 ++ public/stylesheets/style.css | 8 +++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/public/javascripts/game.js b/public/javascripts/game.js index cb51987..184d3a9 100644 --- a/public/javascripts/game.js +++ b/public/javascripts/game.js @@ -91,7 +91,7 @@ var UI = { } var howlong = Math.floor( (now - start) ) - delay; if (own_cursor) { - $("#waiting").html( timeInSecs( howlong ) ); + own_cursor.time.html( timeInSecs( howlong ) ); } } else { if (blurTime) { @@ -119,7 +119,10 @@ var UI = { var cursor = new Cursor( users[i] ); users[i].cursor = cursor; cursors.push(cursor); - } + } + else if (i == _id) { + own_cursor.name.html( users[i].firstname ); + } } }, @@ -141,9 +144,11 @@ function Cursor ( user ) { this.el.css('background-image', 'url(' + cursor_image + '?' + Math.floor(Math.random() * 1000) + ')'); this.name = $("
"); + this.name.addClass('name'); this.name.html( user.firstname ); this.time = $("
"); + this.time.addClass('time'); this.time.html( "0:00" ); this.el.append(this.name); diff --git a/public/javascripts/util.js b/public/javascripts/util.js index 86c8328..91c4713 100644 --- a/public/javascripts/util.js +++ b/public/javascripts/util.js @@ -43,6 +43,8 @@ function timeInSecs (time) { } if (time > 60) { str.push( leading( (time / 60) % 60 ) ); + } else { + str.push( Math.floor( time / 60 ) ); } str.push( leading( time % 60 ) ); diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 2c033a9..93585a3 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -390,12 +390,18 @@ header { .cursor div { position: relative; left: 25px; - top: 0; + top: 3px; font-size: 12px; color: #333; font-family: 'Julius Sans One', sans-serif; z-index:2; } +.cursor div.name { + left: 29px; +} +.cursor div.time { + font-size: 10px; +} .cursor.idle div { color: transparent; } -- cgit v1.2.3-70-g09d2