Sha256: c1b16fa794ac0615a89a10e7174433f4c541fc21e12bd4bd6645406288fe5e83
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
var MultiScreen = function(cometio, options){ if(typeof options === 'undefined' || typeof options.type === 'undefined'){ throw new Error("argument must have connection type."); } var self = this; this.io = cometio; this.options = options; this.io.on("connect", function(session){ self.io.push("__multiscreen__options", self.options); }); if(options.type == "remote"){ this.tv = {}; new EventEmitter().apply(this.tv); this.tv.event = function(selector, event_name, args){ self.io.push("__multiscreen__event", {selector: selector, event: event_name, args: args, options: self.options}); }; this.tv.$ = function(selector){ return { click: function(){ self.tv.event(selector, "click"); }, dblclick: function(){ self.tv.event(selector, "dblclick"); }, mouseover: function(){ self.tv.event(selector, "mouseover"); }, mousedown: function(){ self.tv.event(selector, "mousedown"); }, mouseup: function(){ self.tv.event(selector, "mouseup"); }, val: function(value){ self.tv.event(selector, "val", value); }, change: function(){ self.tv.event(selector, "change"); } }; }; this.io.on("__multiscreen__event", function(data){ self.tv.emit(data.event, data.args); }) } if(options.type == "tv"){ this.remote = {}; this.remote.push = function(event_name, args){ self.io.push("__multiscreen__event", {event: event_name, args: args, options: self.options}); }; this.io.on("__multiscreen__event", function(data){ if(typeof data.selector === 'undefined') return; if(typeof data.args === 'undefined'){ $(data.selector)[data.event](); }else{ $(data.selector)[data.event](data.args); } }); } };
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sinatra-multi-screen-0.0.2 | lib/js/multiscreen.js |