sinatra-multi-screen 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 0.0.5 2013-02-25
2
+
3
+ * echo back UI Event on TV
4
+
1
5
  === 0.0.4 2013-02-24
2
6
 
3
7
  * catch client-side events on server
data/README.md CHANGED
@@ -44,8 +44,12 @@ var screen = new MultiScreen(io, {type: "remote", channel: "1"});
44
44
  var tv = screen.tv;
45
45
 
46
46
  io.on("connect", function(session){
47
- tv.$("#btn").click(); // dispatch click event on TV Side
47
+ tv.$("#btn").click(); // dispatch CLICK event on TV Side
48
48
  };
49
+
50
+ tv.on("ui_event", function(data){ // UI Event echo back from TV
51
+ alert(data.event+' was dispatched on TV-side '+data.selector);
52
+ });
49
53
  ```
50
54
 
51
55
  TV Side
@@ -31,31 +31,31 @@ var MultiScreen = function(cometio, options){
31
31
  })
32
32
 
33
33
  if(options.type == "remote"){
34
- this.tv.event = function(selector, event_name, arg){
34
+ this.tv.ui_event = function(selector, event_name, arg){
35
35
  self.tv.push("ui_event", {selector: selector, event: event_name, arg: arg});
36
36
  };
37
37
  this.tv.$ = function(selector){
38
38
  return {
39
39
  click: function(){
40
- self.tv.event(selector, "click");
40
+ self.tv.ui_event(selector, "click");
41
41
  },
42
42
  dblclick: function(){
43
- self.tv.event(selector, "dblclick");
43
+ self.tv.ui_event(selector, "dblclick");
44
44
  },
45
45
  mouseover: function(){
46
- self.tv.event(selector, "mouseover");
46
+ self.tv.ui_event(selector, "mouseover");
47
47
  },
48
48
  mousedown: function(){
49
- self.tv.event(selector, "mousedown");
49
+ self.tv.ui_event(selector, "mousedown");
50
50
  },
51
51
  mouseup: function(){
52
- self.tv.event(selector, "mouseup");
52
+ self.tv.ui_event(selector, "mouseup");
53
53
  },
54
54
  val: function(value){
55
- self.tv.event(selector, "val", value);
55
+ self.tv.ui_event(selector, "val", value);
56
56
  },
57
57
  change: function(){
58
- self.tv.event(selector, "change");
58
+ self.tv.ui_event(selector, "change");
59
59
  }
60
60
  };
61
61
  };
@@ -70,6 +70,7 @@ var MultiScreen = function(cometio, options){
70
70
  }else{
71
71
  $(data.selector)[data.event](data.arg);
72
72
  }
73
+ self.remote.push("ui_event", data);
73
74
  });
74
75
  }
75
76
  };
@@ -1,3 +1,3 @@
1
1
  module SinatraMultiScreen
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -6,6 +6,7 @@ gem 'sinatra'
6
6
  gem 'thin'
7
7
  gem 'sinatra-contrib'
8
8
  gem 'sinatra-cometio'
9
+ gem 'event_emitter'
9
10
  gem 'json'
10
11
  gem 'haml'
11
12
  gem 'sass'
@@ -15,7 +15,7 @@ GEM
15
15
  rack
16
16
  rack-test (0.6.2)
17
17
  rack (>= 1.0)
18
- sass (3.2.5)
18
+ sass (3.2.6)
19
19
  sinatra (1.3.4)
20
20
  rack (~> 1.4)
21
21
  rack-protection (~> 1.3)
@@ -45,6 +45,7 @@ PLATFORMS
45
45
  ruby
46
46
 
47
47
  DEPENDENCIES
48
+ event_emitter
48
49
  foreman
49
50
  haml
50
51
  json
@@ -7,9 +7,9 @@ io.on("connect", function(session){
7
7
  console.log("connect!! "+session);
8
8
  });
9
9
 
10
- // from TV
11
- tv.on("message", function(msg){
12
- console.log(msg);
10
+ // UI Event echo back from TV
11
+ tv.on("ui_event", function(data){
12
+ $("#message").text(data.event+' was dispatched on TV-side '+data.selector);
13
13
  });
14
14
 
15
15
  $(function(){
@@ -9,18 +9,16 @@ io.on("connect", function(session){
9
9
 
10
10
  // catch UI Event from Remote
11
11
  remote.on("ui_event", function(data){
12
- console.log(data);
12
+ $("#message").text(JSON.stringify(data));
13
13
  });
14
14
 
15
15
  $(function(){
16
16
  $(".btn").click(function(e){
17
17
  alert(e.currentTarget.innerText);
18
- remote.push("message", "click button #"+e.currentTarget.id); // push to Remote
19
18
  });
20
19
 
21
20
  $(".btn").mouseover(function(e){
22
21
  var color = e.currentTarget.attributes['x-color'].value;
23
22
  $("body").css("background-color", color);
24
- remote.push("message", "mouse over "+color); // push to Remote
25
23
  });
26
24
  });
@@ -29,3 +29,4 @@
29
29
  %input#code{:type => :text, :size => 50}
30
30
  %div
31
31
  %input#btn_dispatch{:type => :button, :value => "dispatch"}
32
+ %div#message
@@ -16,3 +16,4 @@
16
16
  %span.btn#btn_red{:type => :button, 'x-color' => '#FAA'} id btn_red
17
17
  %span.btn#btn_green{:type => :button, 'x-color' => '#AFA'} id btn_green
18
18
  %span.btn#btn_blue{:type => :button, 'x-color' => '#AAF'} id btn_blue
19
+ %div#message
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ["lib"]
18
18
  gem.add_dependency 'sinatra', '>= 1.3.3'
19
19
  gem.add_dependency 'sinatra-cometio', '>= 0.1.3', '< 0.2.0'
20
+ gem.add_dependency 'event_emitter'
20
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-multi-screen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-23 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
@@ -49,6 +49,22 @@ dependencies:
49
49
  - - <
50
50
  - !ruby/object:Gem::Version
51
51
  version: 0.2.0
52
+ - !ruby/object:Gem::Dependency
53
+ name: event_emitter
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
52
68
  description: Sinatra Plugin for Multi-Screen Application.
53
69
  email:
54
70
  - hashimoto@shokai.org