# HG changeset patch # User Sean Halle # Date 1404673332 25200 # Node ID 32d17f6062cbc7e820916937fb13f9bdb9eec2a0 # Parent 5c0400b5ae595592e09c76169559aaf88863f02f adding javascript code -- working on Display and Visualizer and srcHolder diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/9__misc/multi_reference_bug.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/9__misc/multi_reference_bug.js Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,90 @@ + + +define(function(require, exports, module) { + var Engine = require("famous/core/Engine"); + var Surface = require("famous/core/Surface"); + var Modifier = require("famous/core/Modifier"); + var Transform = require('famous/core/Transform'); + var StateModifier = require('famous/modifiers/StateModifier'); + var ContainerSurface = require("famous/surfaces/ContainerSurface"); + var Scrollview = require("famous/views/Scrollview"); + + var mainContext = Engine.createContext(); + var mySurface1 = new Surface({ + size: [100, 100], + content: '', + properties: { + color: 'white', + lineHeight: '200%', + textAlign: 'center', + fontSize: '36px', + cursor: 'pointer' + } + }); + + var mySurface2 = new Surface({ + size: [100, 100], + content: '', + properties: { + color: 'white', + lineHeight: '200%', + textAlign: 'center', + fontSize: '36px', + cursor: 'pointer' + } + }); + var mySurface3 = new Surface({ + size: [100, 100], + content: '', + properties: { + color: 'white', + lineHeight: '200%', + textAlign: 'center', + fontSize: '36px', + cursor: 'pointer' + } + }); + var mySurface4 = new Surface({ + size: [100, 100], + content: '', + properties: { + color: 'white', + lineHeight: '200%', + textAlign: 'center', + fontSize: '36px', + cursor: 'pointer' + } + }); + + var moveModifier1 = new StateModifier({ + transform: Transform.translate(50, 50, 0) + }); + var moveModifier2 = new StateModifier({ + transform: Transform.translate(100, 100, 0) + }); + var moveModifier3 = new StateModifier({ + transform: Transform.translate(150, 150, 0) + }); + var moveModifier4 = new StateModifier({ + transform: Transform.translate(100, 100, 0) + }); + var moveModifier5 = new StateModifier({ + transform: Transform.translate(100, 100, 0) + }); +//A given surface object will only render once! Have to +// clone it if want multiple versions to be drawn. +//Same goes for modifiers -- cannot put same modifier object at multiple +// places within tree -- it will only render children of ONE of those places! + mainContext.add(moveModifier1).add(mySurface1); + mainContext.add(moveModifier2).add(mySurface2); +//uncomment this line to see the first disappear +// mainContext.add(moveModifier3).add(mySurface1); + + //this shows ganged modifiers working correctly + mainContext.add(moveModifier4).add(moveModifier5).add(mySurface3); + + //this shows that repeating modifier2 makes the second fail to render! +// uncomment this line to see the second disappear! +// mainContext.add(moveModifier2).add(moveModifier3).add(mySurface4); + +}); diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/9__misc/terminal.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/9__misc/terminal.js Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,1 @@ +!function a(b,c,e){function f(d,j){if(!c[d]){if(!b[d]){var i=typeof require=='function'&&require;if(!j&&i)return i(d,!0);if(g)return g(d,!0);throw new Error("Cannot find module '"+d+"'")}var h=c[d]={exports:{}};b[d][0].call(h.exports,function(c){var a=b[d][1][c];return f(a?a:c)},h,h.exports,a,b,c,e)}return c[d].exports}var g=typeof require=='function'&&require;for(var d=0;d48&&a<64?(this.magnatude=a-48,this.tState=p):a===32||a===9||a===10||a===13||this.charError(e,b);else if(this.tState===c)if(a=e[b],this.bytes_remaining>0){for(var g=0;g=128)if(a>=194&&a<=223&&(this.bytes_in_sequence=2),a>=224&&a<=239&&(this.bytes_in_sequence=3),a>=240&&a<=244&&(this.bytes_in_sequence=4),this.bytes_in_sequence+b>e.length){for(var k=0;k<=e.length-1-b;k++)this.temp_buffs[this.bytes_in_sequence][k]=e[b+k];this.bytes_remaining=b+this.bytes_in_sequence-e.length,b=e.length-1}else this.string+=e.slice(b,b+this.bytes_in_sequence).toString(),b=b+this.bytes_in_sequence-1;else a===34?(this.tState=d,this.onToken(t,this.string),this.string=undefined):a===92?this.tState=N:a>=32?this.string+=String.fromCharCode(a):this.charError(e,b);else this.tState===N?(a=e[b],a===34?(this.string+='"',this.tState=c):a===92?(this.string+='\\',this.tState=c):a===47?(this.string+='/',this.tState=c):a===98?(this.string+='',this.tState=c):a===102?(this.string+=' ',this.tState=c):a===110?(this.string+='\n',this.tState=c):a===114?(this.string+='\r',this.tState=c):a===116?(this.string+=' ',this.tState=c):a===117?(this.unicode='',this.tState=O):this.charError(e,b)):this.tState===O||this.tState===R||this.tState===Q||this.tState===P?(a=e[b],a>=48&&a<64||a>64&&a<=70||a>96&&a<=102?(this.unicode+=String.fromCharCode(a),this.tState++===P&&(this.string+=String.fromCharCode(parseInt(this.unicode,16)),this.unicode=undefined,this.tState=c)):this.charError(e,b)):this.tState===E?(a=e[b],a===48?(this.magnatude=0,this.tState=o):a>48&&a<64?(this.magnatude=a-48,this.tState=p):this.charError(e,b)):this.tState===o?(a=e[b],a===46?(this.position=.1,this.tState=q):a===101||a===69?(this.exponent=0,this.tState=m):(this.tState=d,this.onToken(f,0),this.magnatude=undefined,this.negative=undefined,b--)):this.tState===p?(a=e[b],a===46?(this.position=.1,this.tState=q):a===101||a===69?(this.exponent=0,this.tState=m):a>=48&&a<64?this.magnatude=this.magnatude*10+a-48:(this.tState=d,this.negative&&(this.magnatude=-this.magnatude,this.negative=undefined),this.onToken(f,this.magnatude),this.magnatude=undefined,b--)):this.tState===q?(a=e[b],a>=48&&a<64?(this.magnatude+=this.position*(a-48),this.position/=10,this.tState=I):this.charError(e,b)):this.tState===I?(a=e[b],a>=48&&a<64?(this.magnatude+=this.position*(a-48),this.position/=10):a===101||a===69?(this.exponent=0,this.tState=m):(this.tState=d,this.negative&&(this.magnatude=-this.magnatude,this.negative=undefined),this.onToken(f,this.negative?-this.magnatude:this.magnatude),this.magnatude=undefined,this.position=undefined,b--)):this.tState===m?(a=e[b],a===43||a===45?(a===45&&(this.negativeExponent=!0),this.tState=K):a>=48&&a<64?(this.exponent=this.exponent*10+(a-48),this.tState=s):this.charError(e,b)):this.tState===K?(a=e[b],a>=48&&a<64?(this.exponent=this.exponent*10+(a-48),this.tState=s):this.charError(e,b)):this.tState===s?(a=e[b],a>=48&&a<64?this.exponent=this.exponent*10+(a-48):(this.negativeExponent&&(this.exponent=-this.exponent,this.negativeExponent=undefined),this.magnatude*=Math.pow(10,this.exponent),this.exponent=undefined,this.negative&&(this.magnatude=-this.magnatude,this.negative=undefined),this.tState=d,this.onToken(f,this.magnatude),this.magnatude=undefined,b--)):this.tState===u?e[b]===114?this.tState=v:this.charError(e,b):this.tState===v?e[b]===117?this.tState=w:this.charError(e,b):this.tState===w?e[b]===101?(this.tState=d,this.onToken(F,!0)):this.charError(e,b):this.tState===x?e[b]===97?this.tState=L:this.charError(e,b):this.tState===L?e[b]===108?this.tState=z:this.charError(e,b):this.tState===z?e[b]===115?this.tState=A:this.charError(e,b):this.tState===A?e[b]===101?(this.tState=d,this.onToken(G,!1)):this.charError(e,b):this.tState===B?e[b]===117?this.tState=C:this.charError(e,b):this.tState===C?e[b]===108?this.tState=D:this.charError(e,b):this.tState===D&&(e[b]===108?(this.tState=d,this.onToken(H,null)):this.charError(e,b))},b.onToken=function(a,b){},b.parseError=function(b,a){this.onError(new Error('Unexpected '+y(b)+(a?'('+JSON.stringify(a)+')':'')+' in state '+y(this.state)))},b.onError=function(a){throw a},b.push=function(){this.stack.push({value:this.value,key:this.key,mode:this.mode})},b.pop=function(){var b=this.value,a=this.stack.pop();this.value=a.value,this.key=a.key,this.mode=a.mode,this.emit(b),this.mode||(this.state=e)},b.emit=function(a){this.mode&&(this.state=j),this.onValue(a)},b.onValue=function(a){},b.onToken=function(a,b){this.state===e?a===t||a===f||a===F||a===G||a===H?(this.value&&(this.value[this.key]=b),this.emit(b)):a===M?(this.push(),this.value?this.value=this.value[this.key]={}:this.value={},this.key=undefined,this.state=r,this.mode=g):a===J?(this.push(),this.value?this.value=this.value[this.key]=[]:this.value=[],this.key=0,this.mode=k,this.state=e):a===h?this.mode===g?this.pop():this.parseError(a,b):a===n?this.mode===k?this.pop():this.parseError(a,b):this.parseError(a,b):this.state===r?a===t?(this.key=b,this.state=i):a===h?this.pop():this.parseError(a,b):this.state===i?a===i?this.state=e:this.parseError(a,b):this.state===j?a===j?this.mode===k?(this.key++,this.state=e):this.mode===g&&(this.state=r):a===n&&this.mode===k||a===h&&this.mode===g?this.pop():this.parseError(a,b):this.parseError(a,b)},U.exports=S},{__browserify_Buffer:13}],4:[function(b,e,f){function a(f,g){function i(){while(b.length&&!a.paused){var c=b.shift();if(null===c)return a.emit('end');a.emit('data',c)}}function j(){a.writable=!1,g.call(a),a.readable||a.destroy()}f=f||function(a){this.queue(a)},g=g||function(){this.queue(null)};var e=!1,h=!1,b=[],a=new d;return a.readable=a.writable=!0,a.paused=!1,a.write=function(b){return f.call(this,b),!a.paused},a.queue=a.push=function(c){return b.push(c),i(),a},a.on('end',function(){a.readable=!1,a.writable||c.nextTick(function(){a.destroy()})}),a.end=function(b){return e?void 0:(e=!0,arguments.length&&a.write(b),j(),a)},a.destroy=function(){return h?void 0:(h=!0,e=!0,b.length=0,a.writable=a.readable=!1,a.emit('close'),a)},a.pause=function(){return a.paused?void 0:(a.paused=!0,a.emit('pause'),a)},a.resume=function(){return a.paused&&(a.paused=!1),i(),a.paused||a.emit('drain'),a},a}var c=b('__browserify_process'),d=b('stream');f=e.exports=a,a.through=a},{__browserify_process:14,stream:10}],5:[function(h,i,j){function e(a){a.idle=!a.idle;var d=+new Date-a.olddate;if(a.olddate=+new Date,a.idle&&d0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error('(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.',this._events[a].length),console.trace())}this._events[a].push(c)}else this._events[a]=[this._events[a],c];return this},a.prototype.on=a.prototype.addListener,a.prototype.once=function(b,c){var a=this;return a.on(b,function d(){a.removeListener(b,d),c.apply(this,arguments)}),this},a.prototype.removeListener=function(a,d){if('function'!==typeof d)throw new Error('removeListener only takes instances of Function');if(!(this._events&&this._events[a]))return this;var c=this._events[a];if(b(c)){var e=g(c,d);if(e<0)return this;c.splice(e,1),c.length==0&&delete this._events[a]}else this._events[a]===d&&delete this._events[a];return this},a.prototype.removeAllListeners=function(a){return arguments.length===0?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},a.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),b(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]},a.listenerCount=function(a,c){var b;return a._events&&a._events[c]?typeof a._events[c]==='function'?b=1:b=a._events[c].length:b=0,b}},{__browserify_process:14}],8:[function(a,b,c){},{}],9:[function(u,v,l){function i(a,b){if(a[b].length==0)return a[b]={};var c={};for(var d in a[b])c[d]=a[b][d];return a[b]=c,c}function f(l,e,g,k){var j=l.shift();if(!j)a(e[g])?e[g].push(k):'object'==typeof e[g]?e[g]=k:void 0===e[g]?e[g]=k:e[g]=[e[g],k];else{var h=e[g]=e[g]||[];']'==j?a(h)?''!=k&&h.push(k):'object'==typeof h?h[d(h).length]=k:h=e[g]=[e[g],k]:~b(j,']')?(j=j.substr(0,j.length-1),!c.test(j)&&a(h)&&(h=i(e,g)),f(l,h,j,k)):(!c.test(j)&&a(h)&&(h=i(e,g)),f(l,h,j,k))}}function k(d,e,j){if(~b(e,']')){var g=e.split('['),k=g.length,l=k-1;f(g,d,'base',j)}else{if(!c.test(e)&&a(d.base)){var h={};for(var i in d.base)h[i]=d.base[i];d.base=h}t(d.base,e,j)}return d}function o(b){var a={base:{}};return j(d(b),function(c){k(a,c,b[c])}),a.base}function p(a){return m(String(a).split('&'),function(g,c){var e=b(c,'='),f=n(c),d=c.substr(0,f||e),a=c.substr(f||e,c.length),a=a.substr(b(a,'=')+1,a.length);return''==d&&(d=c,a=''),''==d?g:k(g,h(d),h(a))},{base:{}}).base}function q(b,a){if(!a)throw new TypeError('stringify expects an object');return a+'='+encodeURIComponent(b)}function r(c,d){var b=[];if(!d)throw new TypeError('stringify expects an object');for(var a=0;a0)return;a.end()}function g(){if(d)return;if(d=!0,a._pipeCount--,c(),a._pipeCount>0)return;a.destroy()}function e(a){if(c(),this.listeners('error').length===0)throw a}function c(){b.removeListener('data',i),a.removeListener('drain',j),b.removeListener('end',f),b.removeListener('close',g),b.removeListener('error',e),a.removeListener('error',e),b.removeListener('end',c),b.removeListener('close',c),a.removeListener('end',c),a.removeListener('close',c)}var b=this;b.on('data',i),a.on('drain',j),!a._isStdio&&(!h||h.end!==!1)&&(a._pipeCount=a._pipeCount||0,a._pipeCount++,b.on('end',f),b.on('close',g));var d=!1;return b.on('error',e),a.on('error',e),b.on('end',c),b.on('close',c),a.on('end',c),a.on('close',c),a.emit('pipe',b),a}},{events:7,util:12}],11:[function(v,y,g){function b(b,d){for(var a=0,c=b.length;at)g.hostname='';else{var C=g.hostname.split(/\./);for(var h=0,p=C.length;h127?F+='x':F+=z[E];if(!F.match(m)){var O=C.slice(0,h),H=C.slice(h+1),I=z.match(n);I&&(O.push(I[1]),H.unshift(I[2])),H.length&&(o='/'+H.join('.')+o),g.hostname=O.join('.');break}}}}g.hostname=g.hostname.toLowerCase();var R=g.hostname.split('.'),S=[];for(var h=0;h0?d.host.split('@'):!1;k&&(d.auth=k.shift(),d.host=d.hostname=k.shift())}return d.search=e.search,d.query=e.query,(d.pathname!==undefined||d.search!==undefined)&&(d.path=(d.pathname?d.pathname:'')+(d.search?d.search:'')),d.href=a(d),d}if(!g.length)return delete d.pathname,d.search?delete d.path:d.path='/'+d.search,d.href=a(d),d;var m=g.slice(-1)[0],r=(d.host||e.host)&&(m==='.'||m==='..')||m==='',n=0;for(var l=g.length;l>=0;l--)m=g[l],m=='.'?g.splice(l,1):m==='..'?(g.splice(l,1),n++):n&&(g.splice(l,1),n--);if(!(j||s))for(;n--;n)g.unshift('..');j&&g[0]!==''&&(!g[0]||g[0].charAt(0)!=='/')&&g.unshift(''),r&&g.join('/').substr(-1)!=='/'&&g.push('');var p=g[0]===''||g[0]&&g[0].charAt(0)==='/';if(o){d.hostname=d.host=p?'':g.length?g.shift():'';var k=d.host&&b(d.host,'@')>0?d.host.split('@'):!1;k&&(d.auth=k.shift(),d.host=d.hostname=k.shift())}return j=j||d.host&&g.length,j&&!p&&g.unshift(''),d.pathname=g.join('/'),(d.pathname!==undefined||d.search!==undefined)&&(d.path=(d.pathname?d.pathname:'')+(d.search?d.search:'')),d.auth=e.auth||d.auth,d.slashes=d.slashes||e.slashes,d.href=a(d),d}function w(a){var c={},b=s.exec(a);return b&&(b=b[0],c.port=b.substr(1),a=a.substr(0,a.length-b.length)),a&&(c.hostname=a),c}var r={encode:function(a){return a}};g.parse=h,g.resolve=x,g.resolveObject=o,g.format=a;var j=Object.keys||function a(a){if(a!==Object(a))throw new TypeError('Invalid object');var b=[];for(var c in a)a.hasOwnProperty(c)&&(b[b.length]=c);return b},u=/^([a-z0-9.+-]+:)/i,s=/:[0-9]+$/,d=['<','>','"','`',' ','\r','\n',' '],p=['{','}','|','\\','^','~','[',']','`'].concat(d),i=["'"],k=['%','/','?',';','#'].concat(p).concat(i),e=['/','@','?','#'].concat(d),t=255,m=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,n=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,q={javascript:!0,'javascript:':!0},f={javascript:!0,'javascript:':!0},c={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,'http:':!0,'https:':!0,'ftp:':!0,'gopher:':!0,'file:':!0},l=v('querystring')},{querystring:9}],12:[function(j,k,a){function b(a){return Array.isArray(a)||typeof a==='object'&&Object.prototype.toString.call(a)==='[object Array]'}function c(a){typeof a==='object'&&Object.prototype.toString.call(a)==='[object RegExp]'}function d(a){return typeof a==='object'&&Object.prototype.toString.call(a)==='[object Date]'}var i=j('events');a.isArray=b,a.isDate=function(a){return Object.prototype.toString.call(a)==='[object Date]'},a.isRegExp=function(a){return Object.prototype.toString.call(a)==='[object RegExp]'},a.print=function(){},a.puts=function(){},a.debug=function(){},a.inspect=function(k,l,j,m){function i(j,p){if(j&&typeof j.inspect==='function'&&j!==a&&!(j.constructor&&j.constructor.prototype===j))return j.inspect(p);switch(typeof j){case'undefined':return e('undefined','undefined');case'string':var w="'"+JSON.stringify(j).replace(/^"|"$/g,'').replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e(w,'string');case'number':return e(''+j,'number');case'boolean':return e(''+j,'boolean')}if(j===null)return e('null','null');var q=h(j),o=l?g(j):q;if(typeof j==='function'&&o.length===0)if(c(j))return e(''+j,'regexp');else{var t=j.name?': '+j.name:'';return e('[Function'+t+']','special')}if(d(j)&&o.length===0)return e(j.toUTCString(),'date');var m,r,k;if(b(j)?(r='Array',k=['[',']']):(r='Object',k=['{','}']),typeof j==='function'){var u=j.name?': '+j.name:'';m=c(j)?' '+j:' [Function'+u+']'}else m='';if(d(j)&&(m=' '+j.toUTCString()),o.length===0)return k[0]+m+k[1];if(p<0)return c(j)?e(''+j,'regexp'):e('[Object]','special');f.push(j);var n=o.map(function(d){var a,c;if(j.__lookupGetter__&&(j.__lookupGetter__(d)?j.__lookupSetter__(d)?c=e('[Getter/Setter]','special'):c=e('[Getter]','special'):j.__lookupSetter__(d)&&(c=e('[Setter]','special'))),q.indexOf(d)<0&&(a='['+d+']'),c||(f.indexOf(j[d])<0?(p===null?c=i(j[d]):c=i(j[d],p-1),c.indexOf('\n')>-1&&(b(j)?c=c.split('\n').map(function(a){return' '+a}).join('\n').substr(2):c='\n'+c.split('\n').map(function(a){return' '+a}).join('\n'))):c=e('[Circular]','special')),a===void 0){if(r==='Array'&&d.match(/^\d+$/))return c;a=JSON.stringify(''+d),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e(a,'name')):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e(a,'string'))}return a+': '+c});f.pop();var s=0,v=n.reduce(function(b,a){return s++,a.indexOf('\n')>=0&&s++,b+a.length+1},0);return v>50?n=k[0]+(m===''?'':m+'\n ')+' '+n.join(',\n ')+' '+k[1]:n=k[0]+m+' '+n.join(', ')+' '+k[1],n}var f=[],e=function(c,d){var b={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a={special:'cyan',number:'blue',boolean:'yellow',undefined:'grey',null:'bold',string:'green',date:'magenta',regexp:'red'}[d];return a?'['+b[a][0]+'m'+c+'['+b[a][1]+'m':c};return m||(e=function(a,b){return a}),i(k,j===void 0?2:j)},a.log=function(a){},a.pump=null;var h=Object.keys||function(c){var a=[];for(var b in c)a.push(b);return a},g=Object.getOwnPropertyNames||function(c){var a=[];for(var b in c)Object.hasOwnProperty.call(c,b)&&a.push(b);return a},e=Object.create||function(a,d){var b;if(a===null)b={__proto__:null};else{if(typeof a!=='object')throw new TypeError('typeof prototype['+typeof a+"] != 'object'");var c=function(){};c.prototype=a,b=new c,b.__proto__=a}return d!==void 0&&Object.defineProperties&&Object.defineProperties(b,d),b};a.inherits=function(a,b){a.super_=b,a.prototype=e(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var f=/%[sdj%]/g;a.format=function(i){if(typeof i!=='string'){var g=[];for(var b=0;b=h)return a;switch(a){case'%s':return String(c[b++]);case'%d':return Number(c[b++]);case'%j':return JSON.stringify(c[b++]);default:return a}});for(var d=c[b];b=0;a--)if(g[a]!=i[a])return!1;for(a=g.length-1;a>=0;a--)if(j=g[a],!d(b[j],e[j]))return!1;return!0}function n(b,a){return b&&a?a instanceof RegExp?a.test(b):b instanceof a?!0:a.call({},b)===!0?!0:!1:!1}function o(e,f,a,d){var c;typeof a==='string'&&(d=a,a=null);try{f()}catch(a){c=a}if(d=(a&&a.name?' ('+a.name+').':'.')+(d?' '+d:'.'),e&&!c&&b('Missing expected exception'+d),!e&&n(c,a)&&b('Got unwanted exception'+d),e&&c&&a&&!n(c,a)||!e&&c)throw c}var m=j('util'),e=j('buffer').Buffer,c=Array.prototype.slice,a=q.exports=i;a.AssertionError=function a(a){this.name='AssertionError',this.message=a.message,this.actual=a.actual,this.expected=a.expected,this.operator=a.operator;var c=a.stackStartFunction||b;Error.captureStackTrace&&Error.captureStackTrace(this,c)},m.inherits(a.AssertionError,Error),a.AssertionError.prototype.toString=function(){return this.message?[this.name+':',this.message].join(' '):[this.name+':',g(JSON.stringify(this.actual,l),128),this.operator,g(JSON.stringify(this.expected,l),128)].join(' ')},a.AssertionError.__proto__=Error.prototype,a.fail=b,a.ok=i,a.equal=function c(c,d,e){c!=d&&b(c,d,e,'==',a.equal)},a.notEqual=function c(c,d,e){c==d&&b(c,d,e,'!=',a.notEqual)},a.deepEqual=function c(c,e,f){d(c,e)||b(c,e,f,'deepEqual',a.deepEqual)},a.notDeepEqual=function c(c,e,f){d(c,e)&&b(c,e,f,'notDeepEqual',a.notDeepEqual)},a.strictEqual=function c(c,d,e){c!==d&&b(c,d,e,'===',a.strictEqual)},a.notStrictEqual=function c(c,d,e){c===d&&b(c,d,e,'!==',a.notStrictEqual)},a.throws=function(a,b,d){o.apply(this,[!0].concat(c.call(arguments)))},a.doesNotThrow=function(a,b,d){o.apply(this,[!1].concat(c.call(arguments)))},a.ifError=function(a){if(a)throw a}},{util:2,buffer:3}],2:[function(j,k,a){function b(a){return a instanceof Array||Array.isArray(a)||a&&a!==Object.prototype&&b(a.__proto__)}function d(a){return a instanceof RegExp||typeof a==='object'&&Object.prototype.toString.call(a)==='[object RegExp]'}function e(a){if(a instanceof Date)return!0;if(typeof a!=='object')return!1;var b=Date.prototype&&c(Date.prototype),d=a.__proto__&&c(a.__proto__);return JSON.stringify(d)===JSON.stringify(b)}var i=j('events');a.isArray=b,a.isDate=function(a){return Object.prototype.toString.call(a)==='[object Date]'},a.isRegExp=function(a){return Object.prototype.toString.call(a)==='[object RegExp]'},a.print=function(){},a.puts=function(){},a.debug=function(){},a.inspect=function(k,l,j,m){function i(j,p){if(j&&typeof j.inspect==='function'&&j!==a&&!(j.constructor&&j.constructor.prototype===j))return j.inspect(p);switch(typeof j){case'undefined':return f('undefined','undefined');case'string':var w="'"+JSON.stringify(j).replace(/^"|"$/g,'').replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return f(w,'string');case'number':return f(''+j,'number');case'boolean':return f(''+j,'boolean')}if(j===null)return f('null','null');var q=h(j),o=l?c(j):q;if(typeof j==='function'&&o.length===0)if(d(j))return f(''+j,'regexp');else{var t=j.name?': '+j.name:'';return f('[Function'+t+']','special')}if(e(j)&&o.length===0)return f(j.toUTCString(),'date');var m,r,k;if(b(j)?(r='Array',k=['[',']']):(r='Object',k=['{','}']),typeof j==='function'){var u=j.name?': '+j.name:'';m=d(j)?' '+j:' [Function'+u+']'}else m='';if(e(j)&&(m=' '+j.toUTCString()),o.length===0)return k[0]+m+k[1];if(p<0)return d(j)?f(''+j,'regexp'):f('[Object]','special');g.push(j);var n=o.map(function(d){var a,c;if(j.__lookupGetter__&&(j.__lookupGetter__(d)?j.__lookupSetter__(d)?c=f('[Getter/Setter]','special'):c=f('[Getter]','special'):j.__lookupSetter__(d)&&(c=f('[Setter]','special'))),q.indexOf(d)<0&&(a='['+d+']'),c||(g.indexOf(j[d])<0?(p===null?c=i(j[d]):c=i(j[d],p-1),c.indexOf('\n')>-1&&(b(j)?c=c.split('\n').map(function(a){return' '+a}).join('\n').substr(2):c='\n'+c.split('\n').map(function(a){return' '+a}).join('\n'))):c=f('[Circular]','special')),a===void 0){if(r==='Array'&&d.match(/^\d+$/))return c;a=JSON.stringify(''+d),a.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=f(a,'name')):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=f(a,'string'))}return a+': '+c});g.pop();var s=0,v=n.reduce(function(b,a){return s++,a.indexOf('\n')>=0&&s++,b+a.length+1},0);return v>50?n=k[0]+(m===''?'':m+'\n ')+' '+n.join(',\n ')+' '+k[1]:n=k[0]+m+' '+n.join(', ')+' '+k[1],n}var g=[],f=function(c,d){var b={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a={special:'cyan',number:'blue',boolean:'yellow',undefined:'grey',null:'bold',string:'green',date:'magenta',regexp:'red'}[d];return a?'['+b[a][0]+'m'+c+'['+b[a][1]+'m':c};return m||(f=function(a,b){return a}),i(k,j===void 0?2:j)},a.log=function(a){},a.pump=null;var h=Object.keys||function(c){var a=[];for(var b in c)a.push(b);return a},c=Object.getOwnPropertyNames||function(c){var a=[];for(var b in c)Object.hasOwnProperty.call(c,b)&&a.push(b);return a},g=Object.create||function(a,d){var b;if(a===null)b={__proto__:null};else{if(typeof a!=='object')throw new TypeError('typeof prototype['+typeof a+"] != 'object'");var c=function(){};c.prototype=a,b=new c,b.__proto__=a}return d!==void 0&&Object.defineProperties&&Object.defineProperties(b,d),b};a.inherits=function(a,b){a.super_=b,a.prototype=g(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})};var f=/%[sdj%]/g;a.format=function(i){if(typeof i!=='string'){var g=[];for(var b=0;b=h)return a;switch(a){case'%s':return String(c[b++]);case'%d':return Number(c[b++]);case'%j':return JSON.stringify(c[b++]);default:return a}});for(var d=c[b];b>1,a=-7,c=n?0:m-1,g=n?1:-1,e=h[l+c];for(c+=g,b=e&(1<<-a)-1,e>>=-a,a+=i;a>0;b=b*256+h[l+c],c+=g,a-=8);for(d=b&(1<<-a)-1,b>>=-a,a+=f;a>0;d=d*256+h[l+c],c+=g,a-=8);if(b===0)b=1-k;else if(b===j)return d?NaN:(e?-1:1)*Infinity;else d+=Math.pow(2,f),b-=k;return(e?-1:1)*d*Math.pow(2,b-f)},a.writeIEEE754=function(k,b,m,n,c,p){var a,d,f,h=p*8-c-1,i=(1<>1,l=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?p-1:0,j=n?-1:1,o=b<0||b===0&&1/b<0?1:0;for(b=Math.abs(b),isNaN(b)||b===Infinity?(d=isNaN(b)?1:0,a=i):(a=Math.floor(Math.log(b)/Math.LN2),b*(f=Math.pow(2,-a))<1&&(a--,f*=2),a+e>=1?b+=l/f:b+=l*Math.pow(2,1-e),b*f>=2&&(a++,f/=2),a+e>=i?(d=0,a=i):a+e>=1?(d=(b*f-1)*Math.pow(2,c),a+=e):(d=b*Math.pow(2,e-1)*Math.pow(2,c),a=0));c>=8;k[m+g]=d&255,g+=j,d/=256,c-=8);for(a=a<0;k[m+g]=a&255,g+=j,a/=256,h-=8);k[m+g-j]|=o*128}},{}],6:[function(c,b,d){var a=b.exports={};a.nextTick=function(b,c,a){return b=typeof window!=='undefined'&&window.setImmediate,c=typeof window!=='undefined'&&window.postMessage&&window.addEventListener,b?function(a){return window.setImmediate(a)}:c?(a=[],window.addEventListener('message',function(b){if(b.source===window&&b.data==='process-tick'&&(b.stopPropagation(),a.length>0)){var c=a.shift();c()}},!0),function b(b){a.push(b),window.postMessage('process-tick','*')}):function a(a){setTimeout(a,0)}}(),a.title='browser',a.browser=!0,a.env={},a.argv=[],a.binding=function(a){throw new Error('process.binding is not supported')},a.cwd=function(){return'/'},a.chdir=function(a){throw new Error('process.chdir is not supported')}},{}],4:[function(a,c,b){!function(d,a,c,e){function f(b,c){if(b.indexOf)return b.indexOf(c);for(var a=0;a0&&this._events[a].length>d&&(this._events[a].warned=!0,console.error('(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.',this._events[a].length),console.trace())}this._events[a].push(b)}else this._events[a]=[this._events[a],b];return this},a.prototype.on=a.prototype.addListener,a.prototype.once=function(b,c){var a=this;return a.on(b,function d(){a.removeListener(b,d),c.apply(this,arguments)}),this},a.prototype.removeListener=function(a,d){if('function'!==typeof d)throw new Error('removeListener only takes instances of Function');if(!(this._events&&this._events[a]))return this;var b=this._events[a];if(c(b)){var e=f(b,d);if(e<0)return this;b.splice(e,1),b.length==0&&delete this._events[a]}else this._events[a]===d&&delete this._events[a];return this},a.prototype.removeAllListeners=function(a){return arguments.length===0?(this._events={},this):(a&&this._events&&this._events[a]&&(this._events[a]=null),this)},a.prototype.listeners=function(a){return this._events||(this._events={}),this._events[a]||(this._events[a]=[]),c(this._events[a])||(this._events[a]=[this._events[a]]),this._events[a]}}(a('__browserify_process'))},{__browserify_process:6}],'buffer-browserify':[function(a,b,c){b.exports=a('q9TxCC')},{}],q9TxCC:[function(e,E,f){function c(a){this.length=a}function i(a){return a<16?'0'+a.toString(16):a.toString(16)}function w(b){var c=[];for(var a=0;a=c.length||a>=b.length)break;c[a+d]=b[a],a++}return a}function u(a){try{return decodeURIComponent(a)}catch(a){return String.fromCharCode(65533)}}function l(a){return a=~~Math.ceil(+a),a<0?0:a}function a(b,f,g){if(!(this instanceof a))return new a(b,f,g);var h;if(typeof g==='number')this.length=l(f),this.parent=b,this.offset=g;else{switch(h=typeof b){case'number':this.length=l(b);break;case'string':this.length=a.byteLength(b,f);break;case'object':this.length=l(b.length);break;default:throw new Error('First argument needs to be a number, array or string.')}if(this.length>a.poolSize?(this.parent=new c(this.length),this.offset=0):((!d||d.length-d.used=a.length?0:(e?(d=a.parent[a.offset+c]<<8,c+1=a.length?0:(e?(c+1>>0):(c+2>>0)),d)}function v(d,a,e,f){var g,c;return f||(b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(a!==undefined&&a!==null,'missing offset'),b.ok(a+1=0,'specified a negative value for writing an unsigned value'),b.ok(a<=c,'value is larger than maximum value for type'),b.ok(Math.floor(a)===a,'value has a fractional component')}function h(d,e,c,f,g){g||(b.ok(e!==undefined&&e!==null,'missing value'),b.ok(typeof f==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+1>>(f?1-a:a)*8}function g(d,e,c,f,g){g||(b.ok(e!==undefined&&e!==null,'missing value'),b.ok(typeof f==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+3>>(f?3-a:a)*8&255}function m(a,c,d){b.ok(typeof a=='number','cannot write a non-number as a number'),b.ok(a<=c,'value larger than maximum allowed value'),b.ok(a>=d,'value smaller than minimum allowed value'),b.ok(Math.floor(a)===a,'value has a fractional component')}function x(a,c,d){b.ok(typeof a=='number','cannot write a non-number as a number'),b.ok(a<=c,'value larger than maximum allowed value'),b.ok(a>=d,'value smaller than minimum allowed value')}function y(d,a,c,e,f){f||(b.ok(a!==undefined&&a!==null,'missing value'),b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+1=0?h(d,a,c,e,f):h(d,65535+a+1,c,e,f)}function z(d,a,c,e,f){f||(b.ok(a!==undefined&&a!==null,'missing value'),b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+3=0?g(d,a,c,e,f):g(d,4294967295+a+1,c,e,f)}function A(d,a,c,f,g){g||(b.ok(a!==undefined&&a!==null,'missing value'),b.ok(typeof f==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+3'},c.prototype.hexSlice=function(b,a){var d=this.length;(!b||b<0)&&(b=0),(!a||a<0||a>d)&&(a=d);var e='';for(var c=b;ce&&(a=e)):a=e;var f=h.length;if(f%2)throw new Error('Invalid hex string');a>f/2&&(a=f/2);for(var b=0;be&&(a=e)):a=e,d=String(d||'utf8').toLowerCase();switch(d){case'hex':return this.hexWrite(c,b,a);case'utf8':case'utf-8':return this.utf8Write(c,b,a);case'ascii':return this.asciiWrite(c,b,a);case'binary':return this.binaryWrite(c,b,a);case'base64':return this.base64Write(c,b,a);case'ucs2':case'ucs-2':return this.ucs2Write(c,b,a);default:throw new Error('Unknown encoding')}},c.prototype.slice=function(c,b){if(b===undefined&&(b=this.length),b>this.length)throw new Error('oob');if(c>b)throw new Error('oob');return new a(this,b-c,+c)},c.prototype.copy=function(e,d,f,g){var c=[];for(var a=f;athis.length)throw new Error('oob');if(c>b)throw new Error('oob');for(var a=c;a'},a.prototype.get=function a(a){if(a<0||a>=this.length)throw new Error('oob');return this.parent[this.offset+a]},a.prototype.set=function a(a,b){if(a<0||a>=this.length)throw new Error('oob');return this.parent[this.offset+a]=b},a.prototype.write=function(f,d,b,g){if(isFinite(d))isFinite(b)||(g=b,b=undefined);else{var i=g;g=d,d=b,b=i}d=+d||0;var h=this.length-d;b?(b=+b,b>h&&(b=h)):b=h,g=String(g||'utf8').toLowerCase();var e;switch(g){case'hex':e=this.parent.hexWrite(f,this.offset+d,b);break;case'utf8':case'utf-8':e=this.parent.utf8Write(f,this.offset+d,b);break;case'ascii':e=this.parent.asciiWrite(f,this.offset+d,b);break;case'binary':e=this.parent.binaryWrite(f,this.offset+d,b);break;case'base64':e=this.parent.base64Write(f,this.offset+d,b);break;case'ucs2':case'ucs-2':e=this.parent.ucs2Write(f,this.offset+d,b);break;default:throw new Error('Unknown encoding')}return a._charsWritten=c._charsWritten,e},a.prototype.toString=function(c,a,b){c=String(c||'utf8').toLowerCase(),a===void 0||a<0?a=0:a>this.length&&(a=this.length),b===void 0||b>this.length?b=this.length:b<0&&(b=0),a+=this.offset,b+=this.offset;switch(c){case'hex':return this.parent.hexSlice(a,b);case'utf8':case'utf-8':return this.parent.utf8Slice(a,b);case'ascii':return this.parent.asciiSlice(a,b);case'binary':return this.parent.binarySlice(a,b);case'base64':return this.parent.base64Slice(a,b);case'ucs2':case'ucs-2':return this.parent.ucs2Slice(a,b);default:throw new Error('Unknown encoding')}},a.byteLength=c.byteLength,a.prototype.fill=function a(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),typeof a==='string'&&(a=a.charCodeAt(0)),!(typeof a==='number')||isNaN(a))throw new Error('value is not a number');if(c=this.length)throw new Error('start out of bounds');if(c<0||c>this.length)throw new Error('end out of bounds');return this.parent.fill(a,b+this.offset,c+this.offset)},a.prototype.copy=function(d,c,b,a){var e=this;if(b||(b=0),a||(a=this.length),c||(c=0),a=d.length)throw new Error('targetStart out of bounds');if(b<0||b>=e.length)throw new Error('sourceStart out of bounds');if(a<0||a>e.length)throw new Error('sourceEnd out of bounds');return a>this.length&&(a=this.length),d.length-cthis.length)throw new Error('oob');if(c>b)throw new Error('oob');return new a(this.parent,b-c,+c+this.offset)},a.prototype.utf8Slice=function(a,b){return this.toString('utf8',a,b)},a.prototype.binarySlice=function(a,b){return this.toString('binary',a,b)},a.prototype.asciiSlice=function(a,b){return this.toString('ascii',a,b)},a.prototype.utf8Write=function(a,b){return this.write(a,b,'utf8')},a.prototype.binaryWrite=function(a,b){return this.write(a,b,'binary')},a.prototype.asciiWrite=function(a,b){return this.write(a,b,'ascii')},a.prototype.readUInt8=function(a,d){var c=this;return d||(b.ok(a!==undefined&&a!==null,'missing offset'),b.ok(a=c.length?void 0:c.parent[c.offset+a]},a.prototype.readUInt16LE=function(a,b){return o(this,a,!1,b)},a.prototype.readUInt16BE=function(a,b){return o(this,a,!0,b)},a.prototype.readUInt32LE=function(a,b){return n(this,a,!1,b)},a.prototype.readUInt32BE=function(a,b){return n(this,a,!0,b)},a.prototype.readInt8=function(c,e){var a=this,d;return e||(b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c=a.length?void 0:(d=a.parent[a.offset+c]&128,d?(255-a.parent[a.offset+c]+1)*-1:a.parent[a.offset+c])},a.prototype.readInt16LE=function(a,b){return v(this,a,!1,b)},a.prototype.readInt16BE=function(a,b){return v(this,a,!0,b)},a.prototype.readInt32LE=function(a,b){return r(this,a,!1,b)},a.prototype.readInt32BE=function(a,b){return r(this,a,!0,b)},a.prototype.readFloatLE=function(a,b){return s(this,a,!1,b)},a.prototype.readFloatBE=function(a,b){return s(this,a,!0,b)},a.prototype.readDoubleLE=function(a,b){return t(this,a,!1,b)},a.prototype.readDoubleBE=function(a,b){return t(this,a,!0,b)},a.prototype.writeUInt8=function(d,a,e){var c=this;e||(b.ok(d!==undefined&&d!==null,'missing value'),b.ok(a!==undefined&&a!==null,'missing offset'),b.ok(a=0?d.writeUInt8(a,c,e):d.writeUInt8(255+a+1,c,e)},a.prototype.writeInt16LE=function(a,b,c){y(this,a,b,!1,c)},a.prototype.writeInt16BE=function(a,b,c){y(this,a,b,!0,c)},a.prototype.writeInt32LE=function(a,b,c){z(this,a,b,!1,c)},a.prototype.writeInt32BE=function(a,b,c){z(this,a,b,!0,c)},a.prototype.writeFloatLE=function(a,b,c){A(this,a,b,!1,c)},a.prototype.writeFloatBE=function(a,b,c){A(this,a,b,!0,c)},a.prototype.writeDoubleLE=function(a,b,c){q(this,a,b,!1,c)},a.prototype.writeDoubleBE=function(a,b,c){q(this,a,b,!0,c)},c.prototype.readUInt8=a.prototype.readUInt8,c.prototype.readUInt16LE=a.prototype.readUInt16LE,c.prototype.readUInt16BE=a.prototype.readUInt16BE,c.prototype.readUInt32LE=a.prototype.readUInt32LE,c.prototype.readUInt32BE=a.prototype.readUInt32BE,c.prototype.readInt8=a.prototype.readInt8,c.prototype.readInt16LE=a.prototype.readInt16LE,c.prototype.readInt16BE=a.prototype.readInt16BE,c.prototype.readInt32LE=a.prototype.readInt32LE,c.prototype.readInt32BE=a.prototype.readInt32BE,c.prototype.readFloatLE=a.prototype.readFloatLE,c.prototype.readFloatBE=a.prototype.readFloatBE,c.prototype.readDoubleLE=a.prototype.readDoubleLE,c.prototype.readDoubleBE=a.prototype.readDoubleBE,c.prototype.writeUInt8=a.prototype.writeUInt8,c.prototype.writeUInt16LE=a.prototype.writeUInt16LE,c.prototype.writeUInt16BE=a.prototype.writeUInt16BE,c.prototype.writeUInt32LE=a.prototype.writeUInt32LE,c.prototype.writeUInt32BE=a.prototype.writeUInt32BE,c.prototype.writeInt8=a.prototype.writeInt8,c.prototype.writeInt16LE=a.prototype.writeInt16LE,c.prototype.writeInt16BE=a.prototype.writeInt16BE,c.prototype.writeInt32LE=a.prototype.writeInt32LE,c.prototype.writeInt32BE=a.prototype.writeInt32BE,c.prototype.writeFloatLE=a.prototype.writeFloatLE,c.prototype.writeFloatBE=a.prototype.writeFloatBE,c.prototype.writeDoubleLE=a.prototype.writeDoubleLE,c.prototype.writeDoubleBE=a.prototype.writeDoubleBE},{assert:1,'./buffer_ieee754':5,'base64-js':7}],7:[function(b,a,c){!function(e){'use strict';function c(a){var c,g,h,d,f,e;if(a.length%4>0)throw'Invalid string. Length must be a multiple of 4';for(f=a.indexOf('='),f=f>0?a.length-f:0,e=[],h=f>0?a.length-4:a.length,c=0,g=0;c>16),e.push((d&65280)>>8),e.push(d&255);return f===2?(d=b.indexOf(a[c])<<2|b.indexOf(a[c+1])>>4,e.push(d&255)):f===1&&(d=b.indexOf(a[c])<<10|b.indexOf(a[c+1])<<4|b.indexOf(a[c+2])>>2,e.push(d>>8&255),e.push(d&255)),e}function d(a){function h(a){return b[a>>18&63]+b[a>>12&63]+b[a>>6&63]+b[a&63]}var e,f=a.length%3,c='',d,g;for(e=0,g=a.length-f;e>2];c+=b[d<<4&63];c+='==';break;case 2:d=(a[a.length-2]<<8)+a[a.length-1];c+=b[d>>10];c+=b[d>>4&63];c+=b[d<<2&63];c+='=';break}return c}var b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';a.exports.toByteArray=c,a.exports.fromByteArray=d}()},{}],8:[function(b,c,a){a.readIEEE754=function(h,l,n,f,m){var b,d,i=m*8-f-1,j=(1<>1,a=-7,c=n?0:m-1,g=n?1:-1,e=h[l+c];for(c+=g,b=e&(1<<-a)-1,e>>=-a,a+=i;a>0;b=b*256+h[l+c],c+=g,a-=8);for(d=b&(1<<-a)-1,b>>=-a,a+=f;a>0;d=d*256+h[l+c],c+=g,a-=8);if(b===0)b=1-k;else if(b===j)return d?NaN:(e?-1:1)*Infinity;else d+=Math.pow(2,f),b-=k;return(e?-1:1)*d*Math.pow(2,b-f)},a.writeIEEE754=function(k,b,m,n,c,p){var a,d,f,h=p*8-c-1,i=(1<>1,l=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?p-1:0,j=n?-1:1,o=b<0||b===0&&1/b<0?1:0;for(b=Math.abs(b),isNaN(b)||b===Infinity?(d=isNaN(b)?1:0,a=i):(a=Math.floor(Math.log(b)/Math.LN2),b*(f=Math.pow(2,-a))<1&&(a--,f*=2),a+e>=1?b+=l/f:b+=l*Math.pow(2,1-e),b*f>=2&&(a++,f/=2),a+e>=i?(d=0,a=i):a+e>=1?(d=(b*f-1)*Math.pow(2,c),a+=e):(d=b*Math.pow(2,e-1)*Math.pow(2,c),a=0));c>=8;k[m+g]=d&255,g+=j,d/=256,c-=8);for(a=a<0;k[m+g]=a&255,g+=j,a/=256,h-=8);k[m+g-j]|=o*128}},{}],3:[function(e,E,f){function c(a){this.length=a}function i(a){return a<16?'0'+a.toString(16):a.toString(16)}function w(b){var c=[];for(var a=0;a=c.length||a>=b.length)break;c[a+d]=b[a],a++}return a}function u(a){try{return decodeURIComponent(a)}catch(a){return String.fromCharCode(65533)}}function l(a){return a=~~Math.ceil(+a),a<0?0:a}function a(b,f,g){if(!(this instanceof a))return new a(b,f,g);var h;if(typeof g==='number')this.length=l(f),this.parent=b,this.offset=g;else{switch(h=typeof b){case'number':this.length=l(b);break;case'string':this.length=a.byteLength(b,f);break;case'object':this.length=l(b.length);break;default:throw new Error('First argument needs to be a number, array or string.')}if(this.length>a.poolSize?(this.parent=new c(this.length),this.offset=0):((!d||d.length-d.used>>0):(d=a.parent[a.offset+c+2]<<16,d|=a.parent[a.offset+c+1]<<8,d|=a.parent[a.offset+c],d+=a.parent[a.offset+c+3]<<24>>>0),d}function v(d,a,e,f){var g,c;return f||(b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(a!==undefined&&a!==null,'missing offset'),b.ok(a+1=0,'specified a negative value for writing an unsigned value'),b.ok(a<=c,'value is larger than maximum value for type'),b.ok(Math.floor(a)===a,'value has a fractional component')}function h(a,c,d,e,f){f||(b.ok(c!==undefined&&c!==null,'missing value'),b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(d!==undefined&&d!==null,'missing offset'),b.ok(d+1>>8,a.parent[a.offset+d+1]=c&255):(a.parent[a.offset+d+1]=(c&65280)>>>8,a.parent[a.offset+d]=c&255)}function g(a,c,d,e,f){f||(b.ok(c!==undefined&&c!==null,'missing value'),b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(d!==undefined&&d!==null,'missing offset'),b.ok(d+3>>24&255,a.parent[a.offset+d+1]=c>>>16&255,a.parent[a.offset+d+2]=c>>>8&255,a.parent[a.offset+d+3]=c&255):(a.parent[a.offset+d+3]=c>>>24&255,a.parent[a.offset+d+2]=c>>>16&255,a.parent[a.offset+d+1]=c>>>8&255,a.parent[a.offset+d]=c&255)}function m(a,c,d){b.ok(typeof a=='number','cannot write a non-number as a number'),b.ok(a<=c,'value larger than maximum allowed value'),b.ok(a>=d,'value smaller than minimum allowed value'),b.ok(Math.floor(a)===a,'value has a fractional component')}function x(a,c,d){b.ok(typeof a=='number','cannot write a non-number as a number'),b.ok(a<=c,'value larger than maximum allowed value'),b.ok(a>=d,'value smaller than minimum allowed value')}function y(d,a,c,e,f){f||(b.ok(a!==undefined&&a!==null,'missing value'),b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+1=0?h(d,a,c,e,f):h(d,65535+a+1,c,e,f)}function z(d,a,c,e,f){f||(b.ok(a!==undefined&&a!==null,'missing value'),b.ok(typeof e==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+3=0?g(d,a,c,e,f):g(d,4294967295+a+1,c,e,f)}function A(d,a,c,f,g){g||(b.ok(a!==undefined&&a!==null,'missing value'),b.ok(typeof f==='boolean','missing or invalid endian'),b.ok(c!==undefined&&c!==null,'missing offset'),b.ok(c+3'},c.prototype.hexSlice=function(b,a){var d=this.length;(!b||b<0)&&(b=0),(!a||a<0||a>d)&&(a=d);var e='';for(var c=b;ce&&(a=e)):a=e;var f=h.length;if(f%2)throw new Error('Invalid hex string');a>f/2&&(a=f/2);for(var b=0;be&&(a=e)):a=e,d=String(d||'utf8').toLowerCase();switch(d){case'hex':return this.hexWrite(c,b,a);case'utf8':case'utf-8':return this.utf8Write(c,b,a);case'ascii':return this.asciiWrite(c,b,a);case'binary':return this.binaryWrite(c,b,a);case'base64':return this.base64Write(c,b,a);case'ucs2':case'ucs-2':return this.ucs2Write(c,b,a);default:throw new Error('Unknown encoding')}},c.prototype.slice=function(c,b){if(b===undefined&&(b=this.length),b>this.length)throw new Error('oob');if(c>b)throw new Error('oob');return new a(this,b-c,+c)},c.prototype.copy=function(e,d,f,g){var c=[];for(var a=f;a'},a.prototype.get=function a(a){if(a<0||a>=this.length)throw new Error('oob');return this.parent[this.offset+a]},a.prototype.set=function a(a,b){if(a<0||a>=this.length)throw new Error('oob');return this.parent[this.offset+a]=b},a.prototype.write=function(f,d,b,g){if(isFinite(d))isFinite(b)||(g=b,b=undefined);else{var i=g;g=d,d=b,b=i}d=+d||0;var h=this.length-d;b?(b=+b,b>h&&(b=h)):b=h,g=String(g||'utf8').toLowerCase();var e;switch(g){case'hex':e=this.parent.hexWrite(f,this.offset+d,b);break;case'utf8':case'utf-8':e=this.parent.utf8Write(f,this.offset+d,b);break;case'ascii':e=this.parent.asciiWrite(f,this.offset+d,b);break;case'binary':e=this.parent.binaryWrite(f,this.offset+d,b);break;case'base64':e=this.parent.base64Write(f,this.offset+d,b);break;case'ucs2':case'ucs-2':e=this.parent.ucs2Write(f,this.offset+d,b);break;default:throw new Error('Unknown encoding')}return a._charsWritten=c._charsWritten,e},a.prototype.toString=function(c,a,b){c=String(c||'utf8').toLowerCase(),a===void 0||a<0?a=0:a>this.length&&(a=this.length),b===void 0||b>this.length?b=this.length:b<0&&(b=0),a+=this.offset,b+=this.offset;switch(c){case'hex':return this.parent.hexSlice(a,b);case'utf8':case'utf-8':return this.parent.utf8Slice(a,b);case'ascii':return this.parent.asciiSlice(a,b);case'binary':return this.parent.binarySlice(a,b);case'base64':return this.parent.base64Slice(a,b);case'ucs2':case'ucs-2':return this.parent.ucs2Slice(a,b);default:throw new Error('Unknown encoding')}},a.byteLength=c.byteLength,a.prototype.fill=function a(a,b,c){if(a||(a=0),b||(b=0),c||(c=this.length),typeof a==='string'&&(a=a.charCodeAt(0)),!(typeof a==='number')||isNaN(a))throw new Error('value is not a number');if(c=this.length)throw new Error('start out of bounds');if(c<0||c>this.length)throw new Error('end out of bounds');return this.parent.fill(a,b+this.offset,c+this.offset)},a.prototype.copy=function(d,c,b,a){var e=this;if(b||(b=0),a||(a=this.length),c||(c=0),a=d.length)throw new Error('targetStart out of bounds');if(b<0||b>=e.length)throw new Error('sourceStart out of bounds');if(a<0||a>e.length)throw new Error('sourceEnd out of bounds');return a>this.length&&(a=this.length),d.length-cthis.length)throw new Error('oob');if(c>b)throw new Error('oob');return new a(this.parent,b-c,+c+this.offset)},a.prototype.utf8Slice=function(a,b){return this.toString('utf8',a,b)},a.prototype.binarySlice=function(a,b){return this.toString('binary',a,b)},a.prototype.asciiSlice=function(a,b){return this.toString('ascii',a,b)},a.prototype.utf8Write=function(a,b){return this.write(a,b,'utf8')},a.prototype.binaryWrite=function(a,b){return this.write(a,b,'binary')},a.prototype.asciiWrite=function(a,b){return this.write(a,b,'ascii')},a.prototype.readUInt8=function(a,d){var c=this;return d||(b.ok(a!==undefined&&a!==null,'missing offset'),b.ok(a=0?d.writeUInt8(a,c,e):d.writeUInt8(255+a+1,c,e)},a.prototype.writeInt16LE=function(a,b,c){y(this,a,b,!1,c)},a.prototype.writeInt16BE=function(a,b,c){y(this,a,b,!0,c)},a.prototype.writeInt32LE=function(a,b,c){z(this,a,b,!1,c)},a.prototype.writeInt32BE=function(a,b,c){z(this,a,b,!0,c)},a.prototype.writeFloatLE=function(a,b,c){A(this,a,b,!1,c)},a.prototype.writeFloatBE=function(a,b,c){A(this,a,b,!0,c)},a.prototype.writeDoubleLE=function(a,b,c){q(this,a,b,!1,c)},a.prototype.writeDoubleBE=function(a,b,c){q(this,a,b,!0,c)},c.prototype.readUInt8=a.prototype.readUInt8,c.prototype.readUInt16LE=a.prototype.readUInt16LE,c.prototype.readUInt16BE=a.prototype.readUInt16BE,c.prototype.readUInt32LE=a.prototype.readUInt32LE,c.prototype.readUInt32BE=a.prototype.readUInt32BE,c.prototype.readInt8=a.prototype.readInt8,c.prototype.readInt16LE=a.prototype.readInt16LE,c.prototype.readInt16BE=a.prototype.readInt16BE,c.prototype.readInt32LE=a.prototype.readInt32LE,c.prototype.readInt32BE=a.prototype.readInt32BE,c.prototype.readFloatLE=a.prototype.readFloatLE,c.prototype.readFloatBE=a.prototype.readFloatBE,c.prototype.readDoubleLE=a.prototype.readDoubleLE,c.prototype.readDoubleBE=a.prototype.readDoubleBE,c.prototype.writeUInt8=a.prototype.writeUInt8,c.prototype.writeUInt16LE=a.prototype.writeUInt16LE,c.prototype.writeUInt16BE=a.prototype.writeUInt16BE,c.prototype.writeUInt32LE=a.prototype.writeUInt32LE,c.prototype.writeUInt32BE=a.prototype.writeUInt32BE,c.prototype.writeInt8=a.prototype.writeInt8,c.prototype.writeInt16LE=a.prototype.writeInt16LE,c.prototype.writeInt16BE=a.prototype.writeInt16BE,c.prototype.writeInt32LE=a.prototype.writeInt32LE,c.prototype.writeInt32BE=a.prototype.writeInt32BE,c.prototype.writeFloatLE=a.prototype.writeFloatLE,c.prototype.writeFloatBE=a.prototype.writeFloatBE,c.prototype.writeDoubleLE=a.prototype.writeDoubleLE,c.prototype.writeDoubleBE=a.prototype.writeDoubleBE},{assert:1,'./buffer_ieee754':8,'base64-js':9}],9:[function(b,a,c){!function(e){'use strict';function c(a){var c,g,h,d,f,e;if(a.length%4>0)throw'Invalid string. Length must be a multiple of 4';for(f=a.indexOf('='),f=f>0?a.length-f:0,e=[],h=f>0?a.length-4:a.length,c=0,g=0;c>16),e.push((d&65280)>>8),e.push(d&255);return f===2?(d=b.indexOf(a[c])<<2|b.indexOf(a[c+1])>>4,e.push(d&255)):f===1&&(d=b.indexOf(a[c])<<10|b.indexOf(a[c+1])<<4|b.indexOf(a[c+2])>>2,e.push(d>>8&255),e.push(d&255)),e}function d(a){function h(a){return b[a>>18&63]+b[a>>12&63]+b[a>>6&63]+b[a&63]}var e,f=a.length%3,c='',d,g;for(e=0,g=a.length-f;e>2];c+=b[d<<4&63];c+='==';break;case 2:d=(a[a.length-2]<<8)+a[a.length-1];c+=b[d>>10];c+=b[d>>4&63];c+=b[d<<2&63];c+='=';break}return c}var b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';a.exports.toByteArray=c,a.exports.fromByteArray=d}()},{}]},{},[]),b.exports=a('buffer-browserify')},{}],14:[function(c,b,d){var a=b.exports={};a.nextTick=function(b,c,a){return b=typeof window!=='undefined'&&window.setImmediate,c=typeof window!=='undefined'&&window.postMessage&&window.addEventListener,b?function(a){return window.setImmediate(a)}:c?(a=[],window.addEventListener('message',function(b){var c=b.source;if((c===window||c===null)&&b.data==='process-tick'&&(b.stopPropagation(),a.length>0)){var d=a.shift();d()}},!0),function b(b){a.push(b),window.postMessage('process-tick','*')}):function a(a){setTimeout(a,0)}}(),a.title='browser',a.browser=!0,a.env={},a.argv=[],a.binding=function(a){throw new Error('process.binding is not supported')},a.cwd=function(){return'/'},a.chdir=function(a){throw new Error('process.chdir is not supported')}},{}],15:[function(c,e,a){var d=c('events').EventEmitter,b=c('through');a=e.exports=function(b){return typeof b.pipe==='function'?a.fromStream(b):a.toStream(b)},a.toStream=function(a){var c=b(function a(a){this.emit('data',a)},function b(){var b=a._emitStreams.indexOf(c);a._emitStreams.splice(b,1)});if(!a._emitStreams){a._emitStreams=[];var d=a.emit;a.emit=function(){var b=[].slice.call(arguments);a._emitStreams.forEach(function(a){a.writable&&a.write(b)}),d.apply(a,arguments)}}return a._emitStreams.push(c),c},a.fromStream=function(c){var a=new d;return c.pipe(b(function(b){a.emit.apply(a,b)})),a}},{events:7,through:16}],16:[function(b,e,f){function a(g,f,j){function k(){while(b.length&&!a.paused){var c=b.shift();if(null===c)return a.emit('end');a.emit('data',c)}}function l(){a.writable=!1,f.call(a),!a.readable&&a.autoDestroy&&a.destroy()}g=g||function(a){this.queue(a)},f=f||function(){this.queue(null)};var e=!1,h=!1,b=[],i=!1,a=new d;return a.readable=a.writable=!0,a.paused=!1,a.autoDestroy=!(j&&j.autoDestroy===!1),a.write=function(b){return g.call(this,b),!a.paused},a.queue=a.push=function(c){return i?a:(c==null&&(i=!0),b.push(c),k(),a)},a.on('end',function(){a.readable=!1,!a.writable&&a.autoDestroy&&c.nextTick(function(){a.destroy()})}),a.end=function(b){return e?void 0:(e=!0,arguments.length&&a.write(b),l(),a)},a.destroy=function(){return h?void 0:(h=!0,e=!0,b.length=0,a.writable=a.readable=!1,a.emit('close'),a)},a.pause=function(){return a.paused?void 0:(a.paused=!0,a)},a.resume=function(){return a.paused&&(a.paused=!1,a.emit('resume')),k(),a.paused||a.emit('drain'),a},a}var c=b('__browserify_process'),d=b('stream');f=e.exports=a,a.through=a},{__browserify_process:14,stream:10}],17:[function(a,b,c){!function(a){typeof define=='function'?define(a):typeof YUI=='function'?YUI.add('es5',a):a()}(function(){function j(){}function q(a){return a=+a,a!==a?a=0:a!==0&&a!==1/0&&a!==-(1/0)&&(a=(a>0||-1)*Math.floor(Math.abs(a))),a}function i(b){var a=typeof b;return b===null||a==='undefined'||a==='boolean'||a==='number'||a==='string'}function F(a){var b,c,d;if(i(a))return a;if(c=a.valueOf,typeof c==='function'&&(b=c.call(a),i(b)))return b;if(d=a.toString,typeof d==='function'&&(b=d.call(a),i(b)))return b;throw new TypeError}Function.prototype.bind||(Function.prototype.bind=function a(d){var a=this;if(typeof a!='function')throw new TypeError('Function.prototype.bind called on incompatible '+a);var c=g.call(arguments,1),b=function(){if(this instanceof b){var e=a.apply(this,c.concat(g.call(arguments)));return Object(e)===e?e:this}else return a.apply(d,c.concat(g.call(arguments)))};return a.prototype&&(j.prototype=a.prototype,b.prototype=new j,j.prototype=null),b});var f=Function.prototype.call,s=Array.prototype,d=Object.prototype,g=s.slice,a=f.bind(d.toString),h=f.bind(d.hasOwnProperty),E,D,C,B,A;if((A=h(d,'__defineGetter__'))&&(E=f.bind(d.__defineGetter__),D=f.bind(d.__defineSetter__),C=f.bind(d.__lookupGetter__),B=f.bind(d.__lookupSetter__)),[1,2].splice(0).length!=2){var u=Array.prototype.splice;Array.prototype.splice=function(a,b){return arguments.length?u.apply(this,[a===void 0?0:a,b===void 0?this.length-a:b].concat(g.call(arguments,2))):[]}}if([].unshift(0)!=1){var r=Array.prototype.unshift;Array.prototype.unshift=function(){return r.apply(this,arguments),this.length}}Array.isArray||(Array.isArray=function b(b){return a(b)=='[object Array]'});var k=Object('a'),c=k[0]!='a'||!(0 in k);if(Array.prototype.forEach||(Array.prototype.forEach=function d(g){var f=b(this),e=c&&a(this)=='[object String]'?this.split(''):f,h=arguments[1],d=-1,i=e.length>>>0;if(a(g)!='[object Function]')throw new TypeError;while(++d>>0,i=Array(h),j=arguments[1];if(a(f)!='[object Function]')throw new TypeError(f+' is not a function');for(var d=0;d>>0,h=[],i,k=arguments[1];if(a(f)!='[object Function]')throw new TypeError(f+' is not a function');for(var d=0;d>>0,i=arguments[1];if(a(f)!='[object Function]')throw new TypeError(f+' is not a function');for(var d=0;d>>0,i=arguments[1];if(a(f)!='[object Function]')throw new TypeError(f+' is not a function');for(var d=0;d>>0;if(a(h)!='[object Function]')throw new TypeError(h+' is not a function');if(!g&&arguments.length==1)throw new TypeError('reduce of empty array with no initial value');var d=0,f;if(arguments.length>=2)f=arguments[1];else do{if(d in e){f=e[d++];break}if(++d>=g)throw new TypeError('reduce of empty array with no initial value')}while(!0);for(;d>>0;if(a(g)!='[object Function]')throw new TypeError(g+' is not a function');if(!i&&arguments.length==1)throw new TypeError('reduceRight of empty array with no initial value');var f,d=i-1;if(arguments.length>=2)f=arguments[1];else do{if(d in e){f=e[d--];break}if(--d<0)throw new TypeError('reduceRight of empty array with no initial value')}while(!0);do d in this&&(f=g.call(void 0,f,e[d],d,h));while(d--);return f}),(!Array.prototype.indexOf||[0,1].indexOf(1,2)!=-1)&&(Array.prototype.indexOf=function d(g){var e=c&&a(this)=='[object String]'?this.split(''):b(this),f=e.length>>>0;if(!f)return-1;var d=0;for(arguments.length>1&&(d=q(arguments[1])),d=d>=0?d:Math.max(0,f+d);d>>0;if(!f)return-1;var d=f-1;for(arguments.length>1&&(d=Math.min(d,q(arguments[1]))),d=d>=0?d:f-Math.abs(d);d>=0;d--)if(d in e&&g===e[d])return d;return-1}),!Object.keys){var m=!0,n=['toString','toLocaleString','valueOf','hasOwnProperty','isPrototypeOf','propertyIsEnumerable','constructor'],w=n.length;for(var z in{toString:null})m=!1;Object.keys=function a(a){if(typeof a!='object'&&typeof a!='function'||a===null)throw new TypeError('Object.keys called on a non-object');var b=[];for(var d in a)h(a,d)&&b.push(d);if(m)for(var c=0,f=w;c9999?'+':'')+('00000'+Math.abs(a)).slice(0<=a&&a<=9999?-4:-6),d=b.length;while(d--)e=b[d],e<10&&(b[d]='0'+e);return a+'-'+b.slice(0,2).join('-')+'T'+b.slice(2).join(':')+'.'+('000'+this.getUTCMilliseconds()).slice(-3)+'Z'});var p=!1;try{p=Date.prototype.toJSON&&new Date(NaN).toJSON()===null&&new Date(l).toJSON().indexOf(o)!==-1&&Date.prototype.toJSON.call({toISOString:function(){return!0}})}catch(a){}if(p||(Date.prototype.toJSON=function a(d){var a=Object(this),b=F(a),c;if(typeof b==='number'&&!isFinite(b))return null;if(c=a.toISOString,typeof c!='function')throw new TypeError('toISOString property is not callable');return c.call(a)}),(!Date.parse||'Date.parse is buggy')&&(Date=function(a,e,f,c){function b(c,e,f,g,h,j,k){var d=arguments.length;if(this instanceof a){var i=d==1&&String(c)===c?new a(b.parse(c)):d>=7?new a(c,e,f,g,h,j,k):d>=6?new a(c,e,f,g,h,j):d>=5?new a(c,e,f,g,h):d>=4?new a(c,e,f,g):d>=3?new a(c,e,f):d>=2?new a(c,e):d>=1?new a(c):new a;return i.constructor=b,i}return a.apply(this,arguments)}function d(a,c){var b=c>1?1:0;return f[c]+Math.floor((a-1969+b)/4)-Math.floor((a-1901+b)/100)+Math.floor((a-1601+b)/400)+365*(a-1970)}e=new RegExp('^(\\d{4}|[+-]\\d{6})(?:-(\\d{2})(?:-(\\d{2})(?:T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{3}))?)?(Z|(?:([-+])(\\d{2}):(\\d{2})))?)?)?)?$'),f=[0,31,59,90,120,151,181,212,243,273,304,334,365];for(c in a)b[c]=a[c];return b.now=a.now,b.UTC=a.UTC,b.prototype=a.prototype,b.prototype.constructor=b,b.parse=function b(q){var b=e.exec(q);if(b){var g=Number(b[1]),f=Number(b[2]||1)-1,i=Number(b[3]||1)-1,l=Number(b[4]||0),h=Number(b[5]||0),k=Number(b[6]||0),j=Number(b[7]||0),p=!b[4]||b[8]?0:Number(new a(1970,0)),m=b[9]==='-'?1:-1,n=Number(b[10]||0),o=Number(b[11]||0),c;return l<(h>0||k>0||j>0?24:25)&&h<60&&k<60&&j<1e3&&f>-1&&f<12&&n<24&&o<60&&i>-1&&i1?this._listeners[c]=b.slice(0,d).concat(b.slice(d+1)):delete this._listeners[c];return}return},m.prototype.dispatchEvent=function(d){var a=d.type,c=Array.prototype.slice.call(arguments,0);if(this['on'+a]&&this['on'+a].apply(this,c),this._listeners&&a in this._listeners)for(var b=0;b=3e3&&a<=4999},a.countRTO=function(a){var b;return a>100?b=3*a:b=a+200,b},a.log=function(){c.console&&console.log&&console.log.apply&&console.log.apply(console,arguments)},a.bind=function(a,b){return a.bind?a.bind(b):function(){return a.apply(b,arguments)}},a.flatUrl=function(a){return a.indexOf('?')===-1&&a.indexOf('#')===-1},a.amendUrl=function(b){var c=d.location;if(!b)throw new Error('Wrong url for SockJS');if(!a.flatUrl(b))throw new Error('Only basic urls are supported in SockJS');return b.indexOf('//')===0&&(b=c.protocol+b),b.indexOf('/')===0&&(b=c.protocol+'//'+c.host+b),b=b.replace(/[/]+$/,''),b},a.arrIndexOf=function(b,c){for(var a=0;a=0},a.delay=function(a,b){return typeof a==='function'&&(b=a,a=0),setTimeout(b,a)},D=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,S={'�':'\\u0000','':'\\u0001','':'\\u0002','':'\\u0003','':'\\u0004','':'\\u0005','':'\\u0006','':'\\u0007','':'\\b',' ':'\\t','\n':'\\n',' ':'\\u000b',' ':'\\f','\r':'\\r','':'\\u000e','':'\\u000f','':'\\u0010','':'\\u0011','':'\\u0012','':'\\u0013','':'\\u0014','':'\\u0015','':'\\u0016','':'\\u0017','':'\\u0018','':'\\u0019','':'\\u001a','':'\\u001b','':'\\u001c','':'\\u001d','':'\\u001e','':'\\u001f','"':'\\"','\\':'\\\\','':'\\u007f','€':'\\u0080','':'\\u0081','‚':'\\u0082','ƒ':'\\u0083','„':'\\u0084','Â…':'\\u0085','†':'\\u0086','‡':'\\u0087','ˆ':'\\u0088','‰':'\\u0089','Š':'\\u008a','‹':'\\u008b','ÂŒ':'\\u008c','':'\\u008d','ÂŽ':'\\u008e','':'\\u008f','':'\\u0090','‘':'\\u0091','Â’':'\\u0092','“':'\\u0093','”':'\\u0094','•':'\\u0095','–':'\\u0096','—':'\\u0097','˜':'\\u0098','™':'\\u0099','š':'\\u009a','›':'\\u009b','œ':'\\u009c','':'\\u009d','ž':'\\u009e','Ÿ':'\\u009f','­':'\\u00ad','Ø€':'\\u0600','؁':'\\u0601','Ø‚':'\\u0602','؃':'\\u0603','Ø„':'\\u0604','܏':'\\u070f','áž´':'\\u17b4','ážµ':'\\u17b5','‌':'\\u200c','‍':'\\u200d','‎':'\\u200e','‏':'\\u200f','\u2028':'\\u2028','\u2029':'\\u2029','‪':'\\u202a','‫':'\\u202b','‬':'\\u202c','‭':'\\u202d','‮':'\\u202e',' ':'\\u202f','⁠':'\\u2060','⁡':'\\u2061','⁢':'\\u2062','⁣':'\\u2063','⁤':'\\u2064','⁥':'\\u2065','⁦':'\\u2066','⁧':'\\u2067','⁨':'\\u2068','⁩':'\\u2069','':'\\u206a','':'\\u206b','':'\\u206c','':'\\u206d','':'\\u206e','':'\\u206f','':'\\ufeff','ï¿°':'\\ufff0','￱':'\\ufff1','￲':'\\ufff2','￳':'\\ufff3','ï¿´':'\\ufff4','￵':'\\ufff5','ï¿¶':'\\ufff6','ï¿·':'\\ufff7','￸':'\\ufff8','':'\\ufff9','':'\\ufffa','ï¿»':'\\ufffb','':'\\ufffc','�':'\\ufffd','￾':'\\ufffe','ï¿¿':'\\uffff'},s=/[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f80-\u0f83\u0f93\u0f9d\u0fa2\u0fa7\u0fac\u0fb9\u1939-\u193a\u1a17\u1b6b\u1cda-\u1cdb\u1dc0-\u1dcf\u1dfc\u1dfe\u1f71\u1f73\u1f75\u1f77\u1f79\u1f7b\u1f7d\u1fbb\u1fbe\u1fc9\u1fcb\u1fd3\u1fdb\u1fe3\u1feb\u1fee-\u1fef\u1ff9\u1ffb\u1ffd\u2000-\u2001\u20d0-\u20d1\u20d4-\u20d7\u20e7-\u20e9\u2126\u212a-\u212b\u2329-\u232a\u2adc\u302b-\u302c\uaab2-\uaab3\uf900-\ufa0d\ufa10\ufa12\ufa15-\ufa1e\ufa20\ufa22\ufa25-\ufa26\ufa2a-\ufa2d\ufa30-\ufa6d\ufa70-\ufad9\ufb1d\ufb1f\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufb4e\ufff0-\uffff]/g,V=JSON&&JSON.stringify||function(a){return D.lastIndex=0,D.test(a)&&(a=a.replace(D,function(a){return S[a]})),'"'+a+'"'},a3=function(b){var a,c={},d=[];for(a=0;a<65536;a++)d.push(String.fromCharCode(a));return b.lastIndex=0,d.join('').replace(b,function(a){return c[a]='\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4),''}),b.lastIndex=0,c},a.quote=function(b){var a=V(b);return s.lastIndex=0,s.test(a)?(O||(O=a3(s)),a.replace(s,function(a){return O[a]})):a},E=['websocket','xdr-streaming','xhr-streaming','iframe-eventsource','iframe-htmlfile','xdr-polling','xhr-polling','iframe-xhr-polling','jsonp-polling'],a.probeProtocols=function(){var d={};for(var a=0;a0&&d(a)};return a.websocket!==!1&&d(['websocket']),b['xhr-streaming']&&!a.null_origin?c.push('xhr-streaming'):b['xdr-streaming']&&!a.cookie_needed&&!a.null_origin?c.push('xdr-streaming'):d(['iframe-eventsource','iframe-htmlfile']),b['xhr-polling']&&!a.null_origin?c.push('xhr-polling'):b['xdr-polling']&&!a.cookie_needed&&!a.null_origin?c.push('xdr-polling'):d(['iframe-xhr-polling','jsonp-polling']),c},z='_sockjs_global',a.createHook=function(){var d='a'+a.random_string(8);if(!(z in c)){var b={};c[z]=function(a){return a in b||(b[a]={id:a,del:function(){delete b[a]}}),b[a]}}return c[z](d)},a.attachMessage=function(b){a.attachEvent('message',b)},a.attachEvent=function(a,b){c.addEventListener!==void 0?c.addEventListener(a,b,!1):(d.attachEvent('on'+a,b),c.attachEvent('on'+a,b))},a.detachMessage=function(b){a.detachEvent('message',b)},a.detachEvent=function(a,b){c.addEventListener!==void 0?c.removeEventListener(a,b,!1):(d.detachEvent('on'+a,b),c.detachEvent('on'+a,b))},n={},C=!1,Q=function(){for(var a in n)n[a](),delete n[a]},P=function(){if(C)return;C=!0,Q()},a.attachEvent('beforeunload',P),a.attachEvent('unload',P),a.unload_add=function(c){var b=a.random_string(8);return n[b]=c,C&&a.delay(Q),b},a.unload_del=function(a){a in n&&delete n[a]},a.createIframe=function(j,k){var b=d.createElement('iframe'),c,h,g=function(){clearTimeout(c);try{b.onload=null}catch(a){}b.onerror=null},e=function(){b&&(g(),setTimeout(function(){b&&b.parentNode.removeChild(b),b=null},0),a.unload_del(h))},f=function(a){b&&(e(),k(a))},i=function(a,c){try{b&&b.contentWindow&&b.contentWindow.postMessage(a,c)}catch(a){}};return b.src=j,b.style.display='none',b.style.position='absolute',b.onerror=function(){f('onerror')},b.onload=function(){clearTimeout(c),c=setTimeout(function(){f('onload timeout')},2e3)},d.body.appendChild(b),c=setTimeout(function(){f('timeout')},15e3),h=a.unload_add(e),{post:i,cleanup:e,loaded:g}},a.createHtmlfile=function(m,n){var b=new ActiveXObject('htmlfile'),j,i,d,h=function(){clearTimeout(j)},e=function(){b&&(h(),a.unload_del(i),d.parentNode.removeChild(d),d=b=null,CollectGarbage())},k=function(a){b&&(e(),n(a))},l=function(a,b){try{d&&d.contentWindow&&d.contentWindow.postMessage(a,b)}catch(a){}};b.open(),b.write(''),b.close(),b.parentWindow[g]=c[g];var f=b.createElement('div');return b.body.appendChild(f),d=b.createElement('iframe'),f.appendChild(d),d.src=m,j=setTimeout(function(){k('timeout')},15e3),i=a.unload_add(e),{post:l,cleanup:e,loaded:h}},p=function(){},p.prototype=new l(['chunk','finish']),p.prototype._start=function(g,e,h,d){var b=this;try{b.xhr=new XMLHttpRequest}catch(a){}if(!b.xhr)try{b.xhr=new c.ActiveXObject('Microsoft.XMLHTTP')}catch(a){}(c.ActiveXObject||c.XDomainRequest)&&(e+=(e.indexOf('?')===-1?'?t=':'&t=')+ +new Date),b.unload_ref=a.unload_add(function(){b._cleanup(!0)});try{b.xhr.open(g,e,!0)}catch(a){b.emit('finish',0,''),b._cleanup();return}if(d&&d.no_credentials||(b.xhr.withCredentials='true'),d&&d.headers)for(var f in d.headers)b.xhr.setRequestHeader(f,d.headers[f]);b.xhr.onreadystatechange=function(){if(b.xhr){var a=b.xhr;switch(a.readyState){case 3:try{var d=a.status,c=a.responseText}catch(a){}c&&c.length>0&&b.emit('chunk',d,c);break;case 4:b.emit('finish',a.status,a.responseText);b._cleanup(!1);break}}},b.xhr.send(h)},p.prototype._cleanup=function(c){var b=this;if(!b.xhr)return;if(a.unload_del(b.unload_ref),b.xhr.onreadystatechange=function(){},c)try{b.xhr.abort()}catch(a){}b.unload_ref=b.xhr=null},p.prototype.close=function(){var a=this;a.nuke(),a._cleanup(!0)},Z=a.XHRCorsObject=function(){var b=this,c=arguments;a.delay(function(){b._start.apply(b,c)})},Z.prototype=new p,a0=a.XHRLocalObject=function(c,d,e){var b=this;a.delay(function(){b._start(c,d,e,{no_credentials:!0})})},a0.prototype=new p,x=a.XDRObject=function(c,d,e){var b=this;a.delay(function(){b._start(c,d,e)})},x.prototype=new l(['chunk','finish']),x.prototype._start=function(f,d,g){var b=this,c=new XDomainRequest;d+=(d.indexOf('?')===-1?'?t=':'&t=')+ +new Date;var e=c.ontimeout=c.onerror=function(){b.emit('finish',0,''),b._cleanup(!1)};c.onprogress=function(){b.emit('chunk',200,c.responseText)},c.onload=function(){b.emit('finish',200,c.responseText),b._cleanup(!1)},b.xdr=c,b.unload_ref=a.unload_add(function(){b._cleanup(!0)});try{b.xdr.open(f,d),b.xdr.send(g)}catch(a){e()}},x.prototype._cleanup=function(c){var b=this;if(!b.xdr)return;if(a.unload_del(b.unload_ref),b.xdr.ontimeout=b.xdr.onerror=b.xdr.onprogress=b.xdr.onload=null,c)try{b.xdr.abort()}catch(a){}b.unload_ref=b.xdr=null},x.prototype.close=function(){var a=this;a.nuke(),a._cleanup(!0)},a.isXHRCorsCapable=function(){return c.XMLHttpRequest&&'withCredentials'in new XMLHttpRequest?1:c.XDomainRequest&&d.domain?2:e.enabled()?3:4},b=function(g,d,f){if(this===window)return new b(g,d,f);var c=this,e;c._options={devel:!1,debug:!1,protocols_whitelist:[],info:undefined,rtt:undefined},f&&a.objectExtend(c._options,f),c._base_url=a.amendUrl(g),c._server=c._options.server||a.random_number_string(1e3),c._options.protocols_whitelist&&c._options.protocols_whitelist.length?e=c._options.protocols_whitelist:(typeof d==='string'&&d.length>0?e=[d]:a.isArray(d)?e=d:e=null,e&&c._debug('Deprecated API: Use "protocols_whitelist" option instead of supplying protocol list as a second parameter to SockJS constructor.')),c._protocols=[],c.protocol=null,c.readyState=b.CONNECTING,c._ir=T(c._base_url),c._ir.onfinish=function(b,d){c._ir=null,b?(c._options.info&&(b=a.objectExtend(b,c._options.info)),c._options.rtt&&(d=c._options.rtt),c._applyInfo(b,d,e),c._didClose()):c._didClose(1002,"Can't connect to server",!0)}},b.prototype=new m,b.version='0.3.1.7.ga67f.dirty',b.CONNECTING=0,b.OPEN=1,b.CLOSING=2,b.CLOSED=3,b.prototype._debug=function(){this._options.debug&&a.log.apply(a,arguments)},b.prototype._dispatchOpen=function(){var a=this;a.readyState===b.CONNECTING?(a._transport_tref&&(clearTimeout(a._transport_tref),a._transport_tref=null),a.readyState=b.OPEN,a.dispatchEvent(new f('open'))):a._didClose(1006,'Server lost session')},b.prototype._dispatchMessage=function(c){var a=this;if(a.readyState!==b.OPEN)return;a.dispatchEvent(new f('message',{data:c}))},b.prototype._dispatchHeartbeat=function(c){var a=this;if(a.readyState!==b.OPEN)return;a.dispatchEvent(new f('heartbeat',{}))},b.prototype._didClose=function(e,g,h){var c=this;if(c.readyState!==b.CONNECTING&&c.readyState!==b.OPEN&&c.readyState!==b.CLOSING)throw new Error('INVALID_STATE_ERR');c._ir&&(c._ir.nuke(),c._ir=null),c._transport&&(c._transport.doCleanup(),c._transport=null);var d=new f('close',{code:e,reason:g,wasClean:a.userSetCode(e)});if(!a.userSetCode(e)&&c.readyState===b.CONNECTING&&!h){if(c._try_next_protocol(d))return;d=new f('close',{code:2e3,reason:'All transports failed',wasClean:!1,last_event:d})}c.readyState=b.CLOSED,a.delay(function(){c.dispatchEvent(d)})},b.prototype._didMessage=function(c){var b=this,e=c.slice(0,1);switch(e){case'o':b._dispatchOpen();break;case'a':var a=JSON.parse(c.slice(1)||'[]');for(var d=0;d0){var b='['+a.send_buffer.join(',')+']';a.send_stop=a.sender(a.trans_url,b,function(){a.send_stop=null,a.send_schedule_wait()}),a.send_buffer=[]}},j.prototype.send_destructor=function(){var a=this;a._send_stop&&a._send_stop(),a._send_stop=null},X=function(i,j,k){var f=this;if(!('_send_form'in f)){var c=f._send_form=d.createElement('form'),e=f._send_area=d.createElement('textarea');e.name='d',c.style.display='none',c.style.position='absolute',c.method='POST',c.enctype='application/x-www-form-urlencoded',c.acceptCharset='UTF-8',c.appendChild(e),d.body.appendChild(c)}var c=f._send_form,e=f._send_area,g='a'+a.random_string(8);c.target=g,c.action=i+'/jsonp_send?i='+g;var b;try{b=d.createElement('':(a+=''));switch(h){case'&':a+='&';break;case'<':a+='<';break;case'>':a+='>';break;default:h<=' '?a+=' ':(m(h)&&f++,a+=h);break}j=c}j!==this.defAttr&&(a+=''),this.children[g].innerHTML=a}i&&i.appendChild(this.element)},b.prototype._cursorBlink=function(){if(b.focus!==this)return;this.cursorState^=1,this.refresh(this.y,this.y)},b.prototype.showCursor=function(){this.cursorState||(this.cursorState=1,this.refresh(this.y,this.y))},b.prototype.startBlink=function(){if(!this.cursorBlink)return;var a=this;this._blinker=function(){a._cursorBlink()},this._blink=s(this._blinker,500)},b.prototype.refreshBlink=function(){if(!this.cursorBlink)return;clearInterval(this._blink),this._blink=s(this._blinker,500)},b.prototype.scroll=function(){var a;++this.ybase===this.scrollback&&(this.ybase=this.ybase/2|0,this.lines=this.lines.slice(-(this.ybase+this.rows)+1)),this.ydisp=this.ybase,a=this.ybase+this.rows-1,a-=this.rows-1-this.scrollBottom,a===this.lines.length?this.lines.push(this.blankLine()):this.lines.splice(a,0,this.blankLine()),this.scrollTop!==0&&(this.ybase!==0&&(this.ybase--,this.ydisp=this.ybase),this.lines.splice(this.ybase+this.scrollTop,1)),this.updateRange(this.scrollTop),this.updateRange(this.scrollBottom)},b.prototype.scrollDisp=function(a){this.ydisp+=a,this.ydisp>this.ybase?this.ydisp=this.ybase:this.ydisp<0&&(this.ydisp=0),this.refresh(0,this.rows-1)},b.prototype.write=function(i){var l=i.length,f=0,h,d,a;for(this.refreshStart=this.y,this.refreshEnd=this.y,this.ybase!==this.ydisp&&(this.ydisp=this.ybase,this.maxRange());fthis.scrollBottom&&(this.y--,this.scroll());break;case'\r':this.x=0;break;case'':this.x>0&&this.x--;break;case' ':this.x=this.nextStop();break;case'':this.setgLevel(1);break;case'':this.setgLevel(0);break;case'':this.state=n;break;default:if(a>=' '&&(this.charset&&this.charset[a]&&(a=this.charset[a]),this.x>=this.cols&&(this.x=0,this.y++,this.y>this.scrollBottom&&(this.y--,this.scroll())),this.lines[this.y+this.ybase][this.x]=[this.curAttr,a],this.x++,this.updateRange(this.y),m(a))){if(h=this.y+this.ybase,this.cols<2||this.x>=this.cols){this.lines[h][this.x-1]=[this.curAttr,' '];break}this.lines[h][this.x]=[this.curAttr,' '],this.x++}break}break;case n:switch(a){case'[':this.params=[];this.currentParam=0;this.state=o;break;case']':this.params=[];this.currentParam=0;this.state=p;break;case'P':this.params=[];this.currentParam=0;this.state=r;break;case'_':this.state=j;break;case'^':this.state=j;break;case'c':this.reset();break;case'E':this.x=0;case'D':this.index();break;case'M':this.reverseIndex();break;case'%':this.setgLevel(0);this.setgCharset(0,b.charsets.US);this.state=c;f++;break;case'(':case')':case'*':case'+':case'-':case'.':switch(a){case'(':this.gcharset=0;break;case')':this.gcharset=1;break;case'*':this.gcharset=2;break;case'+':this.gcharset=3;break;case'-':this.gcharset=1;break;case'.':this.gcharset=2;break}this.state=k;break;case'/':this.gcharset=3;this.state=k;f--;break;case'N':break;case'O':break;case'n':this.setgLevel(2);break;case'o':this.setgLevel(3);break;case'|':this.setgLevel(3);break;case'}':this.setgLevel(2);break;case'~':this.setgLevel(1);break;case'7':this.saveCursor();this.state=c;break;case'8':this.restoreCursor();this.state=c;break;case'#':this.state=c;f++;break;case'H':this.tabSet();break;case'=':this.log('Serial port requested application keypad.');this.applicationKeypad=!0;this.state=c;break;case'>':this.log('Switching back to normal keypad.');this.applicationKeypad=!1;this.state=c;break;default:this.state=c;this.error('Unknown ESC control: %s.',a);break}break;case k:switch(a){case'0':d=b.charsets.SCLD;break;case'A':d=b.charsets.UK;break;case'B':d=b.charsets.US;break;case'4':d=b.charsets.Dutch;break;case'C':case'5':d=b.charsets.Finnish;break;case'R':d=b.charsets.French;break;case'Q':d=b.charsets.FrenchCanadian;break;case'K':d=b.charsets.German;break;case'Y':d=b.charsets.Italian;break;case'E':case'6':d=b.charsets.NorwegianDanish;break;case'Z':d=b.charsets.Spanish;break;case'H':case'7':d=b.charsets.Swedish;break;case'=':d=b.charsets.Swiss;break;case'/':d=b.charsets.ISOLatin;f++;break;default:d=b.charsets.US;break}this.setgCharset(this.gcharset,d);this.gcharset=null;this.state=c;break;case p:if(a===''||a===''){a===''&&f++,this.params.push(this.currentParam);switch(this.params[0]){case 0:case 1:case 2:this.params[1]&&(this.title=this.params[1],this.handleTitle(this.title));break;case 3:break;case 4:case 5:break;case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:break;case 46:break;case 50:break;case 51:break;case 52:break;case 104:case 105:case 110:case 111:case 112:case 113:case 114:case 115:case 116:case 117:case 118:break}this.params=[],this.currentParam=0,this.state=c}else this.params.length?this.currentParam+=a:a>='0'&&a<='9'?this.currentParam=this.currentParam*10+a.charCodeAt(0)-48:a===';'&&(this.params.push(this.currentParam),this.currentParam='');break;case o:if(a==='?'||a==='>'||a==='!'){this.prefix=a;break}if(a>='0'&&a<='9'){this.currentParam=this.currentParam*10+a.charCodeAt(0)-48;break}if(a==='$'||a==='"'||a===' '||a==="'"){this.postfix=a;break}this.params.push(this.currentParam);this.currentParam=0;if(a===';')break;this.state=c;switch(a){case'A':this.cursorUp(this.params);break;case'B':this.cursorDown(this.params);break;case'C':this.cursorForward(this.params);break;case'D':this.cursorBackward(this.params);break;case'H':this.cursorPos(this.params);break;case'J':this.eraseInDisplay(this.params);break;case'K':this.eraseInLine(this.params);break;case'm':this.prefix||this.charAttributes(this.params);break;case'n':this.prefix||this.deviceStatus(this.params);break;case'@':this.insertChars(this.params);break;case'E':this.cursorNextLine(this.params);break;case'F':this.cursorPrecedingLine(this.params);break;case'G':this.cursorCharAbsolute(this.params);break;case'L':this.insertLines(this.params);break;case'M':this.deleteLines(this.params);break;case'P':this.deleteChars(this.params);break;case'X':this.eraseChars(this.params);break;case'`':this.charPosAbsolute(this.params);break;case'a':this.HPositionRelative(this.params);break;case'c':this.sendDeviceAttributes(this.params);break;case'd':this.linePosAbsolute(this.params);break;case'e':this.VPositionRelative(this.params);break;case'f':this.HVPosition(this.params);break;case'h':this.setMode(this.params);break;case'l':this.resetMode(this.params);break;case'r':this.setScrollRegion(this.params);break;case's':this.saveCursor(this.params);break;case'u':this.restoreCursor(this.params);break;case'I':this.cursorForwardTab(this.params);break;case'S':this.scrollUp(this.params);break;case'T':this.params.length<2&&!this.prefix&&this.scrollDown(this.params);break;case'Z':this.cursorBackwardTab(this.params);break;case'b':this.repeatPrecedingCharacter(this.params);break;case'g':this.tabClear(this.params);break;case'p':switch(this.prefix){case'!':this.softReset(this.params);break}break;default:this.error('Unknown CSI code: %s.',a);break}this.prefix='';this.postfix='';break;case r:if(a===''||a===''){a===''&&f++;switch(this.prefix){case'':break;case'$q':var e=this.currentParam,g=!1;switch(e){case'"q':e='0"q';break;case'"p':e='61"p';break;case'r':e=''+(this.scrollTop+1)+';'+(this.scrollBottom+1)+'r';break;case'm':e='0m';break;default:this.error('Unknown DCS Pt: %s.',e);e='';break}this.send('P'+ +g+'$r'+e+'\\');break;case'+p':break;case'+q':var e=this.currentParam,g=!1;this.send('P'+ +g+'+r'+e+'\\');break;default:this.error('Unknown DCS prefix: %s.',this.prefix);break}this.currentParam=0,this.prefix='',this.state=c}else this.currentParam?this.currentParam+=a:!this.prefix&&a!=='$'&&a!=='+'?this.currentParam=a:this.prefix.length===2?this.currentParam=a:this.prefix+=a;break;case j:(a===''||a==='')&&(a===''&&f++,this.state=c);break}}this.updateRange(this.y),this.refresh(this.refreshStart,this.refreshEnd)},b.prototype.writeln=function(a){this.write(a+'\r\n')},b.prototype.keyDown=function(b){var c=this,a;switch(b.keyCode){case 8:if(b.shiftKey){a='';break}a='';break;case 9:if(b.shiftKey){a='';break}a=' ';break;case 13:a='\r';break;case 27:a='';break;case 37:if(this.applicationCursor){a='OD';break}a='';break;case 39:if(this.applicationCursor){a='OC';break}a='';break;case 38:if(this.applicationCursor){a='OA';break}if(b.ctrlKey)return this.scrollDisp(-1),d(b);a='';break;case 40:if(this.applicationCursor){a='OB';break}if(b.ctrlKey)return this.scrollDisp(1),d(b);a='';break;case 46:a='[3~';break;case 45:a='[2~';break;case 36:if(this.applicationKeypad){a='OH';break}a='OH';break;case 35:if(this.applicationKeypad){a='OF';break}a='OF';break;case 33:if(b.shiftKey)return this.scrollDisp(-(this.rows-1)),d(b);a='[5~';break;case 34:if(b.shiftKey)return this.scrollDisp(this.rows-1),d(b);a='[6~';break;case 112:a='OP';break;case 113:a='OQ';break;case 114:a='OR';break;case 115:a='OS';break;case 116:a='[15~';break;case 117:a='[17~';break;case 118:a='[18~';break;case 119:a='[19~';break;case 120:a='[20~';break;case 121:a='[21~';break;case 122:a='[23~';break;case 123:a='[24~';break;default:if(b.ctrlKey)if(b.keyCode>=65&&b.keyCode<=90){if(this.screenKeys&&!(this.prefixMode||this.selectMode)&&b.keyCode===65)return this.enterPrefix(),d(b);if(this.prefixMode&&b.keyCode===86){this.leavePrefix();return}if((this.prefixMode||this.selectMode)&&b.keyCode===67){this.visualMode&&i(function(){c.leaveVisual()},1);return}a=g.fromCharCode(b.keyCode-64)}else b.keyCode===32?a=g.fromCharCode(0):b.keyCode>=51&&b.keyCode<=55?a=g.fromCharCode(b.keyCode-51+27):b.keyCode===56?a=g.fromCharCode(127):b.keyCode===219?a=g.fromCharCode(27):b.keyCode===221&&(a=g.fromCharCode(29));else(!this.isMac&&b.altKey||this.isMac&&b.metaKey)&&(b.keyCode>=65&&b.keyCode<=90?a=''+g.fromCharCode(b.keyCode+32):b.keyCode===192?a='`':b.keyCode>=48&&b.keyCode<=57&&(a=''+(b.keyCode-48)));break}return a?this.prefixMode?(this.leavePrefix(),d(b)):this.selectMode?(this.keySelect(b,a),d(b)):(this.emit('keydown',b),this.emit('key',a,b),this.showCursor(),this.handler(a),b.keyCode===86&&(this.isMac&&b.metaKey||!this.isMac&&b.ctrlKey)?!0:d(b)):!0},b.prototype.setgLevel=function(a){this.glevel=a,this.charset=this.charsets[a]},b.prototype.setgCharset=function(a,b){this.charsets[a]=b,this.glevel===a&&(this.charset=b)},b.prototype.keyPress=function(a){var b;if(a.charCode)b=a.charCode;else if(a.which==null)b=a.keyCode;else if(a.which!==0&&a.charCode!==0)b=a.which;else return!1;return b===118&&(this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey)||d(a),!b||a.ctrlKey||a.altKey&&b!=118||a.metaKey&&b!=118?!1:(b=g.fromCharCode(b),this.prefixMode?(this.leavePrefix(),this.keyPrefix(a,b),!1):this.selectMode?(this.keySelect(a,b),!1):(this.emit('keypress',b,a),this.emit('key',b,a),this.showCursor(),b==='v'&&(this.isMac&&a.metaKey||!this.isMac&&a.ctrlKey)||this.handler(b),!1))},b.prototype.send=function(b){var a=this;this.queue||i(function(){a.handler(a.queue),a.queue=''},1),this.queue+=b},b.prototype.bell=function(){if(!this.visualBell)return;var a=this;this.element.style.borderColor='white',i(function(){a.element.style.borderColor=''},10),this.popOnBell&&this.focus()},b.prototype.log=function(){if(!this.debug)return;if(!(this.context.console&&this.context.console.log))return;var a=Array.prototype.slice.call(arguments);this.context.console.log.apply(this.context.console,a)},b.prototype.error=function(){if(!this.debug)return;if(!(this.context.console&&this.context.console.error))return;var a=Array.prototype.slice.call(arguments);this.context.console.error.apply(this.context.console,a)},b.prototype.resize=function(b,a){var f,e,d,c,g;if(b<1&&(b=1),a<1&&(a=1),c=this.cols,cb){d=this.lines.length;while(d--)while(this.lines[d].length>b)this.lines[d].pop()}if(this.setupStops(c),this.cols=b,c=this.rows,ca)while(c-->a)if(this.lines.length>a+this.ybase&&this.lines.pop(),this.children.length>a){if(e=this.children.pop(),!e)continue;e.parentNode.removeChild(e)}this.rows=a,this.y>=a&&(this.y=a-1),this.x>=b&&(this.x=b-1),this.scrollTop=0,this.scrollBottom=a-1,this.refresh(0,this.rows-1),this.normal=null},b.prototype.updateRange=function(a){athis.refreshEnd&&(this.refreshEnd=a)},b.prototype.maxRange=function(){this.refreshStart=0,this.refreshEnd=this.rows-1},b.prototype.setupStops=function(a){for(a!=null?this.tabs[a]||(a=this.prevStop(a)):(this.tabs={},a=0);a0);return a>=this.cols?this.cols-1:a<0?0:a},b.prototype.nextStop=function(a){a==null&&(a=this.x);while(!this.tabs[++a]&&a=this.cols?this.cols-1:a<0?0:a},b.prototype.eraseRight=function(a,b){var c=this.lines[this.ybase+b],d=[this.eraseAttr(),' '];for(;athis.scrollBottom&&(this.y--,this.scroll()),this.state=c},b.prototype.reverseIndex=function(){var a;this.y--,this.y=this.rows&&(this.y=this.rows-1)},b.prototype.cursorForward=function(b){var a=b[0];a<1&&(a=1),this.x+=a,this.x>=this.cols&&(this.x=this.cols-1)},b.prototype.cursorBackward=function(b){var a=b[0];a<1&&(a=1),this.x-=a,this.x<0&&(this.x=0)},b.prototype.cursorPos=function(c){var b,a;b=c[0]-1,c.length>=2?a=c[1]-1:a=0,b<0?b=0:b>=this.rows&&(b=this.rows-1),a<0?a=0:a>=this.cols&&(a=this.cols-1),this.x=a,this.y=b},b.prototype.eraseInDisplay=function(b){var a;switch(b[0]){case 0:this.eraseRight(this.x,this.y);a=this.y+1;for(;a>18,e=this.curAttr>>9&511,f=this.curAttr&511,a;for(;b=30&&a<=37?e=a-30:a>=40&&a<=47?f=a-40:a>=90&&a<=97?(a+=8,e=a-90):a>=100&&a<=107?(a+=8,f=a-100):a===0?(d=this.defAttr>>18,e=this.defAttr>>9&511,f=this.defAttr&511):a===1?d|=1:a===4?d|=2:a===5?d|=4:a===7?d|=8:a===8?d|=16:a===22?d&=-2:a===24?d&=-3:a===25?d&=-5:a===27?d&=-9:a===28?d&=-17:a===39?e=this.defAttr>>9&511:a===49?f=this.defAttr&511:a===38?c[b+1]===2?(b+=2,e=h(c[b]&255,c[b+1]&255,c[b+2]&255),e===-1&&(e=511),b+=2):c[b+1]===5&&(b+=2,a=c[b]&255,e=a):a===48?c[b+1]===2?(b+=2,f=h(c[b]&255,c[b+1]&255,c[b+2]&255),f===-1&&(f=511),b+=2):c[b+1]===5&&(b+=2,a=c[b]&255,f=a):a===100?(e=this.defAttr>>9&511,f=this.defAttr&511):this.error('Unknown SGR attribute: %d.',a);this.curAttr=d<<18|e<<9|f},b.prototype.deviceStatus=function(a){if(!this.prefix)switch(a[0]){case 5:this.send('');break;case 6:this.send('['+(this.y+1)+';'+(this.x+1)+'R');break}else if(this.prefix==='?')switch(a[0]){case 6:this.send('[?'+(this.y+1)+';'+(this.x+1)+'R');break;case 15:break;case 25:break;case 26:break;case 53:break}},b.prototype.insertChars=function(e){var a,b,c,d;a=e[0],a<1&&(a=1),b=this.y+this.ybase,c=this.x,d=[this.eraseAttr(),' '];while(a--&&c=this.rows&&(this.y=this.rows-1),this.x=0},b.prototype.cursorPrecedingLine=function(b){var a=b[0];a<1&&(a=1),this.y-=a,this.y<0&&(this.y=0),this.x=0},b.prototype.cursorCharAbsolute=function(b){var a=b[0];a<1&&(a=1),this.x=a-1},b.prototype.insertLines=function(d){var a,c,b;a=d[0],a<1&&(a=1),c=this.y+this.ybase,b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b+1;while(a--)this.lines.splice(c,0,this.blankLine(!0)),this.lines.splice(b,1);this.updateRange(this.y),this.updateRange(this.scrollBottom)},b.prototype.deleteLines=function(d){var a,c,b;a=d[0],a<1&&(a=1),c=this.y+this.ybase,b=this.rows-1-this.scrollBottom,b=this.rows-1+this.ybase-b;while(a--)this.lines.splice(b+1,0,this.blankLine(!0)),this.lines.splice(c,1);this.updateRange(this.y),this.updateRange(this.scrollBottom)},b.prototype.deleteChars=function(d){var a,b,c;a=d[0],a<1&&(a=1),b=this.y+this.ybase,c=[this.eraseAttr(),' '];while(a--)this.lines[b].splice(this.x,1),this.lines[b].push(c)},b.prototype.eraseChars=function(e){var a,c,b,d;a=e[0],a<1&&(a=1),c=this.y+this.ybase,b=this.x,d=[this.eraseAttr(),' '];while(a--&&b=this.cols&&(this.x=this.cols-1)},b.prototype.HPositionRelative=function(b){var a=b[0];a<1&&(a=1),this.x+=a,this.x>=this.cols&&(this.x=this.cols-1)},b.prototype.sendDeviceAttributes=function(a){if(a[0]>0)return;this.prefix?this.prefix==='>'&&(this.is('xterm')?this.send('[>0;276;0c'):this.is('rxvt-unicode')?this.send('[>85;95;0c'):this.is('linux')?this.send(a[0]+'c'):this.is('screen')&&this.send('[>83;40003;0c')):this.is('xterm')||this.is('rxvt-unicode')||this.is('screen')?this.send('[?1;2c'):this.is('linux')&&this.send('[?6c')},b.prototype.linePosAbsolute=function(b){var a=b[0];a<1&&(a=1),this.y=a-1,this.y>=this.rows&&(this.y=this.rows-1)},b.prototype.VPositionRelative=function(b){var a=b[0];a<1&&(a=1),this.y+=a,this.y>=this.rows&&(this.y=this.rows-1)},b.prototype.HVPosition=function(a){a[0]<1&&(a[0]=1),a[1]<1&&(a[1]=1),this.y=a[0]-1,this.y>=this.rows&&(this.y=this.rows-1),this.x=a[1]-1,this.x>=this.cols&&(this.x=this.cols-1)},b.prototype.setMode=function(a){if(typeof a==='object'){var d=a.length,c=0;for(;c1e3;this.mouseEvents=!0;this.element.style.cursor='default';this.log('Binding to mouse events.');break;case 1004:this.sendFocus=!0;break;case 1005:this.utfMouse=!0;break;case 1006:this.sgrMouse=!0;break;case 1015:this.urxvtMouse=!0;break;case 25:this.cursorHidden=!1;break;case 1049:case 47:case 1047:if(!this.normal){var e={lines:this.lines,ybase:this.ybase,ydisp:this.ydisp,x:this.x,y:this.y,scrollTop:this.scrollTop,scrollBottom:this.scrollBottom,tabs:this.tabs};this.reset(),this.normal=e,this.showCursor()}break}},b.prototype.resetMode=function(a){if(typeof a==='object'){var c=a.length,b=0;for(;b0},b.prototype.eraseRectangle=function(a){var b=a[0],d=a[1],e=a[2],f=a[3],g,c,h;for(h=[this.eraseAttr(),' '];b='0'&&a<='9'?(a=+a-1,~a||(a=9),this.emit('request term',a)):a==='n'?this.emit('request term next'):a==='P'?this.emit('request term previous'):a===':'?this.emit('request command mode'):a==='['&&this.enterSelect()},b.prototype.keySelect=function(o,b){if(this.showCursor(),this.searchMode||b==='n'||b==='N')return this.keySearch(o,b);if(b===''){var c=this.ydisp+this.y;this.ydisp===this.ybase?(this.y=Math.min(this.y+(this.rows-1)/2|0,this.rows-1),this.refresh(0,this.rows-1)):this.scrollDisp((this.rows-1)/2|0),this.visualMode&&this.selectText(this.x,this.x,c,this.ydisp+this.y);return}if(b===''){var c=this.ydisp+this.y;this.ydisp===0?(this.y=Math.max(this.y-(this.rows-1)/2|0,0),this.refresh(0,this.rows-1)):this.scrollDisp(-(this.rows-1)/2|0),this.visualMode&&this.selectText(this.x,this.x,c,this.ydisp+this.y);return}if(b===''){var c=this.ydisp+this.y;this.scrollDisp(this.rows-1),this.visualMode&&this.selectText(this.x,this.x,c,this.ydisp+this.y);return}if(b===''){var c=this.ydisp+this.y;this.scrollDisp(-(this.rows-1)),this.visualMode&&this.selectText(this.x,this.x,c,this.ydisp+this.y);return}if(b==='k'||b===''){var c=this.ydisp+this.y;this.y--,this.y<0&&(this.y=0,this.scrollDisp(-1)),this.visualMode?this.selectText(this.x,this.x,c,this.ydisp+this.y):this.refresh(this.y,this.y+1);return}if(b==='j'||b===''){var c=this.ydisp+this.y;this.y++,this.y>=this.rows&&(this.y=this.rows-1,this.scrollDisp(1)),this.visualMode?this.selectText(this.x,this.x,c,this.ydisp+this.y):this.refresh(this.y-1,this.y);return}if(b==='h'||b===''){var a=this.x;this.x--,this.x<0&&(this.x=0),this.visualMode?this.selectText(a,this.x,this.ydisp+this.y,this.ydisp+this.y):this.refresh(this.y,this.y);return}if(b==='l'||b===''){var a=this.x;this.x++,this.x>=this.cols&&(this.x=this.cols-1),this.visualMode?this.selectText(a,this.x,this.ydisp+this.y,this.ydisp+this.y):this.refresh(this.y,this.y);return}if(b==='v'||b===' '){this.visualMode?this.leaveVisual():this.enterVisual();return}if(b==='y'){if(this.visualMode){var n=this.grabText(this._selected.x1,this._selected.x2,this._selected.y1,this._selected.y2);this.copyText(n),this.leaveVisual()}return}if(b==='q'||b===''){this.visualMode?this.leaveVisual():this.leaveSelect();return}if(b==='w'||b==='W'){var f=this.x,g=this.y,h=this.ydisp,a=this.x,c=this.y,d=this.ydisp,i=!1;for(;;){var e=this.lines[d+c];while(a=this.cols&&(a=this.cols-1),a===this.cols-1&&e[a][1]<=' '){if(a=0,++c>=this.rows&&(c--,++d>this.ybase)){d=this.ybase,a=this.x;break}continue}break}this.x=a,this.y=c,this.scrollDisp(-this.ydisp+d),this.visualMode&&this.selectText(f,this.x,g+h,this.ydisp+this.y);return}if(b==='b'||b==='B'){var f=this.x,g=this.y,h=this.ydisp,a=this.x,c=this.y,d=this.ydisp;for(;;){var e=this.lines[d+c],i=a>0&&e[a][1]>' '&&e[a-1][1]>' ';while(a>=0){if(e[a][1]<=' ')if(i&&a+1' '){a++;break}else i=!0;a--}if(a<0&&(a=0),a===0&&(e[a][1]<=' '||!i)){if(a=this.cols-1,--c<0&&(c++,--d<0)){d++,a=0;break}continue}break}this.x=a,this.y=c,this.scrollDisp(-this.ydisp+d),this.visualMode&&this.selectText(f,this.x,g+h,this.ydisp+this.y);return}if(b==='e'||b==='E'){var a=this.x+1,c=this.y,d=this.ydisp;for(a>=this.cols&&a--;;){var e=this.lines[d+c];while(a=0&&e[a-1][1]>' '){a--;break}a++}if(a>=this.cols&&(a=this.cols-1),a===this.cols-1&&e[a][1]<=' '){if(a=0,++c>=this.rows&&(c--,++d>this.ybase)){d=this.ybase;break}continue}break}this.x=a,this.y=c,this.scrollDisp(-this.ydisp+d),this.visualMode&&this.selectText(f,this.x,g+h,this.ydisp+this.y);return}if(b==='^'||b==='0'){var f=this.x;if(b==='0')this.x=0;else if(b==='^'){var e=this.lines[this.ydisp+this.y],a=0;while(a' ')break;a++}a>=this.cols&&(a=this.cols-1),this.x=a}this.visualMode?this.selectText(f,this.x,this.ydisp+this.y,this.ydisp+this.y):this.refresh(this.y,this.y);return}if(b==='$'){var f=this.x,e=this.lines[this.ydisp+this.y],a=this.cols-1;while(a>=0){if(e[a][1]>' '){this.visualMode&&a0&&d--):b==='}'&&c>=this.rows&&(c--,d' '){j===-1&&(j=0),m=!0;break}else if(l===this.cols-1){j===-1?j=1:j===0?k=!0:j===1&&m&&(k=!0);break}if(k)break;if(b==='{'){if(c--,c<0){if(c++,!(d>0))break;d--}}else if(b==='}'&&(c++,c>=this.rows)){if(c--,!(d=this.cols)break;if(j[d+a][1]!==f[a])break;if(j[d+a][1]===f[a]&&a===f.length-1){h=!0;break}}if(h)break;d+=a+1}if(h)break;if(d=0,!n){if(b++,b>this.ybase+this.rows-1){if(i)break;i=!0,b=0}}else if(b--,b<0){if(i)break;i=!0,b=this.ybase+this.rows-1}}if(h){b-this.ybase<0?(g=b,b=0,g>this.ybase&&(b=g-this.ybase,g=this.ybase)):(g=this.ybase,b-=this.ybase),this.x=d,this.y=b,this.scrollDisp(-this.ydisp+g),this.visualMode&&this.selectText(m,this.x,l+k,this.ydisp+this.y);return}this.refresh(0,this.rows-1);return}if(c===''||c===''){if(this.entry.length===0)return;var e=this.ydisp+this.rows-1;this.entry=this.entry.slice(0,-1);var a=this.entryPrefix.length+this.entry.length;this.lines[e][a]=[this.lines[e][a][0],' '],this.x--,this.refresh(this.rows-1,this.rows-1),this.refresh(this.y,this.y);return}if(c.length===1&&c>=' '&&c<='~'){var e=this.ydisp+this.rows-1;this.entry+=c;var a=this.entryPrefix.length+this.entry.length-1;this.lines[e][a]=[this.defAttr&-512|4,c],this.x++,this.refresh(this.rows-1,this.rows-1),this.refresh(this.y,this.y);return}return!1},b.charsets={},b.charsets.SCLD={'`':'â—†',a:'â–’',b:' ',c:' ',d:'\r',e:'\n',f:'°',g:'±',h:'␤',i:' ',j:'┘',k:'┐',l:'┌',m:'â””',n:'┼',o:'⎺',p:'⎻',q:'─',r:'⎼',s:'⎽',t:'├',u:'┤',v:'â”´',w:'┬',x:'│',y:'≤',z:'≥','{':'Ï€','|':'≠','}':'£','~':'·'},b.charsets.UK=null,b.charsets.US=null,b.charsets.Dutch=null,b.charsets.Finnish=null,b.charsets.French=null,b.charsets.FrenchCanadian=null,b.charsets.German=null,b.charsets.Italian=null,b.charsets.NorwegianDanish=null,b.charsets.Spanish=null,b.charsets.Swedish=null,b.charsets.Swiss=null,b.charsets.ISOLatin=null;var g=this.String,i=this.setTimeout,s=this.setInterval;h._cache={},h.distance=function(a,b,c,d,e,f){return Math.pow(30*(a-d),2)+Math.pow(59*(b-e),2)+Math.pow(11*(c-f),2)},b.EventEmitter=f,b.inherits=u,b.on=e,b.off=q,b.cancel=d,a!==void 0?a.exports=b:this.Terminal=b}.call(function(){return this||(typeof window!=='undefined'?window:b)}()))},{}]},{},[1]) \ No newline at end of file diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/DESIGN_NOTES__14_Jn_22.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/DESIGN_NOTES__14_Jn_22.txt Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,117 @@ + +Working on getting visual of a POP syntax graph + +-] Have Famo.us, which has hierarchical drawning structure that fits well to what had in mind for POP + +-] Famo.us has animations and physics engine, so as user modifies things, they can fly around in pleasing ways. + +-] Famo.us structure is almost one-to-one with the visualizer's internal structure that I was imagining.. seems wasteful to duplicate.. + +-] However.. need the visualization to be independent of any particular drawing facility.. for example, the visualization should be reusable with a Java based canvas that is painted via Swing, as well as via Famo.us and via C++ drawing code.. + +-] The visualization must be specific to the data format.. therefore, it should be part of the holder that the data is inside of. Don't want case where new syntax is added, and have to go around to all the different places, like Java app, and javascript displayer, and so on, and change code in all those! (even if they all take a plugin, that plugin will have to be in terms of the language -- java, javascript, C++, whatever -- and the plugin will have to spit out some standard thing anyway!) +Rather, want the visualizer to be written once, in POP, and plugged into the data-holder. It spits out standardized visual elements.. any technology can then take those visual elements and paint them to a screen. +The visualizer has fingers directly on the raw data, in whatever the internal format is for the holder.. A holder can have a different internal format vs external format.. + +(update: fighting with text -- haven't found any general way of calculating the width of text, given the font.. entry after entry from google search has variations on applying the text to a canvas, causing it to render, then getting the bounding box that was generated during render.. there doesn't seem to be, even for SVG, any way to predict the bounding box!!!?!?!?! So.. there is a cascade effect.. the text must be contained within something, like a rectangle or elipse or whatever.. and, as worked out during the rest of this design session, the visualizer is responsible for calculating the placement of all the SVG shapes.. then the visualizer MUST know the size of the text, in order to know the size of the shape, in order to calculate a reasonable placement of shapes.. + it is tempting to leave all the shape placements specified as relative, and let the final values be figured out inside the Display.. this would also allow things like employing the Famous physics engine to calculate placements, even let the placements evolve by themselves (like the D3 examples with the graph nodes flying around to find their own placement).. that would happen without the visualizer setting the placements.. rather, the visualizer would establish the visual "connectivity".. noooo.. that D3 thing relied upon knowing that it was a graph and that arcs acted like springs and nodes acted like weights, and nodes exerted n-body attraction.. but that is all specific to graphs.. would it generalize to arbitrary syntax? Hmmmm.. if had an "atomic" level, where inside an atomic unit nothing moves relative, then, yes, can treat the connections between these atomic things as springs, and each atomic thing has attractive mass and inertia.. can let them run around and find a stable configuration.. + Okay, so two issues: what about connections that go off-screen to out-side-the-view portions of syntax graph, and what about the user wanting to pin particular things in particular places.. often what a feeling of solidity, reliable placement so you know where everything is.. + Right, so this: for now, visualizer calculates fixed positions, but have in back of mind keeping ability for multiple kinds of visualizer within the same srcHolder.. and visualizer has ability to expect things of the Display, such as providing physics, and visualizer can maybe ask Display what kinds of visualization list it understands.. so then can add, say, dynamic view hierarchy, where visualizer specifies things like masses and springs and lets Display move them around as it sees fit.. can evolve standard view lists over time.. the Commander will have to include some facility for not allowing a user to select a visualizer that is unable to generate any of the list types acceptable to the Display the user is interacting with.) + +-] A holder may also have other data-format-and-semantics specific things, such as a querier -- the querier defines the format of queries it accepts, and those queries are tailored to the nature of the data in the holder. Hence, say, a video holder might have a querier plugged in that accepts canonical shapes, and then searches the raw video data for frames that contain that shape. The querier would spit out things in a format that it defines. For example, it may have a data structure for a video frame, and spit out a stream of frames that contain the requested shape. + +-] Data formats should be visually defined.. for example, I should be able to draw a picture of a graph node, and that picture is the code that defines the data structure, which can then be used in other places in the code. For example, in the Hamiltonian Path code, could have included a picture of a graph node, and connected a line to the portion being accessed, say, in a test, or in the "for all" construct.. + +-] Seeing a hierarchy of holders.. so a higher level holder could have multiple lower level holders inside of it.. getting a bit awkward, say with combining queriers and visualizers -- how do you combine visualizations from siblings? there's something fundamental here.. + +-] No data may be warehoused outside a holder.. the holder collects the things needed to interact with the data, such as modifier, visualizer, querier, and not sure yet what all else.. + +-] Data outside a holder must be in the form of a data structure instance, where the structure was defined by the holder the data came from. The holder took whatever internal format the data resided in and placed it into the data structure form. All data within a POP system that is not inside a holder must be in the format of a structure defined using POP primitives. NO RAW BYTES! Bit twidling only upon bit-vector structures. An adaptor is necessary in order to get a more primitive format of data (IE, can always do conditional tests on bits held in a bit-vector format, and build up values within a higher level format structure based on the test results.. example, do the math to accumulate individual bit values from a bit-vector, but accumulate them into an integer format. Or, can test bits that represent graph edges, and build up a graph data structure. aso..) + +-] A visualizer can include animations as visual elements that it spits out. + +-] Famous will generate events that are gestures such as mouse clicks. The event handler will use the event data to connect the event to one of the original visual elements that was visualized. It will construct a structure that states the visual element and the gesture details, and send that to the commander. + +-] the commander will convert the visual element plus gesture into some action, such as moving the insertion point, or zooming the view, or adding a syntax node.. the command sends the command to the appropriate place -- could be the drawing engine (for zoom or pan actions).. or could be the modifier for insertion point or syntax element actions.. or could be some entity that carries out the action. For example when viewing a worksheet, a gesture could trigger re-calculation, so the action would be a "perform calculation" sent to one or more processors that are connected to the worksheet. + +-] The modifier has access to the holder's internal data format, and can manipulate it directly. It receives commands, such as generated by gestures performed on the display. + +-] A worksheet lives inside a holder as well.. the worksheet can talk to processors.. for example, the visualizer may simply include a reference to a processor that spits out data, and sends the reference in the visual element. An image may be a good example.. the image is on the worksheet for some reason.. the visualizer embeds reference to image in an element and sends that to the display. The display then directly gets the image data and paints it. + +-] Right, so one way to combine visualizers in a hierarchy, is for higher level visualizers to specify a lower-level one that is to fill in the internals of a given bounding box. So the lower-level is sent the bounding box, and it generates a view hierarchy that fits inside of that. Not sure whether the Display should be the one that sends the requests and integrates the various responses, or the Visualizer should send the requests and integrate the responses. + +============================================== += += +============================================== +So, question.. what do display list elements look like? Does visualizer produce the layout, for example, specify a bounding box and position for each element, including text, lines, etc? Does it produce the bezier curves in SVG that connect syntax graph elements? + +Or, does it send something with fewer details? Let the Display calculate exact placement of visual elements? + +What about pan and zoom? Does Visualizer handle that, or Display.. pan means moving some elements out of the painted canvas and moving others in.. zoom does too, in addition to calculating new transforms for each element painted.. So, if Display does this, then it must either have all the visual elements in it, or else it much send a request to Visualizer that triggers sending what's needed.. + +Soooo.. make a two-way path between Display and Visualizer, in order to handle pan, zoom, 3D rotates, and so forth? + +Orrrr.. leave that to the MVDM loop.. the pan/zoom/rotate gestures go into the command-maker, and thence into the visualizer, which then sends view update.. + +sooo.. this view update stuff.. does Display keep a full representation of the visual elements, and then translate that into Famo.us elements? Or, does it keep, say, a current visualizer list.. where visualizer updates simply modify the previous list sent.. then Display translates the updated list into Famo.us elements.. given that Famo.us doesn't support removing render tree elements, that might be a good approach.. and it simplifies the thing about how to figure out what a visualizer update is and what to do with it inside the Display. + +Okay.. now.. just need to figure out what the Visualizer actually sends.. how much detail.. + +You know what? I don't want to think about it! Just going to do something, see what happens, and then can modify later.. probably will never get modified, these choices have a way of sticking, due to momentum of volume of work and low improvement in changing.. but, don't want to stall myself, need to keep moving.. + +sooooo... something has to calculate placement of bounding boxes, and calculate translations and sizing.. and move things in and out based on zoom, pan, rotate.. and trigger redraws and resends of display data for graphs and calculation results.. seems like if put placement and transform calcs inside Display then are making the Display an active thing, giving it intelligence and control.. then, run into problems when have a view that is composed of pieces from many different holders and different processors.. for example, displaying a worksheet, where the worksheet itself is in a holder that generates a view, and locations on the worksheet are calculated by live processors, and locations are graphs which are generated by graphing processors that take calculations from other processors.. want the worksheet holder to handle generating the view, and collecting the data from the other processors.. don't want the Display to have any kind of intelligence related to this! + +Hmmm.. so, if the worksheet holder is doing all of the collecting of data and triggering re-calcs, and melding together into a view.. then Display is simply passively painting that and collecting gestures that it sends back.. the holder then knows what to do with the gestures performed upon view elements.. + +So that means that the Display should not be calculating pan and zoom and rotate!! Those are responses to gestures, and those trigger behaviors from the visualizer (which may, in turn, have to trigger behaviors from other processors in order to get updated calcs to put into the view) + +Got it, so as tempting as it is to peel off such gestures in the Display and build intelligence into there.. it will cause problems.. so best to have all the visual related processing be done inside the visualizers.. + +so.. means the visualizer should send out things pretty close to renderable.. + +Now. The question comes up.. what format? Does the visualizer send out SVG? Is that universal enough? Will that cause problems with non-browser based approaches? If not SVG, then what? Will need to represent paths.. does visualizer calculate Bezier curves and send those? Or does it just say "here are end points, connect these with a smooth path"? Does the visualizer calculate how to route arcs within a graph around the other nodes in an optimal way? If the user supplies helpers by moving things, does the Display remember that, or the Visualizer? + +Ahhhh.. okay.. if what the user to be able to affect the visual arrangement, then need to remember the gestures they give that are related to visual arrangement.. for example, they grab bezier control points and move them, in order to affect a curve, or add new points within a path in order to route it.. those things have to be remembered! The Display has no place to store such things!! + +Right.. that means that the holder must store info related to viewing the holder contents! sooooo.. the visualizer must be the thing that generates any details that a person may want to adjust. + +Right. Any visual arrangement that a person might want to adjust must be stored inside the holder, and so the visualizer must be the thing that generates that level of detail. Right. Got it. + +So. Yes. That means that the visualizer must send out bounding boxes, translations, sizing, path points, control points, and so forth. So. Yes. SVG is looking like a good way to go.. has to be something! Can invent my own equivalent, which specifies paths, shapes, widths, and so forth.. but what is the gain? The only potential is sending in binary, to save the overhead of SVG's text embodiment. The savings worth the effort? NO! + +Okay then. SVG. That is the visualizer's format for POP. Or perhaps it just sends the values that go into the SVG? The Display does the final conversion to text-based SVG format? Hmmmm, what about custom syntax, which is SVG from the programmer? Just send indication of SVG elements, together with the values? Maybe enums for the SVG indicators, or something.. + +Now. Question is, how much effort? Is it more effort to send a representation, then construct text-repr inside Display? Or more effort to construct SVG text in visualizer and send it ready-made? + +Seems easier to just construct SVG text inside visualizer and send that.. + +Heck, if send representation, then are already forcing SVG! It doesn't constrain the Display if send the text form.. the display is just as free to convert the binary form to something else as it is to convert the text form to something else.. so if Display is not browser, and doesn't have SVG drawing primitives, it has to do the extra step of parsing SVG in order to extract the values from the text, and then generate whatever internal form it has, such as calculating paths or even pixels itself.. the extraction from text does not seem like a terribly large burden compared to the rest. + +Buuuut.. don't really care! Going to generate text form inside visualizer, because, why not? Then the Display only translates displayList elements into its internal thing that paints. In the case of browser, Display translates display list into famo.us elements, placing the SVG verbatim onto famous surfaces, and makes the SVG bounding box the same as the famous surface size. + +In fact, display list is going to represent almost verbatim what a Famo.us render tree will look like! It is a fairly universal declaration.. hierarchy of local visual contexts, with relationship among those contexts, including relative placement in 3D space and relative sizing from one to another. + +Alright, getting to it now.. display list will be a serialization of a hierarchy.. The top of the hierarchy is the view painted onto. The Display tells the visualizer what the pixel dimensions are of the view. The visualizer makes that the top level bounding box. It then inserts bounding boxes within that, and inserts bounding boxes within those, and so forth down. Each bounding box is either a hierarchy element, relationship element, or a painted element. Hierarchy elements simply state what elements are included, and give their own bounding box. Relationship elements are attached by the parent hierarchy element. For example, it is the job of the parent to make sure all the children fit inside its bounding box. The bounding box may be 2D or 3D. A parent ensures the fit by attaching relationships to the children elements. The relationships can be translations or scalings or rotations.. or actually any arbitrary 3D transform. A hierarchy element knows nothing of the context in which it fits, so it has no way of attaching relationships to itself! Each hierarchy element is responsible for ensuring that all descendants fit within its bounding box. Any relationship attached to a hierarchy element is transitively applied to all descendants of the hierarchy element. For example, if one is rotated in 3D, then it, together with all its contents, is rotated as a unit. Each descendant maintains the same relationship to its parent as before.. but the entire bundle has been rotated as a unit! + +Great.. so that is the display list.. it is a serialization of that hierarchy. A display update then assumes a given hierarchy, and says "change this relationship between this parent and this child" or "remove this parent and all descendants" etc.. in effect, it specifies a change to the hierarchical structure.. + +Sooooo.. means that have two copies of the view hierarchy.. one inside the visualizer, which is serialized, and another inside the Display, which is translated into Display-local elements that are then painted. + +Not the most efficient.. hurts me.. but, well, what are you going to do? What's better? Need the flexibility of having the visualizer control all changes to the view hierarchy.. and need the visualizer to calculate all placement and path details so that user changes can be remembered inside the holder (without something clunky like "save this view modification info as a black box and hand it to the Display, which knows what it means" yuck, just begging for loss of sync when move from one Display to another or even upgrade the Display!).. + +so, then, there's no way around having the visualizer internally represent the bounding box hierarchy as it constructs the details. Thennnnn.. something must translate that representation into the internal Display representation! The Display could have any native form internally.. canvas with paths drawn upon it, Java 2D, even just pixels, with all the code in between.. well, in effect, every Display ends up being everything between that hierarchy and on down to pixels!! + +So, could just hand the data structure from visualizer to the Display..? This is fine if both are inside same hardware, sharing memory.. but need a serialization if Display has separate memory.. which it will if the src holder is on a server and the display is a browser on a client! + +Hmmm.. what about just handing the data structure to the Display for now.. can always add the serialization later, it's not functional! :-) Ahhh, yes.. less work. Good. Okay, will do that. save serialization for later. For now, in javascript, will build a src holder that saves syntax graph natively in JSON, as an internal data structure of the form made for GabePatterns. The visualizer in the src holder will generate a view hierarchy from that data structure. It will save any view related data within the syntax graph data structure as extra properties added to the nodes. The visualizer will then hand a reference to the view hierarchy directly to the display object. The display object will then generate famous elements from the view hierarcy elements. View updates will simply be the visualizer changing the view hierarchy then calling the display with a reference to the changed hierarchy. + +Done. Make it so. + +BTW, thinking to introduce another component, which is a helper, that maybe takes some higher level view form and generates the view hierarchy from that.. this will ease the burden on developers who make custom syntax.. it will act as a library for them, essentially.. (and, of course, there will be a serializer that turns a view hierarchy into a stream of visual objects sent to the Display, which will reconstruct the view hierarchy then translate that into into elements that it paints.. for now, that serializer is just JSON! It has provision to translate javascript objects into text form, and then on the other side parse that text form to reproduce the javascript objects.. might need extra logic in order to recreate the links among parents and children.. not sure whether JSON can go deep that way..). + + + + + + diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/Display - Copy/POPDisplay.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/Display - Copy/POPDisplay.html Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,35 @@ + + + + POP Display + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/Display - Copy/POPDisplay.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/Display - Copy/POPDisplay.js Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,78 @@ + + +//Make a Display object, and a number of functions that operate on it. +// One of the functions accepts an array of visual element objects as +// input, and turns those visual elements into a famous render tree. +//The famous context, and the surfaces, and so on exist inside the Display +// object. + +//This uses require.js to create a module. This module has the name of the +// file (POPDisplay). Inside the define, a number of data structures and +// functions are created, then returned at the end. The returned things are +// what can be accessed by external functions that load this module, via +// themselves using the require("POPDisplay") call +define(function(require, exports, module) { + //Create the famous infrastructure, which is used for rendering on screen + var Engine = require("famous/core/Engine"); + var Surface = require("famous/core/Surface"); + var Modifier = require("famous/core/Modifier"); + var Transform = require('famous/core/Transform'); + var StateModifier = require('famous/modifiers/StateModifier'); + var ContainerSurface = require("famous/surfaces/ContainerSurface"); + + //make the context, which controls rendering to the screen + // once add something to this context, that add makes the thing visibly + // have effect. + //Note, these are available to the render function via the closure + // mechanism + var mainContext = Engine.createContext(); + + //the functions that access the Display object will be returned below + var Display = { + acceptViewList : function( inViewList ) { + //modify the render tree of the mainContext according to the + // in coming view list + } + + handleGesture : function( event ) { + //not sure this is the right form, but provide a handler for + // gestures made by the programmer/user + //This will make an object that pairs the gesture to the view + // element that is represented by the surface(s) involved in + // the gesture. + //It will then send the object to the command generator, which + // is part of the source holder + } + } + function acceptViewList (viewList) { + //access Display object and its values here, as a closure + } + + function init() { + // var POPStuffToDraw = + var mySurface = new Surface({ + size: [100, 100], + content: '', + properties: { + color: 'white', + lineHeight: '200%', + textAlign: 'center', + fontSize: '36px', + cursor: 'pointer' + } + }); + var stateModifier = new StateModifier({ + transform: Transform.translate(250, 100, 0) + }); + mainContext.add(stateModifier).add(mySurface); + + + + return{ + init: init, + display: Display, + acceptViewList: acceptViewList + } +}); + + diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/Display - Copy/app/CalcCombosOfWord.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/Display - Copy/app/CalcCombosOfWord.js Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,112 @@ +define(function () { + +var sortedLetters = []; + +var fact = []; +var total = 0; +var i = 0; +fact[0] = 0; +fact[1] = 1; +//fill up the array of factorial values +for( i = 2; i <= 25; i++) { + fact[i] = i * fact[i-1]; +} + +//Function to sort the letters in the input word. Returns an array of +// objects. Each object has a field for the letter, and a field for the +// number of times that letter appears in the input word. +var sortLettersOfWord = function( inputWord ) { + var letterArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; + var currLetter = ''; + + for( i = 0; i < inputWord.length; i++ ) { + currLetter = inputWord.charCodeAt(i); +// console.log(currLetter); + index = currLetter - 'a'.charCodeAt(0); + console.log(index); + letterArray[index] += 1; + } + console.log('sorted letter A: ' + letterArray[0]); + return letterArray; +} + +//Calc the number of unique "words" producible from the sorted letters +var calcCombosOfLetters = function( sortedLetters, totalNumLetters ) { + console.log( "num letters: " + totalNumLetters ); + numCombos = fact[ totalNumLetters ]; +// console.log("numCombos: " + numCombos); + //now, divide that by factorial of the multiplicity of each letter. + // skip letters that only appear once (or zero). + for( i=0; i<26; i++) { //be sure sortedLetters shrinks + //when remove a letter object from it, so .size reflects that! + if( sortedLetters[i] > 1 ) { + //divide the number of combos by the factorial of, the number of + // times the letter is repeated within the input word. + numCombos /= fact[ sortedLetters[i] ]; + } + } + console.log("numCombos: " + numCombos); + return numCombos; +} + +//Find number of rearrangements of the word's letters that come +// alphabetically before the word. +var rankThisWord = function(inputWordRaw) { + var inputWord = inputWordRaw.toLowerCase(); + + console.log('started rank this word: ' + inputWord); + var totalCombosComeBefore = 0; + var numCombos = 0; + var currPosInInputWord = 0; + var numLettersInInputWord = inputWord.length; + console.log("num letters: " + numLettersInInputWord); + var numInputWordLettersLeft = inputWord.length; + var sortedLetters = sortLettersOfWord( inputWord ); //returns array of + //objs. Each obj pairs a letter with the multiplicity of that letter + //the order of the objs matches the alphabetical order of the obj letters + var firstLetter = 0; + + //repeat, marching down the letters of the input word + while(currPosInInputWord < numLettersInInputWord) { + //calc index (pos in alphabet) of current first letter in word) + firstLetter = inputWord.charCodeAt(currPosInInputWord) - 'a'.charCodeAt(0); + console.log("first letter:" + firstLetter + " at pos: " + currPosInInputWord); + //Iterate over the letters that come before first + for( currLetter=0; currLetter<26; currLetter++ ) { + //if completed all earlier letters then terminate loop +//Q: count duplicates of first letter? + if( currLetter >= firstLetter ) break; + else if( sortedLetters[currLetter] > 0) { + console.log("earlier letter: " + currLetter); + //for a given earlier letter, remove it from + // the letter pool, leaving duplicates. + sortedLetters[currLetter] -= 1; + + //Calculate the number of unique rearrangements of the + // remaining letters, using the formula. + numCombos = calcCombosOfLetters( sortedLetters, numInputWordLettersLeft - 1 ); + + //accumulate the total number of combos: + totalCombosComeBefore += numCombos; + + //add the letter back! Need it while do other earlier letters + sortedLetters[currLetter] += 1; + } + } + + //Now, done with first letter of input word. Delete that letter from + // the input word, and from the sorted pool of letters, leaving + // duplicates. + numInputWordLettersLeft -= 1; + currPosInInputWord += 1; + sortedLetters[firstLetter] -= 1; + } + console.log("total combos come before: " + totalCombosComeBefore); + return totalCombosComeBefore; +} + + + return { + rankThisWord: rankThisWord + }; +}); \ No newline at end of file diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/Display - Copy/app/POPDisplay.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/Display - Copy/app/POPDisplay.js Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,74 @@ + + +//Make a Display object, and a number of functions that operate on it. +// One of the functions accepts an array of visual element objects as +// input, and turns those visual elements into a famous render tree. +//The famous context, and the surfaces, and so on exist inside the Display +// object. + +//This uses require.js to create a module. This module has the name of the +// file (POPDisplay). Inside the define, a number of data structures and +// functions are created, then returned at the end. The returned things are +// what can be accessed by external functions that load this module, via +// themselves using the require("POPDisplay") call +define(function(require, exports, module) { + //Create the famous infrastructure, which is used for rendering on screen + var Engine = require("famous/core/Engine"); + var Surface = require("famous/core/Surface"); + var Modifier = require("famous/core/Modifier"); + var Transform = require('famous/core/Transform'); + var StateModifier = require('famous/modifiers/StateModifier'); + var ContainerSurface = require("famous/surfaces/ContainerSurface"); + + //make the context, which controls rendering to the screen + // once add something to this context, that add makes the thing visibly + // have effect. + //Note, these are available to the render function via the closure + // mechanism + var mainContext = Engine.createContext(); + + + var handleGesture = function( event ) { + //not sure this is the right form, but provide a handler for + // gestures made by the programmer/user + //This will make an object that pairs the gesture to the view + // element that is represented by the surface(s) involved in + // the gesture. + //It will then send the object to the command generator, which + // is part of the source holder + console.log("handleGesture"); + } + function acceptViewList (viewList) { + //access Display object and its values here, as a closure + console.log("acceptViewList"); + } + + function init() { + console.log("init"); + // var POPStuffToDraw = + var mySurface = new Surface({ + size: [100, 100], + content: '', + properties: { + color: 'white', + lineHeight: '200%', + textAlign: 'center', + fontSize: '36px', + cursor: 'pointer' + } + }); + var stateModifier = new StateModifier({ + transform: Transform.translate(250, 100, 0) + }); + mainContext.add(stateModifier).add(mySurface); + } + + + return{ + init: init, + handleGesture: handleGesture, + acceptViewList: acceptViewList + }; +}); + + diff -r 5c0400b5ae59 -r 32d17f6062cb 1__Development/0__Code_Dev/Javascript_approach/Display - Copy/app/epocratesPuzzle.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/1__Development/0__Code_Dev/Javascript_approach/Display - Copy/app/epocratesPuzzle.js Sun Jul 06 12:02:12 2014 -0700 @@ -0,0 +1,57 @@ +define(function (require) { + +//load the code that calculates the rank +var calcNumCombos = require('./CalcCombosOfWord'); + +//Show title and explanation -- via DOM manipulation +var el = document.createElement("h1") +el.id="title"; +el.innerHTML = "Epocrates Puzzle Test"; +document.body.appendChild(el); + + +el = document.createElement("span") +el.style.display="block"; +el.style.width="100%"; +el.innerHTML = 'This program calculates the "rank" of a word. The rank equals the number of combinations of its letters, that happen to come before it alphabetically (plus 1 for itself)'; +document.body.appendChild(el); + +//Get the word to calc combinations of +//var inputword = prompt('Here you go, your chance to enter the word that you would like ranked!'); +el1 = document.createElement("span") +el1.style.display="block"; +el1.style.width="100%"; +el1.innerHTML ='

Here you go, your chance to enter the word that you would like ranked!'; +document.body.appendChild(el1); + +el = document.createElement("INPUT"); +el.setAttribute("id", "inputWord"); +el.setAttribute("type", "text"); +//el.setAttribute("value", "type word here, click button when done"); +el.style.display="block"; +el.style.width="50%"; +document.body.appendChild(el); + +var inputWord = ""; +//Now use jquery to create a button, display it, and set click event handler +$('