1.1.18 Pre release lint
This commit is contained in:
parent
5015caf55a
commit
6775b427a5
|
@ -0,0 +1,3 @@
|
|||
public/js/vendor
|
||||
public/js/cryptalk.min.js
|
||||
requirejs.build.js
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
|||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'\'': ''',
|
||||
'/': '/'
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
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);
|
||||
|
|
|
@ -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'
|
||||
}*/
|
||||
]
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require.config({
|
||||
baseUrl: "js/lib/",
|
||||
baseUrl: 'js/lib/',
|
||||
paths: {
|
||||
websocket: '/socket.io/socket.io'
|
||||
},
|
||||
|
@ -8,6 +8,11 @@ require.config({
|
|||
name: 'crypto-js',
|
||||
location: '../vendor/crypto-js-3.1.9',
|
||||
main: 'index'
|
||||
},
|
||||
{
|
||||
name: 'castrato',
|
||||
location: '../vendor/castrato',
|
||||
main: 'castrato'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -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,12 +94,12 @@ 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
define(function (){
|
||||
|
||||
var exports = {},
|
||||
queue = [],
|
||||
now = function () {
|
||||
|
@ -12,18 +13,18 @@ define(function (){
|
|||
delay: delay,
|
||||
data: data
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.get = function () {
|
||||
return queue;
|
||||
}
|
||||
};
|
||||
|
||||
exports.run = function () {
|
||||
var i = 0,
|
||||
current,
|
||||
lrt_inner;
|
||||
|
||||
while (current = queue[i++]) {
|
||||
while ((current = queue[i++])) {
|
||||
if (now() - current.pushed > current.delay) {
|
||||
current.func();
|
||||
queue.splice(i - 1, 1);
|
||||
|
@ -34,11 +35,11 @@ define(function (){
|
|||
// 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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return exports;
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
define({
|
||||
|
||||
title: "Cryptalk - Online",
|
||||
title: 'Cryptalk - Online',
|
||||
|
||||
ttl: 600000,
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -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",
|
||||
|
|
|
@ -23,7 +23,7 @@ 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) {
|
||||
|
@ -50,7 +50,7 @@ io.on('connection', function(socket) {
|
|||
}
|
||||
});
|
||||
|
||||
socket.on('room:count', function (req) {
|
||||
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 } );
|
||||
|
|
Loading…
Reference in New Issue