This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add countdown with auto-pass

  • Loading branch information...
1 parent e62358e commit 9a844d6560ec0fadee2633773e6ddbc554e67e3d @novemberborn committed Apr 10, 2011
Showing with 19 additions and 2 deletions.
  1. +1 −1 public/index.html
  2. +18 −1 public/js/enhancement.js
View
@@ -51,7 +51,7 @@
</div>
<div id="count-down">
- <p class="timer">{10}</p>
+ <p class="timer"></p>
</div>
</header>
View
@@ -49,6 +49,23 @@ function updateCash(points){
$("#player-details .cash").text("£ " + points).addClass(points < 0 ? "bankrupt" : "");
}
+function countdown(){
+ clearInterval(countdown.interval);
+ var timer = $("#count-down .timer");
+ var remaining = 10;
+ timer.text(10);
+ countdown.interval = setInterval(function(){
+ remaining--;
+ if(remaining >= 0){
+ timer.text(remaining);
+ }
+ if(remaining <= 0){
+ clearInterval(countdown.interval);
+ socket.send({ type: "move", country: "pass" });
+ }
+ }, 1000);
+}
+
Commands["register-user"] = {
exec: function(data){
if(data.single){
@@ -59,8 +76,8 @@ Commands["register-user"] = {
Commands["move"] = {
exec: function(data){
- console.log(data);
updateCash(data.points);
+ countdown();
$("#current-item h2").text(data.commodity.title);
$("#current-item p").text("£ " + data.commodity.points);
$("#country-list li").each(function(ix, li){

0 comments on commit 9a844d6

Please sign in to comment.