Use strict comparison operators
This commit is contained in:
parent
0cd4f04740
commit
7d386f04c2
|
@ -127,7 +127,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
var group = 'root';
|
||||
nicklist.forEach(function(n) {
|
||||
var buffer = models.getBuffer(n.pointers[0]);
|
||||
if(n.group == 1) {
|
||||
if (n.group === 1) {
|
||||
var g = new models.NickGroup(n);
|
||||
group = g.name;
|
||||
buffer.nicklist[group] = g;
|
||||
|
@ -146,7 +146,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
nicklist.forEach(function(n) {
|
||||
var buffer = models.getBuffer(n.pointers[0]);
|
||||
var d = n._diff;
|
||||
if(n.group == 1) {
|
||||
if (n.group === 1) {
|
||||
group = n.name;
|
||||
if (group === undefined) {
|
||||
var g = new models.NickGroup(n);
|
||||
|
@ -155,25 +155,17 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
}
|
||||
} else {
|
||||
var nick = new models.Nick(n);
|
||||
if(d == 43) { // +
|
||||
if (d === 43) { // +
|
||||
buffer.addNick(group, nick);
|
||||
}else if (d == 45) { // -
|
||||
} else if (d === 45) { // -
|
||||
buffer.delNick(group, nick);
|
||||
}else if (d == 42) { // *
|
||||
} else if (d === 42) { // *
|
||||
buffer.updateNick(group, nick);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var handleEvent = function(event) {
|
||||
|
||||
if (_.has(eventHandlers, event.id)) {
|
||||
eventHandlers[event.id](event);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var eventHandlers = {
|
||||
_buffer_closing: handleBufferClosing,
|
||||
_buffer_line_added: handleBufferLineAdded,
|
||||
|
@ -184,6 +176,12 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
|
|||
_nicklist_diff: handleNicklistDiff
|
||||
};
|
||||
|
||||
var handleEvent = function(event) {
|
||||
if (_.has(eventHandlers, event.id)) {
|
||||
eventHandlers[event.id](event);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
handleEvent: handleEvent,
|
||||
handleLineInfo: handleLineInfo,
|
||||
|
@ -381,7 +379,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
|
|||
// on error it means the connection problem
|
||||
// come from the relay not from the password.
|
||||
|
||||
if (evt.type == "error" && websocket.readyState != 1) {
|
||||
if (evt.type === "error" && websocket.readyState !== 1) {
|
||||
failCallbacks('error');
|
||||
$rootScope.errorMessage = true;
|
||||
}
|
||||
|
@ -501,7 +499,9 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
$scope.favico = new Favico({animation: 'none'});
|
||||
$rootScope.$on('notificationChanged', function() {
|
||||
var notifications = _.reduce(models.model.buffers, function(memo, num) { return (parseInt(memo)||0) + num.notification;});
|
||||
if (typeof(notifications) !== 'number') return;
|
||||
if (typeof notifications !== 'number') {
|
||||
return;
|
||||
}
|
||||
if (notifications > 0) {
|
||||
$scope.favico.badge(notifications, {
|
||||
bgColor: '#d00',
|
||||
|
@ -681,7 +681,7 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
}
|
||||
if ($scope.onlyUnread) {
|
||||
// Always show current buffer in list
|
||||
if (models.getActiveBuffer() == buffer) {
|
||||
if (models.getActiveBuffer() === buffer) {
|
||||
return true;
|
||||
}
|
||||
return buffer.unread > 0 || buffer.notification > 0;
|
||||
|
@ -733,11 +733,11 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
// Support different browser quirks
|
||||
var code = $event.keyCode ? $event.keyCode : $event.charCode;
|
||||
// Handle escape
|
||||
if(code == 27) {
|
||||
if (code === 27) {
|
||||
$event.preventDefault();
|
||||
$scope.search = '';
|
||||
} // Handle enter
|
||||
else if (code == 13) {
|
||||
else if (code === 13) {
|
||||
$event.preventDefault();
|
||||
// TODO Switch to first matching buffer and reset query
|
||||
$scope.search = '';
|
||||
|
@ -869,7 +869,7 @@ weechat.directive('inputBar', function() {
|
|||
|
||||
// Left Alt+[0-9] -> jump to buffer
|
||||
if ($event.altKey && !$event.ctrlKey && (code > 47 && code < 58)) {
|
||||
if (code == 48) {
|
||||
if (code === 48) {
|
||||
code = 58;
|
||||
}
|
||||
|
||||
|
@ -882,7 +882,7 @@ weechat.directive('inputBar', function() {
|
|||
}
|
||||
|
||||
// Tab -> nick completion
|
||||
if (code == 9 && !$event.altKey && !$event.ctrlKey) {
|
||||
if (code === 9 && !$event.altKey && !$event.ctrlKey) {
|
||||
$event.preventDefault();
|
||||
$scope.iterCandidate = tmpIterCandidate;
|
||||
$scope.completeNick();
|
||||
|
@ -890,21 +890,21 @@ weechat.directive('inputBar', function() {
|
|||
}
|
||||
|
||||
// Left Alt+n -> toggle nicklist
|
||||
if ($event.altKey && !$event.ctrlKey && code == 78) {
|
||||
if ($event.altKey && !$event.ctrlKey && code === 78) {
|
||||
$event.preventDefault();
|
||||
$scope.nonicklist = !$scope.nonicklist;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Alt+A -> switch to buffer with activity
|
||||
if ($event.altKey && (code == 97 || code == 65)) {
|
||||
if ($event.altKey && (code === 97 || code === 65)) {
|
||||
$event.preventDefault();
|
||||
$scope.switchToActivityBuffer();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Alt+L -> focus on input bar
|
||||
if ($event.altKey && (code == 76 || code == 108)) {
|
||||
if ($event.altKey && (code === 76 || code === 108)) {
|
||||
$event.preventDefault();
|
||||
var inputNode = document.getElementById('sendMessage');
|
||||
inputNode.focus();
|
||||
|
@ -913,27 +913,27 @@ weechat.directive('inputBar', function() {
|
|||
}
|
||||
|
||||
// Escape -> disconnect
|
||||
if (code == 27) {
|
||||
if (code === 27) {
|
||||
$event.preventDefault();
|
||||
connection.disconnect();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ctrl+G -> focus on buffer filter input
|
||||
if ($event.ctrlKey && (code == 103 || code == 71)) {
|
||||
if ($event.ctrlKey && (code === 103 || code === 71)) {
|
||||
$event.preventDefault();
|
||||
document.getElementById('bufferFilter').focus();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Arrow up -> go up in history
|
||||
if (code == 38) {
|
||||
if (code === 38) {
|
||||
$scope.command = models.getActiveBuffer().getHistoryUp($scope.command);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Arrow down -> go down in history
|
||||
if (code == 40) {
|
||||
if (code === 40) {
|
||||
$scope.command = models.getActiveBuffer().getHistoryDown($scope.command);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ var IrcUtils = {
|
|||
var lcNick = nickList[i].toLowerCase();
|
||||
if (lcNick.search(lcIterCandidate) === 0) {
|
||||
matchingNicks.push(nickList[i]);
|
||||
if (lcCurrentNick == lcNick) {
|
||||
if (lcCurrentNick === lcNick) {
|
||||
at = matchingNicks.length - 1;
|
||||
}
|
||||
} else if (matchingNicks.length > 0) {
|
||||
|
@ -77,7 +77,7 @@ var IrcUtils = {
|
|||
return currentNick;
|
||||
} else {
|
||||
++at;
|
||||
if (at == matchingNicks.length) {
|
||||
if (at === matchingNicks.length) {
|
||||
// cycle
|
||||
at = 0;
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ var IrcUtils = {
|
|||
return ret;
|
||||
}
|
||||
beforeCaret = newNick + suf + ' ';
|
||||
if (afterCaret[0] == ' ') {
|
||||
if (afterCaret[0] === ' ') {
|
||||
// swallow first space after caret if any
|
||||
afterCaret = afterCaret.substring(1);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ var IrcUtils = {
|
|||
return ret;
|
||||
}
|
||||
beforeCaret = m[1] + newNick + ' ';
|
||||
if (afterCaret[0] == ' ') {
|
||||
if (afterCaret[0] === ' ') {
|
||||
// swallow first space after caret if any
|
||||
afterCaret = afterCaret.substring(1);
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@ ls.factory("$store",function($parse){
|
|||
var val;
|
||||
try {
|
||||
val = JSON.parse(res);
|
||||
if (typeof val == 'undefined'){
|
||||
if (val === undefined){
|
||||
val = res;
|
||||
}
|
||||
if (val == 'true'){
|
||||
if (val === 'true'){
|
||||
val = true;
|
||||
}
|
||||
if (val == 'false'){
|
||||
if (val === 'false'){
|
||||
val = false;
|
||||
}
|
||||
if (parseFloat(val) == val && !angular.isObject(val) ){
|
||||
if (parseFloat(val) === val && !angular.isObject(val)) {
|
||||
val = parseFloat(val);
|
||||
}
|
||||
} catch(e){
|
||||
|
|
18
js/models.js
18
js/models.js
|
@ -56,7 +56,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
*/
|
||||
var delNick = function(group, nick) {
|
||||
group = nicklist[group];
|
||||
group.nicks = _.filter(group.nicks, function(n) { return n.name != nick.name;});
|
||||
group.nicks = _.filter(group.nicks, function(n) { return n.name !== nick.name;});
|
||||
flatnicklist = getFlatNicklist();
|
||||
/*
|
||||
for (i in group.nicks) {
|
||||
|
@ -73,7 +73,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
var updateNick = function(group, nick) {
|
||||
group = nicklist[group];
|
||||
for(var i in group.nicks) {
|
||||
if(group.nicks[i].name == nick.name) {
|
||||
if (group.nicks[i].name === nick.name) {
|
||||
group.nicks[i] = nick;
|
||||
break;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
|
||||
var addToHistory = function(line) {
|
||||
var result = "";
|
||||
if (historyPos != history.length) {
|
||||
if (historyPos !== history.length) {
|
||||
// Pop cached line from history. Occurs if we submit something from history
|
||||
result = history.pop();
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
*/
|
||||
this.addBuffer = function(buffer) {
|
||||
BufferList[buffer.id] = buffer;
|
||||
if (BufferList.length == 1) {
|
||||
if (BufferList.length === 1) {
|
||||
activeBuffer = buffer.id;
|
||||
}
|
||||
this.model.buffers[buffer.id] = buffer;
|
||||
|
@ -350,7 +350,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
var i = 0;
|
||||
|
||||
for (var v in BufferList) {
|
||||
if (index == ++i) {
|
||||
if (index === ++i) {
|
||||
return BufferList[v];
|
||||
}
|
||||
}
|
||||
|
@ -374,19 +374,19 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
* @return true on success, false if buffer was not found
|
||||
*/
|
||||
this.setActiveBuffer = function(bufferId, key) {
|
||||
if (typeof(key) === 'undefined') {
|
||||
if (key === undefined) {
|
||||
key = 'id';
|
||||
}
|
||||
|
||||
var previousBuffer = this.getActiveBuffer();
|
||||
|
||||
activeBuffer = _.find(this.model.buffers, function(buffer) {
|
||||
if (buffer[key] == bufferId) {
|
||||
if (buffer[key] === bufferId) {
|
||||
return buffer;
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof(activeBuffer) === 'undefined') {
|
||||
if (activeBuffer === undefined) {
|
||||
// Buffer not found, undo assignment
|
||||
activeBuffer = previousBuffer;
|
||||
return false;
|
||||
|
@ -423,7 +423,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter)
|
|||
*/
|
||||
this.getBuffer = function(bufferId) {
|
||||
return _.find(this.model.buffers, function(buffer) {
|
||||
if (buffer.id == bufferId) {
|
||||
if (buffer.id === bufferId) {
|
||||
return buffer;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -226,17 +226,15 @@
|
|||
|
||||
for (var i = 0; i < str.length; ++i) {
|
||||
var ch = str.charAt(i);
|
||||
if (ch == '|') {
|
||||
if (ch === '|') {
|
||||
// means keep attributes, so unchanged
|
||||
return null;
|
||||
}
|
||||
var attrName = WeeChatProtocol._attrNameFromChar(ch);
|
||||
if (attrName === null) {
|
||||
// ignore invalid attribute
|
||||
continue;
|
||||
}
|
||||
if (attrName !== null) {
|
||||
attrs.override[attrName] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return attrs;
|
||||
};
|
||||
|
@ -249,7 +247,7 @@
|
|||
* @return Color object
|
||||
*/
|
||||
WeeChatProtocol._getColorObj = function(str) {
|
||||
if (str.length == 2) {
|
||||
if (str.length === 2) {
|
||||
var code = parseInt(str);
|
||||
if (code > 16) {
|
||||
// should never happen
|
||||
|
@ -452,7 +450,7 @@
|
|||
var parts = rawText.split(/(\x19|\x1a|\x1b|\x1c)/);
|
||||
|
||||
// no colors/attributes
|
||||
if (parts.length == 1) {
|
||||
if (parts.length === 1) {
|
||||
return [
|
||||
{
|
||||
attrs: WeeChatProtocol._getDefaultAttributes(),
|
||||
|
@ -479,11 +477,11 @@
|
|||
|
||||
if (firstCharCode >= 0x19 && firstCharCode <= 0x1c) {
|
||||
// special token
|
||||
if (firstCharCode == 0x1c) {
|
||||
if (firstCharCode === 0x1c) {
|
||||
// always reset colors
|
||||
curFgColor = WeeChatProtocol._getDefaultColor();
|
||||
curBgColor = WeeChatProtocol._getDefaultColor();
|
||||
if (curSpecialToken != 0x19) {
|
||||
if (curSpecialToken !== 0x19) {
|
||||
// also reset attributes
|
||||
curAttrs = WeeChatProtocol._getDefaultAttributes();
|
||||
}
|
||||
|
@ -493,7 +491,7 @@
|
|||
}
|
||||
|
||||
var text = p;
|
||||
if (curSpecialToken == 0x19) {
|
||||
if (curSpecialToken === 0x19) {
|
||||
// get new style
|
||||
var style = WeeChatProtocol._getStyle(p);
|
||||
|
||||
|
@ -514,12 +512,12 @@
|
|||
|
||||
// set plain text
|
||||
text = style.text;
|
||||
} else if (curSpecialToken == 0x1a || curSpecialToken == 0x1b) {
|
||||
} else if (curSpecialToken === 0x1a || curSpecialToken === 0x1b) {
|
||||
// set/reset attribute
|
||||
var orideVal = (curSpecialToken == 0x1a);
|
||||
var orideVal = (curSpecialToken === 0x1a);
|
||||
|
||||
// set attribute override if we don't have to keep all of them
|
||||
if (firstChar != '|') {
|
||||
if (firstChar !== '|') {
|
||||
var orideName = WeeChatProtocol._attrNameFromChar(firstChar);
|
||||
if (orideName) {
|
||||
// known attribute
|
||||
|
|
Loading…
Reference in New Issue