| var Benchmark = require('benchmark'); | ||
| module.exports = function(client, options){ | ||
| var maxTime = options.maxTime; | ||
| return Benchmark.Suite() | ||
| .on('cycle', function(cycle){ | ||
| console.log(String(cycle.target)); | ||
| }) | ||
| .add('Client.emit.set - array path number', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'onStart': function(){ | ||
| client.on('set', function(){ | ||
| client.deferred.resolve(); | ||
| }); | ||
| }, | ||
| 'fn': function(deferred){ | ||
| client.deferred = deferred; | ||
| client.emit('set', ['b', 0, 0, 0, 0, 0], 3); | ||
| }, | ||
| 'onComplete': function(){ | ||
| delete client.deferred; | ||
| client.removeAllListeners('set'); | ||
| } | ||
| }) | ||
| .add('Client.emit.merge - complex object', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'onStart': function(){ | ||
| client.on('merge', function(){ | ||
| client.deferred.resolve(); | ||
| }); | ||
| }, | ||
| 'fn': function(deferred){ | ||
| client.deferred = deferred; | ||
| client.emit('merge', { | ||
| key: 'foo', | ||
| a: { b: { c: { d: { e: 1 } } } }, | ||
| b: [[[[[1]]]]] | ||
| }); | ||
| }, | ||
| 'onComplete': function(){ | ||
| delete client.deferred; | ||
| client.removeAllListeners('merge'); | ||
| } | ||
| }) | ||
| .add('Client.emit.get - path', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| client.emit('get', ['a', 'b', 'c', 'd', 'e'], function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Client.emit.get - path array', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| client.emit('get', ['b', 0, 0, 0, 0, 0], function(value){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }); | ||
| }; |
| var Benchmark = require('benchmark'); | ||
| module.exports = function(planet, options){ | ||
| var maxTime = options.maxTime; | ||
| return Benchmark.Suite() | ||
| .on('cycle', function(cycle){ | ||
| console.log(String(cycle.target)); | ||
| }) | ||
| .add('Server.set - key string', { | ||
| 'maxTime': maxTime, | ||
| 'onStart': function(){ | ||
| console.log('Set:'); | ||
| }, | ||
| 'fn': function(){ | ||
| planet.set('key', 'bar'); | ||
| } | ||
| }) | ||
| .add('Server.set - path number', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.set(['a', 'b', 'c', 'd', 'e'], 2); | ||
| } | ||
| }) | ||
| .add('Server.set - key nested array', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.set('b', [[[[[2]]]]]); | ||
| } | ||
| }) | ||
| .add('Server.set - array path number', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.set(['b', 0, 0, 0, 0, 0], 3); | ||
| } | ||
| }) | ||
| .add('Server.merge - simple object', { | ||
| 'maxTime': maxTime, | ||
| 'onStart': function(){ | ||
| console.log('Merge:'); | ||
| }, | ||
| 'fn': function(){ | ||
| planet.merge({ key: 'value'}); | ||
| } | ||
| }) | ||
| .add('Server.merge - nested object', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.merge({ a: { b: { c: { d: { e: 0 } } } } }); | ||
| } | ||
| }) | ||
| .add('Server.merge - complex object', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.merge({ | ||
| key: 'foo', | ||
| a: { b: { c: { d: { e: 1 } } } }, | ||
| b: [[[[[1]]]]] | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - complete state', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'onStart': function(){ | ||
| console.log('Get:'); | ||
| }, | ||
| 'fn': function(deferred){ | ||
| planet.get(function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - key', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| planet.get('key', function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - path', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| planet.get(['a', 'b', 'c', 'd', 'e'], function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - path array', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| planet.get(['b', 0, 0, 0, 0, 0], function(value){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }); | ||
| }; |
| var dummy = require('./dummy'); | ||
| for (var i = 0; ++i <= process.argv[2];) (dummy)(i); | ||
| /* | ||
| var dummies = []; | ||
| for (var i = 0; ++i <= process.argv[2];){ | ||
| dummies.push(dummy(i)); | ||
| } | ||
| process.on('exit', function(){ | ||
| for (var i = 0, len = dummies.length; i < len; i++){ | ||
| console.log(dummies[i].socket.connected); | ||
| if (dummies[i].socket.connected) dummies[i].disconnect(); | ||
| } | ||
| }); | ||
| */ |
| var io = require('socket.io-client'); | ||
| module.exports = function(i){ | ||
| var socket = io.connect(process.argv[3] || '//:8004', { | ||
| 'force new connection': 1, | ||
| 'try multiple transports': false, | ||
| 'reconnect': false | ||
| }); | ||
| socket.on('connect', function(){ | ||
| console.log(i); | ||
| }); | ||
| socket.on('connect_failed', function(){}); | ||
| socket.on('error', function(){}); | ||
| //socket.emit('get', function(data){}); | ||
| socket.on('set', function(){}); | ||
| socket.on('merge', function(){}); | ||
| socket.on('remove', function(){}); | ||
| socket.on('delete', function(){}); | ||
| socket.on('disconnect', function(){}); | ||
| /* | ||
| socket.on('disconnect', function(){ | ||
| process.exit(0); | ||
| }); | ||
| // Errors | ||
| socket.on('connect_failed', function(){ | ||
| process.stderr.write('ERROR (connect_failed)! \n'); | ||
| process.exit(1); | ||
| }); | ||
| socket.on('error', function(){ | ||
| process.stderr.write('ERROR! \n'); | ||
| process.exit(1); | ||
| }); | ||
| // process.exit(0); // success = 0, error = 1 | ||
| */ | ||
| return socket; | ||
| } |
| var Planet = require('../../'), | ||
| socket = require('socket.io').listen(8082, { | ||
| 'log level': 1 | ||
| }), | ||
| io = require('socket.io-client'), | ||
| spawn = require('child_process').spawn; | ||
| var planet = Planet(socket, { | ||
| limit: 100 | ||
| }); | ||
| planet.on('listening', function(){ | ||
| var client = io.connect('//:8082', { | ||
| 'force new connection': true | ||
| }); | ||
| var options = { | ||
| maxTime: 4 | ||
| }; | ||
| require('./bench.client')(client, options).on('complete', function(){ | ||
| client.disconnect(); | ||
| require('./bench.server')(planet, options).on('complete', function(){ | ||
| var count = 0, | ||
| dummies = spawn('node', [__dirname + '/dummies.js', 99, '//:8082']); | ||
| process.on('exit', function(){ | ||
| dummies.kill(); | ||
| }); | ||
| dummies.stderr.on('data', function(error){ console.log('ERROR!!', error.toString()); }); | ||
| dummies.stdout.setEncoding('utf8'); | ||
| dummies.stdout.on('data', function(data){ | ||
| count += data.trim().split('\n').length; | ||
| if (count < 99) return; | ||
| console.log('\n', 'Connect 99 dummy clients', '\n'); | ||
| client = io.connect('//:8082', { | ||
| 'force new connection': true | ||
| }); | ||
| require('./bench.client')(client, options).on('complete', function(){ | ||
| client.disconnect(); | ||
| require('./bench.server')(planet, options).on('complete', function(){ | ||
| planet.get(function(data){ | ||
| // console.log(JSON.stringify(data)); | ||
| process.exit(); | ||
| }); | ||
| }) | ||
| .run(); | ||
| }) | ||
| .run(); | ||
| }); | ||
| }) | ||
| .run(); | ||
| }) | ||
| .run(); | ||
| }); |
| var connect = require('connect'), | ||
| io = require('socket.io'), | ||
| planet = require('../../'), | ||
| network = require('os').networkInterfaces(); | ||
| var ip = network.en1[network.en1.length - 1].address; | ||
| var server = connect() | ||
| .use(connect.static(__dirname + '/public')) | ||
| .listen(8004, ip); | ||
| console.log('\nbrowse to http://' + ip + ':8004/'); | ||
| var socket = io.listen(server, { | ||
| 'transports': ['websocket'], | ||
| 'flash policy server': false, | ||
| 'log level': 1//, | ||
| //'browser client': false, | ||
| //'browser client cache': true, | ||
| //'browser client minification': true, | ||
| //'browser client gzip': true | ||
| }); | ||
| planet(socket); |
Sorry, the diff of this file is too big to display
| // MooTools: the javascript framework. | ||
| // Load this file's selection again by visiting: http://mootools.net/more/3646a687e12fabf03bf92a18afb69a22 | ||
| // Or build this file again with packager using: packager build More/Element.Event.Pseudos.Keys More/Slider | ||
| /* | ||
| --- | ||
| copyrights: | ||
| - [MooTools](http://mootools.net) | ||
| licenses: | ||
| - [MIT License](http://mootools.net/license.txt) | ||
| ... | ||
| */ | ||
| MooTools.More={version:"1.4.0.1",build:"a4244edf2aa97ac8a196fc96082dd35af1abab87"};(function(){Events.Pseudos=function(h,e,f){var d="_monitorEvents:";var c=function(i){return{store:i.store?function(j,k){i.store(d+j,k); | ||
| }:function(j,k){(i._monitorEvents||(i._monitorEvents={}))[j]=k;},retrieve:i.retrieve?function(j,k){return i.retrieve(d+j,k);}:function(j,k){if(!i._monitorEvents){return k; | ||
| }return i._monitorEvents[j]||k;}};};var g=function(k){if(k.indexOf(":")==-1||!h){return null;}var j=Slick.parse(k).expressions[0][0],p=j.pseudos,i=p.length,o=[]; | ||
| while(i--){var n=p[i].key,m=h[n];if(m!=null){o.push({event:j.tag,value:p[i].value,pseudo:n,original:k,listener:m});}}return o.length?o:null;};return{addEvent:function(m,p,j){var n=g(m); | ||
| if(!n){return e.call(this,m,p,j);}var k=c(this),r=k.retrieve(m,[]),i=n[0].event,l=Array.slice(arguments,2),o=p,q=this;n.each(function(s){var t=s.listener,u=o; | ||
| if(t==false){i+=":"+s.pseudo+"("+s.value+")";}else{o=function(){t.call(q,s,u,arguments,o);};}});r.include({type:i,event:p,monitor:o});k.store(m,r);if(m!=i){e.apply(this,[m,p].concat(l)); | ||
| }return e.apply(this,[i,o].concat(l));},removeEvent:function(m,l){var k=g(m);if(!k){return f.call(this,m,l);}var n=c(this),j=n.retrieve(m);if(!j){return this; | ||
| }var i=Array.slice(arguments,2);f.apply(this,[m,l].concat(i));j.each(function(o,p){if(!l||o.event==l){f.apply(this,[o.type,o.monitor].concat(i));}delete j[p]; | ||
| },this);n.store(m,j);return this;}};};var b={once:function(e,f,d,c){f.apply(this,d);this.removeEvent(e.event,c).removeEvent(e.original,f);},throttle:function(d,e,c){if(!e._throttled){e.apply(this,c); | ||
| e._throttled=setTimeout(function(){e._throttled=false;},d.value||250);}},pause:function(d,e,c){clearTimeout(e._pause);e._pause=e.delay(d.value||250,this,c); | ||
| }};Events.definePseudo=function(c,d){b[c]=d;return this;};Events.lookupPseudo=function(c){return b[c];};var a=Events.prototype;Events.implement(Events.Pseudos(b,a.addEvent,a.removeEvent)); | ||
| ["Request","Fx"].each(function(c){if(this[c]){this[c].implement(Events.prototype);}});})();(function(){var d={relay:false},c=["once","throttle","pause"],b=c.length; | ||
| while(b--){d[c[b]]=Events.lookupPseudo(c[b]);}DOMEvent.definePseudo=function(e,f){d[e]=f;return this;};var a=Element.prototype;[Element,Window,Document].invoke("implement",Events.Pseudos(d,a.addEvent,a.removeEvent)); | ||
| })();(function(){var a="$moo:keys-pressed",b="$moo:keys-keyup";DOMEvent.definePseudo("keys",function(d,e,c){var g=c[0],f=[],h=this.retrieve(a,[]);f.append(d.value.replace("++",function(){f.push("+"); | ||
| return"";}).split("+"));h.include(g.key);if(f.every(function(j){return h.contains(j);})){e.apply(this,c);}this.store(a,h);if(!this.retrieve(b)){var i=function(j){(function(){h=this.retrieve(a,[]).erase(j.key); | ||
| this.store(a,h);}).delay(0,this);};this.store(b,i).addEvent("keyup",i);}});DOMEvent.defineKeys({"16":"shift","17":"control","18":"alt","20":"capslock","33":"pageup","34":"pagedown","35":"end","36":"home","144":"numlock","145":"scrolllock","186":";","187":"=","188":",","190":".","191":"/","192":"`","219":"[","220":"\\","221":"]","222":"'","107":"+"}).defineKey(Browser.firefox?109:189,"-"); | ||
| })();Class.Mutators.Binds=function(a){if(!this.prototype.initialize){this.implement("initialize",function(){});}return Array.from(a).concat(this.prototype.Binds||[]); | ||
| };Class.Mutators.initialize=function(a){return function(){Array.from(this.Binds).each(function(b){var c=this[b];if(c){this[b]=c.bind(this);}},this);return a.apply(this,arguments); | ||
| };};var Drag=new Class({Implements:[Events,Options],options:{snap:6,unit:"px",grid:false,style:true,limit:false,handle:false,invert:false,preventDefault:false,stopPropagation:false,modifiers:{x:"left",y:"top"}},initialize:function(){var b=Array.link(arguments,{options:Type.isObject,element:function(c){return c!=null; | ||
| }});this.element=document.id(b.element);this.document=this.element.getDocument();this.setOptions(b.options||{});var a=typeOf(this.options.handle);this.handles=((a=="array"||a=="collection")?$$(this.options.handle):document.id(this.options.handle))||this.element; | ||
| this.mouse={now:{},pos:{}};this.value={start:{},now:{}};this.selection=(Browser.ie)?"selectstart":"mousedown";if(Browser.ie&&!Drag.ondragstartFixed){document.ondragstart=Function.from(false); | ||
| Drag.ondragstartFixed=true;}this.bound={start:this.start.bind(this),check:this.check.bind(this),drag:this.drag.bind(this),stop:this.stop.bind(this),cancel:this.cancel.bind(this),eventStop:Function.from(false)}; | ||
| this.attach();},attach:function(){this.handles.addEvent("mousedown",this.bound.start);return this;},detach:function(){this.handles.removeEvent("mousedown",this.bound.start); | ||
| return this;},start:function(a){var j=this.options;if(a.rightClick){return;}if(j.preventDefault){a.preventDefault();}if(j.stopPropagation){a.stopPropagation(); | ||
| }this.mouse.start=a.page;this.fireEvent("beforeStart",this.element);var c=j.limit;this.limit={x:[],y:[]};var e,g;for(e in j.modifiers){if(!j.modifiers[e]){continue; | ||
| }var b=this.element.getStyle(j.modifiers[e]);if(b&&!b.match(/px$/)){if(!g){g=this.element.getCoordinates(this.element.getOffsetParent());}b=g[j.modifiers[e]]; | ||
| }if(j.style){this.value.now[e]=(b||0).toInt();}else{this.value.now[e]=this.element[j.modifiers[e]];}if(j.invert){this.value.now[e]*=-1;}this.mouse.pos[e]=a.page[e]-this.value.now[e]; | ||
| if(c&&c[e]){var d=2;while(d--){var f=c[e][d];if(f||f===0){this.limit[e][d]=(typeof f=="function")?f():f;}}}}if(typeOf(this.options.grid)=="number"){this.options.grid={x:this.options.grid,y:this.options.grid}; | ||
| }var h={mousemove:this.bound.check,mouseup:this.bound.cancel};h[this.selection]=this.bound.eventStop;this.document.addEvents(h);},check:function(a){if(this.options.preventDefault){a.preventDefault(); | ||
| }var b=Math.round(Math.sqrt(Math.pow(a.page.x-this.mouse.start.x,2)+Math.pow(a.page.y-this.mouse.start.y,2)));if(b>this.options.snap){this.cancel();this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop}); | ||
| this.fireEvent("start",[this.element,a]).fireEvent("snap",this.element);}},drag:function(b){var a=this.options;if(a.preventDefault){b.preventDefault(); | ||
| }this.mouse.now=b.page;for(var c in a.modifiers){if(!a.modifiers[c]){continue;}this.value.now[c]=this.mouse.now[c]-this.mouse.pos[c];if(a.invert){this.value.now[c]*=-1; | ||
| }if(a.limit&&this.limit[c]){if((this.limit[c][1]||this.limit[c][1]===0)&&(this.value.now[c]>this.limit[c][1])){this.value.now[c]=this.limit[c][1];}else{if((this.limit[c][0]||this.limit[c][0]===0)&&(this.value.now[c]<this.limit[c][0])){this.value.now[c]=this.limit[c][0]; | ||
| }}}if(a.grid[c]){this.value.now[c]-=((this.value.now[c]-(this.limit[c][0]||0))%a.grid[c]);}if(a.style){this.element.setStyle(a.modifiers[c],this.value.now[c]+a.unit); | ||
| }else{this.element[a.modifiers[c]]=this.value.now[c];}}this.fireEvent("drag",[this.element,b]);},cancel:function(a){this.document.removeEvents({mousemove:this.bound.check,mouseup:this.bound.cancel}); | ||
| if(a){this.document.removeEvent(this.selection,this.bound.eventStop);this.fireEvent("cancel",this.element);}},stop:function(b){var a={mousemove:this.bound.drag,mouseup:this.bound.stop}; | ||
| a[this.selection]=this.bound.eventStop;this.document.removeEvents(a);if(b){this.fireEvent("complete",[this.element,b]);}}});Element.implement({makeResizable:function(a){var b=new Drag(this,Object.merge({modifiers:{x:"width",y:"height"}},a)); | ||
| this.store("resizer",b);return b.addEvent("drag",function(){this.fireEvent("resize",b);}.bind(this));}});(function(){var b=function(e,d){var f=[];Object.each(d,function(g){Object.each(g,function(h){e.each(function(i){f.push(i+"-"+h+(i=="border"?"-width":"")); | ||
| });});});return f;};var c=function(f,e){var d=0;Object.each(e,function(h,g){if(g.test(f)){d=d+h.toInt();}});return d;};var a=function(d){return !!(!d||d.offsetHeight||d.offsetWidth); | ||
| };Element.implement({measure:function(h){if(a(this)){return h.call(this);}var g=this.getParent(),e=[];while(!a(g)&&g!=document.body){e.push(g.expose()); | ||
| g=g.getParent();}var f=this.expose(),d=h.call(this);f();e.each(function(i){i();});return d;},expose:function(){if(this.getStyle("display")!="none"){return function(){}; | ||
| }var d=this.style.cssText;this.setStyles({display:"block",position:"absolute",visibility:"hidden"});return function(){this.style.cssText=d;}.bind(this); | ||
| },getDimensions:function(d){d=Object.merge({computeSize:false},d);var i={x:0,y:0};var h=function(j,e){return(e.computeSize)?j.getComputedSize(e):j.getSize(); | ||
| };var f=this.getParent("body");if(f&&this.getStyle("display")=="none"){i=this.measure(function(){return h(this,d);});}else{if(f){try{i=h(this,d);}catch(g){}}}return Object.append(i,(i.x||i.x===0)?{width:i.x,height:i.y}:{x:i.width,y:i.height}); | ||
| },getComputedSize:function(d){d=Object.merge({styles:["padding","border"],planes:{height:["top","bottom"],width:["left","right"]},mode:"both"},d);var g={},e={width:0,height:0},f; | ||
| if(d.mode=="vertical"){delete e.width;delete d.planes.width;}else{if(d.mode=="horizontal"){delete e.height;delete d.planes.height;}}b(d.styles,d.planes).each(function(h){g[h]=this.getStyle(h).toInt(); | ||
| },this);Object.each(d.planes,function(i,h){var k=h.capitalize(),j=this.getStyle(h);if(j=="auto"&&!f){f=this.getDimensions();}j=g[h]=(j=="auto")?f[h]:j.toInt(); | ||
| e["total"+k]=j;i.each(function(m){var l=c(m,g);e["computed"+m.capitalize()]=l;e["total"+k]+=l;});},this);return Object.append(e,g);}});})();var Slider=new Class({Implements:[Events,Options],Binds:["clickedElement","draggedKnob","scrolledElement"],options:{onTick:function(a){this.setKnobPosition(a); | ||
| },initialStep:0,snap:false,offset:0,range:false,wheel:false,steps:100,mode:"horizontal"},initialize:function(f,a,e){this.setOptions(e);e=this.options;this.element=document.id(f); | ||
| a=this.knob=document.id(a);this.previousChange=this.previousEnd=this.step=-1;var b={},d={x:false,y:false};switch(e.mode){case"vertical":this.axis="y";this.property="top"; | ||
| this.offset="offsetHeight";break;case"horizontal":this.axis="x";this.property="left";this.offset="offsetWidth";}this.setSliderDimensions();this.setRange(e.range); | ||
| if(a.getStyle("position")=="static"){a.setStyle("position","relative");}a.setStyle(this.property,-e.offset);d[this.axis]=this.property;b[this.axis]=[-e.offset,this.full-e.offset]; | ||
| var c={snap:0,limit:b,modifiers:d,onDrag:this.draggedKnob,onStart:this.draggedKnob,onBeforeStart:(function(){this.isDragging=true;}).bind(this),onCancel:function(){this.isDragging=false; | ||
| }.bind(this),onComplete:function(){this.isDragging=false;this.draggedKnob();this.end();}.bind(this)};if(e.snap){this.setSnap(c);}this.drag=new Drag(a,c); | ||
| this.attach();if(e.initialStep!=null){this.set(e.initialStep);}},attach:function(){this.element.addEvent("mousedown",this.clickedElement);if(this.options.wheel){this.element.addEvent("mousewheel",this.scrolledElement); | ||
| }this.drag.attach();return this;},detach:function(){this.element.removeEvent("mousedown",this.clickedElement).removeEvent("mousewheel",this.scrolledElement); | ||
| this.drag.detach();return this;},autosize:function(){this.setSliderDimensions().setKnobPosition(this.toPosition(this.step));this.drag.options.limit[this.axis]=[-this.options.offset,this.full-this.options.offset]; | ||
| if(this.options.snap){this.setSnap();}return this;},setSnap:function(a){if(!a){a=this.drag.options;}a.grid=Math.ceil(this.stepWidth);a.limit[this.axis][1]=this.full; | ||
| return this;},setKnobPosition:function(a){if(this.options.snap){a=this.toPosition(this.step);}this.knob.setStyle(this.property,a);return this;},setSliderDimensions:function(){this.full=this.element.measure(function(){this.half=this.knob[this.offset]/2; | ||
| return this.element[this.offset]-this.knob[this.offset]+(this.options.offset*2);}.bind(this));return this;},set:function(a){if(!((this.range>0)^(a<this.min))){a=this.min; | ||
| }if(!((this.range>0)^(a>this.max))){a=this.max;}this.step=Math.round(a);return this.checkStep().fireEvent("tick",this.toPosition(this.step)).end();},setRange:function(a,b){this.min=Array.pick([a[0],0]); | ||
| this.max=Array.pick([a[1],this.options.steps]);this.range=this.max-this.min;this.steps=this.options.steps||this.full;this.stepSize=Math.abs(this.range)/this.steps; | ||
| this.stepWidth=this.stepSize*this.full/Math.abs(this.range);if(a){this.set(Array.pick([b,this.step]).floor(this.min).max(this.max));}return this;},clickedElement:function(c){if(this.isDragging||c.target==this.knob){return; | ||
| }var b=this.range<0?-1:1,a=c.page[this.axis]-this.element.getPosition()[this.axis]-this.half;a=a.limit(-this.options.offset,this.full-this.options.offset); | ||
| this.step=Math.round(this.min+b*this.toStep(a));this.checkStep().fireEvent("tick",a).end();},scrolledElement:function(a){var b=(this.options.mode=="horizontal")?(a.wheel<0):(a.wheel>0); | ||
| this.set(this.step+(b?-1:1)*this.stepSize);a.stop();},draggedKnob:function(){var b=this.range<0?-1:1,a=this.drag.value.now[this.axis];a=a.limit(-this.options.offset,this.full-this.options.offset); | ||
| this.step=Math.round(this.min+b*this.toStep(a));this.checkStep();},checkStep:function(){var a=this.step;if(this.previousChange!=a){this.previousChange=a; | ||
| this.fireEvent("change",a);}return this;},end:function(){var a=this.step;if(this.previousEnd!==a){this.previousEnd=a;this.fireEvent("complete",a+"");}return this; | ||
| },toStep:function(a){var b=(a+this.options.offset)*this.stepSize/this.full*this.steps;return this.options.steps?Math.round(b-=b%this.stepSize):b;},toPosition:function(a){return(this.full*Math.abs(this.min-a))/(this.steps*this.stepSize)-this.options.offset; | ||
| }}); |
| body { | ||
| background: #f3f3f3; | ||
| margin: 20px 30px; | ||
| max-width: 1000px; | ||
| } | ||
| body, input, select, textarea { | ||
| font: 100%/1.25 Helvetica, sans-serif; | ||
| } | ||
| .clear { clear: both; } | ||
| .clear:before, .clear:after { content: ""; display: table; } | ||
| .clear:after { clear: both; } | ||
| .clear{ zoom: 1; } | ||
| header, | ||
| section { | ||
| display: block; | ||
| float: left; | ||
| margin: 0.5em 1em; | ||
| padding: 0; | ||
| width: 250px; | ||
| } | ||
| #log, | ||
| #lug { | ||
| clear: both; | ||
| font-size: 81.25%; | ||
| height: 6em; | ||
| list-style: square; | ||
| margin: 0.5em 1em; | ||
| overflow-y: auto; | ||
| max-width: 750px; | ||
| } | ||
| hr { | ||
| border-color: #eee white white white; | ||
| clear: both; | ||
| margin: 2em; | ||
| max-width: 780px; | ||
| } | ||
| h1 { | ||
| font-size: 150%; | ||
| margin: 0 0 0.25em 0; | ||
| } | ||
| label { | ||
| -webkit-border-radius: 6px; | ||
| -moz-border-radius: 6px; | ||
| border-radius: 6px; | ||
| display: block; | ||
| margin: 0 0 0.25em 0; | ||
| padding: 0.25em 16px 2px; | ||
| } | ||
| label span { | ||
| display: block; | ||
| } | ||
| .group { | ||
| padding: 0 0.5em; | ||
| } | ||
| .group label { | ||
| float: left; | ||
| padding: 0.25em 0.5em 0; | ||
| } | ||
| .group label:last-child { | ||
| margin-right: 0; | ||
| } | ||
| header .group { | ||
| padding: 0 16px; | ||
| } | ||
| input { | ||
| height: 2em; | ||
| margin: 0 0 1em 0; | ||
| outline: none; | ||
| padding: 0; | ||
| width: 100%; | ||
| } | ||
| input::-webkit-input-placeholder { } | ||
| input[type=text] { | ||
| border: 1px solid #bbb; | ||
| border-spacing: 0; | ||
| display: block; | ||
| outline: none; | ||
| text-indent: 10px; | ||
| } | ||
| input[type=number] { | ||
| border: 1px solid #bbb; | ||
| display: block; | ||
| text-indent: 10px; | ||
| } | ||
| input[type=range] { | ||
| display: block; | ||
| height: auto; | ||
| margin: 0 0 0.5em 0; | ||
| width: 100%; | ||
| } | ||
| input[type=checkbox], | ||
| input[type=radio] { | ||
| height: auto; | ||
| margin: 0 0.375em 0 0; | ||
| position: relative; | ||
| top: -1px; | ||
| vertical-align: baseline; | ||
| width: auto; | ||
| } | ||
| select { | ||
| display: block; | ||
| margin: 0 0 1em 0; | ||
| outline: none; | ||
| width: 100%; | ||
| } | ||
| select[multiple=multiple] { | ||
| border: 1px solid #bbb; | ||
| display: block; | ||
| font-size: 81.25%; | ||
| height: 100px; | ||
| outline: none; | ||
| padding: 10px; | ||
| } | ||
| option[selected=selected] { | ||
| background: #fee; | ||
| } | ||
| textarea { | ||
| border: 1px solid #bbb; | ||
| border-spacing: 0; | ||
| display: block; | ||
| height: 80px; | ||
| margin: 0; | ||
| outline: none; | ||
| padding: 10px; | ||
| resize: none; | ||
| width: 198px; | ||
| } | ||
| .slider { | ||
| background: white; | ||
| -moz-box-shadow: inset 1px 1px -1px -1px #bbb; | ||
| -webkit-box-shadow: inset 0 0 1px 1px #bbb; | ||
| box-shadow: inset 0 0 1px 1px #bbb; | ||
| cursor: pointer; | ||
| height: 22px; | ||
| margin-bottom: 1em; | ||
| position: relative; | ||
| width: 100%; | ||
| } | ||
| .knob { | ||
| background: #bbb; | ||
| cursor: move; | ||
| height: 18px; | ||
| left: 2px; | ||
| position: absolute; | ||
| top: 2px; | ||
| width: 18px; | ||
| } | ||
| /* state stuff */ | ||
| textarea:focus { | ||
| resize: vertical; | ||
| } | ||
| input, | ||
| label, | ||
| select[multiple=multiple], | ||
| textarea { | ||
| -moz-transition: -moz-box-shadow 0.8s ease-in-out; | ||
| -webkit-transition: -webkit-box-shadow 0.8s ease-in-out; | ||
| transition: box-shadow 0.8s ease-in-out; | ||
| } | ||
| input:focus, | ||
| select[multiple=multiple]:focus, | ||
| textarea:focus, | ||
| input.updated, | ||
| select[multiple=multiple].updated, | ||
| textarea.updated { | ||
| -moz-transition: -moz-box-shadow 0.2s ease-in-out; | ||
| -webkit-transition: -webkit-box-shadow 0.2s ease-in-out; | ||
| transition: box-shadow 0.2s ease-in-out; | ||
| } | ||
| label { | ||
| -moz-transition: background 0.8s ease-in-out; | ||
| -webkit-transition: background 0.8s ease-in-out; | ||
| transition: background 0.8s ease-in-out; | ||
| } | ||
| label.updated { | ||
| -moz-transition: background 0.2s ease-in-out; | ||
| -webkit-transition: background 0.2s ease-in-out; | ||
| transition: background 0.2s ease-in-out; | ||
| } | ||
| input, | ||
| select[multiple=multiple], | ||
| textarea { | ||
| -moz-box-shadow: 0 0 10px rgb(255, 255, 255); | ||
| -webkit-box-shadow: 0 0 10px rgb(255, 255, 255); | ||
| box-shadow: 0 0 10px rgb(255, 255, 255); | ||
| } | ||
| input:focus, | ||
| select[multiple=multiple]:focus, | ||
| textarea:focus { | ||
| border-color: transparent; | ||
| -moz-box-shadow: 0 0 10px rgb(0, 166, 222); | ||
| -webkit-box-shadow: 0 0 10px rgb(0, 166, 222); | ||
| box-shadow: 0 0 10px rgb(0, 166, 222); | ||
| } | ||
| input.locked, | ||
| select[multiple=multiple].locked, | ||
| textarea.locked { | ||
| border-color: transparent; | ||
| -moz-box-shadow: 0 0 10px rgb(255, 0, 0); | ||
| -webkit-box-shadow: 0 0 10px rgb(255, 0, 0); | ||
| box-shadow: 0 0 10px rgb(255, 0, 0); | ||
| } | ||
| input.updated, | ||
| select[multiple=multiple].updated, | ||
| textarea.updated { | ||
| border-color: transparent; | ||
| -moz-box-shadow: 0 0 10px rgb(255, 255, 0); | ||
| -webkit-box-shadow: 0 0 10px rgb(255, 255, 0); | ||
| box-shadow: 0 0 10px rgb(255, 255, 0); | ||
| } | ||
| label.updated { | ||
| background: rgb(255, 255, 0); | ||
| } | ||
| <!doctype html> | ||
| <meta charset="utf-8"> | ||
| <title>Cooking Recipe</title> | ||
| <link rel=stylesheet href="assets/styles.css"> | ||
| <header> | ||
| <div class=group> | ||
| <h1>Cooking Recipe</h1> | ||
| <p>Powered by Planet</p> | ||
| </div> | ||
| </header> | ||
| <section> | ||
| <div class="group clear"> | ||
| <label><input type=checkbox name=spice value=pepper>Pepper</label> | ||
| <label><input type=checkbox name=spice value=cinnamon>Cinnamon</label> | ||
| <label><input type=checkbox name=spice value=cumin>Cumin</label> | ||
| </div> | ||
| </section> | ||
| <section> | ||
| <div class="group clear"> | ||
| <label><input type=radio name=herb value=basil>Basil</label> | ||
| <label><input type=radio name=herb value=coriander>Coriander</label> | ||
| <label><input type=radio name=herb value=rosemary>Rosemary</label> | ||
| </div> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Select</span> | ||
| <select name=device> | ||
| <option>Grill</option> | ||
| <option>Microwave</option> | ||
| <option>Oven</option> | ||
| <option>Stove</option> | ||
| </select> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Text</span><input type=text name=specials placeholder=empty> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Number</span><input type=number name=amount min=1 max=1000 step="0.1" value=6> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Textarea</span><textarea name=formula></textarea> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Multiple Select</span> | ||
| <select name=ingredients multiple=multiple> | ||
| <optgroup label=Meat> | ||
| <option value=beaf>Beaf</option> | ||
| <option value=chicken>Chicken</option> | ||
| <option value=fish>Fish</option> | ||
| <option value=pork>Pork</option> | ||
| </optgroup> | ||
| <optgroup label=Vegetable> | ||
| <option value=corn>Corn</option> | ||
| <option value=patatos>Patatos</option> | ||
| <option value=rice>Rice</option> | ||
| <option value=tofu>Tofu</option> | ||
| </optgroup> | ||
| </select> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Range (HTML5)</span><input type=range name=temperature min=50 max=300 value=100> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Slider (JavaScript)</span> | ||
| <div id=slider class=slider><div id=knob class=knob></div></div> | ||
| </label> | ||
| </section> | ||
| <section class=clear> | ||
| <label> | ||
| <input type=reset> | ||
| </labe> | ||
| </section> | ||
| <hr> | ||
| <ul id=log></ul> | ||
| <hr> | ||
| <ul id=lug></ul> | ||
| <script src="socket.io/socket.io.js"></script> | ||
| <script src="assets/mootools-core-1.4.5-full-nocompat-yc.js"></script> | ||
| <script src="assets/mootools-more-1.4.0.1.js"></script> | ||
| <script> | ||
| if (!this.io) new Element('li[text="Could not connect to server!"]').inject('log'); | ||
| var socket = io.connect('//:8004'); | ||
| // log: | ||
| socket.on('connecting', function(transport){ | ||
| new Element('li', { | ||
| text: 'Connecting with ' + transport | ||
| }).inject('log', 'top'); | ||
| }); | ||
| socket.on('connect', function(){ | ||
| new Element('li[text="Connected!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('disconnect', function(){ | ||
| new Element('li[text="Disconnected!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('connect_failed', function(){ | ||
| new Element('li[text="Connect failed!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('error', function(){ | ||
| new Element('li[text="Error!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('reconnecting', function(delay, attempts){ | ||
| new Element('li', { | ||
| text: 'Reconnecting (' + delay + ' ' + attempts + ')' | ||
| }).inject('log', 'top'); | ||
| }); | ||
| socket.on('reconnect', function(transport, attempts){ | ||
| new Element('li', { | ||
| text: 'Reconnected (' + transport + ' ' + attempts + ')!' | ||
| }).inject('log', 'top'); | ||
| }); | ||
| socket.on('reconnect_failed', function(){ | ||
| new Element('li[text="Reconnect failed!"]').inject('log', 'top'); | ||
| }); | ||
| // lug: | ||
| socket.on('get', function(data){ | ||
| new Element('li', { | ||
| text: 'get: ' + key + ' ' + JSON.stringify(value) | ||
| }).inject('lug', 'top'); | ||
| }); | ||
| socket.on('set', function(data){ | ||
| new Element('li', { | ||
| text: 'set: ' + JSON.stringify(data) | ||
| }).inject('lug', 'top'); | ||
| }); | ||
| socket.on('merge', function(key, value){ | ||
| new Element('li', { | ||
| text: 'merge: ' + JSON.stringify(data) | ||
| }).inject('lug', 'top'); | ||
| }); | ||
| </script> | ||
| <script src="scripts/input.js"></script> | ||
| <script src="scripts/input-checkbox.js"></script> | ||
| <script src="scripts/input-radio.js"></script> | ||
| <script src="scripts/select.js"></script> | ||
| <script src="scripts/slider.js"></script> | ||
| <script src="scripts/input-reset.js"></script> |
| $$('input[type=checkbox]').each(function(checkbox){ | ||
| var component = checkbox.get('name') + '.' + checkbox.get('value'); | ||
| checkbox.addEvent('change', function(){ | ||
| socket.emit('set', component, this.get('checked')); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == component){ | ||
| checkbox.set('checked', value); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(checked){ | ||
| checkbox.set('checked', checked); | ||
| }); | ||
| }); |
| (function(){ | ||
| var radios = $$('input[type=radio][name=herb]'), | ||
| values = radios.get('value'); | ||
| radios.addEvent('change', function(){ | ||
| socket.emit('set', 'herb', this.get('value')); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == 'herb'){ | ||
| radios[values.indexOf(value)].set('checked', true); | ||
| } | ||
| }); | ||
| socket.emit('get', 'herb', function(herb){ | ||
| if (herb != null){ | ||
| radios[values.indexOf(herb)].set('checked', true); | ||
| } | ||
| }); | ||
| })(); |
| $$('input[type=reset]').addEvent('click', function(e){ | ||
| e.stop(); | ||
| socket.emit('delete'); | ||
| location.reload(true); | ||
| }); |
| $$('input[type=text], input[type=number], input[type=range], textarea').each(function(input){ | ||
| var component = input.get('tag') + '.' + input.get('name'); | ||
| input.addEvent('change', function(){ | ||
| socket.emit('set', component, this.get('value')); | ||
| }); | ||
| if (input.get('tag') == 'textarea') input.addEvent('keyup', function(){ | ||
| input.fireEvent('change'); | ||
| }); | ||
| if (input.get('type') == 'text') input.addEvent('keyup', function(){ | ||
| input.fireEvent('change'); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == component){ | ||
| input.set('value', value); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(value){ | ||
| if (value != null){ | ||
| input.set('value', value); | ||
| } | ||
| }); | ||
| }); |
| $$('select:not([multiple])').each(function(select){ | ||
| var component = select.get('name'); | ||
| select.addEvent('change', function(){ | ||
| socket.emit('set', component, select.get('value')); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == component){ | ||
| select.set('value', value); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(value){ | ||
| if (value != null){ | ||
| select.set('value', value); | ||
| } | ||
| }); | ||
| }); | ||
| $$('select[multiple]').each(function(select){ | ||
| var component = select.get('name'), | ||
| options = select.getElements('option'); | ||
| select.addEvent('change', function(){ | ||
| socket.emit('set', component, options.get('selected')); | ||
| }); | ||
| socket.on('set', function(key, values){ | ||
| if (key == component){ | ||
| values.each(function(value, i){ | ||
| options[i].set('selected', value); | ||
| }); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(values){ | ||
| if (values != null){ | ||
| values.each(function(value, i){ | ||
| options[i].set('selected', value); | ||
| }); | ||
| } | ||
| }); | ||
| }); |
| (function(){ | ||
| var mySlider = new Slider('slider', 'knob', { | ||
| offset: -2 | ||
| }); | ||
| mySlider.addEvent('change', function(step){ | ||
| socket.emit('set', 'slider', step); | ||
| }); | ||
| mySlider.element.addEvent('mousedown', function(){ | ||
| socket.emit('set', 'slider', mySlider.step); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == 'slider'){ | ||
| mySlider.setKnobPosition(mySlider.toPosition(value)); | ||
| mySlider.step = value; | ||
| } | ||
| }); | ||
| socket.emit('get', 'slider', function(value){ | ||
| mySlider.setKnobPosition(mySlider.toPosition(value)); | ||
| mySlider.step = value; | ||
| }); | ||
| })(); |
| console.log('node', process.version); | ||
| // server | ||
| (function(){ | ||
| var io = require('socket.io'); | ||
| console.log('socket.io', io.version); | ||
| var socket = io.listen(8080, { | ||
| 'log level': 1 | ||
| }); | ||
| socket.sockets.on('connection', function(socket){ | ||
| console.log('server: new connection'); | ||
| }); | ||
| })(); | ||
| // client | ||
| (function(){ | ||
| var io = require('socket.io-client'); | ||
| console.log('socket.io-client', io.version); | ||
| io.connect('//:8080', { | ||
| 'force new connection': true | ||
| , 'transports': ['websocket'] | ||
| , 'connect timeout': 1000 | ||
| , 'try multiple transports': false | ||
| , 'reconnect': false | ||
| }) | ||
| .on('connecting', function(transport_type){ | ||
| console.log('client: connecting', transport_type); | ||
| }) | ||
| .on('connect', function(){ | ||
| console.log('client: connect'); | ||
| }) | ||
| .on('connect_failed', function(){ | ||
| console.log('client: connect_failed'); | ||
| }) | ||
| .on('disconnect', function(){ | ||
| console.log('client: disconnect'); | ||
| }) | ||
| .on('error', function(error){ | ||
| console.log('client: error', error); | ||
| }); | ||
| })(); |
| var io = require('socket.io-client'); | ||
| console.log('socket.io-client', io.version); | ||
| var socket = io.connect('http://localhost:12398', { | ||
| 'force new connection': true | ||
| , 'transports': ['websocket'] | ||
| , 'connect timeout': 1000 | ||
| , 'try multiple transports': false | ||
| , 'reconnect': false | ||
| }); | ||
| socket.on('connect', function(){ | ||
| console.log('client: connect'); | ||
| }) | ||
| .on('connecting', function(transport_type){ | ||
| console.log('client: connecting', transport_type); | ||
| }) | ||
| .on('ready', function(){ | ||
| console.log('client: ready'); | ||
| }) | ||
| .on('connect_failed', function(){ | ||
| console.log('client: connect_failed'); | ||
| }) | ||
| .on('disconnect', function(){ | ||
| console.log('client: disconnect'); | ||
| }) | ||
| .on('error', function(error){ | ||
| console.log('client: error', error); | ||
| }); |
| console.log('node', process.version); | ||
| console.log('socket.io', require('socket.io').version); | ||
| var io = require('socket.io').listen(12398, { | ||
| 'log level': 1 | ||
| }); | ||
| io.sockets.on('connection', function(socket){ | ||
| console.log('server: new connection'); | ||
| socket.emit('ready'); | ||
| }); |
+7
-6
| { | ||
| "name": "planet" | ||
| , "version": "0.14.5" | ||
| , "version": "0.14.6" | ||
| , "author": "Enrique Erne (http://mild.ch/)" | ||
@@ -25,9 +25,10 @@ , "description": "collaboratively edit anything" | ||
| , "dependencies": { | ||
| "socket.io": "= 0.9.13" | ||
| , "optimist": ">= 0.3.5" | ||
| "socket.io": "= 0.9.16" | ||
| , "optimist": ">= 0.6.0" | ||
| } | ||
| , "devDependencies": { | ||
| "socket.io-client": "= 0.9.11" | ||
| , "mocha": ">= 1.8.2" | ||
| "socket.io-client": "= 0.9.16" | ||
| , "mocha": ">= 1.12.0" | ||
| , "expect.js": "0.2.0" | ||
| , "wrapup": "0.12.1" | ||
| , "benchmark": ">= 1.0.0" | ||
@@ -37,3 +38,3 @@ } | ||
| "type": "MIT" | ||
| , "url": "https://raw.github.com/thisconnect/planet/master/LICENSE" | ||
| , "url": "https://raw.github.com/thisconnect/planet/master/license" | ||
| }] | ||
@@ -40,0 +41,0 @@ , "bugs": { |
+10
-8
@@ -70,3 +70,3 @@ # Planet | ||
| ```bash | ||
| node examples/server.js | ||
| node test/example | ||
| ``` | ||
@@ -352,3 +352,3 @@ | ||
| To run Planet form a command-line interface install | ||
| To run `planet` form a command-line interface install | ||
| Planet globally `npm install planet -g` | ||
@@ -370,5 +370,7 @@ or `cd bin && ./planet`. | ||
| [Socket.IO configuration](https://github.com/LearnBoost/Socket.IO/wiki/Configuring-Socket.IO) | ||
| for example: `--io.transports=websocket,htmlfile` or | ||
| `--no-io.browser-client-cache`. Note the dot notation. Dashes after | ||
| io. will be replaced by whitespace. | ||
| for example: | ||
| `--io.transports=websocket,htmlfile` | ||
| `--no-io.browser-client-cache` | ||
| Note the dot notation and that dashes after --io. will | ||
| be replaced by whitespace to match Socket.IO configs. | ||
@@ -384,3 +386,3 @@ - `-v`, `--version` - Prints the current version. | ||
| ```bash | ||
| ```make | ||
| #test server api | ||
@@ -405,3 +407,3 @@ make test-server | ||
| ```bash | ||
| node bench/run.js | ||
| node test/benchmark | ||
| ``` | ||
@@ -426,3 +428,3 @@ | ||
| - [Socket.IO](http://socket.io/) 0.9.x | ||
| - Optparse-js 1.0.x | ||
| - Optimist 0.4.x | ||
+22
-12
| @charset "utf-8"; | ||
| body { | ||
| margin:0; | ||
| } | ||
| #mocha { | ||
| font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
| padding: 60px 50px; | ||
| margin: 60px 50px; | ||
| } | ||
@@ -41,3 +45,3 @@ | ||
| .hidden { | ||
| #mocha .hidden { | ||
| display: none; | ||
@@ -63,3 +67,3 @@ } | ||
| content: '(pending)'; | ||
| font-family: arial; | ||
| font-family: arial, sans-serif; | ||
| } | ||
@@ -190,3 +194,3 @@ | ||
| color: #c00; | ||
| font-size: 1.5 em; | ||
| font-size: 1.5em; | ||
| font-weight: 100; | ||
@@ -203,2 +207,3 @@ letter-spacing: 1px; | ||
| color: #888; | ||
| z-index: 1; | ||
| } | ||
@@ -231,16 +236,21 @@ | ||
| code .comment { color: #ddd } | ||
| code .init { color: #2F6FAD } | ||
| code .string { color: #5890AD } | ||
| code .keyword { color: #8A6343 } | ||
| code .number { color: #2F6FAD } | ||
| #mocha-stats canvas { | ||
| width: 40px; | ||
| height: 40px; | ||
| } | ||
| #mocha code .comment { color: #ddd } | ||
| #mocha code .init { color: #2F6FAD } | ||
| #mocha code .string { color: #5890AD } | ||
| #mocha code .keyword { color: #8A6343 } | ||
| #mocha code .number { color: #2F6FAD } | ||
| @media screen and (max-device-width: 480px) { | ||
| body { | ||
| padding: 60px 0px; | ||
| #mocha { | ||
| margin: 60px 0px; | ||
| } | ||
| #stats { | ||
| #mocha #stats { | ||
| position: absolute; | ||
| } | ||
| } |
@@ -56,14 +56,47 @@ var expect = require('expect.js'); | ||
| it('should start planet without a http server', function(done){ | ||
| it('should start planet and connect with a client', function(done){ | ||
| var socket = io.listen(8103, { | ||
| 'log level': 1 | ||
| var server = http.createServer(), | ||
| socket = io.listen(server, {'log level': 1}); | ||
| var mars = planet(socket); | ||
| expect(mars).to.be.a(planet); | ||
| mars.on('listening', function(location, port){ | ||
| expect(port).to.be(8102); | ||
| require('socket.io-client') | ||
| .connect('//:8102', { | ||
| 'force new connection': true | ||
| }) | ||
| .on('connect_failed', function(){ | ||
| console.log('connect_failed'); | ||
| }) | ||
| .on('connect', function(){ | ||
| this.disconnect(); | ||
| }) | ||
| .on('disconnect', function(){ | ||
| mars.destroy(); | ||
| server.close(); | ||
| done(); | ||
| }); | ||
| }); | ||
| server.listen(8102, 'localhost'); | ||
| }); | ||
| it('should start planet without a http server and connect with a client', function(done){ | ||
| var socket = io.listen(8103, {'log level': 1}); | ||
| planet(socket) | ||
| .on('listening', function(location, port){ | ||
| expect(port).to.be(8103); | ||
| require('socket.io-client') | ||
| .connect('//:8103') | ||
| .connect('//:8103', { | ||
| 'force new connection': true | ||
| }) | ||
| .on('connect', function(){ | ||
@@ -70,0 +103,0 @@ this.disconnect(); |
| var Benchmark = require('benchmark'); | ||
| module.exports = function(client, options){ | ||
| var maxTime = options.maxTime; | ||
| return Benchmark.Suite() | ||
| .on('cycle', function(cycle){ | ||
| console.log(String(cycle.target)); | ||
| }) | ||
| .add('Client.emit.set - array path number', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'onStart': function(){ | ||
| client.on('set', function(){ | ||
| client.deferred.resolve(); | ||
| }); | ||
| }, | ||
| 'fn': function(deferred){ | ||
| client.deferred = deferred; | ||
| client.emit('set', ['b', 0, 0, 0, 0, 0], 3); | ||
| }, | ||
| 'onComplete': function(){ | ||
| delete client.deferred; | ||
| client.removeAllListeners('set'); | ||
| } | ||
| }) | ||
| .add('Client.emit.merge - complex object', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'onStart': function(){ | ||
| client.on('merge', function(){ | ||
| client.deferred.resolve(); | ||
| }); | ||
| }, | ||
| 'fn': function(deferred){ | ||
| client.deferred = deferred; | ||
| client.emit('merge', { | ||
| key: 'foo', | ||
| a: { b: { c: { d: { e: 1 } } } }, | ||
| b: [[[[[1]]]]] | ||
| }); | ||
| }, | ||
| 'onComplete': function(){ | ||
| delete client.deferred; | ||
| client.removeAllListeners('merge'); | ||
| } | ||
| }) | ||
| .add('Client.emit.get - path', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| client.emit('get', ['a', 'b', 'c', 'd', 'e'], function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Client.emit.get - path array', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| client.emit('get', ['b', 0, 0, 0, 0, 0], function(value){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }); | ||
| }; |
| var Benchmark = require('benchmark'); | ||
| module.exports = function(planet, options){ | ||
| var maxTime = options.maxTime; | ||
| return Benchmark.Suite() | ||
| .on('cycle', function(cycle){ | ||
| console.log(String(cycle.target)); | ||
| }) | ||
| .add('Server.set - key string', { | ||
| 'maxTime': maxTime, | ||
| 'onStart': function(){ | ||
| console.log('Set:'); | ||
| }, | ||
| 'fn': function(){ | ||
| planet.set('key', 'bar'); | ||
| } | ||
| }) | ||
| .add('Server.set - path number', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.set(['a', 'b', 'c', 'd', 'e'], 2); | ||
| } | ||
| }) | ||
| .add('Server.set - key nested array', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.set('b', [[[[[2]]]]]); | ||
| } | ||
| }) | ||
| .add('Server.set - array path number', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.set(['b', 0, 0, 0, 0, 0], 3); | ||
| } | ||
| }) | ||
| .add('Server.merge - simple object', { | ||
| 'maxTime': maxTime, | ||
| 'onStart': function(){ | ||
| console.log('Merge:'); | ||
| }, | ||
| 'fn': function(){ | ||
| planet.merge({ key: 'value'}); | ||
| } | ||
| }) | ||
| .add('Server.merge - nested object', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.merge({ a: { b: { c: { d: { e: 0 } } } } }); | ||
| } | ||
| }) | ||
| .add('Server.merge - complex object', { | ||
| 'maxTime': maxTime, | ||
| 'fn': function(){ | ||
| planet.merge({ | ||
| key: 'foo', | ||
| a: { b: { c: { d: { e: 1 } } } }, | ||
| b: [[[[[1]]]]] | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - complete state', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'onStart': function(){ | ||
| console.log('Get:'); | ||
| }, | ||
| 'fn': function(deferred){ | ||
| planet.get(function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - key', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| planet.get('key', function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - path', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| planet.get(['a', 'b', 'c', 'd', 'e'], function(){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }) | ||
| .add('Server.get - path array', { | ||
| 'maxTime': maxTime, | ||
| 'defer': true, | ||
| 'fn': function(deferred){ | ||
| planet.get(['b', 0, 0, 0, 0, 0], function(value){ | ||
| deferred.resolve(); | ||
| }); | ||
| } | ||
| }); | ||
| }; |
| var dummy = require('./dummy'); | ||
| for (var i = 0; ++i <= process.argv[2];) (dummy)(i); | ||
| /* | ||
| var dummies = []; | ||
| for (var i = 0; ++i <= process.argv[2];){ | ||
| dummies.push(dummy(i)); | ||
| } | ||
| process.on('exit', function(){ | ||
| for (var i = 0, len = dummies.length; i < len; i++){ | ||
| console.log(dummies[i].socket.connected); | ||
| if (dummies[i].socket.connected) dummies[i].disconnect(); | ||
| } | ||
| }); | ||
| */ |
| var io = require('socket.io-client'); | ||
| module.exports = function(i){ | ||
| var socket = io.connect(process.argv[3] || '//:8004', { | ||
| 'force new connection': 1, | ||
| 'try multiple transports': false, | ||
| 'reconnect': false | ||
| }); | ||
| socket.on('connect', function(){ | ||
| console.log(i); | ||
| }); | ||
| socket.on('connect_failed', function(){}); | ||
| socket.on('error', function(){}); | ||
| //socket.emit('get', function(data){}); | ||
| socket.on('set', function(){}); | ||
| socket.on('merge', function(){}); | ||
| socket.on('remove', function(){}); | ||
| socket.on('delete', function(){}); | ||
| socket.on('disconnect', function(){}); | ||
| /* | ||
| socket.on('disconnect', function(){ | ||
| process.exit(0); | ||
| }); | ||
| // Errors | ||
| socket.on('connect_failed', function(){ | ||
| process.stderr.write('ERROR (connect_failed)! \n'); | ||
| process.exit(1); | ||
| }); | ||
| socket.on('error', function(){ | ||
| process.stderr.write('ERROR! \n'); | ||
| process.exit(1); | ||
| }); | ||
| // process.exit(0); // success = 0, error = 1 | ||
| */ | ||
| return socket; | ||
| } |
-65
| var Planet = require('../'), | ||
| socket = require('socket.io').listen(8082, { | ||
| 'log level': 1 | ||
| }), | ||
| io = require('socket.io-client'), | ||
| spawn = require('child_process').spawn; | ||
| var planet = Planet(socket, { | ||
| limit: 100 | ||
| }); | ||
| planet.on('listening', function(){ | ||
| var client = io.connect('//:8082', { | ||
| 'force new connection': true | ||
| }); | ||
| var options = { | ||
| maxTime: 4 | ||
| }; | ||
| require('./bench.client')(client, options).on('complete', function(){ | ||
| client.disconnect(); | ||
| require('./bench.server')(planet, options).on('complete', function(){ | ||
| var count = 0, | ||
| dummies = spawn('node', [__dirname + '/dummies.js', 99, '//:8082']); | ||
| process.on('exit', function(){ | ||
| dummies.kill(); | ||
| }); | ||
| dummies.stderr.on('data', function(error){ console.log('ERROR!!', error.toString()); }); | ||
| dummies.stdout.setEncoding('utf8'); | ||
| dummies.stdout.on('data', function(data){ | ||
| count += data.trim().split('\n').length; | ||
| if (count < 99) return; | ||
| console.log('\n', 'Connect 99 dummy clients', '\n'); | ||
| client = io.connect('//:8082', { | ||
| 'force new connection': true | ||
| }); | ||
| require('./bench.client')(client, options).on('complete', function(){ | ||
| client.disconnect(); | ||
| require('./bench.server')(planet, options).on('complete', function(){ | ||
| planet.get(function(data){ | ||
| // console.log(JSON.stringify(data)); | ||
| process.exit(); | ||
| }); | ||
| }) | ||
| .run(); | ||
| }) | ||
| .run(); | ||
| }); | ||
| }) | ||
| .run(); | ||
| }) | ||
| .run(); | ||
| }); |
Sorry, the diff of this file is too big to display
| // MooTools: the javascript framework. | ||
| // Load this file's selection again by visiting: http://mootools.net/more/3646a687e12fabf03bf92a18afb69a22 | ||
| // Or build this file again with packager using: packager build More/Element.Event.Pseudos.Keys More/Slider | ||
| /* | ||
| --- | ||
| copyrights: | ||
| - [MooTools](http://mootools.net) | ||
| licenses: | ||
| - [MIT License](http://mootools.net/license.txt) | ||
| ... | ||
| */ | ||
| MooTools.More={version:"1.4.0.1",build:"a4244edf2aa97ac8a196fc96082dd35af1abab87"};(function(){Events.Pseudos=function(h,e,f){var d="_monitorEvents:";var c=function(i){return{store:i.store?function(j,k){i.store(d+j,k); | ||
| }:function(j,k){(i._monitorEvents||(i._monitorEvents={}))[j]=k;},retrieve:i.retrieve?function(j,k){return i.retrieve(d+j,k);}:function(j,k){if(!i._monitorEvents){return k; | ||
| }return i._monitorEvents[j]||k;}};};var g=function(k){if(k.indexOf(":")==-1||!h){return null;}var j=Slick.parse(k).expressions[0][0],p=j.pseudos,i=p.length,o=[]; | ||
| while(i--){var n=p[i].key,m=h[n];if(m!=null){o.push({event:j.tag,value:p[i].value,pseudo:n,original:k,listener:m});}}return o.length?o:null;};return{addEvent:function(m,p,j){var n=g(m); | ||
| if(!n){return e.call(this,m,p,j);}var k=c(this),r=k.retrieve(m,[]),i=n[0].event,l=Array.slice(arguments,2),o=p,q=this;n.each(function(s){var t=s.listener,u=o; | ||
| if(t==false){i+=":"+s.pseudo+"("+s.value+")";}else{o=function(){t.call(q,s,u,arguments,o);};}});r.include({type:i,event:p,monitor:o});k.store(m,r);if(m!=i){e.apply(this,[m,p].concat(l)); | ||
| }return e.apply(this,[i,o].concat(l));},removeEvent:function(m,l){var k=g(m);if(!k){return f.call(this,m,l);}var n=c(this),j=n.retrieve(m);if(!j){return this; | ||
| }var i=Array.slice(arguments,2);f.apply(this,[m,l].concat(i));j.each(function(o,p){if(!l||o.event==l){f.apply(this,[o.type,o.monitor].concat(i));}delete j[p]; | ||
| },this);n.store(m,j);return this;}};};var b={once:function(e,f,d,c){f.apply(this,d);this.removeEvent(e.event,c).removeEvent(e.original,f);},throttle:function(d,e,c){if(!e._throttled){e.apply(this,c); | ||
| e._throttled=setTimeout(function(){e._throttled=false;},d.value||250);}},pause:function(d,e,c){clearTimeout(e._pause);e._pause=e.delay(d.value||250,this,c); | ||
| }};Events.definePseudo=function(c,d){b[c]=d;return this;};Events.lookupPseudo=function(c){return b[c];};var a=Events.prototype;Events.implement(Events.Pseudos(b,a.addEvent,a.removeEvent)); | ||
| ["Request","Fx"].each(function(c){if(this[c]){this[c].implement(Events.prototype);}});})();(function(){var d={relay:false},c=["once","throttle","pause"],b=c.length; | ||
| while(b--){d[c[b]]=Events.lookupPseudo(c[b]);}DOMEvent.definePseudo=function(e,f){d[e]=f;return this;};var a=Element.prototype;[Element,Window,Document].invoke("implement",Events.Pseudos(d,a.addEvent,a.removeEvent)); | ||
| })();(function(){var a="$moo:keys-pressed",b="$moo:keys-keyup";DOMEvent.definePseudo("keys",function(d,e,c){var g=c[0],f=[],h=this.retrieve(a,[]);f.append(d.value.replace("++",function(){f.push("+"); | ||
| return"";}).split("+"));h.include(g.key);if(f.every(function(j){return h.contains(j);})){e.apply(this,c);}this.store(a,h);if(!this.retrieve(b)){var i=function(j){(function(){h=this.retrieve(a,[]).erase(j.key); | ||
| this.store(a,h);}).delay(0,this);};this.store(b,i).addEvent("keyup",i);}});DOMEvent.defineKeys({"16":"shift","17":"control","18":"alt","20":"capslock","33":"pageup","34":"pagedown","35":"end","36":"home","144":"numlock","145":"scrolllock","186":";","187":"=","188":",","190":".","191":"/","192":"`","219":"[","220":"\\","221":"]","222":"'","107":"+"}).defineKey(Browser.firefox?109:189,"-"); | ||
| })();Class.Mutators.Binds=function(a){if(!this.prototype.initialize){this.implement("initialize",function(){});}return Array.from(a).concat(this.prototype.Binds||[]); | ||
| };Class.Mutators.initialize=function(a){return function(){Array.from(this.Binds).each(function(b){var c=this[b];if(c){this[b]=c.bind(this);}},this);return a.apply(this,arguments); | ||
| };};var Drag=new Class({Implements:[Events,Options],options:{snap:6,unit:"px",grid:false,style:true,limit:false,handle:false,invert:false,preventDefault:false,stopPropagation:false,modifiers:{x:"left",y:"top"}},initialize:function(){var b=Array.link(arguments,{options:Type.isObject,element:function(c){return c!=null; | ||
| }});this.element=document.id(b.element);this.document=this.element.getDocument();this.setOptions(b.options||{});var a=typeOf(this.options.handle);this.handles=((a=="array"||a=="collection")?$$(this.options.handle):document.id(this.options.handle))||this.element; | ||
| this.mouse={now:{},pos:{}};this.value={start:{},now:{}};this.selection=(Browser.ie)?"selectstart":"mousedown";if(Browser.ie&&!Drag.ondragstartFixed){document.ondragstart=Function.from(false); | ||
| Drag.ondragstartFixed=true;}this.bound={start:this.start.bind(this),check:this.check.bind(this),drag:this.drag.bind(this),stop:this.stop.bind(this),cancel:this.cancel.bind(this),eventStop:Function.from(false)}; | ||
| this.attach();},attach:function(){this.handles.addEvent("mousedown",this.bound.start);return this;},detach:function(){this.handles.removeEvent("mousedown",this.bound.start); | ||
| return this;},start:function(a){var j=this.options;if(a.rightClick){return;}if(j.preventDefault){a.preventDefault();}if(j.stopPropagation){a.stopPropagation(); | ||
| }this.mouse.start=a.page;this.fireEvent("beforeStart",this.element);var c=j.limit;this.limit={x:[],y:[]};var e,g;for(e in j.modifiers){if(!j.modifiers[e]){continue; | ||
| }var b=this.element.getStyle(j.modifiers[e]);if(b&&!b.match(/px$/)){if(!g){g=this.element.getCoordinates(this.element.getOffsetParent());}b=g[j.modifiers[e]]; | ||
| }if(j.style){this.value.now[e]=(b||0).toInt();}else{this.value.now[e]=this.element[j.modifiers[e]];}if(j.invert){this.value.now[e]*=-1;}this.mouse.pos[e]=a.page[e]-this.value.now[e]; | ||
| if(c&&c[e]){var d=2;while(d--){var f=c[e][d];if(f||f===0){this.limit[e][d]=(typeof f=="function")?f():f;}}}}if(typeOf(this.options.grid)=="number"){this.options.grid={x:this.options.grid,y:this.options.grid}; | ||
| }var h={mousemove:this.bound.check,mouseup:this.bound.cancel};h[this.selection]=this.bound.eventStop;this.document.addEvents(h);},check:function(a){if(this.options.preventDefault){a.preventDefault(); | ||
| }var b=Math.round(Math.sqrt(Math.pow(a.page.x-this.mouse.start.x,2)+Math.pow(a.page.y-this.mouse.start.y,2)));if(b>this.options.snap){this.cancel();this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop}); | ||
| this.fireEvent("start",[this.element,a]).fireEvent("snap",this.element);}},drag:function(b){var a=this.options;if(a.preventDefault){b.preventDefault(); | ||
| }this.mouse.now=b.page;for(var c in a.modifiers){if(!a.modifiers[c]){continue;}this.value.now[c]=this.mouse.now[c]-this.mouse.pos[c];if(a.invert){this.value.now[c]*=-1; | ||
| }if(a.limit&&this.limit[c]){if((this.limit[c][1]||this.limit[c][1]===0)&&(this.value.now[c]>this.limit[c][1])){this.value.now[c]=this.limit[c][1];}else{if((this.limit[c][0]||this.limit[c][0]===0)&&(this.value.now[c]<this.limit[c][0])){this.value.now[c]=this.limit[c][0]; | ||
| }}}if(a.grid[c]){this.value.now[c]-=((this.value.now[c]-(this.limit[c][0]||0))%a.grid[c]);}if(a.style){this.element.setStyle(a.modifiers[c],this.value.now[c]+a.unit); | ||
| }else{this.element[a.modifiers[c]]=this.value.now[c];}}this.fireEvent("drag",[this.element,b]);},cancel:function(a){this.document.removeEvents({mousemove:this.bound.check,mouseup:this.bound.cancel}); | ||
| if(a){this.document.removeEvent(this.selection,this.bound.eventStop);this.fireEvent("cancel",this.element);}},stop:function(b){var a={mousemove:this.bound.drag,mouseup:this.bound.stop}; | ||
| a[this.selection]=this.bound.eventStop;this.document.removeEvents(a);if(b){this.fireEvent("complete",[this.element,b]);}}});Element.implement({makeResizable:function(a){var b=new Drag(this,Object.merge({modifiers:{x:"width",y:"height"}},a)); | ||
| this.store("resizer",b);return b.addEvent("drag",function(){this.fireEvent("resize",b);}.bind(this));}});(function(){var b=function(e,d){var f=[];Object.each(d,function(g){Object.each(g,function(h){e.each(function(i){f.push(i+"-"+h+(i=="border"?"-width":"")); | ||
| });});});return f;};var c=function(f,e){var d=0;Object.each(e,function(h,g){if(g.test(f)){d=d+h.toInt();}});return d;};var a=function(d){return !!(!d||d.offsetHeight||d.offsetWidth); | ||
| };Element.implement({measure:function(h){if(a(this)){return h.call(this);}var g=this.getParent(),e=[];while(!a(g)&&g!=document.body){e.push(g.expose()); | ||
| g=g.getParent();}var f=this.expose(),d=h.call(this);f();e.each(function(i){i();});return d;},expose:function(){if(this.getStyle("display")!="none"){return function(){}; | ||
| }var d=this.style.cssText;this.setStyles({display:"block",position:"absolute",visibility:"hidden"});return function(){this.style.cssText=d;}.bind(this); | ||
| },getDimensions:function(d){d=Object.merge({computeSize:false},d);var i={x:0,y:0};var h=function(j,e){return(e.computeSize)?j.getComputedSize(e):j.getSize(); | ||
| };var f=this.getParent("body");if(f&&this.getStyle("display")=="none"){i=this.measure(function(){return h(this,d);});}else{if(f){try{i=h(this,d);}catch(g){}}}return Object.append(i,(i.x||i.x===0)?{width:i.x,height:i.y}:{x:i.width,y:i.height}); | ||
| },getComputedSize:function(d){d=Object.merge({styles:["padding","border"],planes:{height:["top","bottom"],width:["left","right"]},mode:"both"},d);var g={},e={width:0,height:0},f; | ||
| if(d.mode=="vertical"){delete e.width;delete d.planes.width;}else{if(d.mode=="horizontal"){delete e.height;delete d.planes.height;}}b(d.styles,d.planes).each(function(h){g[h]=this.getStyle(h).toInt(); | ||
| },this);Object.each(d.planes,function(i,h){var k=h.capitalize(),j=this.getStyle(h);if(j=="auto"&&!f){f=this.getDimensions();}j=g[h]=(j=="auto")?f[h]:j.toInt(); | ||
| e["total"+k]=j;i.each(function(m){var l=c(m,g);e["computed"+m.capitalize()]=l;e["total"+k]+=l;});},this);return Object.append(e,g);}});})();var Slider=new Class({Implements:[Events,Options],Binds:["clickedElement","draggedKnob","scrolledElement"],options:{onTick:function(a){this.setKnobPosition(a); | ||
| },initialStep:0,snap:false,offset:0,range:false,wheel:false,steps:100,mode:"horizontal"},initialize:function(f,a,e){this.setOptions(e);e=this.options;this.element=document.id(f); | ||
| a=this.knob=document.id(a);this.previousChange=this.previousEnd=this.step=-1;var b={},d={x:false,y:false};switch(e.mode){case"vertical":this.axis="y";this.property="top"; | ||
| this.offset="offsetHeight";break;case"horizontal":this.axis="x";this.property="left";this.offset="offsetWidth";}this.setSliderDimensions();this.setRange(e.range); | ||
| if(a.getStyle("position")=="static"){a.setStyle("position","relative");}a.setStyle(this.property,-e.offset);d[this.axis]=this.property;b[this.axis]=[-e.offset,this.full-e.offset]; | ||
| var c={snap:0,limit:b,modifiers:d,onDrag:this.draggedKnob,onStart:this.draggedKnob,onBeforeStart:(function(){this.isDragging=true;}).bind(this),onCancel:function(){this.isDragging=false; | ||
| }.bind(this),onComplete:function(){this.isDragging=false;this.draggedKnob();this.end();}.bind(this)};if(e.snap){this.setSnap(c);}this.drag=new Drag(a,c); | ||
| this.attach();if(e.initialStep!=null){this.set(e.initialStep);}},attach:function(){this.element.addEvent("mousedown",this.clickedElement);if(this.options.wheel){this.element.addEvent("mousewheel",this.scrolledElement); | ||
| }this.drag.attach();return this;},detach:function(){this.element.removeEvent("mousedown",this.clickedElement).removeEvent("mousewheel",this.scrolledElement); | ||
| this.drag.detach();return this;},autosize:function(){this.setSliderDimensions().setKnobPosition(this.toPosition(this.step));this.drag.options.limit[this.axis]=[-this.options.offset,this.full-this.options.offset]; | ||
| if(this.options.snap){this.setSnap();}return this;},setSnap:function(a){if(!a){a=this.drag.options;}a.grid=Math.ceil(this.stepWidth);a.limit[this.axis][1]=this.full; | ||
| return this;},setKnobPosition:function(a){if(this.options.snap){a=this.toPosition(this.step);}this.knob.setStyle(this.property,a);return this;},setSliderDimensions:function(){this.full=this.element.measure(function(){this.half=this.knob[this.offset]/2; | ||
| return this.element[this.offset]-this.knob[this.offset]+(this.options.offset*2);}.bind(this));return this;},set:function(a){if(!((this.range>0)^(a<this.min))){a=this.min; | ||
| }if(!((this.range>0)^(a>this.max))){a=this.max;}this.step=Math.round(a);return this.checkStep().fireEvent("tick",this.toPosition(this.step)).end();},setRange:function(a,b){this.min=Array.pick([a[0],0]); | ||
| this.max=Array.pick([a[1],this.options.steps]);this.range=this.max-this.min;this.steps=this.options.steps||this.full;this.stepSize=Math.abs(this.range)/this.steps; | ||
| this.stepWidth=this.stepSize*this.full/Math.abs(this.range);if(a){this.set(Array.pick([b,this.step]).floor(this.min).max(this.max));}return this;},clickedElement:function(c){if(this.isDragging||c.target==this.knob){return; | ||
| }var b=this.range<0?-1:1,a=c.page[this.axis]-this.element.getPosition()[this.axis]-this.half;a=a.limit(-this.options.offset,this.full-this.options.offset); | ||
| this.step=Math.round(this.min+b*this.toStep(a));this.checkStep().fireEvent("tick",a).end();},scrolledElement:function(a){var b=(this.options.mode=="horizontal")?(a.wheel<0):(a.wheel>0); | ||
| this.set(this.step+(b?-1:1)*this.stepSize);a.stop();},draggedKnob:function(){var b=this.range<0?-1:1,a=this.drag.value.now[this.axis];a=a.limit(-this.options.offset,this.full-this.options.offset); | ||
| this.step=Math.round(this.min+b*this.toStep(a));this.checkStep();},checkStep:function(){var a=this.step;if(this.previousChange!=a){this.previousChange=a; | ||
| this.fireEvent("change",a);}return this;},end:function(){var a=this.step;if(this.previousEnd!==a){this.previousEnd=a;this.fireEvent("complete",a+"");}return this; | ||
| },toStep:function(a){var b=(a+this.options.offset)*this.stepSize/this.full*this.steps;return this.options.steps?Math.round(b-=b%this.stepSize):b;},toPosition:function(a){return(this.full*Math.abs(this.min-a))/(this.steps*this.stepSize)-this.options.offset; | ||
| }}); |
| body { | ||
| background: #f3f3f3; | ||
| margin: 20px 30px; | ||
| max-width: 1000px; | ||
| } | ||
| body, input, select, textarea { | ||
| font: 100%/1.25 Helvetica, sans-serif; | ||
| } | ||
| .clear { clear: both; } | ||
| .clear:before, .clear:after { content: ""; display: table; } | ||
| .clear:after { clear: both; } | ||
| .clear{ zoom: 1; } | ||
| header, | ||
| section { | ||
| display: block; | ||
| float: left; | ||
| margin: 0.5em 1em; | ||
| padding: 0; | ||
| width: 250px; | ||
| } | ||
| #log, | ||
| #lug { | ||
| clear: both; | ||
| font-size: 81.25%; | ||
| height: 6em; | ||
| list-style: square; | ||
| margin: 0.5em 1em; | ||
| overflow-y: auto; | ||
| max-width: 750px; | ||
| } | ||
| hr { | ||
| border-color: #eee white white white; | ||
| clear: both; | ||
| margin: 2em; | ||
| max-width: 780px; | ||
| } | ||
| h1 { | ||
| font-size: 150%; | ||
| margin: 0 0 0.25em 0; | ||
| } | ||
| label { | ||
| -webkit-border-radius: 6px; | ||
| -moz-border-radius: 6px; | ||
| border-radius: 6px; | ||
| display: block; | ||
| margin: 0 0 0.25em 0; | ||
| padding: 0.25em 16px 2px; | ||
| } | ||
| label span { | ||
| display: block; | ||
| } | ||
| .group { | ||
| padding: 0 0.5em; | ||
| } | ||
| .group label { | ||
| float: left; | ||
| padding: 0.25em 0.5em 0; | ||
| } | ||
| .group label:last-child { | ||
| margin-right: 0; | ||
| } | ||
| header .group { | ||
| padding: 0 16px; | ||
| } | ||
| input { | ||
| height: 2em; | ||
| margin: 0 0 1em 0; | ||
| outline: none; | ||
| padding: 0; | ||
| width: 100%; | ||
| } | ||
| input::-webkit-input-placeholder { } | ||
| input[type=text] { | ||
| border: 1px solid #bbb; | ||
| border-spacing: 0; | ||
| display: block; | ||
| outline: none; | ||
| text-indent: 10px; | ||
| } | ||
| input[type=number] { | ||
| border: 1px solid #bbb; | ||
| display: block; | ||
| text-indent: 10px; | ||
| } | ||
| input[type=range] { | ||
| display: block; | ||
| height: auto; | ||
| margin: 0 0 0.5em 0; | ||
| width: 100%; | ||
| } | ||
| input[type=checkbox], | ||
| input[type=radio] { | ||
| height: auto; | ||
| margin: 0 0.375em 0 0; | ||
| position: relative; | ||
| top: -1px; | ||
| vertical-align: baseline; | ||
| width: auto; | ||
| } | ||
| select { | ||
| display: block; | ||
| margin: 0 0 1em 0; | ||
| outline: none; | ||
| width: 100%; | ||
| } | ||
| select[multiple=multiple] { | ||
| border: 1px solid #bbb; | ||
| display: block; | ||
| font-size: 81.25%; | ||
| height: 100px; | ||
| outline: none; | ||
| padding: 10px; | ||
| } | ||
| option[selected=selected] { | ||
| background: #fee; | ||
| } | ||
| textarea { | ||
| border: 1px solid #bbb; | ||
| border-spacing: 0; | ||
| display: block; | ||
| height: 80px; | ||
| margin: 0; | ||
| outline: none; | ||
| padding: 10px; | ||
| resize: none; | ||
| width: 198px; | ||
| } | ||
| .slider { | ||
| background: white; | ||
| -moz-box-shadow: inset 1px 1px -1px -1px #bbb; | ||
| -webkit-box-shadow: inset 0 0 1px 1px #bbb; | ||
| box-shadow: inset 0 0 1px 1px #bbb; | ||
| cursor: pointer; | ||
| height: 22px; | ||
| margin-bottom: 1em; | ||
| position: relative; | ||
| width: 100%; | ||
| } | ||
| .knob { | ||
| background: #bbb; | ||
| cursor: move; | ||
| height: 18px; | ||
| left: 2px; | ||
| position: absolute; | ||
| top: 2px; | ||
| width: 18px; | ||
| } | ||
| /* state stuff */ | ||
| textarea:focus { | ||
| resize: vertical; | ||
| } | ||
| input, | ||
| label, | ||
| select[multiple=multiple], | ||
| textarea { | ||
| -moz-transition: -moz-box-shadow 0.8s ease-in-out; | ||
| -webkit-transition: -webkit-box-shadow 0.8s ease-in-out; | ||
| transition: box-shadow 0.8s ease-in-out; | ||
| } | ||
| input:focus, | ||
| select[multiple=multiple]:focus, | ||
| textarea:focus, | ||
| input.updated, | ||
| select[multiple=multiple].updated, | ||
| textarea.updated { | ||
| -moz-transition: -moz-box-shadow 0.2s ease-in-out; | ||
| -webkit-transition: -webkit-box-shadow 0.2s ease-in-out; | ||
| transition: box-shadow 0.2s ease-in-out; | ||
| } | ||
| label { | ||
| -moz-transition: background 0.8s ease-in-out; | ||
| -webkit-transition: background 0.8s ease-in-out; | ||
| transition: background 0.8s ease-in-out; | ||
| } | ||
| label.updated { | ||
| -moz-transition: background 0.2s ease-in-out; | ||
| -webkit-transition: background 0.2s ease-in-out; | ||
| transition: background 0.2s ease-in-out; | ||
| } | ||
| input, | ||
| select[multiple=multiple], | ||
| textarea { | ||
| -moz-box-shadow: 0 0 10px rgb(255, 255, 255); | ||
| -webkit-box-shadow: 0 0 10px rgb(255, 255, 255); | ||
| box-shadow: 0 0 10px rgb(255, 255, 255); | ||
| } | ||
| input:focus, | ||
| select[multiple=multiple]:focus, | ||
| textarea:focus { | ||
| border-color: transparent; | ||
| -moz-box-shadow: 0 0 10px rgb(0, 166, 222); | ||
| -webkit-box-shadow: 0 0 10px rgb(0, 166, 222); | ||
| box-shadow: 0 0 10px rgb(0, 166, 222); | ||
| } | ||
| input.locked, | ||
| select[multiple=multiple].locked, | ||
| textarea.locked { | ||
| border-color: transparent; | ||
| -moz-box-shadow: 0 0 10px rgb(255, 0, 0); | ||
| -webkit-box-shadow: 0 0 10px rgb(255, 0, 0); | ||
| box-shadow: 0 0 10px rgb(255, 0, 0); | ||
| } | ||
| input.updated, | ||
| select[multiple=multiple].updated, | ||
| textarea.updated { | ||
| border-color: transparent; | ||
| -moz-box-shadow: 0 0 10px rgb(255, 255, 0); | ||
| -webkit-box-shadow: 0 0 10px rgb(255, 255, 0); | ||
| box-shadow: 0 0 10px rgb(255, 255, 0); | ||
| } | ||
| label.updated { | ||
| background: rgb(255, 255, 0); | ||
| } | ||
| var connect = require('connect'), | ||
| io = require('socket.io'), | ||
| planet = require('../'), | ||
| network = require('os').networkInterfaces(); | ||
| var ip = network.en1[network.en1.length - 1].address; | ||
| var server = connect() | ||
| .use(connect.static(__dirname)) | ||
| .listen(8004, ip); | ||
| console.log('\nbrowse to http://' + ip + ':8004/simple.html'); | ||
| var socket = io.listen(server, { | ||
| 'transports': ['websocket'], | ||
| 'flash policy server': false, | ||
| 'log level': 1//, | ||
| //'browser client': false, | ||
| //'browser client cache': true, | ||
| //'browser client minification': true, | ||
| //'browser client gzip': true | ||
| }); | ||
| planet(socket); |
| <!doctype html> | ||
| <meta charset="utf-8"> | ||
| <title>Cooking Recipe</title> | ||
| <link rel=stylesheet href="assets/styles.css"> | ||
| <header> | ||
| <div class=group> | ||
| <h1>Cooking Recipe</h1> | ||
| <p>Powered by Planet</p> | ||
| </div> | ||
| </header> | ||
| <section> | ||
| <div class="group clear"> | ||
| <label><input type=checkbox name=spice value=pepper>Pepper</label> | ||
| <label><input type=checkbox name=spice value=cinnamon>Cinnamon</label> | ||
| <label><input type=checkbox name=spice value=cumin>Cumin</label> | ||
| </div> | ||
| </section> | ||
| <section> | ||
| <div class="group clear"> | ||
| <label><input type=radio name=herb value=basil>Basil</label> | ||
| <label><input type=radio name=herb value=coriander>Coriander</label> | ||
| <label><input type=radio name=herb value=rosemary>Rosemary</label> | ||
| </div> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Select</span> | ||
| <select name=device> | ||
| <option>Grill</option> | ||
| <option>Microwave</option> | ||
| <option>Oven</option> | ||
| <option>Stove</option> | ||
| </select> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Text</span><input type=text name=specials placeholder=empty> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Number</span><input type=number name=amount min=1 max=1000 step="0.1" value=6> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Textarea</span><textarea name=formula></textarea> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Multiple Select</span> | ||
| <select name=ingredients multiple=multiple> | ||
| <optgroup label=Meat> | ||
| <option value=beaf>Beaf</option> | ||
| <option value=chicken>Chicken</option> | ||
| <option value=fish>Fish</option> | ||
| <option value=pork>Pork</option> | ||
| </optgroup> | ||
| <optgroup label=Vegetable> | ||
| <option value=corn>Corn</option> | ||
| <option value=patatos>Patatos</option> | ||
| <option value=rice>Rice</option> | ||
| <option value=tofu>Tofu</option> | ||
| </optgroup> | ||
| </select> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Range (HTML5)</span><input type=range name=temperature min=50 max=300 value=100> | ||
| </label> | ||
| </section> | ||
| <section> | ||
| <label> | ||
| <span>Slider (JavaScript)</span> | ||
| <div id=slider class=slider><div id=knob class=knob></div></div> | ||
| </label> | ||
| </section> | ||
| <section class=clear> | ||
| <label> | ||
| <input type=reset> | ||
| </labe> | ||
| </section> | ||
| <hr> | ||
| <ul id=log></ul> | ||
| <hr> | ||
| <ul id=lug></ul> | ||
| <script src="socket.io/socket.io.js"></script> | ||
| <script src="assets/mootools-core-1.4.5-full-nocompat-yc.js"></script> | ||
| <script src="assets/mootools-more-1.4.0.1.js"></script> | ||
| <script> | ||
| if (!this.io) new Element('li[text="Could not connect to server!"]').inject('log'); | ||
| var socket = io.connect('//:8004'); | ||
| // log: | ||
| socket.on('connecting', function(transport){ | ||
| new Element('li', { | ||
| text: 'Connecting with ' + transport | ||
| }).inject('log', 'top'); | ||
| }); | ||
| socket.on('connect', function(){ | ||
| new Element('li[text="Connected!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('disconnect', function(){ | ||
| new Element('li[text="Disconnected!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('connect_failed', function(){ | ||
| new Element('li[text="Connect failed!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('error', function(){ | ||
| new Element('li[text="Error!"]').inject('log', 'top'); | ||
| }); | ||
| socket.on('reconnecting', function(delay, attempts){ | ||
| new Element('li', { | ||
| text: 'Reconnecting (' + delay + ' ' + attempts + ')' | ||
| }).inject('log', 'top'); | ||
| }); | ||
| socket.on('reconnect', function(transport, attempts){ | ||
| new Element('li', { | ||
| text: 'Reconnected (' + transport + ' ' + attempts + ')!' | ||
| }).inject('log', 'top'); | ||
| }); | ||
| socket.on('reconnect_failed', function(){ | ||
| new Element('li[text="Reconnect failed!"]').inject('log', 'top'); | ||
| }); | ||
| // lug: | ||
| socket.on('get', function(data){ | ||
| new Element('li', { | ||
| text: 'get: ' + key + ' ' + JSON.stringify(value) | ||
| }).inject('lug', 'top'); | ||
| }); | ||
| socket.on('set', function(data){ | ||
| new Element('li', { | ||
| text: 'set: ' + JSON.stringify(data) | ||
| }).inject('lug', 'top'); | ||
| }); | ||
| socket.on('merge', function(key, value){ | ||
| new Element('li', { | ||
| text: 'merge: ' + JSON.stringify(data) | ||
| }).inject('lug', 'top'); | ||
| }); | ||
| </script> | ||
| <script src="simple/input.js"></script> | ||
| <script src="simple/input-checkbox.js"></script> | ||
| <script src="simple/input-radio.js"></script> | ||
| <script src="simple/select.js"></script> | ||
| <script src="simple/slider.js"></script> | ||
| <script src="simple/input-reset.js"></script> |
| $$('input[type=checkbox]').each(function(checkbox){ | ||
| var component = checkbox.get('name') + '.' + checkbox.get('value'); | ||
| checkbox.addEvent('change', function(){ | ||
| socket.emit('set', component, this.get('checked')); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == component){ | ||
| checkbox.set('checked', value); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(checked){ | ||
| checkbox.set('checked', checked); | ||
| }); | ||
| }); |
| (function(){ | ||
| var radios = $$('input[type=radio][name=herb]'), | ||
| values = radios.get('value'); | ||
| radios.addEvent('change', function(){ | ||
| socket.emit('set', 'herb', this.get('value')); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == 'herb'){ | ||
| radios[values.indexOf(value)].set('checked', true); | ||
| } | ||
| }); | ||
| socket.emit('get', 'herb', function(herb){ | ||
| if (herb != null){ | ||
| radios[values.indexOf(herb)].set('checked', true); | ||
| } | ||
| }); | ||
| })(); |
| $$('input[type=reset]').addEvent('click', function(e){ | ||
| e.stop(); | ||
| socket.emit('delete'); | ||
| location.reload(true); | ||
| }); |
| $$('input[type=text], input[type=number], input[type=range], textarea').each(function(input){ | ||
| var component = input.get('tag') + '.' + input.get('name'); | ||
| input.addEvent('change', function(){ | ||
| socket.emit('set', component, this.get('value')); | ||
| }); | ||
| if (input.get('tag') == 'textarea') input.addEvent('keyup', function(){ | ||
| input.fireEvent('change'); | ||
| }); | ||
| if (input.get('type') == 'text') input.addEvent('keyup', function(){ | ||
| input.fireEvent('change'); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == component){ | ||
| input.set('value', value); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(value){ | ||
| if (value != null){ | ||
| input.set('value', value); | ||
| } | ||
| }); | ||
| }); |
| $$('select:not([multiple])').each(function(select){ | ||
| var component = select.get('name'); | ||
| select.addEvent('change', function(){ | ||
| socket.emit('set', component, select.get('value')); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == component){ | ||
| select.set('value', value); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(value){ | ||
| if (value != null){ | ||
| select.set('value', value); | ||
| } | ||
| }); | ||
| }); | ||
| $$('select[multiple]').each(function(select){ | ||
| var component = select.get('name'), | ||
| options = select.getElements('option'); | ||
| select.addEvent('change', function(){ | ||
| socket.emit('set', component, options.get('selected')); | ||
| }); | ||
| socket.on('set', function(key, values){ | ||
| if (key == component){ | ||
| values.each(function(value, i){ | ||
| options[i].set('selected', value); | ||
| }); | ||
| } | ||
| }); | ||
| socket.emit('get', component, function(values){ | ||
| if (values != null){ | ||
| values.each(function(value, i){ | ||
| options[i].set('selected', value); | ||
| }); | ||
| } | ||
| }); | ||
| }); |
| (function(){ | ||
| var mySlider = new Slider('slider', 'knob', { | ||
| offset: -2 | ||
| }); | ||
| mySlider.addEvent('change', function(step){ | ||
| socket.emit('set', 'slider', step); | ||
| }); | ||
| mySlider.element.addEvent('mousedown', function(){ | ||
| socket.emit('set', 'slider', mySlider.step); | ||
| }); | ||
| socket.on('set', function(key, value){ | ||
| if (key == 'slider'){ | ||
| mySlider.setKnobPosition(mySlider.toPosition(value)); | ||
| mySlider.step = value; | ||
| } | ||
| }); | ||
| socket.emit('get', 'slider', function(value){ | ||
| mySlider.setKnobPosition(mySlider.toPosition(value)); | ||
| mySlider.step = value; | ||
| }); | ||
| })(); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
399346
1.14%45
7.14%9791
1.86%425
0.47%8
-11.11%5
25%Updated
Updated