diff --git a/public/css/default.css b/public/css/default.css index b105b58..935ded9 100644 --- a/public/css/default.css +++ b/public/css/default.css @@ -85,8 +85,6 @@ body, html { border: 0; outline: 0; - - padding: 5px 5px 5px 15px; color: #FFFFFF; diff --git a/public/index.html b/public/index.html index 91b49d9..4747cb8 100644 --- a/public/index.html +++ b/public/index.html @@ -21,7 +21,7 @@ - + diff --git a/public/js/bootstrap.js b/public/js/bootstrap.js index 577db78..f109547 100644 --- a/public/js/bootstrap.js +++ b/public/js/bootstrap.js @@ -25,5 +25,6 @@ fandango.defaults({ // Require main cryptalk module. require(['cryptalk'], function () {}, function (e) { document.getElementById('chat').innerHTML = '
  • Fatal: An error was thrown during initialization causing the application to stop.
    Examine the logs for more details.
  • '; + console.log && console.log(e); throw e; }); \ No newline at end of file diff --git a/public/js/cryptalk_modules/$.js b/public/js/cryptalk_modules/$.js index 22f071b..71492ce 100644 --- a/public/js/cryptalk_modules/$.js +++ b/public/js/cryptalk_modules/$.js @@ -50,9 +50,10 @@ define(['fandango', 'websocket', 'aes'], function (fandango, websocket, aes) { decrypt: function (string, fgh) { return aes.decrypt(string, fgh).toString(CryptoJS.enc.Utf8); }, + encrypt: function (string, fgh) { return aes.encrypt(string, fgh).toString(); - }, + } }; // Namespace websocket @@ -149,18 +150,22 @@ define(['fandango', 'websocket', 'aes'], function (fandango, websocket, aes) { }; proto.append = function (string) { - each(this, function (element) { - element.innerHTML += string; - }); + for (var i = 0, len = this.length; i < len; i++) { + this[0].innerHTML += string; + } return this; }; - // Extremely naive implementations of .on() + // Naive implementations of .on() proto.on = function (eventName, callback) { - each(this, function (element) { - element.addEventListener(eventName, callback); - }); + for (var i = 0, len = this.length; i < len; i++) { + if (this[0].addEventListener) { + this[0].addEventListener(eventName, callback, false); + } else if (this[0].attachEvent) { + this[0].attachEvent('on' + eventName, callback); + } + } return this; }; diff --git a/public/js/cryptalk_modules/cryptalk.js b/public/js/cryptalk_modules/cryptalk.js index 621a012..8df7787 100644 --- a/public/js/cryptalk_modules/cryptalk.js +++ b/public/js/cryptalk_modules/cryptalk.js @@ -71,6 +71,10 @@ define({ done(); }, + host: function () { + post('info', JSON.stringify(host || {})); + }, + hosts: function (force, done) { var i = 0, left = hosts.length, @@ -86,7 +90,7 @@ define({ index: index }); - if (!--left) { + if (--left === 0) { post('info', strhosts); done(); } @@ -415,8 +419,8 @@ define({ // Wierd hack to move caret to end of input-box setTimeout(function() {if(input.setSelectionRange) input.setSelectionRange(input.value.length, input.value.length);}, 0); - return; - } + return; + } // Return immediatly if the buffer is empty or if the hit key was not if (e.keyCode !== 13 || !(buffer = components.input[0].value)) { @@ -427,7 +431,7 @@ define({ history_pos = -1; // Handle command - if (buffer[0] === '/') { + if ((buffer[0] || buffer.slice(0, 1)) === '/') { parts = $.ssplit(buffer.slice(1), ' '); command = parts[0]; payload = parts[1]; diff --git a/public/js/cryptalk_modules/sound.js b/public/js/cryptalk_modules/sound.js index 953e6cd..5576ecf 100644 --- a/public/js/cryptalk_modules/sound.js +++ b/public/js/cryptalk_modules/sound.js @@ -15,7 +15,7 @@ define(['queue'], function (queue) { i = (i === undefined) ? 0 : i; // Stop if we've reached the end of iteration, and require ac - if( !(i < Object.keys(tones).length) || !ac ) return; + if( ac && !(i < Object.keys(tones).length) || !ac ) return; // Add tones to execution queue var current_tones = tones[i], diff --git a/public/js/cryptalk_modules/templates.js b/public/js/cryptalk_modules/templates.js index 7e61386..96ee5f9 100644 --- a/public/js/cryptalk_modules/templates.js +++ b/public/js/cryptalk_modules/templates.js @@ -1,24 +1,24 @@ // The templating function only supports variables. // Define a variable as so: {variable_name} define({ - motd: '\n\n' + + motd: '
    \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'+
    -		'                                                                      \n'+
    -		'----------------------------------------------------------------------',
    +		'▒██▀ ▀█  ▓██ ▒ ██▒▒██  ██▒▓██░  ██▒▓  ██▒ ▓▒▒████▄    ▓██▒     ██▄█▒  \n' +
    +		'▒▓█    ▄ ▓██ ░▄█ ▒ ▒██ ██░▓██░ ██▓▒▒ ▓██░ ▒░▒██  ▀█▄  ▒██░    ▓███▄░  \n' +
    +		'▒▓▓▄ ▄██▒▒██▀▀█▄   ░ ▐██▓░▒██▄█▓▒ ▒░ ▓██▓ ░ ░██▄▄▄▄██ ▒██░    ▓██ █▄  \n' +
    +		'▒ ▓███▀ ░░██▓ ▒██▒ ░ ██▒▓░▒██▒ ░  ░  ▒██▒ ░  ▓█   ▓██▒░██████▒▒██▒ █▄ \n' +
    +		'░ ░▒ ▒  ░░ ▒▓ ░▒▓░  ██▒▒▒ ▒▓▒░ ░  ░  ▒ ░░    ▒▒   ▓▒█░░ ▒░▓  ░▒ ▒▒ ▓▒ \n' +
    +		'  ░  ▒     ░▒ ░ ▒░▓██ ░▒░ ░▒ ░         ░      ▒   ▒▒ ░░ ░ ▒  ░░ ░▒ ▒░ \n' +
    +		'░          ░░   ░ ▒ ▒ ░░  ░░         ░        ░   ▒     ░ ░   ░ ░░ ░  \n' +
    +		'░ ░         ░     ░ ░                             ░  ░    ░  ░░  ░    \n' +
    +		'░                 ░ ░                                                 \n' +
    +		'                                  https://github.com/hexagon/cryptalk \n' +
    +		'                                                                      \n' +
    +		' Tip of the day: /help                                                \n' +
    +		'----------------------------------------------------------------------' +
    +		'
    ', - help: ' \n' + + help: '
                                                                    \n' +
     		'Cryptalk, encrypted instant chat.                                      \n' +
     		'                                                                       \n' +
     		'----------------------------------------------------------------------	\n' +
    @@ -44,7 +44,7 @@ define({
     		'to prevent browsers from keeping history or cache.            \n' +
     		'                                                                       \n' +
     		'----------------------------------------------------------------------	\n' +
    -		'                                                                    ',
    +		'
    ', default_nick: 'Anonymous', @@ -108,6 +108,6 @@ define({ room_generated: 'Room {payload} generated.', 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.', + bogus: 'Received a bogus message from server.' } }); \ No newline at end of file diff --git a/public/js/vendor/fandango.v20140921.min.js b/public/js/vendor/fandango.v20140921.min.js deleted file mode 100644 index 50e73c8..0000000 --- a/public/js/vendor/fandango.v20140921.min.js +++ /dev/null @@ -1,20 +0,0 @@ -(function(s){function A(f){this.name="TimeoutError";this.message=f||""}function B(f){this.name="RejectedError";this.message=f||""}function F(f,c,e,g){var d,a,b=[],n,m,k,h=function(a){f.length===b.push(l[a].exports)&&(g&&clearTimeout(n),c(b))};g=g||v.timeout;for(k=0;m=f[k++];)if((d=l[m])&&1!==d.state)if(2===d.state)if(a=new B('Could resolve all dependencies; dependency "'+m+'" has been rejected.'),e)e(a);else throw a;else 3===d.state&&h(m);else(u[m]=u[m]||[]).push(h);g&&(n=setTimeout(function(){for(var d, -c,n=0,m=0;d=f[n++];)for(m=0;c=b[m++];)d===c&&(b.splice(--m,1),f.splice(--n,1));a=new A("Load timeout of "+g+'ms exceeded for module(s) "'+f.join('", "')+'".');if(e)e(a);else throw a;},g))}function y(){var f=!1,c,e,g,d,a,b,n;if(arguments[0]!==C){for(c=0;(e=arguments[c++])&&(_type=(typeof e)[0]);)if("s"===_type?d?g=1:d=e:"f"===_type?b?n?g=1:n=e:b=e:"o"===_type&&(h.is(e,"array")?(a={requires:e},f=!0):a?b=e:a=e),g)throw new TypeError("define called with unrecognized signature; `"+Array.prototype.join.call(arguments, -", ")+"`.");a=a||{};d=d||a.UID;b=b||a.factory;n=n||a.onRejected}else if(c=D.pop())d=arguments[1],a=c[0],b=c[1],n=c[2],f=c[3];else throw Error("Inconsistent naming queue");if(!b)if(a)b=a,a={};else throw Error('Missing factory for module "'+d+'"');if(l[d])throw Error('Duplicate entry for module "'+d+'"');d?(c=l[d]=a,c.UID=d,c.amdStyle=f,c.factory=b,c.state=1,c.requires=h.is(c.requires,"array")&&c.requires,c.inherits=h.is(c.inherits,"array")&&c.inherits,c.compiles=h.is(c.compiles,"array")&&c.compiles, -c.instances||(c.instances={instance1:{}})):D.unshift([a,b,n,f])}var l={},v={deepCopy:!0,baseUrl:"",namespace:"default",timeout:1E3,paths:{},shim:{}},h={},C={a:1},u={},D=[],z=Array.prototype.push;A.prototype=Error.prototype;B.prototype=Error.prototype;h.is=function(){var f=Object.prototype.hasOwnProperty,c=Object.prototype.toString,e={array:Array.isArray||function(a){return"[object Array]"==c.call(a)},arraylike:function(a){if(!a||!a.length&&0!==a.length||e.window(a))return!1;var b=a.length;return 1=== -a.nodeType||e.array(a)||!e["function"](a)&&(0===b||"number"===typeof b&&0a&&Math.floor(a)===a},iterable:function(a){try{1 in obj}catch(b){return!1}return!0},nan:function(a){return e.number(a)&& -a!=+a},number:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},object:function(a){return a===Object(a)},primitive:function(a){return!0===a||!1===a||null==a||!!{string:1,number:1}[typeof a]},string:function(a){return"string"==typeof a||a instanceof String},undefined:function(a){return void 0===a},untyped:function(a){if(!a||a.nodeType||"[object Object]"!==c.call(a)||e.window(a))return!1;try{if(a.constructor&&!f.call(a,"constructor")&&!f.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}for(var d in a); -return void 0===d||f.call(a,d)},window:function(a){return null!=a&&a==a.window},empty:function(a){if(a){if(h.is(a,"array"))return 0===a.length;for(var b in a)if(f.call(a,b))return!1}return!0}},g=0,d=["Arguments","Date","Function","RegExp"];for(;4>g;g++)e[d[g].toLowerCase()]=function(a){a="[object "+a+"]";return function(b){return c.call(b)==a}}(d[g]);e.args=e.arguments;e.bool=e["boolean"];e.plain=e.untyped;return function(a,b){if(e["function"](b))return a===b(a);if(!e.string(b))return a===b;if((b= -b.toLowerCase())&&e[b])return e[b](a);throw'Unknown type "'+b+'"';}}();h.each=function(){var f=Array.prototype.some;return function(c,e,g){var d,a;if(void 0===c)return obj;g=g||h;if(f&&c.some===f)return c.some(e,g),c;if(h.is(c,"array")||h.is(c,"arraylike")){d=0;for(a=c.length;dt.length&&t.push(d.data?h.merge(d.deepCopy,{},d.data,b.data):b.data),m>t.length&&t.push(h.merge(d.deepCopy,{},d,b))),d.exports=n?b.factory.apply(d.context,t)||{}:b.factory,void 0===b.exports&&(b.exports=g?d.exports?h.merge(!0,{},g,d.exports):g:d.exports);b.state=3;if(u[c])for(;u[c].length;)u[c].pop()(c)}return function e(g, -d){var a,b=l[g],n=h.is(b.factory,"function")?b.factory.length:0,m=b.amdStyle,k=[],t,q,s;a=[];var r,p;if(!d&&(b.requires||b.compiles||b.inherits)){b.requires&&z.apply(a,b.requires);b.inherits&&z.apply(a,b.inherits);b.compiles&&z.apply(a,b.compiles);for(r=0;p=a[r++];)if(l[p])if(3===l[p].state)a.splice(--r,1);else if(2===l[p].state)throw Error('Could not instantiate "'+UID+'"; dependency "'+dependency+'" has been rejected.');if(0a&&Math.floor(a)===a},iterable:function(a){try{1 in +obj}catch(b){return!1}return!0},nan:function(a){return e.number(a)&&a!=+a},number:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},object:function(a){return a===Object(a)},primitive:function(a){return!0===a||!1===a||null==a||!!{string:1,number:1}[typeof a]},string:function(a){return"string"==typeof a||a instanceof String},undefined:function(a){return void 0===a},untyped:function(a){if(!a||a.nodeType||"[object Object]"!==d.call(a)||e.window(a))return!1;try{if(a.constructor&&!f.call(a,"constructor")&& +!f.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}for(var g in a);return void 0===g||f.call(a,g)},window:function(a){return null!=a&&a==a.window},empty:function(a){if(a){if(l.is(a,"array"))return 0===a.length;for(var b in a)if(f.call(a,b))return!1}return!0}},k=0,c=["Arguments","Date","Function","RegExp"];for(;4>k;k++)e[c[k].toLowerCase()]=function(a){a="[object "+a+"]";return function(b){return d.call(b)==a}}(c[k]);e.args=e.arguments;e.bool=e["boolean"];e.plain=e.untyped; +return function(a,b){if(e["function"](b))return a===b(a);if(!e.string(b))return a===b;if((b=b.toLowerCase())&&e[b])return e[b](a);throw'Unknown type "'+b+'"';}}();l.each=function(){var f=Array.prototype.some;return function(d,e,k){var c,a;if(void 0===d)return obj;k=k||l;if(f&&d.some===f)return d.some(e,k),d;if(l.is(d,"array")||l.is(d,"arraylike")){c=0;for(a=d.length;cs.length&&s.push(c.data?l.merge(c.deepCopy,{},c.data,b.data):b.data),h>s.length&&s.push(l.merge(c.deepCopy, +{},c,b))),c.exports=g?b.factory.apply(c.context,s)||{}:b.factory,void 0===b.exports&&(b.exports=k?c.exports?l.merge(!0,{},k,c.exports):k:c.exports);b.state=3;if(u[d])for(;u[d].length;)u[d].pop()(d)}return function e(k,c,a){var b,g;g=n[k];var h,r,s=[],p,q,t;b=[];var m;if(g){h=l.is(g.factory,"function")?g.factory.length:0;r=g.amdStyle;if(!c&&(g.requires||g.compiles||g.inherits)){g.requires&&z.apply(b,g.requires);g.inherits&&z.apply(b,g.inherits);g.compiles&&z.apply(b,g.compiles);for(c=0;m=b[c++];)if(n[m])if(3=== +n[m].state)b.splice(--c,1);else if(2===n[m].state)throw Error('Could not instantiate "'+UID+'"; dependency "'+dependency+'" has been rejected.');if(0c.attachEvent.toString().indexOf("[native code")||e);buildUrl=function(){var a={"http://":1,"https://":1,"file://":1};return function(b){var c=b.toLowerCase(),d=c[0]||c.slice(0,1);"/"===d||"\\"===d||"h"===d&&(a[c.slice(0,7)]||a[c.slice(0,8)])||"f"===d&&a[c.slice(0,7)]||(b=v.baseUrl+b);".js"!==b.slice(-3)&&(b+=".js");return b}}();onErrorEvent=function(a,b,c,d){return function(e){f[b]=0;a.error=e||!0;d.parentElement.removeChild(d); +if(a.onError)a.onError(e,c,b)}};onLoadEvent=function(a,b,c,d,e){return function(){if((!e||"loaded"===d.readyState||"complete"===d.readyState)&&2===f[b]){f[b]=3;if(a.onPartial)a.onPartial(b,c,d);e?d.detachEvent("onreadystatechange",a.loadListener):(d.removeEventListener("load",a.loadListener),d.removeEventListener("error",a.errorListener));if(a.loaded.push(b)===a.paths.length&&a.onDone)a.onDone(a.load)}}};get=function(a){for(var b=0,g,h,e;!a.error&&(g=a.paths[b++]);)h=a.names[b-1],f[g]=2,e=k(g),c? +e.attachEvent("onreadystatechange",onLoadEvent(a,g,h,e,!0)):(a.loadListener=onLoadEvent(a,g,h,e),a.errorListener=onErrorEvent(a,g,h,e),e.addEventListener("load",a.loadListener,!1),e.addEventListener("error",a.errorListener,!1)),e.src=g,d.appendChild(e)};return function(a,b,c,d){var e=[],k=[],p={paths:[],names:[],loaded:[],error:null,loadListener:null,errorListener:null},u,t,m,w,x;p.onError=function(a,b,d){a instanceof Error||(a=Error('Could require "'+b+'"; an error occurred while trying to load "'+ +d+'".'));if(c)c(a);else throw a;};for(x=0;t=a[x++];)if(n[t])if(3===n[t].state)k.push(n[t].exports);else{if(2===n[t].state)throw Error("require(): Rejected dependency. Cannot continue.");E(t,null,p.onError);e.push(t)}else f[u]||(u=buildUrl(v.paths[t]||t),p.paths.push(u),p.names.push(t)),e.push(t);e.length?(p.paths&&(p.onPartial=function(a,b,c){n[b]||((m=v.shim[b])?(w=l.is(m.exports,"function")?m.exports:function(){return q[m.exports]},y(b,w,p.onError)):y(C,b,p.onError));E(b,null,p.onError);d&&d(a, +c)},get(p)),F(e,function(a){b.apply(null,a)},p.onError)):b&&b.apply(null,k)}}();y("fandango",l);var H=q.fandango,I=q.define,J=q.require,w={fn:l,define:y,require:x,noConflict:function(f){q.define===y&&(q.define=I);q.require===x&&(q.require=J);f&&q.fandango===w&&(q.fandango=H);return w},defaults:function(f){return f?l.merge(v,f):v}};q.define||(q.define=w.define);q.require||(q.require=w.require);q.fandango=w})(this); \ No newline at end of file