Fix eslint warnings

This commit is contained in:
RainLoop Team 2016-04-20 20:12:51 +03:00
parent dd824179f1
commit 72ca818500
35 changed files with 510 additions and 290 deletions

View file

@ -21,7 +21,7 @@ class Audio
this.player = this.createNewObject();
this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play;
if (this.supported && this.player.canPlayType)
if (this.supported && this.player.canPlayType)
{
this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, '');
this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, '');

View file

@ -4,7 +4,8 @@
const BASE_64_CHR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/*jslint bitwise: true*/
/* jslint bitwise: true */
/* eslint-disable */
const Base64 = {
// public method for urlsafe encoding
@ -13,7 +14,7 @@ const Base64 = {
// public method for encoding
encode: (input) => {
let
output = '',
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
@ -164,4 +165,5 @@ const Base64 = {
};
module.exports = Base64;
/*jslint bitwise: false*/
/* jslint bitwise: false */
/* eslint-enable */

View file

@ -1,5 +1,4 @@
import {_} from 'common';
import {Capa, MessageSetAction} from 'Common/Enums';
import Utils from 'Common/Utils';
@ -239,17 +238,17 @@ class CacheUserStorage
if (0 < message.threads().length)
{
const unseenSubUid = _.find(message.threads(), (sSubUid) => {
if (uid !== sSubUid){
const flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
return flags && 0 < flags.length && !!flags[0];
if (uid !== sSubUid) {
const subFlags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
return subFlags && 0 < subFlags.length && !!subFlags[0];
}
return false;
});
const flaggedSubUid = _.find(message.threads(), (sSubUid) => {
if (uid !== sSubUid) {
const flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
return flags && 0 < flags.length && !!flags[1];
const subFlags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid);
return subFlags && 0 < subFlags.length && !!subFlags[1];
}
return false;
});
@ -269,7 +268,7 @@ class CacheUserStorage
this.setMessageFlagsToCache(
message.folderFullNameRaw, message.uid,
[message.unseen(), message.flagged(), message.answered(), message.forwarded(),
message.isReadReceipt(), message.deletedMark()]
message.isReadReceipt(), message.deletedMark()]
);
}
}
@ -293,7 +292,7 @@ class CacheUserStorage
*/
storeMessageFlagsToCacheBySetAction(folder, uid, setAction) {
let unread = 0;
let unread = 0;
const flags = this.getMessageFlagsFromCache(folder, uid);
if (Utils.isArray(flags) && 0 < flags.length)

View file

@ -22,19 +22,25 @@ class CookieDriver
const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME);
storageResult = null === storageValue ? null : JSON.parse(storageValue);
}
catch (e) {}
catch (e)
{
// eslint-disable-line no-empty
}
(storageResult || (storageResult = {}))[key] = data;
try
{
$.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME, JSON.stringify(storageResult), {
'expires': 30
expires: 30
});
result = true;
}
catch (e) {}
catch (e)
{
// eslint-disable-line no-empty
}
return result;
}
@ -43,7 +49,7 @@ class CookieDriver
* @param {string} key
* @return {*}
*/
get(sKey) {
get(key) {
let result = null;
@ -56,10 +62,13 @@ class CookieDriver
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e) {}
catch (e)
{
// eslint-disable-line no-empty
}
return mResult;
};
return result;
}
/**
* @return {boolean}

View file

@ -22,7 +22,10 @@ class LocalStorageDriver
const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null;
storageResult = null === storageValue ? null : JSON.parse(storageValue);
}
catch (e) {}
catch (e)
{
// eslint-disable-line no-empty
}
(storageResult || (storageResult = {}))[key] = data;
@ -31,7 +34,10 @@ class LocalStorageDriver
window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult);
result = true;
}
catch (e) {}
catch (e)
{
// eslint-disable-line no-empty
}
return result;
}
@ -41,19 +47,22 @@ class LocalStorageDriver
* @return {*}
*/
get(key) {
let result = null;
try
{
const
const
storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null,
storageResult = null === storageValue ? null : JSON.parse(storageValue)
;
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null
result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e)
{
// eslint-disable-line no-empty
}
catch (e) {}
return result;
}

View file

@ -1,7 +1,9 @@
/* eslint max-len: 0 */
export const MESSAGES_PER_PAGE = 20;
export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100/*, 150, 200, 300*/];
export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100];
export const CONTACTS_PER_PAGE = 50;

View file

@ -1,4 +1,6 @@
/* eslint quote-props: 0 */
/**
* @enum {string}
*/
@ -18,7 +20,7 @@ export const FileType = {
'Certificate': 'certificate',
'CertificateBin': 'certificate-bin',
'Archive': 'archive'
}
};
/**
* @enum {string}
@ -28,7 +30,7 @@ export const StorageResultType = {
'Abort': 'abort',
'Error': 'error',
'Unload': 'unload'
}
};
/**
* @enum {string}
@ -38,7 +40,7 @@ export const Focused = {
'MessageList': 'message-list',
'MessageView': 'message-view',
'FolderList': 'folder-list'
}
};
/**
* @enum {number}
@ -47,7 +49,7 @@ export const State = {
'Empty': 10,
'Login': 20,
'Auth': 30
}
};
/**
* @enum {number}
@ -55,7 +57,7 @@ export const State = {
export const StateType = {
'Webmail': 0,
'Admin': 1
}
};
/**
* @enum {string}
@ -87,7 +89,7 @@ export const Capa = {
'AutoLogout': 'AUTOLOGOUT',
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
'Identities': 'IDENTITIES'
}
};
/**
* @enum {string}
@ -107,7 +109,7 @@ export const KeyState = {
'PopupViewOpenPGP': 'view-open-pgp',
'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help',
'PopupAsk': 'popup-ask'
}
};
/**
* @enum {number}
@ -121,7 +123,7 @@ export const FolderType = {
'Archive': 15,
'NotSpam': 80,
'User': 99
}
};
/**
* @enum {number}
@ -136,7 +138,7 @@ export const ServerFolderType = {
'IMPORTANT': 10,
'FLAGGED': 11,
'ALL': 12
}
};
/**
* @enum {string}
@ -145,7 +147,7 @@ export const LoginSignMeTypeAsString = {
'DefaultOff': 'defaultoff',
'DefaultOn': 'defaulton',
'Unused': 'unused'
}
};
/**
* @enum {number}
@ -154,7 +156,7 @@ export const LoginSignMeType = {
'DefaultOff': 0,
'DefaultOn': 1,
'Unused': 2
}
};
/**
* @enum {string}
@ -167,7 +169,7 @@ export const ComposeType = {
'ForwardAsAttachment': 'forward-as-attachment',
'Draft': 'draft',
'EditAsNew': 'editasnew'
}
};
/**
* @enum {number}
@ -181,7 +183,7 @@ export const UploadErrorCode = {
'FileOnSaveingError': 5,
'FileType': 98,
'Unknown': 99
}
};
/**
* @enum {number}
@ -193,7 +195,7 @@ export const SetSystemFoldersNotification = {
'Spam': 3,
'Trash': 4,
'Archive': 5
}
};
/**
* @enum {number}
@ -208,7 +210,7 @@ export const ClientSideKeyName = {
'LastReplyAction': 6,
'LastSignMe': 7,
'ComposeLastIdentityID': 8
}
};
/**
* @enum {number}
@ -231,7 +233,7 @@ export const EventKeyCode = {
'Delete': 46,
'A': 65,
'S': 83
}
};
/**
* @enum {number}
@ -241,7 +243,7 @@ export const MessageSetAction = {
'UnsetSeen': 1,
'SetFlag': 2,
'UnsetFlag': 3
}
};
/**
* @enum {number}
@ -254,7 +256,7 @@ export const MessageSelectAction = {
'Seen': 4,
'Flagged': 5,
'Unflagged': 6
}
};
/**
* @enum {number}
@ -264,7 +266,7 @@ export const DesktopNotification = {
'NotAllowed': 1,
'Denied': 2,
'NotSupported': 9
}
};
/**
* @enum {number}
@ -273,7 +275,7 @@ export const MessagePriority = {
'Low': 5,
'Normal': 3,
'High': 1
}
};
/**
* @enum {string}
@ -283,7 +285,7 @@ export const EditorDefaultType = {
'Plain': 'Plain',
'HtmlForced': 'HtmlForced',
'PlainForced': 'PlainForced'
}
};
/**
* @enum {number}
@ -292,7 +294,7 @@ export const ServerSecure = {
'None': 0,
'SSL': 1,
'TLS': 2
}
};
/**
* @enum {number}
@ -302,7 +304,7 @@ export const SearchDateType = {
'Days3': 3,
'Days7': 7,
'Month': 30
}
};
/**
* @enum {number}
@ -312,7 +314,7 @@ export const SaveSettingsStep = {
'Idle': -1,
'TrueResult': 1,
'FalseResult': 0
}
};
/**
* @enum {number}
@ -322,7 +324,7 @@ export const Layout = {
'SidePreview': 1,
'BottomPreview': 2,
'Mobile': 3
}
};
/**
* @enum {string}
@ -333,7 +335,7 @@ export const FilterConditionField = {
'Subject': 'Subject',
'Header': 'Header',
'Size': 'Size'
}
};
/**
* @enum {string}
@ -345,7 +347,7 @@ export const FilterConditionType = {
'NotEqualTo': 'NotEqualTo',
'Over': 'Over',
'Under': 'Under'
}
};
/**
* @enum {string}
@ -357,7 +359,7 @@ export const FiltersAction = {
'Vacation': 'Vacation',
'Reject': 'Reject',
'Forward': 'Forward'
}
};
/**
* @enum {string}
@ -365,7 +367,7 @@ export const FiltersAction = {
export const FilterRulesType = {
'All': 'All',
'Any': 'Any'
}
};
/**
* @enum {number}
@ -377,7 +379,7 @@ export const SignedVerifyStatus = {
'Error': -1,
'None': 0,
'Success': 1
}
};
/**
* @enum {number}
@ -409,7 +411,7 @@ export const ContactPropertyType = {
'Note': 110,
'Custom': 250
}
};
/**
* @enum {number}
@ -489,4 +491,4 @@ export const Notification = {
'UnknownNotification': 999,
'UnknownError': 999
}
};

View file

@ -1,5 +1,5 @@
import {window, _} from 'common';
import {window, _, $} from 'common';
import Globals from 'Common/Globals';
import Settings from 'Storage/Settings';
@ -9,7 +9,7 @@ class HtmlEditor
$element = null;
blurTimer = 0;
onBlur = null;
onReady = null;
onModeChange = null;
@ -70,9 +70,9 @@ class HtmlEditor
if (this.editor)
{
this.editor.execCommand('insertSignature', {
'isHtml': html,
'insertBefore': insertBefore,
'signature': signature
isHtml: html,
insertBefore: insertBefore,
signature: signature
});
}
}
@ -117,12 +117,11 @@ class HtmlEditor
}
else
{
result = wrapIsHtml ?
result = wrapIsHtml ?
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
this.editor.getData() + '</div>' : this.editor.getData();
}
}
catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
if (clearSignatureSigns)
{
@ -160,7 +159,7 @@ class HtmlEditor
this.editor.setMode('plain');
}
}
} catch(e) {}
} catch (e) {/* eslint-disable-line no-empty */}
if (resize)
{
@ -189,7 +188,7 @@ class HtmlEditor
try {
this.editor.setData(html);
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
if (focus)
{
@ -204,7 +203,7 @@ class HtmlEditor
try {
this.editor.setData(
this.editor.getData().replace(find, replaceHtml));
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -214,13 +213,13 @@ class HtmlEditor
this.modeToggle(false);
if ('plain' === this.editor.mode && this.editor.plugins.plain && this.editor.__plain)
{
return this.editor.__plain.setRawData(plain);
this.editor.__plain.setRawData(plain);
}
else
{
try {
this.editor.setData(plain);
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
if (focus)
@ -254,7 +253,7 @@ class HtmlEditor
if (!biti)
{
config.removePlugins += (config.removePlugins ? ',' : '') + 'bidi';
config.removePlugins += (config.removePlugins ? ',' : '') + 'bidi';
}
}
@ -294,7 +293,7 @@ class HtmlEditor
if (window.FileReader)
{
this.editor.on('drop', (event) => {
this.editor.on('drop', (event) => {
if (0 < event.data.dataTransfer.getFilesCount())
{
const file = event.data.dataTransfer.getFile(0);
@ -304,7 +303,7 @@ class HtmlEditor
var
id = event.data.dataTransfer.id,
imageId = `[img=${id}]`,
reader = new window.FileReader()
reader = new window.FileReader()
;
reader.onloadend = () => {
@ -361,7 +360,7 @@ class HtmlEditor
{
try {
this.editor.focus();
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -370,7 +369,7 @@ class HtmlEditor
{
try {
return !!this.editor.focusManager.hasFocus;
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
return false;
@ -381,7 +380,7 @@ class HtmlEditor
{
try {
this.editor.focusManager.blur(true);
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -390,7 +389,7 @@ class HtmlEditor
{
try {
this.editor.resize(this.$element.width(), this.$element.innerHeight());
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -399,7 +398,7 @@ class HtmlEditor
{
try {
this.editor.setReadOnly(!!value);
} catch (e) {}
} catch (e) {/* eslint-disable-line no-empty */}
}
}

View file

@ -314,7 +314,7 @@ class Links
* @return {string}
*/
sound(fileName) {
return this.sStaticPrefix + 'sounds/' + fileName;
return this.sStaticPrefix + 'sounds/' + fileName;
}
/**

View file

@ -1,6 +1,8 @@
/* eslint key-spacing: 0 */
/* eslint quote-props: 0 */
module.exports = {
'eml' : 'message/rfc822',
'mime' : 'message/rfc822',
'txt' : 'text/plain',
@ -159,5 +161,4 @@ module.exports = {
// open office
'odt' : 'application/vnd.oasis.opendocument.text',
'ods' : 'application/vnd.oasis.opendocument.spreadsheet'
};

View file

@ -53,11 +53,11 @@ class Momentor
return m.fromNow();
case now.format('L') === m.format('L'):
return Translator.i18n('MESSAGE_LIST/TODAY_AT', {
'TIME': m.format('LT')
TIME: m.format('LT')
});
case now.clone().subtract('days', 1).format('L') === m.format('L'):
return Translator.i18n('MESSAGE_LIST/YESTERDAY_AT', {
'TIME': m.format('LT')
TIME: m.format('LT')
});
case now.year() === m.year():
return m.format('D MMM.');

View file

@ -23,7 +23,7 @@ class Selector
this.listChecked = ko.computed(() => {
return _.filter(this.list(), (item) => item.checked());
}, this).extend({'rateLimit': 0});
}, this).extend({rateLimit: 0});
this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
@ -77,7 +77,7 @@ class Selector
}, this);
this.selectedItem = this.selectedItem.extend({'toggleSubscribe': [null,
this.selectedItem = this.selectedItem.extend({toggleSubscribe: [null,
(prev) => {
if (prev)
{
@ -91,7 +91,7 @@ class Selector
}
]});
this.focusedItem = this.focusedItem.extend({'toggleSubscribe': [null,
this.focusedItem = this.focusedItem.extend({toggleSubscribe: [null,
(prev) => {
if (prev)
{
@ -291,14 +291,14 @@ class Selector
{
if (!item)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(item || null);
(this.oCallbacks.onItemSelect || this.emptyFunction)(item || null);
}
}
else
{
if (item)
{
(this.oCallbacks['onItemSelect'] || this.emptyFunction)(item);
(this.oCallbacks.onItemSelect || this.emptyFunction)(item);
}
}
}
@ -416,14 +416,14 @@ class Selector
* @return {boolean}
*/
autoSelect() {
return !!(this.oCallbacks['onAutoSelect'] || this.emptyTrueFunction)();
return !!(this.oCallbacks.onAutoSelect || this.emptyTrueFunction)();
}
/**
* @param {boolean} up
*/
doUpUpOrDownDown(up) {
(this.oCallbacks['onUpUpOrDownDown'] || this.emptyTrueFunction)(!!up);
(this.oCallbacks.onUpUpOrDownDown || this.emptyTrueFunction)(!!up);
}
/**
@ -434,7 +434,7 @@ class Selector
let uid = '';
const getItemUidCallback = this.oCallbacks['onItemGetUid'] || null;
const getItemUidCallback = this.oCallbacks.onItemGetUid || null;
if (getItemUidCallback && item)
{
uid = getItemUidCallback(item);
@ -465,18 +465,22 @@ class Selector
{
if (!oFocused)
{
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode || EventKeyCode.PageUp === iEventKeyCode)
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode ||
EventKeyCode.Space === iEventKeyCode || EventKeyCode.Home === iEventKeyCode ||
EventKeyCode.PageUp === iEventKeyCode)
{
oResult = aList[0];
}
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode || EventKeyCode.PageDown === iEventKeyCode)
else if (EventKeyCode.Up === iEventKeyCode || EventKeyCode.End === iEventKeyCode ||
EventKeyCode.PageDown === iEventKeyCode)
{
oResult = aList[aList.length - 1];
}
}
else if (oFocused)
{
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode || EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
if (EventKeyCode.Down === iEventKeyCode || EventKeyCode.Up === iEventKeyCode ||
EventKeyCode.Insert === iEventKeyCode || EventKeyCode.Space === iEventKeyCode)
{
_.each(aList, (item) => {
if (!bStop)
@ -649,7 +653,7 @@ class Selector
}
else
{
this.oContentScrollable.stop().animate({'scrollTop': 0}, 200);
this.oContentScrollable.stop().animate({scrollTop: 0}, 200);
}
return true;

View file

@ -11,7 +11,7 @@ class Translator
notificationI18N = {};
constructor() {
this.data = window['rainloopI18N'] || {};
this.data = window.rainloopI18N || {};
this.trigger = ko.observable(false);
this.i18n = _.bind(this.i18n, this);
this.init();
@ -27,9 +27,14 @@ class Translator
let
valueName = '',
result = _.isUndefined(this.data[key]) ? (_.isUndefined(defaulValue) ? key : defaulValue) : this.data[key]
result = this.data[key]
;
if (_.isUndefined(result))
{
result = _.isUndefined(defaulValue) ? key : defaulValue;
}
if (!_.isUndefined(valueList) && !_.isNull(valueList))
{
for (valueName in valueList)
@ -92,16 +97,21 @@ class Translator
if (animate && Globals.bAnimationSupported)
{
$('.i18n-animation[data-i18n]', elements).letterfx({
'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
fx: 'fall fade',
backwards: false,
timing: 50,
fx_duration: '50ms',
letter_end: 'restore',
element_end: 'restore'
});
}
});
}
reloadData() {
if (window['rainloopI18N'])
if (window.rainloopI18N)
{
this.data = window['rainloopI18N'] || {};
this.data = window.rainloopI18N || {};
this.i18nToNodes(window.document, true);
@ -109,7 +119,7 @@ class Translator
this.trigger(!this.trigger());
}
window['rainloopI18N'] = null;
window.rainloopI18N = null;
}
initNotificationLanguage() {
@ -299,9 +309,9 @@ class Translator
Globals.$html.addClass('rl-changing-language');
$.ajax({
'url': require('Common/Links').langLink(language, admin),
'dataType': 'script',
'cache': true
url: require('Common/Links').langLink(language, admin),
dataType: 'script',
cache: true
})
.fail(fail || Utils.emptyFunction)
.done(function () {

View file

@ -30,6 +30,21 @@
Utils.isNull = _.isNull;
Utils.emptyFunction = Utils.noop = function () {};
/**
* @param {Function} callback
*/
Utils.silentTryCatch = function (callback)
{
try
{
callback();
}
catch (e)
{
// eslint-disable-line no-empty
}
};
/**
* @param {*} oValue
* @return {boolean}
@ -576,16 +591,17 @@
Utils.createCommand = function (oContext, fExecute, fCanExecute)
{
var
fResult = Utils.emptyFunction,
fNonEmpty = function () {
if (fResult && fResult.canExecute && fResult.canExecute())
{
fExecute.apply(oContext, Array.prototype.slice.call(arguments));
}
return false;
},
fResult = fExecute ? fNonEmpty : Utils.emptyFunction
}
;
fResult = fExecute ? fNonEmpty : Utils.emptyFunction;
fResult.enabled = ko.observable(true);
fCanExecute = Utils.isUnd(fCanExecute) ? true : fCanExecute;