Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

working.. some how :)

  • Loading branch information...
commit fc6a521aa525428edc950f740a7cade4575d94df 1 parent e645163
Fernando Guillen authored
12  client/app/ControlsView.js
@@ -36,8 +36,20 @@ $(function(){
36 36
 
37 37
     render: function(){
38 38
       this.$el.html( this.template() );
  39
+      this.ajaxWatcher();
39 40
 
40 41
       return this;
  42
+    },
  43
+
  44
+
  45
+    ajaxWatcher: function() {
  46
+      this.$el.find('#ajax-loading').ajaxStart( function() {
  47
+        $(this).fadeIn();
  48
+      });
  49
+
  50
+      this.$el.find('#ajax-loading').ajaxStop( function() {
  51
+        $(this).fadeOut();
  52
+      });
41 53
     }
42 54
 
43 55
   });
5  client/app/LoadGame.js
@@ -2,7 +2,6 @@ App.RootUrl = "http://localhost:4567";
2 2
 
3 3
 $(function(){
4 4
   console.log( "Loading Game..." );
5  
-  App.Utils.ajaxWatcher();
6 5
 
7 6
   App.Game = new App.Universe();
8 7
 
@@ -12,8 +11,8 @@ $(function(){
12 11
   App.Navigator = new App.Router();
13 12
 
14 13
   // App.Game.synch();
15  
-  // App.Game.fetch({ success: function(){ Backbone.history.start() } });
16  
-  Backbone.history.start();
  14
+  App.Game.fetch({ success: function(){ Backbone.history.start() } });
  15
+  // Backbone.history.start();
17 16
 
18 17
 
19 18
 
23  client/app/Universe.js
@@ -27,21 +27,22 @@ $(function(){
27 27
 
28 28
       var _self = this;
29 29
       this.interval =
30  
-        setInterval(function() {
31  
-          _self.refresh();
32  
-        }, 1000);
  30
+        setInterval(
  31
+          function() { _self.refresh(); },
  32
+          1000
  33
+        );
33 34
     },
34 35
 
35 36
     refresh: function(){
36 37
       console.log( "Refresh Universe..." );
37  
-      if( this.actualStep == 1 ) {
38  
-        this.set( data1 );
39  
-        this.actualStep = 2;
40  
-      } else {
41  
-        this.set( data2 );
42  
-        this.actualStep = 1;
43  
-      }
44  
-      // this.fetch();
  38
+      // if( this.actualStep == 1 ) {
  39
+      //   this.set( data1 );
  40
+      //   this.actualStep = 2;
  41
+      // } else {
  42
+      //   this.set( data2 );
  43
+      //   this.actualStep = 1;
  44
+      // }
  45
+      this.fetch();
45 46
     },
46 47
 
47 48
     pause: function(){
10  client/app/Utils.js
@@ -25,15 +25,5 @@ $(function(){
25 25
         collection.remove( model_id_to_remove );
26 26
       });
27 27
     },
28  
-
29  
-    ajaxWatcher: function() {
30  
-      $('#ajax-loading').ajaxStart( function() {
31  
-        $(this).animate({ top: "0" }, 200);
32  
-      });
33  
-
34  
-      $('#ajax-loading').ajaxStop( function() {
35  
-        $(this).animate({ top: "-200" }, 100);
36  
-      });
37  
-    }
38 28
   }
39 29
 });
8  client/csss/planets.css
@@ -526,11 +526,3 @@ border-bottom:1px solid #ccc;
526 526
 .planet-small.fleet-origin .cover#fleet-origin{
527 527
   display: block;
528 528
 }
529  
-
530  
-#ajax-loading {
531  
-  position: fixed;
532  
-  width: 100px;
533  
-  height: 200px;
534  
-  /*top: -200px;*/
535  
-  right: 100px;
536  
-}
5  client/index.html
@@ -82,8 +82,6 @@
82 82
   <div id="wrapper">
83 83
   </div> <!-- wrapper -->
84 84
 
85  
-  <div id="ajax-loading">AJAX</div>
86  
-
87 85
 
88 86
 
89 87
 </body>
@@ -95,7 +93,10 @@
95 93
     <a href="#" id="pause" style="display:none" onclick="return false;">pause</a>
96 94
     <a href="#" id="step" onclick="return false;">step</a>
97 95
     <a href="#" id="dashboard" onclick="return false;">dashboard</a>
  96
+
  97
+    <div id="ajax-loading" style="display: none">ajax</div>
98 98
   </div>
  99
+
99 100
 </script>
100 101
 
101 102
 <script type="text/template" id="screen-template">
24  gem/lib/s2c/utils.rb
@@ -23,18 +23,18 @@ def self.feed_universe( universe )
23 23
 
24 24
       planets = []
25 25
 
26  
-      planets[0]  = universe.planets.create!( :position =>  [1, 1] )
27  
-      planets[1]  = universe.planets.create!( :position =>  [1, 2] )
28  
-      planets[2]  = universe.planets.create!( :position =>  [1, 3] )
29  
-      planets[3]  = universe.planets.create!( :position =>  [1, 4] )
30  
-      planets[4]  = universe.planets.create!( :position =>  [2, 1] )
31  
-      planets[5]  = universe.planets.create!( :position =>  [2, 2] )
32  
-      planets[6]  = universe.planets.create!( :position =>  [2, 3] )
33  
-      planets[7]  = universe.planets.create!( :position =>  [2, 4] )
34  
-      planets[8]  = universe.planets.create!( :position =>  [3, 1] )
35  
-      planets[9]  = universe.planets.create!( :position =>  [3, 2] )
36  
-      planets[10] = universe.planets.create!( :position =>  [3, 3] )
37  
-      planets[11] = universe.planets.create!( :position =>  [3, 4] )
  26
+      planets[0]  = universe.planets.create!( :position =>  [100, 100] )
  27
+      planets[1]  = universe.planets.create!( :position =>  [100, 200] )
  28
+      planets[2]  = universe.planets.create!( :position =>  [100, 300] )
  29
+      planets[3]  = universe.planets.create!( :position =>  [100, 400] )
  30
+      planets[4]  = universe.planets.create!( :position =>  [200, 100] )
  31
+      planets[5]  = universe.planets.create!( :position =>  [200, 200] )
  32
+      planets[6]  = universe.planets.create!( :position =>  [200, 300] )
  33
+      planets[7]  = universe.planets.create!( :position =>  [200, 400] )
  34
+      planets[8]  = universe.planets.create!( :position =>  [300, 100] )
  35
+      planets[9]  = universe.planets.create!( :position =>  [300, 200] )
  36
+      planets[10] = universe.planets.create!( :position =>  [300, 300] )
  37
+      planets[11] = universe.planets.create!( :position =>  [300, 400] )
38 38
 
39 39
       planets.each do |planet|
40 40
         planet.furnish
2  server/config/config.yml
@@ -19,7 +19,7 @@ ship:
19 19
   power: 20
20 20
   attack: 12
21 21
   defense: 8
22  
-  life: 10
  22
+  life: 100
23 23
 
24 24
 mine:
25 25
   production: 10
14  server/lib/s2c/server/app.rb
@@ -10,7 +10,7 @@ class App < Sinatra::Base
10 10
       S2C::Utils.feed_universe( @@universe )
11 11
       @@universe.reload
12 12
     end
13  
-    # @@universe.start
  13
+    @@universe.start
14 14
 
15 15
     before do
16 16
       headers(
@@ -27,12 +27,12 @@ class App < Sinatra::Base
27 27
     end
28 28
 
29 29
     get "/universe" do
30  
-      @@universe.step
31  
-      @@universe.reload
  30
+      # @@universe.step
  31
+      # @@universe.reload
32 32
       result = S2C::JSONer.to_json( @@universe )
33 33
 
34 34
       File.open( "#{File.dirname(__FILE__)}/../../../tmp/univers2_#{Time.now.to_i}.json", "w" ) { |f| f.write result }
35  
-      # puts result
  35
+      puts result
36 36
       # result
37 37
 
38 38
 
@@ -61,7 +61,11 @@ class App < Sinatra::Base
61 61
 
62 62
       fleet.start_trip
63 63
 
64  
-      JSON.pretty_generate( S2C::JSONer.fleet_to_hash( fleet ) )
  64
+      result = JSON.pretty_generate( S2C::JSONer.fleet_to_hash( fleet ) )
  65
+
  66
+      puts "XXX: result: #{result}"
  67
+
  68
+      result
65 69
     end
66 70
 
67 71
     post "/upgrade/:id" do

0 notes on commit fc6a521

Please sign in to comment.
Something went wrong with that request. Please try again.