Skip to content

Commit

Permalink
1.1.18 Pre release lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Feb 22, 2017
1 parent 5015caf commit 6775b42
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 174 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public/js/vendor
public/js/cryptalk.min.js
requirejs.build.js
40 changes: 40 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="stylesheet" type="text/css" href="css/default.css">
<link rel="icon" type="image/png" href="gfx/icon_32x32.png">

<script src="js/vendor/requirejs-2.3.2/require.js"></script>
<script src="js/vendor/requirejs-2.3.3/require.js"></script>

</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions public/js/cryptalk.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions public/js/lib/$.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions public/js/lib/$.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
};

/**
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -91,7 +91,7 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
'\'': '&#39;',
'/': '&#x2F;'
};

Expand Down
14 changes: 7 additions & 7 deletions public/js/lib/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down
6 changes: 3 additions & 3 deletions public/js/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)}));
Expand All @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions public/js/lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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', {
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion public/js/lib/cryptalk.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 8 additions & 12 deletions public/js/lib/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 || {}));
},

Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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) } ));

Expand Down Expand Up @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions public/js/lib/hosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}*/
]
});
21 changes: 13 additions & 8 deletions public/js/lib/main.js
Original file line number Diff line number Diff line change
@@ -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']);
21 changes: 10 additions & 11 deletions public/js/lib/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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});
Expand All @@ -95,30 +94,30 @@ 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); });
mediator.on('notification:on',function() { on(); });
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
Expand Down
Loading

0 comments on commit 6775b42

Please sign in to comment.