forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirector.js
More file actions
36 lines (30 loc) · 860 Bytes
/
Copy pathdirector.js
File metadata and controls
36 lines (30 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(function(){
var p = PUBNUB.init({ publish_key: 'demo', subscribe_key : 'demo' })
, channel = 'my_directors_channel';
p.bind( 'mousedown,touchstart', p.$('buttons'), function(e) {
var target = e.target || e.srcElement;
send(
p.attr( target, 'source' ) ||
p.attr( target.parentNode, 'source' )
);
} );
function send(data) {
p.publish({
channel : channel,
message : data
});
}
p.subscribe({
channel : channel,
callback : function(message) {
output.innerHTML = message;
animate();
}
});
function animate() {
p.css( output, { background: "#eef66c" } );
setTimeout( function() {
p.css( output, { background: "#fff" } );
}, 500 );
}
})();