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="stylesheet" type="text/css" href="css/default.css">
|
||||||
<link rel="icon" type="image/png" href="gfx/icon_32x32.png">
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,9 @@
|
||||||
define(['$.utils', '$.proto'], function (utils, proto) {
|
define(['$.utils', '$.proto'], function (utils, proto) {
|
||||||
|
|
||||||
// Create a custom edition of Array, extended with $.proto
|
// Create a custom edition of Array, extended with $.proto
|
||||||
function ElementArray () {};
|
function ElementArray () {}
|
||||||
ElementArray.prototype = new Array;
|
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
|
// Create to actual dollar function
|
||||||
function Dollar (selector) {
|
function Dollar (selector) {
|
||||||
|
@ -30,7 +30,7 @@ define(['$.utils', '$.proto'], function (utils, proto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add utils to Dollar
|
// Add utils to Dollar
|
||||||
for(var key in utils) Dollar[key] = utils[key];
|
for(var l in utils) Dollar[l] = utils[l];
|
||||||
|
|
||||||
return Dollar;
|
return Dollar;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ define(['websocket','crypto-js/aes', 'crypto-js/sha1', 'crypto-js/enc-utf8'],fun
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.activeElement = function () {
|
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) {
|
exports.getJSON = function (path, onSuccess, onError) {
|
||||||
var data, request = new XMLHttpRequest();
|
var request = new XMLHttpRequest();
|
||||||
request.open('GET', path, true);
|
request.open('GET', path, true);
|
||||||
|
|
||||||
request.onreadystatechange = function() {
|
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); },
|
setTorch = function (payload) { mediator.emit('console:torch',payload); },
|
||||||
|
|
||||||
nick = function (payload) {
|
setNick = function (payload) {
|
||||||
|
|
||||||
// Make sure the nick meets the length requirements
|
// Make sure the nick meets the length requirements
|
||||||
if (payload.length > settings.nick.maxLen) {
|
if (payload.length > settings.nick.maxLen) {
|
||||||
|
@ -79,7 +79,7 @@ define(['$','castrato','settings','templates'], function ($, mediator, settings,
|
||||||
|
|
||||||
mediator.on('command:help', help);
|
mediator.on('command:help', help);
|
||||||
mediator.on('command:clear', clear);
|
mediator.on('command:clear', clear);
|
||||||
mediator.on('command:nick', nick);
|
mediator.on('command:nick', setNick);
|
||||||
mediator.on('command:key', setKey);
|
mediator.on('command:key', setKey);
|
||||||
mediator.on('command:torch', setTorch);
|
mediator.on('command:torch', setTorch);
|
||||||
mediator.on('command:title', title);
|
mediator.on('command:title', title);
|
||||||
|
|
|
@ -59,7 +59,7 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio
|
||||||
},
|
},
|
||||||
|
|
||||||
torch: function (ttl) {
|
torch: function (ttl) {
|
||||||
var ttl = parseInt(ttl);
|
ttl = parseInt(ttl);
|
||||||
if( ttl > 0 && ttl < 3600) {
|
if( ttl > 0 && ttl < 3600) {
|
||||||
mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) );
|
mediator.emit('console:info', $.template(templates.messages.torch_is_now, { ttl: ttl }) );
|
||||||
settings.ttl = ttl*1000;
|
settings.ttl = ttl*1000;
|
||||||
|
@ -73,8 +73,8 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification: function (type, nick, text) {
|
showNotification: function (type, nick, text) {
|
||||||
var title = type !== 'message' ? 'Cryptalk' : nick,
|
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');
|
icon = (type === 'message' ? 'gfx/icon_128x128.png' : (type === 'error' ? 'gfx/icon_128x128_error.png' : 'gfx/icon_128x128_info.png'));
|
||||||
|
|
||||||
// Emit notification
|
// Emit notification
|
||||||
mediator.emit('notification:send', {
|
mediator.emit('notification:send', {
|
||||||
|
@ -148,8 +148,7 @@ define(['$', 'castrato', 'settings', 'templates', 'sounds', 'room', 'notificatio
|
||||||
var buffer,
|
var buffer,
|
||||||
parts,
|
parts,
|
||||||
payload,
|
payload,
|
||||||
command,
|
command;
|
||||||
save;
|
|
||||||
|
|
||||||
// The Document object is bound to this element.
|
// The Document object is bound to this element.
|
||||||
// If the active element is not the input, focus on it and exit the function.
|
// If the active element is not the input, focus on it and exit the function.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Main cryptalk module
|
// Main cryptalk module
|
||||||
define(['castrato','host','client','console'], function (mediator, host, client) {
|
define(['castrato','host','client','console'], function (mediator) {
|
||||||
|
|
||||||
// Route mediator messages
|
// Route mediator messages
|
||||||
mediator
|
mediator
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
Emits:
|
Emits:
|
||||||
mediator.on('socket:emit', emit);
|
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
|
var
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m
|
||||||
if(socket) socket.emit(payload.data,payload.payload);
|
if(socket) socket.emit(payload.data,payload.payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
host = function () {
|
hostInfo = function () {
|
||||||
mediator.emit('info', JSON.stringify(host || {}));
|
mediator.emit('info', JSON.stringify(host || {}));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -76,10 +76,10 @@ define(['$', 'castrato','settings','templates','hosts','window'], function ($, m
|
||||||
mediator.emit('console:lockInput');
|
mediator.emit('console:lockInput');
|
||||||
|
|
||||||
var
|
var
|
||||||
request,
|
request;
|
||||||
|
|
||||||
// Use hostconfig.autoconnect as default host
|
// Use hostconfig.autoconnect as default host
|
||||||
toHost = (toHost == undefined) ? hostconfig.autoconnect : toHost;
|
toHost = (toHost === undefined) ? hostconfig.autoconnect : toHost;
|
||||||
|
|
||||||
if (host && host.connected) {
|
if (host && host.connected) {
|
||||||
mediator.emit('console:error', $.template(templates.messages.already_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
|
// Bind socket events
|
||||||
socket
|
socket
|
||||||
.on('room:joined', function (data) {
|
.on('room:joined', function () {
|
||||||
|
|
||||||
mediator.emit('console:info', $.template(templates.messages.joined_room, { roomName: $.escapeHtml(parameters.room) } ));
|
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 () {
|
.on('disconnect', function () {
|
||||||
|
|
||||||
room = 0;
|
|
||||||
key = 0;
|
|
||||||
host.connected = 0;
|
host.connected = 0;
|
||||||
|
|
||||||
// Tell the user that the chat is ready to interact with
|
// 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 () {
|
.on('connect_error', function () {
|
||||||
|
|
||||||
room = 0;
|
|
||||||
key = 0;
|
|
||||||
host.connected = 0;
|
host.connected = 0;
|
||||||
mediator.emit('console:error', templates.messages.socket_error);
|
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 );
|
parameters = Object.assign({}, parameters, p );
|
||||||
};
|
};
|
||||||
|
|
||||||
mediator.on('command:host', host);
|
mediator.on('command:host', hostInfo);
|
||||||
mediator.on('command:hosts', hosts);
|
mediator.on('command:hosts', hosts);
|
||||||
mediator.on('command:connect', connect);
|
mediator.on('command:connect', connect);
|
||||||
mediator.on('command:disconnect', disconnect);
|
mediator.on('command:disconnect', disconnect);
|
||||||
mediator.on('command:reconnect', disconnect);
|
mediator.on('command:reconnect', reconnect);
|
||||||
|
|
||||||
mediator.on('socket:emit', emit);
|
mediator.on('socket:emit', emit);
|
||||||
mediator.on('host:param', param);
|
mediator.on('host:param', param);
|
||||||
|
|
|
@ -12,9 +12,9 @@ define({
|
||||||
path: '/js/lib/settings.js'
|
path: '/js/lib/settings.js'
|
||||||
}/*,
|
}/*,
|
||||||
{
|
{
|
||||||
name: 'Example',
|
name: 'Official host - cryptalk.56k.guru',
|
||||||
host: 'http://www.example.com',
|
host: 'https://cryptalk.56k.guru',
|
||||||
path: 'http://www.example.com/js/cryptalk_modules/settings.js'
|
path: 'https://cryptalk.56k.guru/js/cryptalk_modules/settings.js'
|
||||||
}*/
|
}*/
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require.config({
|
require.config({
|
||||||
baseUrl: "js/lib/",
|
baseUrl: 'js/lib/',
|
||||||
paths: {
|
paths: {
|
||||||
websocket: '/socket.io/socket.io'
|
websocket: '/socket.io/socket.io'
|
||||||
},
|
},
|
||||||
|
@ -8,6 +8,11 @@ require.config({
|
||||||
name: 'crypto-js',
|
name: 'crypto-js',
|
||||||
location: '../vendor/crypto-js-3.1.9',
|
location: '../vendor/crypto-js-3.1.9',
|
||||||
main: 'index'
|
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);
|
if (original_title !== undefined) win.setTitle(original_title);
|
||||||
original_title = undefined;
|
original_title = undefined;
|
||||||
new_title = undefined;
|
new_title = undefined;
|
||||||
window_active = true;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
doBlink = function() {
|
doBlink = function() {
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
if( win.getTitle() == original_title )
|
if( win.getTitle() === original_title )
|
||||||
win.setTitle( new_title );
|
win.setTitle( new_title );
|
||||||
else
|
else
|
||||||
win.setTitle( original_title);
|
win.setTitle( original_title);
|
||||||
|
@ -70,7 +69,7 @@ define(['castrato','window','settings'], function (mediator, win, settings) {
|
||||||
},
|
},
|
||||||
|
|
||||||
blinkTitleUntilFocus = function(t,i) {
|
blinkTitleUntilFocus = function(t,i) {
|
||||||
interval = (i == undefined) ? 1000 : i;
|
interval = (i === undefined) ? 1000 : i;
|
||||||
if ( enabled && original_title === undefined ) {
|
if ( enabled && original_title === undefined ) {
|
||||||
new_title = t;
|
new_title = t;
|
||||||
original_title = win.getTitle();
|
original_title = win.getTitle();
|
||||||
|
@ -86,7 +85,7 @@ define(['castrato','window','settings'], function (mediator, win, settings) {
|
||||||
// Set default value for fallback parameter
|
// Set default value for fallback parameter
|
||||||
if ( fallback === undefined) fallback = false;
|
if ( fallback === undefined) fallback = false;
|
||||||
|
|
||||||
if ( native_supported && Notification.permission === "granted") {
|
if ( native_supported && Notification.permission === 'granted') {
|
||||||
|
|
||||||
// Create notification
|
// Create notification
|
||||||
var n = new Notification(title, {body: body, icon:icon});
|
var n = new Notification(title, {body: body, icon:icon});
|
||||||
|
@ -95,12 +94,12 @@ define(['castrato','window','settings'], function (mediator, win, settings) {
|
||||||
n.onshow = function () {
|
n.onshow = function () {
|
||||||
// Automatically close the notification after 5000ms
|
// Automatically close the notification after 5000ms
|
||||||
setTimeout(function(){n.close();},3000);
|
setTimeout(function(){n.close();},3000);
|
||||||
}
|
};
|
||||||
|
|
||||||
last = now();
|
last = now();
|
||||||
|
|
||||||
} else if ( fallback ) {
|
} else if ( fallback ) {
|
||||||
blinkTitleUntilFocus("Attention",1000);
|
blinkTitleUntilFocus('Attention', 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
define(function (){
|
define(function (){
|
||||||
|
|
||||||
var exports = {},
|
var exports = {},
|
||||||
queue = [],
|
queue = [],
|
||||||
now = function () {
|
now = function () {
|
||||||
|
@ -12,18 +13,18 @@ define(function (){
|
||||||
delay: delay,
|
delay: delay,
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.get = function () {
|
exports.get = function () {
|
||||||
return queue;
|
return queue;
|
||||||
}
|
};
|
||||||
|
|
||||||
exports.run = function () {
|
exports.run = function () {
|
||||||
var i = 0,
|
var i = 0,
|
||||||
current,
|
current,
|
||||||
lrt_inner;
|
lrt_inner;
|
||||||
|
|
||||||
while (current = queue[i++]) {
|
while ((current = queue[i++])) {
|
||||||
if (now() - current.pushed > current.delay) {
|
if (now() - current.pushed > current.delay) {
|
||||||
current.func();
|
current.func();
|
||||||
queue.splice(i - 1, 1);
|
queue.splice(i - 1, 1);
|
||||||
|
@ -34,11 +35,11 @@ define(function (){
|
||||||
// Waste a ms to prevent callstack overflow
|
// Waste a ms to prevent callstack overflow
|
||||||
lrt_inner = now();
|
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;
|
||||||
});
|
});
|
|
@ -1,6 +1,6 @@
|
||||||
define({
|
define({
|
||||||
|
|
||||||
title: "Cryptalk - Online",
|
title: 'Cryptalk - Online',
|
||||||
|
|
||||||
ttl: 600000,
|
ttl: 600000,
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ define(['castrato'],function (mediator){
|
||||||
// Keep track of document focus/blur
|
// Keep track of document focus/blur
|
||||||
if (window.addEventListener){
|
if (window.addEventListener){
|
||||||
// Normal browsers
|
// Normal browsers
|
||||||
window.addEventListener("focus", focusCallback, true);
|
window.addEventListener('focus', focusCallback, true);
|
||||||
window.addEventListener("blur", blurCallback, true);
|
window.addEventListener('blur', blurCallback, true);
|
||||||
} else {
|
} else {
|
||||||
// IE
|
// IE
|
||||||
window.observe("focusin", focusCallback);
|
window.observe('focusin', focusCallback);
|
||||||
window.observe("focusout", blurCallback);
|
window.observe('focusout', blurCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
mediator.on('window:title',exports.setTitle);
|
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',
|
name: 'crypto-js',
|
||||||
location: '../vendor/crypto-js-3.1.9',
|
location: '../vendor/crypto-js-3.1.9',
|
||||||
main: 'index'
|
main: 'index'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'castrato',
|
||||||
|
location: '../vendor/castrato',
|
||||||
|
main: 'castrato'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
name: "main",
|
name: "main",
|
||||||
|
|
|
@ -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 ) {
|
if( socket.current_room !== undefined ) {
|
||||||
var clientsList = io.sockets.adapter.rooms[socket.current_room];
|
var clientsList = io.sockets.adapter.rooms[socket.current_room];
|
||||||
socket.emit('message:server', {msg:'person_count', payload: clientsList.length } );
|
socket.emit('message:server', {msg:'person_count', payload: clientsList.length } );
|
||||||
|
|
Loading…
Reference in New Issue