From 6775b427a52bd628324dda682ee46efd550c3f56 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Wed, 22 Feb 2017 23:09:50 +0100 Subject: [PATCH] 1.1.18 Pre release lint --- .eslintignore | 3 + .eslintrc.json | 40 ++++++ public/index.html | 2 +- public/js/cryptalk.min.js | 4 +- public/js/lib/$.js | 6 +- public/js/lib/$.utils.js | 6 +- public/js/lib/audio.js | 14 +- public/js/lib/client.js | 6 +- public/js/lib/console.js | 9 +- public/js/lib/cryptalk.js | 2 +- public/js/lib/host.js | 20 ++- public/js/lib/hosts.js | 6 +- public/js/lib/main.js | 21 +-- public/js/lib/notifications.js | 21 ++- public/js/lib/queue.js | 69 +++++----- public/js/lib/settings.js | 2 +- public/js/lib/window.js | 8 +- .../js/{lib => vendor/castrato}/castrato.js | 0 public/js/vendor/requirejs-2.3.2/require.js | 5 - public/js/vendor/requirejs-2.3.3/require.js | 5 + requirejs.build.js | 5 + server.js | 126 +++++++++--------- 22 files changed, 214 insertions(+), 166 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json rename public/js/{lib => vendor/castrato}/castrato.js (100%) delete mode 100644 public/js/vendor/requirejs-2.3.2/require.js create mode 100644 public/js/vendor/requirejs-2.3.3/require.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..8cb1e0c --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +public/js/vendor +public/js/cryptalk.min.js +requirejs.build.js \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..444ad97 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,40 @@ +{ + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "indent": [ + "error", + "tab" + ], + "linebreak-style": [ + "error", + "windows" + ], + "quotes": [ + "error", + "single" + ], + "semi": [ + "error", + "always" + ], + "eqeqeq": [ + "error", + "always" + ], + "no-undef": [ + "warn" + ], + "no-console": [ + "warn" + ] + } +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index dd12d36..e8143c0 100644 --- a/public/index.html +++ b/public/index.html @@ -7,7 +7,7 @@ - + diff --git a/public/js/cryptalk.min.js b/public/js/cryptalk.min.js index d21a3da..476fca2 100644 --- a/public/js/cryptalk.min.js +++ b/public/js/cryptalk.min.js @@ -1,2 +1,2 @@ -!function(t,e){"function"==typeof define&&define.amd?define("castrato",[],e()):"object"==typeof exports?module.exports=e:t.castrato=e}(this,function(){function t(t,e,o,s){var c=[t,o,1>>2]>>>24-r%4*8&255;e[o+r>>>2]|=s<<24-(o+r)%4*8}else for(var r=0;r>>2]=n[r>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=r.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,o=[],i=function(e){var e=e,n=987654321,o=4294967295;return function(){n=36969*(65535&n)+(n>>16)&o,e=18e3*(65535&e)+(e>>16)&o;var i=(n<<16)+e&o;return i/=4294967296,i+=.5,i*(t.random()>.5?1:-1)}},r=0;r>>2]>>>24-i%4*8&255;o.push((r>>>4).toString(16)),o.push((15&r).toString(16))}return o.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>3]|=parseInt(t.substr(o,2),16)<<24-o%8*4;return new s.init(n,e/2)}},u=c.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,o=[],i=0;i>>2]>>>24-i%4*8&255;o.push(String.fromCharCode(r))}return o.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>2]|=(255&t.charCodeAt(o))<<24-o%4*8;return new s.init(n,e)}},f=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},d=i.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,o=n.words,i=n.sigBytes,r=this.blockSize,c=4*r,a=i/c;a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0);var u=a*r,f=t.min(4*u,i);if(u){for(var d=0;d>>6-s%4*2;o[r>>>2]|=(c|a)<<24-r%4*8,r++}return i.create(o,r)}var n=t,o=n.lib,i=o.WordArray,r=n.enc;r.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,o=this._map;t.clamp();for(var i=[],r=0;r>>2]>>>24-r%4*8&255,c=e[r+1>>>2]>>>24-(r+1)%4*8&255,a=e[r+2>>>2]>>>24-(r+2)%4*8&255,u=s<<16|c<<8|a,f=0;f<4&&r+.75*f>>6*(3-f)&63));var d=o.charAt(64);if(d)for(;i.length%4;)i.push(d);return i.join("")},parse:function(t){var n=t.length,o=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var r=0;r>>32-r)+e}function o(t,e,n,o,i,r,s){var c=t+(e&o|n&~o)+i+s;return(c<>>32-r)+e}function i(t,e,n,o,i,r,s){var c=t+(e^n^o)+i+s;return(c<>>32-r)+e}function r(t,e,n,o,i,r,s){var c=t+(n^(e|~o))+i+s;return(c<>>32-r)+e}var s=t,c=s.lib,a=c.WordArray,u=c.Hasher,f=s.algo,d=[];!function(){for(var t=0;t<64;t++)d[t]=4294967296*e.abs(e.sin(t+1))|0}();var l=f.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var s=0;s<16;s++){var c=e+s,a=t[c];t[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var u=this._hash.words,f=t[e+0],l=t[e+1],m=t[e+2],p=t[e+3],h=t[e+4],g=t[e+5],y=t[e+6],v=t[e+7],_=t[e+8],k=t[e+9],w=t[e+10],x=t[e+11],b=t[e+12],S=t[e+13],B=t[e+14],A=t[e+15],C=u[0],j=u[1],E=u[2],H=u[3];C=n(C,j,E,H,f,7,d[0]),H=n(H,C,j,E,l,12,d[1]),E=n(E,H,C,j,m,17,d[2]),j=n(j,E,H,C,p,22,d[3]),C=n(C,j,E,H,h,7,d[4]),H=n(H,C,j,E,g,12,d[5]),E=n(E,H,C,j,y,17,d[6]),j=n(j,E,H,C,v,22,d[7]),C=n(C,j,E,H,_,7,d[8]),H=n(H,C,j,E,k,12,d[9]),E=n(E,H,C,j,w,17,d[10]),j=n(j,E,H,C,x,22,d[11]),C=n(C,j,E,H,b,7,d[12]),H=n(H,C,j,E,S,12,d[13]),E=n(E,H,C,j,B,17,d[14]),j=n(j,E,H,C,A,22,d[15]),C=o(C,j,E,H,l,5,d[16]),H=o(H,C,j,E,y,9,d[17]),E=o(E,H,C,j,x,14,d[18]),j=o(j,E,H,C,f,20,d[19]),C=o(C,j,E,H,g,5,d[20]),H=o(H,C,j,E,w,9,d[21]),E=o(E,H,C,j,A,14,d[22]),j=o(j,E,H,C,h,20,d[23]),C=o(C,j,E,H,k,5,d[24]),H=o(H,C,j,E,B,9,d[25]),E=o(E,H,C,j,p,14,d[26]),j=o(j,E,H,C,_,20,d[27]),C=o(C,j,E,H,S,5,d[28]),H=o(H,C,j,E,m,9,d[29]),E=o(E,H,C,j,v,14,d[30]),j=o(j,E,H,C,b,20,d[31]),C=i(C,j,E,H,g,4,d[32]),H=i(H,C,j,E,_,11,d[33]),E=i(E,H,C,j,x,16,d[34]),j=i(j,E,H,C,B,23,d[35]),C=i(C,j,E,H,l,4,d[36]),H=i(H,C,j,E,h,11,d[37]),E=i(E,H,C,j,v,16,d[38]),j=i(j,E,H,C,w,23,d[39]),C=i(C,j,E,H,S,4,d[40]),H=i(H,C,j,E,f,11,d[41]),E=i(E,H,C,j,p,16,d[42]),j=i(j,E,H,C,y,23,d[43]),C=i(C,j,E,H,k,4,d[44]),H=i(H,C,j,E,b,11,d[45]),E=i(E,H,C,j,A,16,d[46]),j=i(j,E,H,C,m,23,d[47]),C=r(C,j,E,H,f,6,d[48]),H=r(H,C,j,E,v,10,d[49]),E=r(E,H,C,j,B,15,d[50]),j=r(j,E,H,C,g,21,d[51]),C=r(C,j,E,H,b,6,d[52]),H=r(H,C,j,E,p,10,d[53]),E=r(E,H,C,j,w,15,d[54]),j=r(j,E,H,C,l,21,d[55]),C=r(C,j,E,H,_,6,d[56]),H=r(H,C,j,E,A,10,d[57]),E=r(E,H,C,j,y,15,d[58]),j=r(j,E,H,C,S,21,d[59]),C=r(C,j,E,H,h,6,d[60]),H=r(H,C,j,E,x,10,d[61]),E=r(E,H,C,j,m,15,d[62]),j=r(j,E,H,C,k,21,d[63]),u[0]=u[0]+C|0,u[1]=u[1]+j|0,u[2]=u[2]+E|0,u[3]=u[3]+H|0},_doFinalize:function(){var t=this._data,n=t.words,o=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var r=e.floor(o/4294967296),s=o;n[(i+64>>>9<<4)+15]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[(i+64>>>9<<4)+14]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var c=this._hash,a=c.words,u=0;u<4;u++){var f=a[u];a[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var t=u.clone.call(this);return t._hash=this._hash.clone(),t}});s.MD5=u._createHelper(l),s.HmacMD5=u._createHmacHelper(l)}(Math),t.MD5}),function(t,e){"object"==typeof exports?module.exports=exports=e(require("./core")):"function"==typeof define&&define.amd?define("crypto-js/sha1",["./core"],e):e(t.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,o=n.WordArray,i=n.Hasher,r=e.algo,s=[],c=r.SHA1=i.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,o=n[0],i=n[1],r=n[2],c=n[3],a=n[4],u=0;u<80;u++){if(u<16)s[u]=0|t[e+u];else{var f=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=f<<1|f>>>31}var d=(o<<5|o>>>27)+a+s[u];d+=u<20?(i&r|~i&c)+1518500249:u<40?(i^r^c)+1859775393:u<60?(i&r|i&c|r&c)-1894007588:(i^r^c)-899497514,a=c,c=r,r=i<<30|i>>>2,i=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+i|0,n[2]=n[2]+r|0,n[3]=n[3]+c|0,n[4]=n[4]+a|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;return e[o>>>5]|=128<<24-o%32,e[(o+64>>>9<<4)+14]=Math.floor(n/4294967296),e[(o+64>>>9<<4)+15]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA1=i._createHelper(c),e.HmacSHA1=i._createHmacHelper(c)}(),t.SHA1}),function(t,e){"object"==typeof exports?module.exports=exports=e(require("./core")):"function"==typeof define&&define.amd?define("crypto-js/hmac",["./core"],e):e(t.CryptoJS)}(this,function(t){!function(){var e=t,n=e.lib,o=n.Base,i=e.enc,r=i.Utf8,s=e.algo;s.HMAC=o.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=r.parse(e));var n=t.blockSize,o=4*n;e.sigBytes>o&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),s=this._iKey=e.clone(),c=i.words,a=s.words,u=0;u>>2];t.sigBytes-=e}},y=(o.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:g}),reset:function(){d.reset.call(this);var t=this.cfg,e=t.iv,n=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var o=n.createEncryptor;else{var o=n.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==o?this._mode.init(this,e&&e.words):(this._mode=o.call(n,this,e&&e.words),this._mode.__creator=o)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{var e=this._process(!0);t.unpad(e)}return e},blockSize:4}),o.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),v=n.format={},_=v.OpenSSL={stringify:function(t){var e=t.ciphertext,n=t.salt;if(n)var o=r.create([1398893684,1701076831]).concat(n).concat(e);else var o=e;return o.toString(a)},parse:function(t){var e=a.parse(t),n=e.words;if(1398893684==n[0]&&1701076831==n[1]){var o=r.create(n.slice(2,4));n.splice(0,4),e.sigBytes-=16}return y.create({ciphertext:e,salt:o})}},k=o.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(t,e,n,o){o=this.cfg.extend(o);var i=t.createEncryptor(n,o),r=i.finalize(e),s=i.cfg;return y.create({ciphertext:r,key:n,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:o.format})},decrypt:function(t,e,n,o){o=this.cfg.extend(o),e=this._parse(e,o.format);var i=t.createDecryptor(n,o).finalize(e.ciphertext);return i},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),w=n.kdf={},x=w.OpenSSL={execute:function(t,e,n,o){o||(o=r.random(8));var i=f.create({keySize:e+n}).compute(t,o),s=r.create(i.words.slice(e),4*n);return i.sigBytes=4*e,y.create({key:i,iv:s,salt:o})}},b=o.PasswordBasedCipher=k.extend({cfg:k.cfg.extend({kdf:x}),encrypt:function(t,e,n,o){o=this.cfg.extend(o);var i=o.kdf.execute(n,t.keySize,t.ivSize);o.iv=i.iv;var r=k.encrypt.call(this,t,e,i.key,o);return r.mixIn(i),r},decrypt:function(t,e,n,o){o=this.cfg.extend(o),e=this._parse(e,o.format);var i=o.kdf.execute(n,t.keySize,t.ivSize,e.salt);o.iv=i.iv;var r=k.decrypt.call(this,t,e,i.key,o);return r}})}()}),function(t,e,n){"object"==typeof exports?module.exports=exports=e(require("./core"),require("./enc-base64"),require("./md5"),require("./evpkdf"),require("./cipher-core")):"function"==typeof define&&define.amd?define("crypto-js/aes",["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(t.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,o=n.BlockCipher,i=e.algo,r=[],s=[],c=[],a=[],u=[],f=[],d=[],l=[],m=[],p=[];!function(){for(var t=[],e=0;e<256;e++)e<128?t[e]=e<<1:t[e]=e<<1^283;for(var n=0,o=0,e=0;e<256;e++){var i=o^o<<1^o<<2^o<<3^o<<4;i=i>>>8^255&i^99,r[n]=i,s[i]=n;var h=t[n],g=t[h],y=t[g],v=257*t[i]^16843008*i;c[n]=v<<24|v>>>8,a[n]=v<<16|v>>>16,u[n]=v<<8|v>>>24,f[n]=v;var v=16843009*y^65537*g^257*h^16843008*n;d[i]=v<<24|v>>>8,l[i]=v<<16|v>>>16,m[i]=v<<8|v>>>24,p[i]=v,n?(n=h^t[t[t[y^h]]],o^=t[t[o]]):n=o=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],g=i.AES=o.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,n=t.sigBytes/4,o=this._nRounds=n+6,i=4*(o+1),s=this._keySchedule=[],c=0;c6&&c%n==4&&(a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=a<<8|a>>>24,a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=h[c/n|0]<<24),s[c]=s[c-n]^a}for(var u=this._invKeySchedule=[],f=0;f>>24]]^l[r[a>>>16&255]]^m[r[a>>>8&255]]^p[r[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,c,a,u,f,r)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,d,l,m,p,s);var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,o,i,r,s,c){for(var a=this._nRounds,u=t[e]^n[0],f=t[e+1]^n[1],d=t[e+2]^n[2],l=t[e+3]^n[3],m=4,p=1;p>>24]^i[f>>>16&255]^r[d>>>8&255]^s[255&l]^n[m++],g=o[f>>>24]^i[d>>>16&255]^r[l>>>8&255]^s[255&u]^n[m++],y=o[d>>>24]^i[l>>>16&255]^r[u>>>8&255]^s[255&f]^n[m++],v=o[l>>>24]^i[u>>>16&255]^r[f>>>8&255]^s[255&d]^n[m++];u=h,f=g,d=y,l=v}var h=(c[u>>>24]<<24|c[f>>>16&255]<<16|c[d>>>8&255]<<8|c[255&l])^n[m++],g=(c[f>>>24]<<24|c[d>>>16&255]<<16|c[l>>>8&255]<<8|c[255&u])^n[m++],y=(c[d>>>24]<<24|c[l>>>16&255]<<16|c[u>>>8&255]<<8|c[255&f])^n[m++],v=(c[l>>>24]<<24|c[u>>>16&255]<<16|c[f>>>8&255]<<8|c[255&d])^n[m++];t[e]=h,t[e+1]=g,t[e+2]=y,t[e+3]=v},keySize:8});e.AES=o._createHelper(g)}(),t.AES}),function(t,e){"object"==typeof exports?module.exports=exports=e(require("./core")):"function"==typeof define&&define.amd?define("crypto-js/enc-utf8",["./core"],e):e(t.CryptoJS)}(this,function(t){return t.enc.Utf8}),define("$.utils",["websocket","crypto-js/aes","crypto-js/sha1","crypto-js/enc-utf8"],function(t,e,n,o){var i={},r=/^\d+$/;return i.io=t,i.SHA1=function(t){return n(t).toString()},i.AES={decrypt:function(t,n){return e.decrypt(t,n).toString(o)},encrypt:function(t,n){return e.encrypt(t,n).toString()}},i.ssplit=function(t,e){var n=t.split(e);return[n.shift(),n.join(e)]},i.activeElement=function(){try{return document.activeElement}catch(t){}},i.isDigits=function(t){return r.test(t)},i.template=function(t,e){return t&&t.replace(/{(\w+)}/gi,function(t,n){return e.hasOwnProperty(n)?e[n]:t})},i.getJSON=function(t,e,n){var o=new XMLHttpRequest;o.open("GET",t,!0),o.onreadystatechange=function(){if(4===this.readyState)if(this.status>=200&&this.status<400)try{e&&e(JSON.parse(this.responseText))}catch(t){n&&n()}else n&&n()},o.send(),o=null},i.escapeHtml=function(){var t=/[&<>"'\/]/g,e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return function(n){return String(n).replace(t,function(t){return e[t]})}}(),i}),define("$.proto",[],function(){var t={};return t.html=function(t){return this.forEach(function(e){e.innerHTML=t}),this},t.append=function(t){return this.forEach(function(e){e.innerHTML+=t}),this},t.first=function(){return this[0]},t.on=function(t,e){return this.forEach(function(n){n.addEventListener?n.addEventListener(t,e,!1):n.attachEvent&&n.attachEvent("on"+t,e)}),this},t.focus=function(){return this[0]&&this[0].focus(),this},t}),define("$",["$.utils","$.proto"],function(t,e){function n(){}function o(t){var e,o=new n;if(void 0!==t)if(t===document)o.push(document);else if(t===window)o.push(window);else if(e=document.querySelectorAll(t))for(var i=0;i\n\n▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▄▄▄ ██▓ ██ ▄█▀ \n▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒████▄ ▓██▒ ██▄█▒ \n▒▓█ ▄ ▓██ ░▄█ ▒ ▒██ ██░▓██░ ██▓▒▒ ▓██░ ▒░▒██ ▀█▄ ▒██░ ▓███▄░ \n▒▓▓▄ ▄██▒▒██▀▀█▄ ░ ▐██▓░▒██▄█▓▒ ▒░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░ ▓██ █▄ \n▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██▒ ░ ░ ▒██▒ ░ ▓█ ▓██▒░██████▒▒██▒ █▄ \n░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ██▒▒▒ ▒▓▒░ ░ ░ ▒ ░░ ▒▒ ▓▒█░░ ▒░▓ ░▒ ▒▒ ▓▒ \n ░ ▒ ░▒ ░ ▒░▓██ ░▒░ ░▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░░ ░▒ ▒░ \n░ ░░ ░ ▒ ▒ ░░ ░░ ░ ░ ▒ ░ ░ ░ ░░ ░ \n░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ \n░ ░ ░ \n https://github.com/hexagon/cryptalk \n \n Tip of the day: /help \n----------------------------------------------------------------------",nick:{maxLen:20,minLen:2},key:{maxLen:1024,minLen:8},room:{minLen:1,maxLen:64},notifications:{maxOnePerMs:3e3}}),define("templates",{help:"
                                                                \nCryptalk, encrypted instant chat.                                      \n                                                                       \n----------------------------------------------------------------------\t\n                                                                       \nClient:                                                    \t\t\t\n\t/key\t\tStrongPassphrase\tSets encryption key                 \n\t/nick\t\tNickName\t\tSets an optional nick                   \n\t/mute  \t\t\t\t\tAudio on\t\t\t\t\t\t\t\t\t\n\t/unmute  \t\t\t\tAudio off\t\t\t\t\t\t\t\t\t\n\t/clear\t\t\t\t\tClear on-screen buffer                      \n\t/help\t\t\t\t\tThis                                        \n\t/title\t\t\t\t\tSet your local page title\t\t\t\t\t\n\t/torch\t\tAfterSeconds\t\tConsole messages are torched  \t\t\n\t\t\t\t\t\tafter this amount of seconds \t\t\t\t\t\n\t\t\t\t\t\t(default 600).\t\t\t\t\t\t\t\t\t\n                                                                       \nRoom:                                                    \t\t\t\t\n\t/join\t\tRoomId\t\t\tJoin a room\t                            \n\t/leave\t\t\t\t\tLeave the room                              \n\t/count\t\t\t\t\tCount participants                          \n                                                                       \nHost:  \t\t                                                    \t\n\t/hosts\t\t\t\t\tList available hosts                   \t\t\n\t/connect\tHostIndex\t\tConnect to selected host               \t\n\t/disconnect\t\t\t\tDisconnect from host    \t\t\t        \n                                                                       \nYou can select any of the five last commands/messages with up/down key.\n                                                                       \nDue to security reasons, /key command is not saved, and command        \nhistory is  automatically cleared after one minute of inactivity.      \n                                                                       \nIt is highly recommended to use incognito mode while chatting, \nto prevent browsers from keeping history or cache.            \n                                                                       \n----------------------------------------------------------------------\t\n
",default_nick:"Anonymous",post:{motd:'
  • {text}
  • ',info:'
  • [{timestamp}] INF> {text}
  • ',server:'
  • [{timestamp}] SRV> {text}
  • ',error:'
  • [{timestamp}] ERR> {text}
  • ',message:'
  • [{timestamp}] MSG> {nick}> {text}
  • '},messages:{key_to_short:"Hmm, that's a weak key, try again...",key_to_long:"Man that's a long key. Make it a tad short, 'kay?",key_ok:"Key set, you can now start communicating.",key_no_host:"You have to connect to a host before setting the key.",join_no_host:"You have to connect to a host before joining a room.",nick_to_short:"Nickname is too short, it has to be at least {nick_minLen} characters long. Try again.",nick_to_long:"Nickname is too long, it can be at most {nick_maxLen} characters long. Try again.",nick_set:"From now on, you're referred to as '{nick}'.",msg_no_room:"You have to join a room before sending messages. See /help.",not_in_room:"You have to be in a room to count participants...",msg_no_key:"You have to set an encryption key before sending a message. See /help.",leave_from_nowhere:"How are you supposed to leave, while being nowhere?",torch_is_now:"Messages are now torched after {ttl} seconds.",torch_not_set:"Invalid torch delay entered, nothing changed. See /help.",title_set:"The title of this window is now '{title}'.",muted:"Notifications and sounds are now muted.",unmuted:"Notifications and sounds are now on.",unrecognized_command:'Unrecognized command: "{commandName}"',room_name_too_long:"Isn't that a bit long?",room_name_too_short:"Nah, too short.",joined_room:"Joined room {roomName}.",left_room:"Left room {roomName}.",already_in_room:"You are already in a room ({room}), stoopid.",unable_to_decrypt:"Unabled to decrypt received message, keys does not match.",socket_error:"A network error has occurred. A restart may be required to bring back full functionality.
    Examine the logs for more details.",connecting:"Connecting to host {host}...",connected:"A connection to the server has been established. Happy chatting!",disconnected:"Disconnected from host {host}.",already_connected:"You have to disconnect from {host} before joining another.",reconnect_no_host:"There is no host to reconnect with.",host_available:'{index}\t[AVAILABLE]\t{name}\n',host_unavailable:'{index}\t[UNAVAILABLE]\t{name}\n'},server:{person_joined:"A person joined this room.",person_left:"A person left this room.",person_count:"There is {payload} person(s) in this room, including you.",command_failed:"Server command failed, you're probably trying to du something bogus.",bogus:"Received a bogus message from server."},client:{title:"Cryptalk - Offline"}}),define("hosts",{autoconnect:0,hosts:[{name:"default",host:"",path:"/js/lib/settings.js"}]}),define("window",["castrato"],function(t){var e={},n=function(){t.emit("window:focused")},o=function(){t.emit("window:blurred")};return e.setTitle=function(t){document.title=t},e.getTitle=function(){return document.title},window.addEventListener?(window.addEventListener("focus",n,!0),window.addEventListener("blur",o,!0)):(window.observe("focusin",n),window.observe("focusout",o)),t.on("window:title",e.setTitle),e}),define("host",["$","castrato","settings","templates","hosts","window"],function(t,e,n,o,i,r){var s,c,a={},u=function(t){s&&s.emit(t.data,t.payload)},c=function(){e.emit("info",JSON.stringify(c||{}))},f=function(n,r){var s,c=0,a=i.hosts.length,u="\n",f=function(n,i,s){return function(c){n.settings=s?c:0,u+=t.template(o.messages[s?"host_available":"host_unavailable"],{name:n.name,path:n.path,index:i}),0===--a&&(e.emit("console:info",u),r())}};for(n=n&&"force"===n.toLowerCase();s=i.hosts[c];)n||void 0===s.settings?require([s.path],f(s,c,1),f(s,c,0)):s.settings?f(s,c,1)():f(s,c,0)(),c++},d=function(r,u){e.emit("console:lockInput");var f,r=void 0==r?i.autoconnect:r;if(c&&c.connected)return e.emit("console:error",t.template(o.messages.already_connected,{host:c.name||"localhost"})),void e.emit("console:unlockInput");if(t.isDigits(r)){if(!(c=i.hosts[+r]))return e.emit("console:error","Undefined host index: "+r),void e.emit("console:unlockInput");c.settings?n=c.settings:f=c.path}else r?f=r.settings:n=r.settings;return f?require([f],function(t){return c.settings=t,d(r,u)},function(){e.emit("console:error","Could not fetch host settings: "+f),e.emit("console:unlockInput")}):(e.emit("console:info",t.template(o.messages.connecting,{host:c.name||"localhost"})),e.emit("console:motd",c.settings.motd),s=t.io(c.host,{forceNew:!0,"force new connection":!0}),void s.on("room:joined",function(n){e.emit("console:info",t.template(o.messages.joined_room,{roomName:t.escapeHtml(a.room)})),s.emit("room:count")}).on("room:left",function(){e.emit("console:info",t.template(o.messages.left_room,{roomName:t.escapeHtml(a.room)})),e.emit("room:changed",!1)}).on("message:send",function(n){var i=t.AES.decrypt(n.msg,t.SHA1(a.room)+a.key),r=t.escapeHtml(i),s=n.nick?t.escapeHtml(t.AES.decrypt(n.nick,t.SHA1(a.room)+a.key)):o.default_nick;i?e.emit("console:message",{message:r,nick:s}):e.emit("console:error",o.messages.unable_to_decrypt)}).on("message:server",function(n){if(n.msg){var i=t.escapeHtml(n.msg);if(o.server[i])if(void 0!==n.payload){var r=t.escapeHtml(n.payload);e.emit("console:server",t.template(o.server[i],{payload:r}))}else e.emit("console:server",o.server[i]);else e.emit("console:error",o.server.bogus)}else e.emit("console:error",o.server.bogus)}).on("connect",function(){e.emit("console:info",t.template(o.messages.connected,{host:c.name||"localhost"})),e.emit("window:title",c.settings.title),e.emit("console:unlockInput"),u(),c.connected=1}).on("disconnect",function(){room=0,key=0,c.connected=0,e.emit("console:info",t.template(o.messages.disconnected,{host:c.name||"localhost"})),e.emit("room:changed",void 0),e.emit("window:title",o.client.title)}).on("connect_error",function(){room=0,key=0,c.connected=0,e.emit("console:error",o.messages.socket_error),e.emit("console:unlockInput")}))},l=function(){s.disconnect()},m=function(t){a=Object.assign({},a,t)};e.on("command:host",c),e.on("command:hosts",f),e.on("command:connect",d),e.on("command:disconnect",l),e.on("command:reconnect",l),e.on("socket:emit",u),e.on("host:param",m)}),define("client",["$","castrato","settings","templates"],function(t,e,n,o){var i,r,s=function(t){return t.length>n.key.maxLen?e.emit("console:error",o.messages.key_to_long):t.lengthn.nick.maxLen?e("console:error",t.template(o.messages.nick_to_long,{nick_maxLen:n.nick.maxLen})):r.length=n.room.maxLen?e.emit("console:error",t.template(o.messages.room_name_too_long)):r.lengthn.notifications.maxOnePerMs)if(void 0===i&&(i=!1),u&&"granted"===Notification.permission){var r=new Notification(t,{body:e,icon:o});r.onshow=function(){setTimeout(function(){r.close()},3e3)},c=f()}else i&&g("Attention",1e3)};u=void 0!==window.Notification,t.on("notification:send",function(t){y(t.title,t.body,t.icon,!0)}),t.on("notification:on",function(){d()}),t.on("notification:off",function(){l()}),h(),l(),c=f(),m()}),define("queue",[],function(){var t={},e=[],n=function(){return performance.now()||Date.now()};return t.add_function_delayed=function(t,o,i){e.push({func:o,pushed:n(),delay:t,data:i})},t.get=function(){return e},t.run=function(){for(var o,i,r=0;o=e[r++];)n()-o.pushed>o.delay&&(o.func(),e.splice(r-1,1));if(e.length){for(i=n();n()-i<1;);t.run()}},t}),define("audio",["queue","castrato","templates"],function(t,e,n){var o=!1,i=!0,r=!1,s=function(e,n){if(n=void 0===n?0:n,o&&i&&n0&&i<3600?(e.emit("console:info",t.template(o.messages.torch_is_now,{ttl:i})),n.ttl=1e3*i):e.emit("console:error",t.template(o.messages.torch_not_set))},param:function(t){s=Object.assign({},s,t)},showNotification:function(t,n,o){var r="message"!==t?"Cryptalk":n,s="message"===t?"gfx/icon_128x128.png":"error"==t?"gfx/icon_128x128_error.png":"gfx/icon_128x128_info.png";e.emit("notification:send",{title:r.substring(0,20),body:o.substring(0,80),icon:s}),"message"===t&&e.emit("audio:play",i.message)},motd:function(t){c.post("motd",t)},info:function(t){c.post("info",t)},error:function(t){c.post("error",t)},server:function(t){c.post("server",t)},message:function(t){c.post("message",t.message,t.nick)},clearInput:function(){r.input[0].value=""},clear:function(){r.chat[0].innerHTML=""},lockInput:function(){r.input[0].setAttribute("disabled","disabled"),r.inputWrapper[0].className="loading"},unlockInput:function(){r.input[0].removeAttribute("disabled"),r.inputWrapper[0].className="",r.input.focus()},_require:function(t,e){c.lockInput(),c.post("info","Requiring "+t+"..."),require([t],function(){c.post("info","Successfully required "+t+"."),c.unlockInput(),e()},function(n){c.post("error",'An error occurred while trying to load "'+t+'":\n'+n),c.unlockInput(),e()})}},a=function(n){var i,a,u,f;if(!n.ctrlKey&&!n.altKey&&r.input[0]!==t.activeElement())return r.input.focus();if(13===n.keyCode&&(i=r.input[0].value))if("/"===(i[0]||i.slice(0,1)))a=t.ssplit(i.slice(1)," "),f=a[0],u=a[1],e.emit("command:"+f,u,function(e,n){return n?void c.clearInput():c.post("error",t.template(o.messages.unrecognized_command,{commandName:f}))});else{if(!s.room||!s.key)return s.room?c.post("error",o.messages.msg_no_key):c.post("error",o.messages.msg_no_room);e.emit("socket:emit",{data:"message:send",payload:{room:t.SHA1(s.room),msg:t.AES.encrypt(i,t.SHA1(s.room)+s.key).toString(),nick:!!s.nick&&t.AES.encrypt(s.nick,t.SHA1(s.room)+s.key).toString()}}),c.clearInput()}};t(document).on("keydown",a),r.input.focus();for(var u in c)"_require"!==u&&"post"!==u&&e.on("console:"+u,c[u]);e.on("console:require",c._require),e.on("console:post",function(t){c.post(t.type,t.data,t.nick)})}),define("cryptalk",["castrato","host","client","console"],function(t,e,n){t.on("window:focused",function(){t.emit("audio:off"),t.emit("notification:off")}).on("window:blurred",function(){t.emit("audio:on"),t.emit("notification:on")}).on("command:mute",function(){t.emit("audio:mute")}).on("command:unmute",function(){t.emit("audio:unmute")}).on("room:changed",function(e){t.emit("console:param",{room:e}).emit("host:param",{room:e})}).on("nick:changed",function(e){t.emit("console:param",{nick:e})}).on("key:changed",function(e){t.emit("console:param",{key:e}).emit("host:param",{key:e})}).emit("command:connect",void 0,function(){(hash=window.location.hash)&&(parts=hash.slice(1).split(":"),parts[0]&&t.emit("command:join",parts[0]),parts[1]&&t.emit("command:key",parts[1]))})}),require.config({baseUrl:"js/lib/",paths:{websocket:"/socket.io/socket.io"},packages:[{name:"crypto-js",location:"../vendor/crypto-js-3.1.9",main:"index"}]}),require(["cryptalk"]),define("main",function(){}); \ No newline at end of file +!function(t,e){"function"==typeof define&&define.amd?define("castrato/castrato",[],e()):"object"==typeof exports?module.exports=e:t.castrato=e}(this,function(){function t(t,e,o,s){var c=[t,o,1>>2]>>>24-r%4*8&255;e[o+r>>>2]|=s<<24-(o+r)%4*8}else for(var r=0;r>>2]=n[r>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,n=this.sigBytes;e[n>>>2]&=4294967295<<32-n%4*8,e.length=t.ceil(n/4)},clone:function(){var t=r.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var n,o=[],i=function(e){var e=e,n=987654321,o=4294967295;return function(){n=36969*(65535&n)+(n>>16)&o,e=18e3*(65535&e)+(e>>16)&o;var i=(n<<16)+e&o;return i/=4294967296,i+=.5,i*(t.random()>.5?1:-1)}},r=0;r>>2]>>>24-i%4*8&255;o.push((r>>>4).toString(16)),o.push((15&r).toString(16))}return o.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>3]|=parseInt(t.substr(o,2),16)<<24-o%8*4;return new s.init(n,e/2)}},u=c.Latin1={stringify:function(t){for(var e=t.words,n=t.sigBytes,o=[],i=0;i>>2]>>>24-i%4*8&255;o.push(String.fromCharCode(r))}return o.join("")},parse:function(t){for(var e=t.length,n=[],o=0;o>>2]|=(255&t.charCodeAt(o))<<24-o%4*8;return new s.init(n,e)}},f=c.Utf8={stringify:function(t){try{return decodeURIComponent(escape(u.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return u.parse(unescape(encodeURIComponent(t)))}},d=i.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var n=this._data,o=n.words,i=n.sigBytes,r=this.blockSize,c=4*r,a=i/c;a=e?t.ceil(a):t.max((0|a)-this._minBufferSize,0);var u=a*r,f=t.min(4*u,i);if(u){for(var d=0;d>>6-s%4*2;o[r>>>2]|=(c|a)<<24-r%4*8,r++}return i.create(o,r)}var n=t,o=n.lib,i=o.WordArray,r=n.enc;r.Base64={stringify:function(t){var e=t.words,n=t.sigBytes,o=this._map;t.clamp();for(var i=[],r=0;r>>2]>>>24-r%4*8&255,c=e[r+1>>>2]>>>24-(r+1)%4*8&255,a=e[r+2>>>2]>>>24-(r+2)%4*8&255,u=s<<16|c<<8|a,f=0;f<4&&r+.75*f>>6*(3-f)&63));var d=o.charAt(64);if(d)for(;i.length%4;)i.push(d);return i.join("")},parse:function(t){var n=t.length,o=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var r=0;r>>32-r)+e}function o(t,e,n,o,i,r,s){var c=t+(e&o|n&~o)+i+s;return(c<>>32-r)+e}function i(t,e,n,o,i,r,s){var c=t+(e^n^o)+i+s;return(c<>>32-r)+e}function r(t,e,n,o,i,r,s){var c=t+(n^(e|~o))+i+s;return(c<>>32-r)+e}var s=t,c=s.lib,a=c.WordArray,u=c.Hasher,f=s.algo,d=[];!function(){for(var t=0;t<64;t++)d[t]=4294967296*e.abs(e.sin(t+1))|0}();var l=f.MD5=u.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var s=0;s<16;s++){var c=e+s,a=t[c];t[c]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)}var u=this._hash.words,f=t[e+0],l=t[e+1],m=t[e+2],p=t[e+3],h=t[e+4],g=t[e+5],y=t[e+6],v=t[e+7],_=t[e+8],k=t[e+9],w=t[e+10],x=t[e+11],b=t[e+12],S=t[e+13],B=t[e+14],A=t[e+15],C=u[0],j=u[1],E=u[2],H=u[3];C=n(C,j,E,H,f,7,d[0]),H=n(H,C,j,E,l,12,d[1]),E=n(E,H,C,j,m,17,d[2]),j=n(j,E,H,C,p,22,d[3]),C=n(C,j,E,H,h,7,d[4]),H=n(H,C,j,E,g,12,d[5]),E=n(E,H,C,j,y,17,d[6]),j=n(j,E,H,C,v,22,d[7]),C=n(C,j,E,H,_,7,d[8]),H=n(H,C,j,E,k,12,d[9]),E=n(E,H,C,j,w,17,d[10]),j=n(j,E,H,C,x,22,d[11]),C=n(C,j,E,H,b,7,d[12]),H=n(H,C,j,E,S,12,d[13]),E=n(E,H,C,j,B,17,d[14]),j=n(j,E,H,C,A,22,d[15]),C=o(C,j,E,H,l,5,d[16]),H=o(H,C,j,E,y,9,d[17]),E=o(E,H,C,j,x,14,d[18]),j=o(j,E,H,C,f,20,d[19]),C=o(C,j,E,H,g,5,d[20]),H=o(H,C,j,E,w,9,d[21]),E=o(E,H,C,j,A,14,d[22]),j=o(j,E,H,C,h,20,d[23]),C=o(C,j,E,H,k,5,d[24]),H=o(H,C,j,E,B,9,d[25]),E=o(E,H,C,j,p,14,d[26]),j=o(j,E,H,C,_,20,d[27]),C=o(C,j,E,H,S,5,d[28]),H=o(H,C,j,E,m,9,d[29]),E=o(E,H,C,j,v,14,d[30]),j=o(j,E,H,C,b,20,d[31]),C=i(C,j,E,H,g,4,d[32]),H=i(H,C,j,E,_,11,d[33]),E=i(E,H,C,j,x,16,d[34]),j=i(j,E,H,C,B,23,d[35]),C=i(C,j,E,H,l,4,d[36]),H=i(H,C,j,E,h,11,d[37]),E=i(E,H,C,j,v,16,d[38]),j=i(j,E,H,C,w,23,d[39]),C=i(C,j,E,H,S,4,d[40]),H=i(H,C,j,E,f,11,d[41]),E=i(E,H,C,j,p,16,d[42]),j=i(j,E,H,C,y,23,d[43]),C=i(C,j,E,H,k,4,d[44]),H=i(H,C,j,E,b,11,d[45]),E=i(E,H,C,j,A,16,d[46]),j=i(j,E,H,C,m,23,d[47]),C=r(C,j,E,H,f,6,d[48]),H=r(H,C,j,E,v,10,d[49]),E=r(E,H,C,j,B,15,d[50]),j=r(j,E,H,C,g,21,d[51]),C=r(C,j,E,H,b,6,d[52]),H=r(H,C,j,E,p,10,d[53]),E=r(E,H,C,j,w,15,d[54]),j=r(j,E,H,C,l,21,d[55]),C=r(C,j,E,H,_,6,d[56]),H=r(H,C,j,E,A,10,d[57]),E=r(E,H,C,j,y,15,d[58]),j=r(j,E,H,C,S,21,d[59]),C=r(C,j,E,H,h,6,d[60]),H=r(H,C,j,E,x,10,d[61]),E=r(E,H,C,j,m,15,d[62]),j=r(j,E,H,C,k,21,d[63]),u[0]=u[0]+C|0,u[1]=u[1]+j|0,u[2]=u[2]+E|0,u[3]=u[3]+H|0},_doFinalize:function(){var t=this._data,n=t.words,o=8*this._nDataBytes,i=8*t.sigBytes;n[i>>>5]|=128<<24-i%32;var r=e.floor(o/4294967296),s=o;n[(i+64>>>9<<4)+15]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[(i+64>>>9<<4)+14]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var c=this._hash,a=c.words,u=0;u<4;u++){var f=a[u];a[u]=16711935&(f<<8|f>>>24)|4278255360&(f<<24|f>>>8)}return c},clone:function(){var t=u.clone.call(this);return t._hash=this._hash.clone(),t}});s.MD5=u._createHelper(l),s.HmacMD5=u._createHmacHelper(l)}(Math),t.MD5}),function(t,e){"object"==typeof exports?module.exports=exports=e(require("./core")):"function"==typeof define&&define.amd?define("crypto-js/sha1",["./core"],e):e(t.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,o=n.WordArray,i=n.Hasher,r=e.algo,s=[],c=r.SHA1=i.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var n=this._hash.words,o=n[0],i=n[1],r=n[2],c=n[3],a=n[4],u=0;u<80;u++){if(u<16)s[u]=0|t[e+u];else{var f=s[u-3]^s[u-8]^s[u-14]^s[u-16];s[u]=f<<1|f>>>31}var d=(o<<5|o>>>27)+a+s[u];d+=u<20?(i&r|~i&c)+1518500249:u<40?(i^r^c)+1859775393:u<60?(i&r|i&c|r&c)-1894007588:(i^r^c)-899497514,a=c,c=r,r=i<<30|i>>>2,i=o,o=d}n[0]=n[0]+o|0,n[1]=n[1]+i|0,n[2]=n[2]+r|0,n[3]=n[3]+c|0,n[4]=n[4]+a|0},_doFinalize:function(){var t=this._data,e=t.words,n=8*this._nDataBytes,o=8*t.sigBytes;return e[o>>>5]|=128<<24-o%32,e[(o+64>>>9<<4)+14]=Math.floor(n/4294967296),e[(o+64>>>9<<4)+15]=n,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA1=i._createHelper(c),e.HmacSHA1=i._createHmacHelper(c)}(),t.SHA1}),function(t,e){"object"==typeof exports?module.exports=exports=e(require("./core")):"function"==typeof define&&define.amd?define("crypto-js/hmac",["./core"],e):e(t.CryptoJS)}(this,function(t){!function(){var e=t,n=e.lib,o=n.Base,i=e.enc,r=i.Utf8,s=e.algo;s.HMAC=o.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=r.parse(e));var n=t.blockSize,o=4*n;e.sigBytes>o&&(e=t.finalize(e)),e.clamp();for(var i=this._oKey=e.clone(),s=this._iKey=e.clone(),c=i.words,a=s.words,u=0;u>>2];t.sigBytes-=e}},y=(o.BlockCipher=d.extend({cfg:d.cfg.extend({mode:p,padding:g}),reset:function(){d.reset.call(this);var t=this.cfg,e=t.iv,n=t.mode;if(this._xformMode==this._ENC_XFORM_MODE)var o=n.createEncryptor;else{var o=n.createDecryptor;this._minBufferSize=1}this._mode&&this._mode.__creator==o?this._mode.init(this,e&&e.words):(this._mode=o.call(n,this,e&&e.words),this._mode.__creator=o)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else{var e=this._process(!0);t.unpad(e)}return e},blockSize:4}),o.CipherParams=i.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),v=n.format={},_=v.OpenSSL={stringify:function(t){var e=t.ciphertext,n=t.salt;if(n)var o=r.create([1398893684,1701076831]).concat(n).concat(e);else var o=e;return o.toString(a)},parse:function(t){var e=a.parse(t),n=e.words;if(1398893684==n[0]&&1701076831==n[1]){var o=r.create(n.slice(2,4));n.splice(0,4),e.sigBytes-=16}return y.create({ciphertext:e,salt:o})}},k=o.SerializableCipher=i.extend({cfg:i.extend({format:_}),encrypt:function(t,e,n,o){o=this.cfg.extend(o);var i=t.createEncryptor(n,o),r=i.finalize(e),s=i.cfg;return y.create({ciphertext:r,key:n,iv:s.iv,algorithm:t,mode:s.mode,padding:s.padding,blockSize:t.blockSize,formatter:o.format})},decrypt:function(t,e,n,o){o=this.cfg.extend(o),e=this._parse(e,o.format);var i=t.createDecryptor(n,o).finalize(e.ciphertext);return i},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),w=n.kdf={},x=w.OpenSSL={execute:function(t,e,n,o){o||(o=r.random(8));var i=f.create({keySize:e+n}).compute(t,o),s=r.create(i.words.slice(e),4*n);return i.sigBytes=4*e,y.create({key:i,iv:s,salt:o})}},b=o.PasswordBasedCipher=k.extend({cfg:k.cfg.extend({kdf:x}),encrypt:function(t,e,n,o){o=this.cfg.extend(o);var i=o.kdf.execute(n,t.keySize,t.ivSize);o.iv=i.iv;var r=k.encrypt.call(this,t,e,i.key,o);return r.mixIn(i),r},decrypt:function(t,e,n,o){o=this.cfg.extend(o),e=this._parse(e,o.format);var i=o.kdf.execute(n,t.keySize,t.ivSize,e.salt);o.iv=i.iv;var r=k.decrypt.call(this,t,e,i.key,o);return r}})}()}),function(t,e,n){"object"==typeof exports?module.exports=exports=e(require("./core"),require("./enc-base64"),require("./md5"),require("./evpkdf"),require("./cipher-core")):"function"==typeof define&&define.amd?define("crypto-js/aes",["./core","./enc-base64","./md5","./evpkdf","./cipher-core"],e):e(t.CryptoJS)}(this,function(t){return function(){var e=t,n=e.lib,o=n.BlockCipher,i=e.algo,r=[],s=[],c=[],a=[],u=[],f=[],d=[],l=[],m=[],p=[];!function(){for(var t=[],e=0;e<256;e++)e<128?t[e]=e<<1:t[e]=e<<1^283;for(var n=0,o=0,e=0;e<256;e++){var i=o^o<<1^o<<2^o<<3^o<<4;i=i>>>8^255&i^99,r[n]=i,s[i]=n;var h=t[n],g=t[h],y=t[g],v=257*t[i]^16843008*i;c[n]=v<<24|v>>>8,a[n]=v<<16|v>>>16,u[n]=v<<8|v>>>24,f[n]=v;var v=16843009*y^65537*g^257*h^16843008*n;d[i]=v<<24|v>>>8,l[i]=v<<16|v>>>16,m[i]=v<<8|v>>>24,p[i]=v,n?(n=h^t[t[t[y^h]]],o^=t[t[o]]):n=o=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],g=i.AES=o.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,n=t.sigBytes/4,o=this._nRounds=n+6,i=4*(o+1),s=this._keySchedule=[],c=0;c6&&c%n==4&&(a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a]):(a=a<<8|a>>>24,a=r[a>>>24]<<24|r[a>>>16&255]<<16|r[a>>>8&255]<<8|r[255&a],a^=h[c/n|0]<<24),s[c]=s[c-n]^a}for(var u=this._invKeySchedule=[],f=0;f>>24]]^l[r[a>>>16&255]]^m[r[a>>>8&255]]^p[r[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,c,a,u,f,r)},decryptBlock:function(t,e){var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n,this._doCryptBlock(t,e,this._invKeySchedule,d,l,m,p,s);var n=t[e+1];t[e+1]=t[e+3],t[e+3]=n},_doCryptBlock:function(t,e,n,o,i,r,s,c){for(var a=this._nRounds,u=t[e]^n[0],f=t[e+1]^n[1],d=t[e+2]^n[2],l=t[e+3]^n[3],m=4,p=1;p>>24]^i[f>>>16&255]^r[d>>>8&255]^s[255&l]^n[m++],g=o[f>>>24]^i[d>>>16&255]^r[l>>>8&255]^s[255&u]^n[m++],y=o[d>>>24]^i[l>>>16&255]^r[u>>>8&255]^s[255&f]^n[m++],v=o[l>>>24]^i[u>>>16&255]^r[f>>>8&255]^s[255&d]^n[m++];u=h,f=g,d=y,l=v}var h=(c[u>>>24]<<24|c[f>>>16&255]<<16|c[d>>>8&255]<<8|c[255&l])^n[m++],g=(c[f>>>24]<<24|c[d>>>16&255]<<16|c[l>>>8&255]<<8|c[255&u])^n[m++],y=(c[d>>>24]<<24|c[l>>>16&255]<<16|c[u>>>8&255]<<8|c[255&f])^n[m++],v=(c[l>>>24]<<24|c[u>>>16&255]<<16|c[f>>>8&255]<<8|c[255&d])^n[m++];t[e]=h,t[e+1]=g,t[e+2]=y,t[e+3]=v},keySize:8});e.AES=o._createHelper(g)}(),t.AES}),function(t,e){"object"==typeof exports?module.exports=exports=e(require("./core")):"function"==typeof define&&define.amd?define("crypto-js/enc-utf8",["./core"],e):e(t.CryptoJS)}(this,function(t){return t.enc.Utf8}),define("$.utils",["websocket","crypto-js/aes","crypto-js/sha1","crypto-js/enc-utf8"],function(t,e,n,o){var i={},r=/^\d+$/;return i.io=t,i.SHA1=function(t){return n(t).toString()},i.AES={decrypt:function(t,n){return e.decrypt(t,n).toString(o)},encrypt:function(t,n){return e.encrypt(t,n).toString()}},i.ssplit=function(t,e){var n=t.split(e);return[n.shift(),n.join(e)]},i.activeElement=function(){try{return document.activeElement}catch(t){return}},i.isDigits=function(t){return r.test(t)},i.template=function(t,e){return t&&t.replace(/{(\w+)}/gi,function(t,n){return e.hasOwnProperty(n)?e[n]:t})},i.getJSON=function(t,e,n){var o=new XMLHttpRequest;o.open("GET",t,!0),o.onreadystatechange=function(){if(4===this.readyState)if(this.status>=200&&this.status<400)try{e&&e(JSON.parse(this.responseText))}catch(t){n&&n()}else n&&n()},o.send(),o=null},i.escapeHtml=function(){var t=/[&<>"'\/]/g,e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};return function(n){return String(n).replace(t,function(t){return e[t]})}}(),i}),define("$.proto",[],function(){var t={};return t.html=function(t){return this.forEach(function(e){e.innerHTML=t}),this},t.append=function(t){return this.forEach(function(e){e.innerHTML+=t}),this},t.first=function(){return this[0]},t.on=function(t,e){return this.forEach(function(n){n.addEventListener?n.addEventListener(t,e,!1):n.attachEvent&&n.attachEvent("on"+t,e)}),this},t.focus=function(){return this[0]&&this[0].focus(),this},t}),define("$",["$.utils","$.proto"],function(t,e){function n(){}function o(t){var e,o=new n;if(void 0!==t)if(t===document)o.push(document);else if(t===window)o.push(window);else if(e=document.querySelectorAll(t))for(var i=0;i\n\n▄████▄ ██▀███ ▓██ ██▓ ██▓███ ▄▄▄█████▓ ▄▄▄ ██▓ ██ ▄█▀ \n▒██▀ ▀█ ▓██ ▒ ██▒▒██ ██▒▓██░ ██▒▓ ██▒ ▓▒▒████▄ ▓██▒ ██▄█▒ \n▒▓█ ▄ ▓██ ░▄█ ▒ ▒██ ██░▓██░ ██▓▒▒ ▓██░ ▒░▒██ ▀█▄ ▒██░ ▓███▄░ \n▒▓▓▄ ▄██▒▒██▀▀█▄ ░ ▐██▓░▒██▄█▓▒ ▒░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░ ▓██ █▄ \n▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██▒ ░ ░ ▒██▒ ░ ▓█ ▓██▒░██████▒▒██▒ █▄ \n░ ░▒ ▒ ░░ ▒▓ ░▒▓░ ██▒▒▒ ▒▓▒░ ░ ░ ▒ ░░ ▒▒ ▓▒█░░ ▒░▓ ░▒ ▒▒ ▓▒ \n ░ ▒ ░▒ ░ ▒░▓██ ░▒░ ░▒ ░ ░ ▒ ▒▒ ░░ ░ ▒ ░░ ░▒ ▒░ \n░ ░░ ░ ▒ ▒ ░░ ░░ ░ ░ ▒ ░ ░ ░ ░░ ░ \n░ ░ ░ ░ ░ ░ ░ ░ ░░ ░ \n░ ░ ░ \n https://github.com/hexagon/cryptalk \n \n Tip of the day: /help \n----------------------------------------------------------------------",nick:{maxLen:20,minLen:2},key:{maxLen:1024,minLen:8},room:{minLen:1,maxLen:64},notifications:{maxOnePerMs:3e3}}),define("templates",{help:"
                                                                    \nCryptalk, encrypted instant chat.                                      \n                                                                       \n----------------------------------------------------------------------\t\n                                                                       \nClient:                                                    \t\t\t\n\t/key\t\tStrongPassphrase\tSets encryption key                 \n\t/nick\t\tNickName\t\tSets an optional nick                   \n\t/mute  \t\t\t\t\tAudio on\t\t\t\t\t\t\t\t\t\n\t/unmute  \t\t\t\tAudio off\t\t\t\t\t\t\t\t\t\n\t/clear\t\t\t\t\tClear on-screen buffer                      \n\t/help\t\t\t\t\tThis                                        \n\t/title\t\t\t\t\tSet your local page title\t\t\t\t\t\n\t/torch\t\tAfterSeconds\t\tConsole messages are torched  \t\t\n\t\t\t\t\t\tafter this amount of seconds \t\t\t\t\t\n\t\t\t\t\t\t(default 600).\t\t\t\t\t\t\t\t\t\n                                                                       \nRoom:                                                    \t\t\t\t\n\t/join\t\tRoomId\t\t\tJoin a room\t                            \n\t/leave\t\t\t\t\tLeave the room                              \n\t/count\t\t\t\t\tCount participants                          \n                                                                       \nHost:  \t\t                                                    \t\n\t/hosts\t\t\t\t\tList available hosts                   \t\t\n\t/connect\tHostIndex\t\tConnect to selected host               \t\n\t/disconnect\t\t\t\tDisconnect from host    \t\t\t        \n                                                                       \nYou can select any of the five last commands/messages with up/down key.\n                                                                       \nDue to security reasons, /key command is not saved, and command        \nhistory is  automatically cleared after one minute of inactivity.      \n                                                                       \nIt is highly recommended to use incognito mode while chatting, \nto prevent browsers from keeping history or cache.            \n                                                                       \n----------------------------------------------------------------------\t\n
    ",default_nick:"Anonymous",post:{motd:'
  • {text}
  • ',info:'
  • [{timestamp}] INF> {text}
  • ',server:'
  • [{timestamp}] SRV> {text}
  • ',error:'
  • [{timestamp}] ERR> {text}
  • ',message:'
  • [{timestamp}] MSG> {nick}> {text}
  • '},messages:{key_to_short:"Hmm, that's a weak key, try again...",key_to_long:"Man that's a long key. Make it a tad short, 'kay?",key_ok:"Key set, you can now start communicating.",key_no_host:"You have to connect to a host before setting the key.",join_no_host:"You have to connect to a host before joining a room.",nick_to_short:"Nickname is too short, it has to be at least {nick_minLen} characters long. Try again.",nick_to_long:"Nickname is too long, it can be at most {nick_maxLen} characters long. Try again.",nick_set:"From now on, you're referred to as '{nick}'.",msg_no_room:"You have to join a room before sending messages. See /help.",not_in_room:"You have to be in a room to count participants...",msg_no_key:"You have to set an encryption key before sending a message. See /help.",leave_from_nowhere:"How are you supposed to leave, while being nowhere?",torch_is_now:"Messages are now torched after {ttl} seconds.",torch_not_set:"Invalid torch delay entered, nothing changed. See /help.",title_set:"The title of this window is now '{title}'.",muted:"Notifications and sounds are now muted.",unmuted:"Notifications and sounds are now on.",unrecognized_command:'Unrecognized command: "{commandName}"',room_name_too_long:"Isn't that a bit long?",room_name_too_short:"Nah, too short.",joined_room:"Joined room {roomName}.",left_room:"Left room {roomName}.",already_in_room:"You are already in a room ({room}), stoopid.",unable_to_decrypt:"Unabled to decrypt received message, keys does not match.",socket_error:"A network error has occurred. A restart may be required to bring back full functionality.
    Examine the logs for more details.",connecting:"Connecting to host {host}...",connected:"A connection to the server has been established. Happy chatting!",disconnected:"Disconnected from host {host}.",already_connected:"You have to disconnect from {host} before joining another.",reconnect_no_host:"There is no host to reconnect with.",host_available:'{index}\t[AVAILABLE]\t{name}\n',host_unavailable:'{index}\t[UNAVAILABLE]\t{name}\n'},server:{person_joined:"A person joined this room.",person_left:"A person left this room.",person_count:"There is {payload} person(s) in this room, including you.",command_failed:"Server command failed, you're probably trying to du something bogus.",bogus:"Received a bogus message from server."},client:{title:"Cryptalk - Offline"}}),define("hosts",{autoconnect:0,hosts:[{name:"default",host:"",path:"/js/lib/settings.js"}]}),define("window",["castrato"],function(t){var e={},n=function(){t.emit("window:focused")},o=function(){t.emit("window:blurred")};return e.setTitle=function(t){document.title=t},e.getTitle=function(){return document.title},window.addEventListener?(window.addEventListener("focus",n,!0),window.addEventListener("blur",o,!0)):(window.observe("focusin",n),window.observe("focusout",o)),t.on("window:title",e.setTitle),e}),define("host",["$","castrato","settings","templates","hosts","window"],function(t,e,n,o,i){var r,s,c={},a=function(t){r&&r.emit(t.data,t.payload)},u=function(){e.emit("info",JSON.stringify(s||{}))},f=function(n,r){var s,c=0,a=i.hosts.length,u="\n",f=function(n,i,s){return function(c){n.settings=s?c:0,u+=t.template(o.messages[s?"host_available":"host_unavailable"],{name:n.name,path:n.path,index:i}),0===--a&&(e.emit("console:info",u),r())}};for(n=n&&"force"===n.toLowerCase();s=i.hosts[c];)n||void 0===s.settings?require([s.path],f(s,c,1),f(s,c,0)):s.settings?f(s,c,1)():f(s,c,0)(),c++},d=function(a,u){e.emit("console:lockInput");var f;if(a=void 0===a?i.autoconnect:a,s&&s.connected)return e.emit("console:error",t.template(o.messages.already_connected,{host:s.name||"localhost"})),void e.emit("console:unlockInput");if(t.isDigits(a)){if(!(s=i.hosts[+a]))return e.emit("console:error","Undefined host index: "+a),void e.emit("console:unlockInput");s.settings?n=s.settings:f=s.path}else a?f=a.settings:n=a.settings;return f?require([f],function(t){return s.settings=t,d(a,u)},function(){e.emit("console:error","Could not fetch host settings: "+f),e.emit("console:unlockInput")}):(e.emit("console:info",t.template(o.messages.connecting,{host:s.name||"localhost"})),e.emit("console:motd",s.settings.motd),r=t.io(s.host,{forceNew:!0,"force new connection":!0}),void r.on("room:joined",function(){e.emit("console:info",t.template(o.messages.joined_room,{roomName:t.escapeHtml(c.room)})),r.emit("room:count")}).on("room:left",function(){e.emit("console:info",t.template(o.messages.left_room,{roomName:t.escapeHtml(c.room)})),e.emit("room:changed",!1)}).on("message:send",function(n){var i=t.AES.decrypt(n.msg,t.SHA1(c.room)+c.key),r=t.escapeHtml(i),s=n.nick?t.escapeHtml(t.AES.decrypt(n.nick,t.SHA1(c.room)+c.key)):o.default_nick;i?e.emit("console:message",{message:r,nick:s}):e.emit("console:error",o.messages.unable_to_decrypt)}).on("message:server",function(n){if(n.msg){var i=t.escapeHtml(n.msg);if(o.server[i])if(void 0!==n.payload){var r=t.escapeHtml(n.payload);e.emit("console:server",t.template(o.server[i],{payload:r}))}else e.emit("console:server",o.server[i]);else e.emit("console:error",o.server.bogus)}else e.emit("console:error",o.server.bogus)}).on("connect",function(){e.emit("console:info",t.template(o.messages.connected,{host:s.name||"localhost"})),e.emit("window:title",s.settings.title),e.emit("console:unlockInput"),u(),s.connected=1}).on("disconnect",function(){s.connected=0,e.emit("console:info",t.template(o.messages.disconnected,{host:s.name||"localhost"})),e.emit("room:changed",void 0),e.emit("window:title",o.client.title)}).on("connect_error",function(){s.connected=0,e.emit("console:error",o.messages.socket_error),e.emit("console:unlockInput")}))},l=function(t,n){return s?void(s.connected?(m(),d(s,n)):d(s,n)):(n(),e.emit("console:error",o.messages.reconnect_no_host))},m=function(){r.disconnect()},p=function(t){c=Object.assign({},c,t)};e.on("command:host",u),e.on("command:hosts",f),e.on("command:connect",d),e.on("command:disconnect",m),e.on("command:reconnect",l),e.on("socket:emit",a),e.on("host:param",p)}),define("client",["$","castrato","settings","templates"],function(t,e,n,o){var i,r,s=function(t){return t.length>n.key.maxLen?e.emit("console:error",o.messages.key_to_long):t.lengthn.nick.maxLen?e("console:error",t.template(o.messages.nick_to_long,{nick_maxLen:n.nick.maxLen})):r.length=n.room.maxLen?e.emit("console:error",t.template(o.messages.room_name_too_long)):r.lengthn.notifications.maxOnePerMs)if(void 0===i&&(i=!1),u&&"granted"===Notification.permission){var r=new Notification(t,{body:e,icon:o});r.onshow=function(){setTimeout(function(){r.close()},3e3)},c=f()}else i&&g("Attention",1e3)};u=void 0!==window.Notification,t.on("notification:send",function(t){y(t.title,t.body,t.icon,!0)}),t.on("notification:on",function(){d()}),t.on("notification:off",function(){l()}),h(),l(),c=f(),m()}),define("queue",[],function(){var t={},e=[],n=function(){return performance.now()||Date.now()};return t.add_function_delayed=function(t,o,i){e.push({func:o,pushed:n(),delay:t,data:i})},t.get=function(){return e},t.run=function(){for(var o,i,r=0;o=e[r++];)n()-o.pushed>o.delay&&(o.func(),e.splice(r-1,1));if(e.length){for(i=n();n()-i<1;);t.run()}},t}),define("audio",["queue","castrato","templates"],function(t,e,n){var o=!1,i=!0,r=!1,s=function(e,n){if(n=void 0===n?0:n,o&&i&&n0&&i<3600?(e.emit("console:info",t.template(o.messages.torch_is_now,{ttl:i})),n.ttl=1e3*i):e.emit("console:error",t.template(o.messages.torch_not_set))},param:function(t){s=Object.assign({},s,t)},showNotification:function(t,n,o){var r="message"!==t?"Cryptalk":n,s="message"===t?"gfx/icon_128x128.png":"error"===t?"gfx/icon_128x128_error.png":"gfx/icon_128x128_info.png";e.emit("notification:send",{title:r.substring(0,20),body:o.substring(0,80),icon:s}),"message"===t&&e.emit("audio:play",i.message)},motd:function(t){c.post("motd",t)},info:function(t){c.post("info",t)},error:function(t){c.post("error",t)},server:function(t){c.post("server",t)},message:function(t){c.post("message",t.message,t.nick)},clearInput:function(){r.input[0].value=""},clear:function(){r.chat[0].innerHTML=""},lockInput:function(){r.input[0].setAttribute("disabled","disabled"),r.inputWrapper[0].className="loading"},unlockInput:function(){r.input[0].removeAttribute("disabled"),r.inputWrapper[0].className="",r.input.focus()},_require:function(t,e){c.lockInput(),c.post("info","Requiring "+t+"..."),require([t],function(){c.post("info","Successfully required "+t+"."),c.unlockInput(),e()},function(n){c.post("error",'An error occurred while trying to load "'+t+'":\n'+n),c.unlockInput(),e()})}},a=function(n){var i,a,u,f;if(!n.ctrlKey&&!n.altKey&&r.input[0]!==t.activeElement())return r.input.focus();if(13===n.keyCode&&(i=r.input[0].value))if("/"===(i[0]||i.slice(0,1)))a=t.ssplit(i.slice(1)," "),f=a[0],u=a[1],e.emit("command:"+f,u,function(e,n){return n?void c.clearInput():c.post("error",t.template(o.messages.unrecognized_command,{commandName:f}))});else{if(!s.room||!s.key)return s.room?c.post("error",o.messages.msg_no_key):c.post("error",o.messages.msg_no_room);e.emit("socket:emit",{data:"message:send",payload:{room:t.SHA1(s.room),msg:t.AES.encrypt(i,t.SHA1(s.room)+s.key).toString(),nick:!!s.nick&&t.AES.encrypt(s.nick,t.SHA1(s.room)+s.key).toString()}}),c.clearInput()}};t(document).on("keydown",a),r.input.focus();for(var u in c)"_require"!==u&&"post"!==u&&e.on("console:"+u,c[u]);e.on("console:require",c._require),e.on("console:post",function(t){c.post(t.type,t.data,t.nick)})}),define("cryptalk",["castrato","host","client","console"],function(t){t.on("window:focused",function(){t.emit("audio:off"),t.emit("notification:off")}).on("window:blurred",function(){t.emit("audio:on"),t.emit("notification:on")}).on("command:mute",function(){t.emit("audio:mute")}).on("command:unmute",function(){t.emit("audio:unmute")}).on("room:changed",function(e){t.emit("console:param",{room:e}).emit("host:param",{room:e})}).on("nick:changed",function(e){t.emit("console:param",{nick:e})}).on("key:changed",function(e){t.emit("console:param",{key:e}).emit("host:param",{key:e})}).emit("command:connect",void 0,function(){(hash=window.location.hash)&&(parts=hash.slice(1).split(":"),parts[0]&&t.emit("command:join",parts[0]),parts[1]&&t.emit("command:key",parts[1]))})}),require.config({baseUrl:"js/lib/",paths:{websocket:"/socket.io/socket.io"},packages:[{name:"crypto-js",location:"../vendor/crypto-js-3.1.9",main:"index"},{name:"castrato",location:"../vendor/castrato",main:"castrato"}]}),require(["cryptalk"]),define("main",function(){}); \ No newline at end of file diff --git a/public/js/lib/$.js b/public/js/lib/$.js index 6442782..36f1972 100644 --- a/public/js/lib/$.js +++ b/public/js/lib/$.js @@ -1,9 +1,9 @@ define(['$.utils', '$.proto'], function (utils, proto) { // Create a custom edition of Array, extended with $.proto - function ElementArray () {}; + function ElementArray () {} ElementArray.prototype = new Array; - for(var key in proto) ElementArray.prototype[key] = proto[key]; + for(var k in proto) ElementArray.prototype[k] = proto[k]; // Create to actual dollar function function Dollar (selector) { @@ -30,7 +30,7 @@ define(['$.utils', '$.proto'], function (utils, proto) { } // Add utils to Dollar - for(var key in utils) Dollar[key] = utils[key]; + for(var l in utils) Dollar[l] = utils[l]; return Dollar; diff --git a/public/js/lib/$.utils.js b/public/js/lib/$.utils.js index 1cfe1e2..5cfec72 100644 --- a/public/js/lib/$.utils.js +++ b/public/js/lib/$.utils.js @@ -30,7 +30,7 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun }; exports.activeElement = function () { - try { return document.activeElement; } catch (e) {} + try { return document.activeElement; } catch (e) { return; } }; /** @@ -60,7 +60,7 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun }; exports.getJSON = function (path, onSuccess, onError) { - var data, request = new XMLHttpRequest(); + var request = new XMLHttpRequest(); request.open('GET', path, true); request.onreadystatechange = function() { @@ -91,7 +91,7 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun '<': '<', '>': '>', '"': '"', - "'": ''', + '\'': ''', '/': '/' }; diff --git a/public/js/lib/audio.js b/public/js/lib/audio.js index 99e1132..1e7ee60 100644 --- a/public/js/lib/audio.js +++ b/public/js/lib/audio.js @@ -30,11 +30,11 @@ define(['queue','castrato','templates'], function (queue,mediator,templates) { } // Add tones to execution queue - var current_tones = tones[i], - freqs = current_tones[0], - start = current_tones[1], - duration = current_tones[2]; - + var current_tones = tones[i], + freqs = current_tones[0], + start = current_tones[1], + duration = current_tones[2]; + var o = ac.createOscillator(); var g = ac.createGain(); o.frequency.value = freqs; @@ -73,12 +73,12 @@ define(['queue','castrato','templates'], function (queue,mediator,templates) { mediator.emit('console:info',templates.messages.unmuted); }; - // Find audio context + // Find audio context if (window.AudioContext || window.webkitAudioContext) { ac = new (window.AudioContext || window.webkitAudioContext); } - // Connect events + // Connect events mediator.on('audio:play', function(tones) {playTones(tones); } ); mediator.on('audio:on', on ); mediator.on('audio:off', off ); diff --git a/public/js/lib/client.js b/public/js/lib/client.js index cfad668..4aa958d 100644 --- a/public/js/lib/client.js +++ b/public/js/lib/client.js @@ -52,7 +52,7 @@ define(['$','castrato','settings','templates'], function ($, mediator, settings, setTorch = function (payload) { mediator.emit('console:torch',payload); }, - nick = function (payload) { + setNick = function (payload) { // Make sure the nick meets the length requirements if (payload.length > settings.nick.maxLen) { @@ -65,7 +65,7 @@ define(['$','castrato','settings','templates'], function ($, mediator, settings, nick = payload; // Keep other modules informed - mediator.emit('nick:changed',nick); + mediator.emit('nick:changed', nick); // Inform that the nick has been set mediator.emit('console:info', $.template(templates.messages.nick_set, { nick: $.escapeHtml(nick)})); @@ -79,7 +79,7 @@ define(['$','castrato','settings','templates'], function ($, mediator, settings, mediator.on('command:help', help); mediator.on('command:clear', clear); - mediator.on('command:nick', nick); + mediator.on('command:nick', setNick); mediator.on('command:key', setKey); mediator.on('command:torch', setTorch); mediator.on('command:title', title); diff --git a/public/js/lib/console.js b/public/js/lib/console.js index 5b145ad..45661c3 100644 --- a/public/js/lib/console.js +++ b/public/js/lib/console.js @@ -59,7 +59,7 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio }, torch: function (ttl) { - var ttl = parseInt(ttl); + ttl = parseInt(ttl); if( ttl > 0 && ttl < 3600) { mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) ); settings.ttl = ttl*1000; @@ -73,8 +73,8 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio }, showNotification: function (type, nick, text) { - var title = type !== 'message' ? 'Cryptalk' : nick, - icon = type === 'message'? 'gfx/icon_128x128.png' : (type == 'error' ? 'gfx/icon_128x128_error.png' : 'gfx/icon_128x128_info.png'); + var title = (type !== 'message' ? 'Cryptalk' : nick), + icon = (type === 'message' ? 'gfx/icon_128x128.png' : (type === 'error' ? 'gfx/icon_128x128_error.png' : 'gfx/icon_128x128_info.png')); // Emit notification mediator.emit('notification:send', { @@ -148,8 +148,7 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio var buffer, parts, payload, - command, - save; + command; // The Document object is bound to this element. // If the active element is not the input, focus on it and exit the function. diff --git a/public/js/lib/cryptalk.js b/public/js/lib/cryptalk.js index db73be2..5a5ce8d 100644 --- a/public/js/lib/cryptalk.js +++ b/public/js/lib/cryptalk.js @@ -1,5 +1,5 @@ // Main cryptalk module -define(['castrato','host','client','console'], function (mediator, host, client) { +define(['castrato','host','client','console'], function (mediator) { // Route mediator messages mediator diff --git a/public/js/lib/host.js b/public/js/lib/host.js index f819490..5c5796c 100644 --- a/public/js/lib/host.js +++ b/public/js/lib/host.js @@ -10,7 +10,7 @@ Emits: mediator.on('socket:emit', emit); */ -define(['$', 'castrato','settings','templates','hosts','window'], function ($, mediator, settings, templates, hostconfig, window) { +define(['$', 'castrato','settings','templates','hosts','window'], function ($, mediator, settings, templates, hostconfig) { var @@ -26,7 +26,7 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m if(socket) socket.emit(payload.data,payload.payload); }, - host = function () { + hostInfo = function () { mediator.emit('info', JSON.stringify(host || {})); }, @@ -76,10 +76,10 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m mediator.emit('console:lockInput'); var - request, + request; - // Use hostconfig.autoconnect as default host - toHost = (toHost == undefined) ? hostconfig.autoconnect : toHost; + // Use hostconfig.autoconnect as default host + toHost = (toHost === undefined) ? hostconfig.autoconnect : toHost; if (host && host.connected) { mediator.emit('console:error', $.template(templates.messages.already_connected, { @@ -133,7 +133,7 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m // Bind socket events socket - .on('room:joined', function (data) { + .on('room:joined', function () { mediator.emit('console:info', $.template(templates.messages.joined_room, { roomName: $.escapeHtml(parameters.room) } )); @@ -195,8 +195,6 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m .on('disconnect', function () { - room = 0; - key = 0; host.connected = 0; // Tell the user that the chat is ready to interact with @@ -211,8 +209,6 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m .on('connect_error', function () { - room = 0; - key = 0; host.connected = 0; mediator.emit('console:error', templates.messages.socket_error); @@ -245,11 +241,11 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m parameters = Object.assign({}, parameters, p ); }; - mediator.on('command:host', host); + mediator.on('command:host', hostInfo); mediator.on('command:hosts', hosts); mediator.on('command:connect', connect); mediator.on('command:disconnect', disconnect); - mediator.on('command:reconnect', disconnect); + mediator.on('command:reconnect', reconnect); mediator.on('socket:emit', emit); mediator.on('host:param', param); diff --git a/public/js/lib/hosts.js b/public/js/lib/hosts.js index 8b387d6..918101b 100644 --- a/public/js/lib/hosts.js +++ b/public/js/lib/hosts.js @@ -12,9 +12,9 @@ define({ path: '/js/lib/settings.js' }/*, { - name: 'Example', - host: 'http://www.example.com', - path: 'http://www.example.com/js/cryptalk_modules/settings.js' + name: 'Official host - cryptalk.56k.guru', + host: 'https://cryptalk.56k.guru', + path: 'https://cryptalk.56k.guru/js/cryptalk_modules/settings.js' }*/ ] }); diff --git a/public/js/lib/main.js b/public/js/lib/main.js index f6c6c4d..c409f56 100644 --- a/public/js/lib/main.js +++ b/public/js/lib/main.js @@ -1,15 +1,20 @@ require.config({ - baseUrl: "js/lib/", + baseUrl: 'js/lib/', paths: { websocket: '/socket.io/socket.io' }, - packages: [ - { - name: 'crypto-js', - location: '../vendor/crypto-js-3.1.9', - main: 'index' - } - ] + packages: [ + { + name: 'crypto-js', + location: '../vendor/crypto-js-3.1.9', + main: 'index' + }, + { + name: 'castrato', + location: '../vendor/castrato', + main: 'castrato' + } + ] }); require(['cryptalk']); \ No newline at end of file diff --git a/public/js/lib/notifications.js b/public/js/lib/notifications.js index 277305d..d39506d 100644 --- a/public/js/lib/notifications.js +++ b/public/js/lib/notifications.js @@ -45,12 +45,11 @@ define(['castrato','window','settings'], function (mediator, win, settings) { if (original_title !== undefined) win.setTitle(original_title); original_title = undefined; new_title = undefined; - window_active = true; }, doBlink = function() { if(enabled) { - if( win.getTitle() == original_title ) + if( win.getTitle() === original_title ) win.setTitle( new_title ); else win.setTitle( original_title); @@ -70,7 +69,7 @@ define(['castrato','window','settings'], function (mediator, win, settings) { }, blinkTitleUntilFocus = function(t,i) { - interval = (i == undefined) ? 1000 : i; + interval = (i === undefined) ? 1000 : i; if ( enabled && original_title === undefined ) { new_title = t; original_title = win.getTitle(); @@ -86,7 +85,7 @@ define(['castrato','window','settings'], function (mediator, win, settings) { // Set default value for fallback parameter if ( fallback === undefined) fallback = false; - if ( native_supported && Notification.permission === "granted") { + if ( native_supported && Notification.permission === 'granted') { // Create notification var n = new Notification(title, {body: body, icon:icon}); @@ -95,17 +94,17 @@ define(['castrato','window','settings'], function (mediator, win, settings) { n.onshow = function () { // Automatically close the notification after 5000ms setTimeout(function(){n.close();},3000); - } + }; last = now(); } else if ( fallback ) { - blinkTitleUntilFocus("Attention",1000); + blinkTitleUntilFocus('Attention', 1000); } } }; - + native_supported = (window.Notification !== undefined); mediator.on('notification:send',function(data) { notify(data.title,data.body,data.icon,true); }); @@ -113,12 +112,12 @@ define(['castrato','window','settings'], function (mediator, win, settings) { mediator.on('notification:off',function() { off(); }); // Always enable native notifications - enableNative(); + enableNative(); - // Start with notifications disabled - off(); + // Start with notifications disabled + off(); - // If this is undefined, notifications will fail to show + // If this is undefined, notifications will fail to show last = now(); // Make sure we are at square one diff --git a/public/js/lib/queue.js b/public/js/lib/queue.js index 8c560db..fc8918d 100644 --- a/public/js/lib/queue.js +++ b/public/js/lib/queue.js @@ -1,44 +1,45 @@ define(function (){ - var exports = {}, - queue = [], - now = function () { - return performance.now() || Date.now(); - }; + + var exports = {}, + queue = [], + now = function () { + return performance.now() || Date.now(); + }; - exports.add_function_delayed = function(delay, callback, data) { - queue.push({ - func: callback, - pushed: now(), - delay: delay, - data: data - }); - } + exports.add_function_delayed = function(delay, callback, data) { + queue.push({ + func: callback, + pushed: now(), + delay: delay, + data: data + }); + }; - exports.get = function () { - return queue; - } + exports.get = function () { + return queue; + }; - exports.run = function () { - var i = 0, - current, - lrt_inner; + exports.run = function () { + var i = 0, + current, + lrt_inner; - while (current = queue[i++]) { - if (now() - current.pushed > current.delay) { - current.func(); - queue.splice(i - 1, 1); - } - } + while ((current = queue[i++])) { + if (now() - current.pushed > current.delay) { + current.func(); + queue.splice(i - 1, 1); + } + } - if (queue.length) { - // Waste a ms to prevent callstack overflow - lrt_inner = now(); + if (queue.length) { + // Waste a ms to prevent callstack overflow + lrt_inner = now(); - while (now() - lrt_inner < 1) { void 0; }; + while (now() - lrt_inner < 1) { void 0; } - exports.run(); - } - } + exports.run(); + } + }; - return exports; + return exports; }); \ No newline at end of file diff --git a/public/js/lib/settings.js b/public/js/lib/settings.js index 045cbda..73bc882 100644 --- a/public/js/lib/settings.js +++ b/public/js/lib/settings.js @@ -1,6 +1,6 @@ define({ - title: "Cryptalk - Online", + title: 'Cryptalk - Online', ttl: 600000, diff --git a/public/js/lib/window.js b/public/js/lib/window.js index 150f9fb..96761b3 100644 --- a/public/js/lib/window.js +++ b/public/js/lib/window.js @@ -30,12 +30,12 @@ define(['castrato'],function (mediator){ // Keep track of document focus/blur if (window.addEventListener){ // Normal browsers - window.addEventListener("focus", focusCallback, true); - window.addEventListener("blur", blurCallback, true); + window.addEventListener('focus', focusCallback, true); + window.addEventListener('blur', blurCallback, true); } else { // IE - window.observe("focusin", focusCallback); - window.observe("focusout", blurCallback); + window.observe('focusin', focusCallback); + window.observe('focusout', blurCallback); } mediator.on('window:title',exports.setTitle); diff --git a/public/js/lib/castrato.js b/public/js/vendor/castrato/castrato.js similarity index 100% rename from public/js/lib/castrato.js rename to public/js/vendor/castrato/castrato.js diff --git a/public/js/vendor/requirejs-2.3.2/require.js b/public/js/vendor/requirejs-2.3.2/require.js deleted file mode 100644 index 3eaa2a7..0000000 --- a/public/js/vendor/requirejs-2.3.2/require.js +++ /dev/null @@ -1,5 +0,0 @@ -/** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.3.2 Copyright jQuery Foundation and other contributors. - * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE - */ -var requirejs,require,define;!function(global,setTimeout){function commentReplace(e,t){return t||""}function isFunction(e){return"[object Function]"===ostring.call(e)}function isArray(e){return"[object Array]"===ostring.call(e)}function each(e,t){if(e){var i;for(i=0;i-1&&(!e[i]||!t(e[i],i,e));i-=1);}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var i;for(i in e)if(hasProp(e,i)&&t(e[i],i))break}function mixin(e,t,i,r){return t&&eachProp(t,function(t,n){!i&&hasProp(e,n)||(!r||"object"!=typeof t||!t||isArray(t)||isFunction(t)||t instanceof RegExp?e[n]=t:(e[n]||(e[n]={}),mixin(e[n],t,i,r)))}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,i,r){var n=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return n.requireType=e,n.requireModules=r,i&&(n.originalError=i),n}function newContext(e){function t(e){var t,i;for(t=0;t0&&(e.splice(t-1,2),t-=2)}}function i(e,i,r){var n,o,a,s,u,c,d,p,f,l,h,m,g=i&&i.split("/"),v=y.map,x=v&&v["*"];if(e&&(e=e.split("/"),d=e.length-1,y.nodeIdCompat&&jsSuffixRegExp.test(e[d])&&(e[d]=e[d].replace(jsSuffixRegExp,"")),"."===e[0].charAt(0)&&g&&(m=g.slice(0,g.length-1),e=m.concat(e)),t(e),e=e.join("/")),r&&v&&(g||x)){a=e.split("/");e:for(s=a.length;s>0;s-=1){if(c=a.slice(0,s).join("/"),g)for(u=g.length;u>0;u-=1)if(o=getOwn(v,g.slice(0,u).join("/")),o&&(o=getOwn(o,c))){p=o,f=s;break e}!l&&x&&getOwn(x,c)&&(l=getOwn(x,c),h=s)}!p&&l&&(p=l,f=h),p&&(a.splice(0,f,p),e=a.join("/"))}return n=getOwn(y.pkgs,e),n?n:e}function r(e){isBrowser&&each(scripts(),function(t){if(t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===q.contextName)return t.parentNode.removeChild(t),!0})}function n(e){var t=getOwn(y.paths,e);if(t&&isArray(t)&&t.length>1)return t.shift(),q.require.undef(e),q.makeRequire(null,{skipMap:!0})([e]),!0}function o(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function a(e,t,r,n){var a,s,u,c,d=null,p=t?t.name:null,f=e,l=!0,h="";return e||(l=!1,e="_@r"+(T+=1)),c=o(e),d=c[0],e=c[1],d&&(d=i(d,p,n),s=getOwn(j,d)),e&&(d?h=s&&s.normalize?s.normalize(e,function(e){return i(e,p,n)}):e.indexOf("!")===-1?i(e,p,n):e:(h=i(e,p,n),c=o(h),d=c[0],h=c[1],r=!0,a=q.nameToUrl(h))),u=!d||s||r?"":"_unnormalized"+(A+=1),{prefix:d,name:h,parentMap:t,unnormalized:!!u,url:a,originalName:f,isDefine:l,id:(d?d+"!"+h:h)+u}}function s(e){var t=e.id,i=getOwn(S,t);return i||(i=S[t]=new q.Module(e)),i}function u(e,t,i){var r=e.id,n=getOwn(S,r);!hasProp(j,r)||n&&!n.defineEmitComplete?(n=s(e),n.error&&"error"===t?i(n.error):n.on(t,i)):"defined"===t&&i(j[r])}function c(e,t){var i=e.requireModules,r=!1;t?t(e):(each(i,function(t){var i=getOwn(S,t);i&&(i.error=e,i.events.error&&(r=!0,i.emit("error",e)))}),r||req.onError(e))}function d(){globalDefQueue.length&&(each(globalDefQueue,function(e){var t=e[0];"string"==typeof t&&(q.defQueueMap[t]=!0),O.push(e)}),globalDefQueue=[])}function p(e){delete S[e],delete k[e]}function f(e,t,i){var r=e.map.id;e.error?e.emit("error",e.error):(t[r]=!0,each(e.depMaps,function(r,n){var o=r.id,a=getOwn(S,o);!a||e.depMatched[n]||i[o]||(getOwn(t,o)?(e.defineDep(n,j[o]),e.check()):f(a,t,i))}),i[r]=!0)}function l(){var e,t,i=1e3*y.waitSeconds,o=i&&q.startTime+i<(new Date).getTime(),a=[],s=[],u=!1,d=!0;if(!x){if(x=!0,eachProp(k,function(e){var i=e.map,c=i.id;if(e.enabled&&(i.isDefine||s.push(e),!e.error))if(!e.inited&&o)n(c)?(t=!0,u=!0):(a.push(c),r(c));else if(!e.inited&&e.fetched&&i.isDefine&&(u=!0,!i.prefix))return d=!1}),o&&a.length)return e=makeError("timeout","Load timeout for modules: "+a,null,a),e.contextName=q.contextName,c(e);d&&each(s,function(e){f(e,{},{})}),o&&!t||!u||!isBrowser&&!isWebWorker||w||(w=setTimeout(function(){w=0,l()},50)),x=!1}}function h(e){hasProp(j,e[0])||s(a(e[0],null,!0)).init(e[1],e[2])}function m(e,t,i,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(i,t,!1)}function g(e){var t=e.currentTarget||e.srcElement;return m(t,q.onScriptLoad,"load","onreadystatechange"),m(t,q.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function v(){var e;for(d();O.length;){if(e=O.shift(),null===e[0])return c(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));h(e)}q.defQueueMap={}}var x,b,q,E,w,y={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},S={},k={},M={},O=[],j={},P={},R={},T=1,A=1;return E={require:function(e){return e.require?e.require:e.require=q.makeRequire(e.map)},exports:function(e){if(e.usingExports=!0,e.map.isDefine)return e.exports?j[e.map.id]=e.exports:e.exports=j[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return getOwn(y.config,e.map.id)||{}},exports:e.exports||(e.exports={})}}},b=function(e){this.events=getOwn(M,e.id)||{},this.map=e,this.shim=getOwn(y.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},b.prototype={init:function(e,t,i,r){r=r||{},this.inited||(this.factory=t,i?this.on("error",i):this.events.error&&(i=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=i,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check())},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(!this.fetched){this.fetched=!0,q.startTime=(new Date).getTime();var e=this.map;return this.shim?void q.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()})):e.prefix?this.callPlugin():this.load()}},load:function(){var e=this.map.url;P[e]||(P[e]=!0,q.load(this.map.id,e))},check:function(){if(this.enabled&&!this.enabling){var e,t,i=this.map.id,r=this.depExports,n=this.exports,o=this.factory;if(this.inited){if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,this.depCount<1&&!this.defined){if(isFunction(o)){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)try{n=q.execCb(i,o,r,n)}catch(t){e=t}else n=q.execCb(i,o,r,n);if(this.map.isDefine&&void 0===n&&(t=this.module,t?n=t.exports:this.usingExports&&(n=this.exports)),e)return e.requireMap=this.map,e.requireModules=this.map.isDefine?[this.map.id]:null,e.requireType=this.map.isDefine?"define":"require",c(this.error=e)}else n=o;if(this.exports=n,this.map.isDefine&&!this.ignore&&(j[i]=n,req.onResourceLoad)){var a=[];each(this.depMaps,function(e){a.push(e.normalizedMap||e)}),req.onResourceLoad(q,this.map,a)}p(i),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else hasProp(q.defQueueMap,i)||this.fetch()}},callPlugin:function(){var e=this.map,t=e.id,r=a(e.prefix);this.depMaps.push(r),u(r,"defined",bind(this,function(r){var n,o,d,f=getOwn(R,this.map.id),l=this.map.name,h=this.map.parentMap?this.map.parentMap.name:null,m=q.makeRequire(e.parentMap,{enableBuildCallback:!0});return this.map.unnormalized?(r.normalize&&(l=r.normalize(l,function(e){return i(e,h,!0)})||""),o=a(e.prefix+"!"+l,this.map.parentMap),u(o,"defined",bind(this,function(e){this.map.normalizedMap=o,this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),d=getOwn(S,o.id),void(d&&(this.depMaps.push(o),this.events.error&&d.on("error",bind(this,function(e){this.emit("error",e)})),d.enable()))):f?(this.map.url=q.nameToUrl(f),void this.load()):(n=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})}),n.error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(S,function(e){0===e.map.id.indexOf(t+"_unnormalized")&&p(e.map.id)}),c(e)}),n.fromText=bind(this,function(i,r){var o=e.name,u=a(o),d=useInteractive;r&&(i=r),d&&(useInteractive=!1),s(u),hasProp(y.config,t)&&(y.config[o]=y.config[t]);try{req.exec(i)}catch(e){return c(makeError("fromtexteval","fromText eval for "+t+" failed: "+e,e,[t]))}d&&(useInteractive=!0),this.depMaps.push(u),q.completeLoad(o),m([o],n)}),void r.load(e.name,m,n,y))})),q.enable(r,this),this.pluginMaps[r.id]=r},enable:function(){k[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var i,r,n;if("string"==typeof e){if(e=a(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,n=getOwn(E,e.id))return void(this.depExports[t]=n(this));this.depCount+=1,u(e,"defined",bind(this,function(e){this.undefed||(this.defineDep(t,e),this.check())})),this.errback?u(e,"error",bind(this,this.errback)):this.events.error&&u(e,"error",bind(this,function(e){this.emit("error",e)}))}i=e.id,r=S[i],hasProp(E,i)||!r||r.enabled||q.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(S,e.id);t&&!t.enabled&&q.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var i=this.events[e];i||(i=this.events[e]=[]),i.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),"error"===e&&delete this.events[e]}},q={config:y,contextName:e,registry:S,defined:j,urlFetched:P,defQueue:O,defQueueMap:{},Module:b,makeModuleMap:a,nextTick:req.nextTick,onError:c,configure:function(e){if(e.baseUrl&&"/"!==e.baseUrl.charAt(e.baseUrl.length-1)&&(e.baseUrl+="/"),"string"==typeof e.urlArgs){var t=e.urlArgs;e.urlArgs=function(e,i){return(i.indexOf("?")===-1?"?":"&")+t}}var i=y.shim,r={paths:!0,bundles:!0,config:!0,map:!0};eachProp(e,function(e,t){r[t]?(y[t]||(y[t]={}),mixin(y[t],e,!0,!0)):y[t]=e}),e.bundles&&eachProp(e.bundles,function(e,t){each(e,function(e){e!==t&&(R[e]=t)})}),e.shim&&(eachProp(e.shim,function(e,t){isArray(e)&&(e={deps:e}),!e.exports&&!e.init||e.exportsFn||(e.exportsFn=q.makeShimExports(e)),i[t]=e}),y.shim=i),e.packages&&each(e.packages,function(e){var t,i;e="string"==typeof e?{name:e}:e,i=e.name,t=e.location,t&&(y.paths[i]=e.location),y.pkgs[i]=e.name+"/"+(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(S,function(e,t){e.inited||e.map.unnormalized||(e.map=a(t,null,!0))}),(e.deps||e.callback)&&q.require(e.deps||[],e.callback)},makeShimExports:function(e){function t(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}return t},makeRequire:function(t,n){function o(i,r,u){var d,p,f;return n.enableBuildCallback&&r&&isFunction(r)&&(r.__requireJsBuild=!0),"string"==typeof i?isFunction(r)?c(makeError("requireargs","Invalid require call"),u):t&&hasProp(E,i)?E[i](S[t.id]):req.get?req.get(q,i,t,o):(p=a(i,t,!1,!0),d=p.id,hasProp(j,d)?j[d]:c(makeError("notloaded",'Module name "'+d+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(v(),q.nextTick(function(){v(),f=s(a(null,t)),f.skipMap=n.skipMap,f.init(i,r,u,{enabled:!0}),l()}),o)}return n=n||{},mixin(o,{isBrowser:isBrowser,toUrl:function(e){var r,n=e.lastIndexOf("."),o=e.split("/")[0],a="."===o||".."===o;return n!==-1&&(!a||n>1)&&(r=e.substring(n,e.length),e=e.substring(0,n)),q.nameToUrl(i(e,t&&t.id,!0),r,!0)},defined:function(e){return hasProp(j,a(e,t,!1,!0).id)},specified:function(e){return e=a(e,t,!1,!0).id,hasProp(j,e)||hasProp(S,e)}}),t||(o.undef=function(e){d();var i=a(e,t,!0),n=getOwn(S,e);n.undefed=!0,r(e),delete j[e],delete P[i.url],delete M[e],eachReverse(O,function(t,i){t[0]===e&&O.splice(i,1)}),delete q.defQueueMap[e],n&&(n.events.defined&&(M[e]=n.events),p(e))}),o},enable:function(e){var t=getOwn(S,e.id);t&&s(e).enable()},completeLoad:function(e){var t,i,r,o=getOwn(y.shim,e)||{},a=o.exports;for(d();O.length;){if(i=O.shift(),null===i[0]){if(i[0]=e,t)break;t=!0}else i[0]===e&&(t=!0);h(i)}if(q.defQueueMap={},r=getOwn(S,e),!t&&!hasProp(j,e)&&r&&!r.inited){if(!(!y.enforceDefine||a&&getGlobal(a)))return n(e)?void 0:c(makeError("nodefine","No define call for "+e,null,[e]));h([e,o.deps||[],o.exportsFn])}l()},nameToUrl:function(e,t,i){var r,n,o,a,s,u,c,d=getOwn(y.pkgs,e);if(d&&(e=d),c=getOwn(R,e))return q.nameToUrl(c,t,i);if(req.jsExtRegExp.test(e))s=e+(t||"");else{for(r=y.paths,n=e.split("/"),o=n.length;o>0;o-=1)if(a=n.slice(0,o).join("/"),u=getOwn(r,a)){isArray(u)&&(u=u[0]),n.splice(0,o,u);break}s=n.join("/"),s+=t||(/^data\:|^blob\:|\?/.test(s)||i?"":".js"),s=("/"===s.charAt(0)||s.match(/^[\w\+\.\-]+:/)?"":y.baseUrl)+s}return y.urlArgs&&!/^blob\:/.test(s)?s+y.urlArgs(e,s):s},load:function(e,t){req.load(q,e,t)},execCb:function(e,t,i,r){return t.apply(r,i)},onScriptLoad:function(e){if("load"===e.type||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=g(e);q.completeLoad(t.id)}},onScriptError:function(e){var t=g(e);if(!n(t.id)){var i=[];return eachProp(S,function(e,r){0!==r.indexOf("_@r")&&each(e.depMaps,function(e){if(e.id===t.id)return i.push(r),!0})}),c(makeError("scripterror",'Script error for "'+t.id+(i.length?'", needed by: '+i.join(", "):'"'),e,[t.id]))}}},q.require=q.makeRequire(),q}function getInteractiveScript(){return interactiveScript&&"interactive"===interactiveScript.readyState?interactiveScript:(eachReverse(scripts(),function(e){if("interactive"===e.readyState)return interactiveScript=e}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.3.2",commentRegExp=/\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/gm,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,isBrowser=!("undefined"==typeof window||"undefined"==typeof navigator||!window.document),isWebWorker=!isBrowser&&"undefined"!=typeof importScripts,readyRegExp=isBrowser&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if("undefined"==typeof define){if("undefined"!=typeof requirejs){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}"undefined"==typeof require||isFunction(require)||(cfg=require,require=void 0),req=requirejs=function(e,t,i,r){var n,o,a=defContextName;return isArray(e)||"string"==typeof e||(o=e,isArray(t)?(e=t,t=i,i=r):e=[]),o&&o.context&&(a=o.context),n=getOwn(contexts,a),n||(n=contexts[a]=req.s.newContext(a)),o&&n.configure(o),n.require(e,t,i)},req.config=function(e){return req(e)},req.nextTick="undefined"!=typeof setTimeout?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,i){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,i){var r,n=e&&e.config||{};if(isBrowser)return r=req.createNode(n,t,i),r.setAttribute("data-requirecontext",e.contextName),r.setAttribute("data-requiremodule",t),!r.attachEvent||r.attachEvent.toString&&r.attachEvent.toString().indexOf("[native code")<0||isOpera?(r.addEventListener("load",e.onScriptLoad,!1),r.addEventListener("error",e.onScriptError,!1)):(useInteractive=!0,r.attachEvent("onreadystatechange",e.onScriptLoad)),r.src=i,n.onNodeCreated&&n.onNodeCreated(r,n,t,i),currentlyAddingScript=r,baseElement?head.insertBefore(r,baseElement):head.appendChild(r),currentlyAddingScript=null,r;if(isWebWorker)try{setTimeout(function(){},0),importScripts(i),e.completeLoad(t)}catch(r){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+i,r,[t]))}},isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){if(head||(head=e.parentNode),dataMain=e.getAttribute("data-main"))return mainScript=dataMain,cfg.baseUrl||mainScript.indexOf("!")!==-1||(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,i){var r,n;"string"!=typeof e&&(i=t,t=e,e=null),isArray(t)||(i=t,t=null),!t&&isFunction(i)&&(t=[],i.length&&(i.toString().replace(commentRegExp,commentReplace).replace(cjsRequireRegExp,function(e,i){t.push(i)}),t=(1===i.length?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),n=contexts[r.getAttribute("data-requirecontext")])),n?(n.defQueue.push([e,t,i]),n.defQueueMap[e]=!0):globalDefQueue.push([e,t,i])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)}}(this,"undefined"==typeof setTimeout?void 0:setTimeout); \ No newline at end of file diff --git a/public/js/vendor/requirejs-2.3.3/require.js b/public/js/vendor/requirejs-2.3.3/require.js new file mode 100644 index 0000000..c32e6c1 --- /dev/null +++ b/public/js/vendor/requirejs-2.3.3/require.js @@ -0,0 +1,5 @@ +/** vim: et:ts=4:sw=4:sts=4 + * @license RequireJS 2.3.3 Copyright jQuery Foundation and other contributors. + * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE + */ +var requirejs,require,define;!function(global,setTimeout){function commentReplace(e,t){return t||""}function isFunction(e){return"[object Function]"===ostring.call(e)}function isArray(e){return"[object Array]"===ostring.call(e)}function each(e,t){if(e){var i;for(i=0;i-1&&(!e[i]||!t(e[i],i,e));i-=1);}}function hasProp(e,t){return hasOwn.call(e,t)}function getOwn(e,t){return hasProp(e,t)&&e[t]}function eachProp(e,t){var i;for(i in e)if(hasProp(e,i)&&t(e[i],i))break}function mixin(e,t,i,r){return t&&eachProp(t,function(t,n){!i&&hasProp(e,n)||(!r||"object"!=typeof t||!t||isArray(t)||isFunction(t)||t instanceof RegExp?e[n]=t:(e[n]||(e[n]={}),mixin(e[n],t,i,r)))}),e}function bind(e,t){return function(){return t.apply(e,arguments)}}function scripts(){return document.getElementsByTagName("script")}function defaultOnError(e){throw e}function getGlobal(e){if(!e)return e;var t=global;return each(e.split("."),function(e){t=t[e]}),t}function makeError(e,t,i,r){var n=new Error(t+"\nhttp://requirejs.org/docs/errors.html#"+e);return n.requireType=e,n.requireModules=r,i&&(n.originalError=i),n}function newContext(e){function t(e){var t,i;for(t=0;t0&&(e.splice(t-1,2),t-=2)}}function i(e,i,r){var n,o,a,s,u,c,d,p,f,l,h,m,g=i&&i.split("/"),v=y.map,x=v&&v["*"];if(e&&(e=e.split("/"),d=e.length-1,y.nodeIdCompat&&jsSuffixRegExp.test(e[d])&&(e[d]=e[d].replace(jsSuffixRegExp,"")),"."===e[0].charAt(0)&&g&&(m=g.slice(0,g.length-1),e=m.concat(e)),t(e),e=e.join("/")),r&&v&&(g||x)){a=e.split("/");e:for(s=a.length;s>0;s-=1){if(c=a.slice(0,s).join("/"),g)for(u=g.length;u>0;u-=1)if(o=getOwn(v,g.slice(0,u).join("/")),o&&(o=getOwn(o,c))){p=o,f=s;break e}!l&&x&&getOwn(x,c)&&(l=getOwn(x,c),h=s)}!p&&l&&(p=l,f=h),p&&(a.splice(0,f,p),e=a.join("/"))}return n=getOwn(y.pkgs,e),n?n:e}function r(e){isBrowser&&each(scripts(),function(t){if(t.getAttribute("data-requiremodule")===e&&t.getAttribute("data-requirecontext")===q.contextName)return t.parentNode.removeChild(t),!0})}function n(e){var t=getOwn(y.paths,e);if(t&&isArray(t)&&t.length>1)return t.shift(),q.require.undef(e),q.makeRequire(null,{skipMap:!0})([e]),!0}function o(e){var t,i=e?e.indexOf("!"):-1;return i>-1&&(t=e.substring(0,i),e=e.substring(i+1,e.length)),[t,e]}function a(e,t,r,n){var a,s,u,c,d=null,p=t?t.name:null,f=e,l=!0,h="";return e||(l=!1,e="_@r"+(T+=1)),c=o(e),d=c[0],e=c[1],d&&(d=i(d,p,n),s=getOwn(j,d)),e&&(d?h=r?e:s&&s.normalize?s.normalize(e,function(e){return i(e,p,n)}):e.indexOf("!")===-1?i(e,p,n):e:(h=i(e,p,n),c=o(h),d=c[0],h=c[1],r=!0,a=q.nameToUrl(h))),u=!d||s||r?"":"_unnormalized"+(A+=1),{prefix:d,name:h,parentMap:t,unnormalized:!!u,url:a,originalName:f,isDefine:l,id:(d?d+"!"+h:h)+u}}function s(e){var t=e.id,i=getOwn(S,t);return i||(i=S[t]=new q.Module(e)),i}function u(e,t,i){var r=e.id,n=getOwn(S,r);!hasProp(j,r)||n&&!n.defineEmitComplete?(n=s(e),n.error&&"error"===t?i(n.error):n.on(t,i)):"defined"===t&&i(j[r])}function c(e,t){var i=e.requireModules,r=!1;t?t(e):(each(i,function(t){var i=getOwn(S,t);i&&(i.error=e,i.events.error&&(r=!0,i.emit("error",e)))}),r||req.onError(e))}function d(){globalDefQueue.length&&(each(globalDefQueue,function(e){var t=e[0];"string"==typeof t&&(q.defQueueMap[t]=!0),O.push(e)}),globalDefQueue=[])}function p(e){delete S[e],delete k[e]}function f(e,t,i){var r=e.map.id;e.error?e.emit("error",e.error):(t[r]=!0,each(e.depMaps,function(r,n){var o=r.id,a=getOwn(S,o);!a||e.depMatched[n]||i[o]||(getOwn(t,o)?(e.defineDep(n,j[o]),e.check()):f(a,t,i))}),i[r]=!0)}function l(){var e,t,i=1e3*y.waitSeconds,o=i&&q.startTime+i<(new Date).getTime(),a=[],s=[],u=!1,d=!0;if(!x){if(x=!0,eachProp(k,function(e){var i=e.map,c=i.id;if(e.enabled&&(i.isDefine||s.push(e),!e.error))if(!e.inited&&o)n(c)?(t=!0,u=!0):(a.push(c),r(c));else if(!e.inited&&e.fetched&&i.isDefine&&(u=!0,!i.prefix))return d=!1}),o&&a.length)return e=makeError("timeout","Load timeout for modules: "+a,null,a),e.contextName=q.contextName,c(e);d&&each(s,function(e){f(e,{},{})}),o&&!t||!u||!isBrowser&&!isWebWorker||w||(w=setTimeout(function(){w=0,l()},50)),x=!1}}function h(e){hasProp(j,e[0])||s(a(e[0],null,!0)).init(e[1],e[2])}function m(e,t,i,r){e.detachEvent&&!isOpera?r&&e.detachEvent(r,t):e.removeEventListener(i,t,!1)}function g(e){var t=e.currentTarget||e.srcElement;return m(t,q.onScriptLoad,"load","onreadystatechange"),m(t,q.onScriptError,"error"),{node:t,id:t&&t.getAttribute("data-requiremodule")}}function v(){var e;for(d();O.length;){if(e=O.shift(),null===e[0])return c(makeError("mismatch","Mismatched anonymous define() module: "+e[e.length-1]));h(e)}q.defQueueMap={}}var x,b,q,E,w,y={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},S={},k={},M={},O=[],j={},P={},R={},T=1,A=1;return E={require:function(e){return e.require?e.require:e.require=q.makeRequire(e.map)},exports:function(e){if(e.usingExports=!0,e.map.isDefine)return e.exports?j[e.map.id]=e.exports:e.exports=j[e.map.id]={}},module:function(e){return e.module?e.module:e.module={id:e.map.id,uri:e.map.url,config:function(){return getOwn(y.config,e.map.id)||{}},exports:e.exports||(e.exports={})}}},b=function(e){this.events=getOwn(M,e.id)||{},this.map=e,this.shim=getOwn(y.shim,e.id),this.depExports=[],this.depMaps=[],this.depMatched=[],this.pluginMaps={},this.depCount=0},b.prototype={init:function(e,t,i,r){r=r||{},this.inited||(this.factory=t,i?this.on("error",i):this.events.error&&(i=bind(this,function(e){this.emit("error",e)})),this.depMaps=e&&e.slice(0),this.errback=i,this.inited=!0,this.ignore=r.ignore,r.enabled||this.enabled?this.enable():this.check())},defineDep:function(e,t){this.depMatched[e]||(this.depMatched[e]=!0,this.depCount-=1,this.depExports[e]=t)},fetch:function(){if(!this.fetched){this.fetched=!0,q.startTime=(new Date).getTime();var e=this.map;return this.shim?void q.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],bind(this,function(){return e.prefix?this.callPlugin():this.load()})):e.prefix?this.callPlugin():this.load()}},load:function(){var e=this.map.url;P[e]||(P[e]=!0,q.load(this.map.id,e))},check:function(){if(this.enabled&&!this.enabling){var e,t,i=this.map.id,r=this.depExports,n=this.exports,o=this.factory;if(this.inited){if(this.error)this.emit("error",this.error);else if(!this.defining){if(this.defining=!0,this.depCount<1&&!this.defined){if(isFunction(o)){if(this.events.error&&this.map.isDefine||req.onError!==defaultOnError)try{n=q.execCb(i,o,r,n)}catch(t){e=t}else n=q.execCb(i,o,r,n);if(this.map.isDefine&&void 0===n&&(t=this.module,t?n=t.exports:this.usingExports&&(n=this.exports)),e)return e.requireMap=this.map,e.requireModules=this.map.isDefine?[this.map.id]:null,e.requireType=this.map.isDefine?"define":"require",c(this.error=e)}else n=o;if(this.exports=n,this.map.isDefine&&!this.ignore&&(j[i]=n,req.onResourceLoad)){var a=[];each(this.depMaps,function(e){a.push(e.normalizedMap||e)}),req.onResourceLoad(q,this.map,a)}p(i),this.defined=!0}this.defining=!1,this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else hasProp(q.defQueueMap,i)||this.fetch()}},callPlugin:function(){var e=this.map,t=e.id,r=a(e.prefix);this.depMaps.push(r),u(r,"defined",bind(this,function(r){var n,o,d,f=getOwn(R,this.map.id),l=this.map.name,h=this.map.parentMap?this.map.parentMap.name:null,m=q.makeRequire(e.parentMap,{enableBuildCallback:!0});return this.map.unnormalized?(r.normalize&&(l=r.normalize(l,function(e){return i(e,h,!0)})||""),o=a(e.prefix+"!"+l,this.map.parentMap,!0),u(o,"defined",bind(this,function(e){this.map.normalizedMap=o,this.init([],function(){return e},null,{enabled:!0,ignore:!0})})),d=getOwn(S,o.id),void(d&&(this.depMaps.push(o),this.events.error&&d.on("error",bind(this,function(e){this.emit("error",e)})),d.enable()))):f?(this.map.url=q.nameToUrl(f),void this.load()):(n=bind(this,function(e){this.init([],function(){return e},null,{enabled:!0})}),n.error=bind(this,function(e){this.inited=!0,this.error=e,e.requireModules=[t],eachProp(S,function(e){0===e.map.id.indexOf(t+"_unnormalized")&&p(e.map.id)}),c(e)}),n.fromText=bind(this,function(i,r){var o=e.name,u=a(o),d=useInteractive;r&&(i=r),d&&(useInteractive=!1),s(u),hasProp(y.config,t)&&(y.config[o]=y.config[t]);try{req.exec(i)}catch(e){return c(makeError("fromtexteval","fromText eval for "+t+" failed: "+e,e,[t]))}d&&(useInteractive=!0),this.depMaps.push(u),q.completeLoad(o),m([o],n)}),void r.load(e.name,m,n,y))})),q.enable(r,this),this.pluginMaps[r.id]=r},enable:function(){k[this.map.id]=this,this.enabled=!0,this.enabling=!0,each(this.depMaps,bind(this,function(e,t){var i,r,n;if("string"==typeof e){if(e=a(e,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap),this.depMaps[t]=e,n=getOwn(E,e.id))return void(this.depExports[t]=n(this));this.depCount+=1,u(e,"defined",bind(this,function(e){this.undefed||(this.defineDep(t,e),this.check())})),this.errback?u(e,"error",bind(this,this.errback)):this.events.error&&u(e,"error",bind(this,function(e){this.emit("error",e)}))}i=e.id,r=S[i],hasProp(E,i)||!r||r.enabled||q.enable(e,this)})),eachProp(this.pluginMaps,bind(this,function(e){var t=getOwn(S,e.id);t&&!t.enabled&&q.enable(e,this)})),this.enabling=!1,this.check()},on:function(e,t){var i=this.events[e];i||(i=this.events[e]=[]),i.push(t)},emit:function(e,t){each(this.events[e],function(e){e(t)}),"error"===e&&delete this.events[e]}},q={config:y,contextName:e,registry:S,defined:j,urlFetched:P,defQueue:O,defQueueMap:{},Module:b,makeModuleMap:a,nextTick:req.nextTick,onError:c,configure:function(e){if(e.baseUrl&&"/"!==e.baseUrl.charAt(e.baseUrl.length-1)&&(e.baseUrl+="/"),"string"==typeof e.urlArgs){var t=e.urlArgs;e.urlArgs=function(e,i){return(i.indexOf("?")===-1?"?":"&")+t}}var i=y.shim,r={paths:!0,bundles:!0,config:!0,map:!0};eachProp(e,function(e,t){r[t]?(y[t]||(y[t]={}),mixin(y[t],e,!0,!0)):y[t]=e}),e.bundles&&eachProp(e.bundles,function(e,t){each(e,function(e){e!==t&&(R[e]=t)})}),e.shim&&(eachProp(e.shim,function(e,t){isArray(e)&&(e={deps:e}),!e.exports&&!e.init||e.exportsFn||(e.exportsFn=q.makeShimExports(e)),i[t]=e}),y.shim=i),e.packages&&each(e.packages,function(e){var t,i;e="string"==typeof e?{name:e}:e,i=e.name,t=e.location,t&&(y.paths[i]=e.location),y.pkgs[i]=e.name+"/"+(e.main||"main").replace(currDirRegExp,"").replace(jsSuffixRegExp,"")}),eachProp(S,function(e,t){e.inited||e.map.unnormalized||(e.map=a(t,null,!0))}),(e.deps||e.callback)&&q.require(e.deps||[],e.callback)},makeShimExports:function(e){function t(){var t;return e.init&&(t=e.init.apply(global,arguments)),t||e.exports&&getGlobal(e.exports)}return t},makeRequire:function(t,n){function o(i,r,u){var d,p,f;return n.enableBuildCallback&&r&&isFunction(r)&&(r.__requireJsBuild=!0),"string"==typeof i?isFunction(r)?c(makeError("requireargs","Invalid require call"),u):t&&hasProp(E,i)?E[i](S[t.id]):req.get?req.get(q,i,t,o):(p=a(i,t,!1,!0),d=p.id,hasProp(j,d)?j[d]:c(makeError("notloaded",'Module name "'+d+'" has not been loaded yet for context: '+e+(t?"":". Use require([])")))):(v(),q.nextTick(function(){v(),f=s(a(null,t)),f.skipMap=n.skipMap,f.init(i,r,u,{enabled:!0}),l()}),o)}return n=n||{},mixin(o,{isBrowser:isBrowser,toUrl:function(e){var r,n=e.lastIndexOf("."),o=e.split("/")[0],a="."===o||".."===o;return n!==-1&&(!a||n>1)&&(r=e.substring(n,e.length),e=e.substring(0,n)),q.nameToUrl(i(e,t&&t.id,!0),r,!0)},defined:function(e){return hasProp(j,a(e,t,!1,!0).id)},specified:function(e){return e=a(e,t,!1,!0).id,hasProp(j,e)||hasProp(S,e)}}),t||(o.undef=function(e){d();var i=a(e,t,!0),n=getOwn(S,e);n.undefed=!0,r(e),delete j[e],delete P[i.url],delete M[e],eachReverse(O,function(t,i){t[0]===e&&O.splice(i,1)}),delete q.defQueueMap[e],n&&(n.events.defined&&(M[e]=n.events),p(e))}),o},enable:function(e){var t=getOwn(S,e.id);t&&s(e).enable()},completeLoad:function(e){var t,i,r,o=getOwn(y.shim,e)||{},a=o.exports;for(d();O.length;){if(i=O.shift(),null===i[0]){if(i[0]=e,t)break;t=!0}else i[0]===e&&(t=!0);h(i)}if(q.defQueueMap={},r=getOwn(S,e),!t&&!hasProp(j,e)&&r&&!r.inited){if(!(!y.enforceDefine||a&&getGlobal(a)))return n(e)?void 0:c(makeError("nodefine","No define call for "+e,null,[e]));h([e,o.deps||[],o.exportsFn])}l()},nameToUrl:function(e,t,i){var r,n,o,a,s,u,c,d=getOwn(y.pkgs,e);if(d&&(e=d),c=getOwn(R,e))return q.nameToUrl(c,t,i);if(req.jsExtRegExp.test(e))s=e+(t||"");else{for(r=y.paths,n=e.split("/"),o=n.length;o>0;o-=1)if(a=n.slice(0,o).join("/"),u=getOwn(r,a)){isArray(u)&&(u=u[0]),n.splice(0,o,u);break}s=n.join("/"),s+=t||(/^data\:|^blob\:|\?/.test(s)||i?"":".js"),s=("/"===s.charAt(0)||s.match(/^[\w\+\.\-]+:/)?"":y.baseUrl)+s}return y.urlArgs&&!/^blob\:/.test(s)?s+y.urlArgs(e,s):s},load:function(e,t){req.load(q,e,t)},execCb:function(e,t,i,r){return t.apply(r,i)},onScriptLoad:function(e){if("load"===e.type||readyRegExp.test((e.currentTarget||e.srcElement).readyState)){interactiveScript=null;var t=g(e);q.completeLoad(t.id)}},onScriptError:function(e){var t=g(e);if(!n(t.id)){var i=[];return eachProp(S,function(e,r){0!==r.indexOf("_@r")&&each(e.depMaps,function(e){if(e.id===t.id)return i.push(r),!0})}),c(makeError("scripterror",'Script error for "'+t.id+(i.length?'", needed by: '+i.join(", "):'"'),e,[t.id]))}}},q.require=q.makeRequire(),q}function getInteractiveScript(){return interactiveScript&&"interactive"===interactiveScript.readyState?interactiveScript:(eachReverse(scripts(),function(e){if("interactive"===e.readyState)return interactiveScript=e}),interactiveScript)}var req,s,head,baseElement,dataMain,src,interactiveScript,currentlyAddingScript,mainScript,subPath,version="2.3.3",commentRegExp=/\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/gm,cjsRequireRegExp=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,jsSuffixRegExp=/\.js$/,currDirRegExp=/^\.\//,op=Object.prototype,ostring=op.toString,hasOwn=op.hasOwnProperty,isBrowser=!("undefined"==typeof window||"undefined"==typeof navigator||!window.document),isWebWorker=!isBrowser&&"undefined"!=typeof importScripts,readyRegExp=isBrowser&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,defContextName="_",isOpera="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),contexts={},cfg={},globalDefQueue=[],useInteractive=!1;if("undefined"==typeof define){if("undefined"!=typeof requirejs){if(isFunction(requirejs))return;cfg=requirejs,requirejs=void 0}"undefined"==typeof require||isFunction(require)||(cfg=require,require=void 0),req=requirejs=function(e,t,i,r){var n,o,a=defContextName;return isArray(e)||"string"==typeof e||(o=e,isArray(t)?(e=t,t=i,i=r):e=[]),o&&o.context&&(a=o.context),n=getOwn(contexts,a),n||(n=contexts[a]=req.s.newContext(a)),o&&n.configure(o),n.require(e,t,i)},req.config=function(e){return req(e)},req.nextTick="undefined"!=typeof setTimeout?function(e){setTimeout(e,4)}:function(e){e()},require||(require=req),req.version=version,req.jsExtRegExp=/^\/|:|\?|\.js$/,req.isBrowser=isBrowser,s=req.s={contexts:contexts,newContext:newContext},req({}),each(["toUrl","undef","defined","specified"],function(e){req[e]=function(){var t=contexts[defContextName];return t.require[e].apply(t,arguments)}}),isBrowser&&(head=s.head=document.getElementsByTagName("head")[0],baseElement=document.getElementsByTagName("base")[0],baseElement&&(head=s.head=baseElement.parentNode)),req.onError=defaultOnError,req.createNode=function(e,t,i){var r=e.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");return r.type=e.scriptType||"text/javascript",r.charset="utf-8",r.async=!0,r},req.load=function(e,t,i){var r,n=e&&e.config||{};if(isBrowser)return r=req.createNode(n,t,i),r.setAttribute("data-requirecontext",e.contextName),r.setAttribute("data-requiremodule",t),!r.attachEvent||r.attachEvent.toString&&r.attachEvent.toString().indexOf("[native code")<0||isOpera?(r.addEventListener("load",e.onScriptLoad,!1),r.addEventListener("error",e.onScriptError,!1)):(useInteractive=!0,r.attachEvent("onreadystatechange",e.onScriptLoad)),r.src=i,n.onNodeCreated&&n.onNodeCreated(r,n,t,i),currentlyAddingScript=r,baseElement?head.insertBefore(r,baseElement):head.appendChild(r),currentlyAddingScript=null,r;if(isWebWorker)try{setTimeout(function(){},0),importScripts(i),e.completeLoad(t)}catch(r){e.onError(makeError("importscripts","importScripts failed for "+t+" at "+i,r,[t]))}},isBrowser&&!cfg.skipDataMain&&eachReverse(scripts(),function(e){if(head||(head=e.parentNode),dataMain=e.getAttribute("data-main"))return mainScript=dataMain,cfg.baseUrl||mainScript.indexOf("!")!==-1||(src=mainScript.split("/"),mainScript=src.pop(),subPath=src.length?src.join("/")+"/":"./",cfg.baseUrl=subPath),mainScript=mainScript.replace(jsSuffixRegExp,""),req.jsExtRegExp.test(mainScript)&&(mainScript=dataMain),cfg.deps=cfg.deps?cfg.deps.concat(mainScript):[mainScript],!0}),define=function(e,t,i){var r,n;"string"!=typeof e&&(i=t,t=e,e=null),isArray(t)||(i=t,t=null),!t&&isFunction(i)&&(t=[],i.length&&(i.toString().replace(commentRegExp,commentReplace).replace(cjsRequireRegExp,function(e,i){t.push(i)}),t=(1===i.length?["require"]:["require","exports","module"]).concat(t))),useInteractive&&(r=currentlyAddingScript||getInteractiveScript(),r&&(e||(e=r.getAttribute("data-requiremodule")),n=contexts[r.getAttribute("data-requirecontext")])),n?(n.defQueue.push([e,t,i]),n.defQueueMap[e]=!0):globalDefQueue.push([e,t,i])},define.amd={jQuery:!0},req.exec=function(text){return eval(text)},req(cfg)}}(this,"undefined"==typeof setTimeout?void 0:setTimeout); \ No newline at end of file diff --git a/requirejs.build.js b/requirejs.build.js index e9c9e15..8d9bb1a 100644 --- a/requirejs.build.js +++ b/requirejs.build.js @@ -8,6 +8,11 @@ name: 'crypto-js', location: '../vendor/crypto-js-3.1.9', main: 'index' + }, + { + name: 'castrato', + location: '../vendor/castrato', + main: 'castrato' } ], name: "main", diff --git a/server.js b/server.js index c3b9aca..ad99050 100644 --- a/server.js +++ b/server.js @@ -1,21 +1,21 @@ #!/usr/bin/env node const - files = require('node-static'), - port = process.env.PORT || 8080, - path = require('path'); + files = require('node-static'), + port = process.env.PORT || 8080, + path = require('path'); var - file, - server, - io; + file, + server, + io; // Set up files.file location file = new files.Server(path.resolve(__dirname, 'public')); // Create http server, handle files.assets server = require('http').createServer(function (req, res) { - req.addListener('end', function () { file.serve(req, res); }).resume(); + req.addListener('end', function () { file.serve(req, res); }).resume(); }); // Append socket.io to http server @@ -23,80 +23,80 @@ io = require('socket.io')(server), // Listen to port env:PORT or 8080 server.listen(port, function(){ - console.log('listening on *:'+port); + console.log('listening on *:' + port); }); io.on('connection', function(socket) { - socket.on('room:join', function(req) { - if( req ) { - socket.emit('room:joined',req); - socket.join(req); - socket.broadcast.to(req).emit('message:server', {msg:'person_joined'} ); - socket.current_room = req; - } else { - socket.emit('message:server', {msg:'command_failed'} ); - } - }); + socket.on('room:join', function(req) { + if( req ) { + socket.emit('room:joined',req); + socket.join(req); + socket.broadcast.to(req).emit('message:server', {msg:'person_joined'} ); + socket.current_room = req; + } else { + socket.emit('message:server', {msg:'command_failed'} ); + } + }); - socket.on('room:leave', function(req) { - if( req ) { - socket.emit('room:left'); - socket.leave(req); - socket.broadcast.to(req).emit('message:server', {msg:'person_left'} ); - socket.current_room = undefined; - } else { - socket.emit('message:server', {msg:'command_failed'} ); - } - }); + socket.on('room:leave', function(req) { + if( req ) { + socket.emit('room:left'); + socket.leave(req); + socket.broadcast.to(req).emit('message:server', {msg:'person_left'} ); + socket.current_room = undefined; + } else { + socket.emit('message:server', {msg:'command_failed'} ); + } + }); - socket.on('room:count', function (req) { - if( socket.current_room !== undefined ) { - var clientsList = io.sockets.adapter.rooms[socket.current_room]; - socket.emit('message:server', {msg:'person_count', payload: clientsList.length } ); - } else { - socket.emit('message:server', {msg:'command_failed'} ); - } - }); + socket.on('room:count', function () { + if( socket.current_room !== undefined ) { + var clientsList = io.sockets.adapter.rooms[socket.current_room]; + socket.emit('message:server', {msg:'person_count', payload: clientsList.length } ); + } else { + socket.emit('message:server', {msg:'command_failed'} ); + } + }); - socket.on('message:send', function(req) { + socket.on('message:send', function(req) { - // Check that the user is in a room - if(req && req.room) { + // Check that the user is in a room + if(req && req.room) { - // Check that the message size is within bounds - var total_msg_size = (req.msg) ? req.msg.length : 0 + (req.nick) ? req.nick.length : 0; - if( total_msg_size <= 4096) { + // Check that the message size is within bounds + var total_msg_size = (req.msg) ? req.msg.length : 0 + (req.nick) ? req.nick.length : 0; + if( total_msg_size <= 4096) { - // Check that at least 100ms has passed since last message - if( socket.last_message === undefined || new Date().getTime() - socket.last_message > 100 ) { + // Check that at least 100ms has passed since last message + if( socket.last_message === undefined || new Date().getTime() - socket.last_message > 100 ) { - socket.broadcast.to(req.room).emit('message:send', { msg: req.msg, nick: req.nick} ); - socket.emit('message:send', { msg: req.msg, nick: req.nick} ); + socket.broadcast.to(req.room).emit('message:send', { msg: req.msg, nick: req.nick} ); + socket.emit('message:send', { msg: req.msg, nick: req.nick} ); - socket.last_message = new Date().getTime(); + socket.last_message = new Date().getTime(); - } else { + } else { - // Do not complain if message rate is too fast, that would only generate more traffic + // Do not complain if message rate is too fast, that would only generate more traffic - } + } - } else { + } else { - // Message size is out of bounds, complain - socket.emit('message:server', {msg:'command_failed'} ); - } + // Message size is out of bounds, complain + socket.emit('message:server', {msg:'command_failed'} ); + } - } + } - }); + }); - socket.on('disconnect', function() { - // Notify other users of the room - if( socket.current_room !== undefined ) { - socket.broadcast.to(socket.current_room).emit('message:server', {msg:'person_left'} ); - } - }); + socket.on('disconnect', function() { + // Notify other users of the room + if( socket.current_room !== undefined ) { + socket.broadcast.to(socket.current_room).emit('message:server', {msg:'person_left'} ); + } + }); -}); +}); \ No newline at end of file