From 2ba34532c278f3d7680fd2daa08798c53d5b1951 Mon Sep 17 00:00:00 2001 From: djmaze Date: Tue, 28 Jul 2020 17:20:14 +0200 Subject: [PATCH] JavaScript string compare '' is always a ToBoolean See https://www.ecma-international.org/ecma-262/5.1/#sec-9.2 --- README.md | 24 ++++++++-------- dev/App/User.js | 14 ++++----- dev/Common/Audio.js | 8 +++--- dev/Common/Cache.js | 14 ++++----- dev/Common/Links.js | 4 +-- dev/Common/Selector.js | 6 ++-- dev/Common/Utils.js | 12 ++++---- dev/External/ko.js | 20 ++++++------- dev/Helper/Message.js | 2 +- dev/Knoin/Knoin.js | 10 +++---- dev/Model/Attachment.js | 2 +- dev/Model/ComposeAttachment.js | 3 +- dev/Model/Contact.js | 4 +-- dev/Model/Email.js | 12 ++++---- dev/Model/Filter.js | 10 +++---- dev/Model/FilterCondition.js | 4 +-- dev/Model/Folder.js | 4 +-- dev/Model/Identity.js | 4 +-- dev/Model/Message.js | 10 +++---- dev/Promises/User/Populator.js | 7 ++--- dev/Remote/AbstractAjax.js | 2 +- dev/Remote/User/Ajax.js | 6 ++-- dev/Screen/User/MailBox.js | 12 ++++---- dev/Screen/User/Settings.js | 2 +- dev/Settings/Admin/Contacts.js | 2 +- dev/Settings/Admin/Packages.js | 6 ++-- dev/Settings/Admin/Plugins.js | 2 +- dev/Settings/Admin/Security.js | 4 +-- dev/Settings/User/Filters.js | 2 +- dev/Settings/User/Folders.js | 2 +- dev/Settings/User/General.js | 2 +- dev/Settings/User/Templates.js | 2 +- dev/Stores/User/Account.js | 2 +- dev/Stores/User/Folder.js | 12 ++++---- dev/Stores/User/Message.js | 16 +++++------ dev/View/Admin/Login.js | 4 +-- dev/View/Popup/Account.js | 4 +-- dev/View/Popup/Activate.js | 4 +-- dev/View/Popup/AddOpenPgpKey.js | 2 +- dev/View/Popup/AdvancedSearch.js | 10 +++---- dev/View/Popup/Compose.js | 30 ++++++++++---------- dev/View/Popup/ComposeOpenPgp.js | 8 +++--- dev/View/Popup/Contacts.js | 12 ++++---- dev/View/Popup/Domain.js | 25 ++++++++-------- dev/View/Popup/DomainAlias.js | 4 +-- dev/View/Popup/FolderCreate.js | 4 +-- dev/View/Popup/Identity.js | 4 +-- dev/View/Popup/NewOpenPgpKey.js | 4 +-- dev/View/Popup/Plugin.js | 2 +- dev/View/Popup/Template.js | 4 +-- dev/View/Popup/TwoFactorTest.js | 2 +- dev/View/User/Login.js | 18 ++++++------ dev/View/User/MailBox/FolderList.js | 2 +- dev/View/User/MailBox/MessageList.js | 24 ++++++++-------- dev/View/User/MailBox/MessageView.js | 8 +++--- vendors/ckeditor-plugins/signature/plugin.js | 6 ++-- vendors/jua/jua.js | 2 +- 57 files changed, 213 insertions(+), 218 deletions(-) diff --git a/README.md b/README.md index 67cc42c9d..cd2284f0e 100644 --- a/README.md +++ b/README.md @@ -61,23 +61,23 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf |js/* |1.14.0 |native | |----------- |--------: |--------: | -|admin.js |2.130.942 |1.359.501 | -|app.js |4.184.455 |3.121.743 | +|admin.js |2.130.942 |1.356.246 | +|app.js |4.184.455 |3.117.728 | |boot.js | 671.522 | 109.651 | |libs.js | 647.614 | 508.324 | |polyfills.js | 325.834 | 0 | -|TOTAL js |7.960.367 |5.097.142 | +|TOTAL js |7.960.367 |5.091.949 | -|js/min/* |1.14.0 |native | -|----------- |--------: |--------: | -|admin.js | 252.147 | 177.094 | -|app.js | 511.202 | 409.173 | -|boot.js | 66.007 | 13.380 | -|libs.js | 572.545 | 465.247 | -|polyfills.js | 32.452 | 0 | -|TOTAL js/min |1.434.353 |1.064.753 | +|js/min/* |1.14.0 |native | +|--------------- |--------: |--------: | +|admin.min.js | 252.147 | 176.702 | +|app.min.js | 511.202 | 408.359 | +|boot.min.js | 66.007 | 13.380 | +|libs.min.js | 572.545 | 465.247 | +|polyfills.min.js | 32.452 | 0 | +|TOTAL js/min |1.434.353 |1.063.688 | -369.600 bytes is not much, but it feels faster. +370.665 bytes is not much, but it feels faster. ### PHP73 branch diff --git a/dev/App/User.js b/dev/App/User.js index b375629a9..cc8d72d7f 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -581,9 +581,7 @@ class AppUser extends AbstractApp { if (StorageResultType.Success === sResult && oData.Result) { const counts = {}, sAccountEmail = AccountStore.email(); - let parentEmail = Settings.settingsGet('ParentEmail'); - - parentEmail = '' === parentEmail ? sAccountEmail : parentEmail; + let parentEmail = Settings.settingsGet('ParentEmail') || sAccountEmail; if (isArray(oData.Result.Accounts)) { AccountStore.accounts().forEach(oAccount => { @@ -667,7 +665,7 @@ class AppUser extends AbstractApp { * @param {Array=} list = [] */ folderInformation(folder, list) { - if ('' !== trim(folder)) { + if (trim(folder)) { Remote.folderInformation( (result, data) => { if (StorageResultType.Success === result) { @@ -727,7 +725,7 @@ class AppUser extends AbstractApp { ); const hash = getFolderHash(data.Result.Folder); - if (data.Result.Hash !== hash || '' === hash || unreadCountChange) { + if (!hash || unreadCountChange || data.Result.Hash !== hash) { if (folderFromCache.fullNameRaw === FolderStore.currentFolderFullNameRaw()) { this.reloadMessageList(); } else if (getFolderInboxName() === folderFromCache.fullNameRaw) { @@ -782,7 +780,7 @@ class AppUser extends AbstractApp { clearMessageFlagsFromCacheByFolder(folder.fullNameRaw); } - if (item.Hash !== hash || '' === hash) { + if (!hash || item.Hash !== hash) { if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw()) { this.reloadMessageList(); } @@ -823,7 +821,7 @@ class AppUser extends AbstractApp { rootUids = messages.map(oMessage => oMessage && oMessage.uid ? oMessage.uid : null) .filter((value, index, self) => !!value && self.indexOf(value) == index); - if ('' !== sFolderFullNameRaw && rootUids.length) { + if (sFolderFullNameRaw && rootUids.length) { switch (iSetAction) { case MessageSetAction.SetSeen: rootUids.forEach(sSubUid => { @@ -1083,7 +1081,7 @@ class AppUser extends AbstractApp { this.bootend(); if (value) { - if ('' !== startupUrl) { + if (startupUrl) { routeOff(); setHash(root(startupUrl), true); routeOn(); diff --git a/dev/Common/Audio.js b/dev/Common/Audio.js index 8a8565baf..eb05e9b8e 100644 --- a/dev/Common/Audio.js +++ b/dev/Common/Audio.js @@ -19,9 +19,9 @@ class Audio { this.supported = !bMobileDevice && !bSafari && !!this.player && !!this.player.play; if (this.supported && this.player && this.player.canPlayType) { - this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, ''); - this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, ''); - this.supportedOgg = '' !== this.player.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, ''); + this.supportedMp3 = !!this.player.canPlayType('audio/mpeg;').replace(/no/, ''); + this.supportedWav = !!this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, ''); + this.supportedOgg = !!this.player.canPlayType('audio/ogg; codecs="vorbis"').replace(/no/, ''); this.supportedNotification = this.supported && this.supportedMp3; } @@ -81,7 +81,7 @@ class Audio { name = trim(name.substr(0, name.length - 4)); } - return '' === name ? 'audio' : name; + return name || 'audio'; } playMp3(url, name) { diff --git a/dev/Common/Cache.js b/dev/Common/Cache.js index 6702b6d4e..d706d849d 100644 --- a/dev/Common/Cache.js +++ b/dev/Common/Cache.js @@ -89,7 +89,7 @@ export function clearNewMessageCache() { * @returns {string} */ export function getFolderInboxName() { - return '' === inboxFolderName ? 'INBOX' : inboxFolderName; + return inboxFolderName || 'INBOX'; } /** @@ -97,7 +97,7 @@ export function getFolderInboxName() { * @returns {string} */ export function getFolderFullNameRaw(folderHash) { - return '' !== folderHash && FOLDERS_NAME_CACHE[folderHash] ? FOLDERS_NAME_CACHE[folderHash] : ''; + return folderHash && FOLDERS_NAME_CACHE[folderHash] ? FOLDERS_NAME_CACHE[folderHash] : ''; } /** @@ -106,7 +106,7 @@ export function getFolderFullNameRaw(folderHash) { */ export function setFolderFullNameRaw(folderHash, folderFullNameRaw) { FOLDERS_NAME_CACHE[folderHash] = folderFullNameRaw; - if ('INBOX' === folderFullNameRaw || '' === inboxFolderName) { + if (!inboxFolderName || 'INBOX' === folderFullNameRaw) { inboxFolderName = folderFullNameRaw; } } @@ -116,7 +116,7 @@ export function setFolderFullNameRaw(folderHash, folderFullNameRaw) { * @returns {string} */ export function getFolderHash(folderFullNameRaw) { - return '' !== folderFullNameRaw && FOLDERS_HASH_CACHE[folderFullNameRaw] ? FOLDERS_HASH_CACHE[folderFullNameRaw] : ''; + return folderFullNameRaw && FOLDERS_HASH_CACHE[folderFullNameRaw] ? FOLDERS_HASH_CACHE[folderFullNameRaw] : ''; } /** @@ -124,7 +124,7 @@ export function getFolderHash(folderFullNameRaw) { * @param {string} folderHash */ export function setFolderHash(folderFullNameRaw, folderHash) { - if ('' !== folderFullNameRaw) { + if (folderFullNameRaw) { FOLDERS_HASH_CACHE[folderFullNameRaw] = folderHash; } } @@ -134,7 +134,7 @@ export function setFolderHash(folderFullNameRaw, folderHash) { * @returns {string} */ export function getFolderUidNext(folderFullNameRaw) { - return '' !== folderFullNameRaw && FOLDERS_UID_NEXT_CACHE[folderFullNameRaw] + return folderFullNameRaw && FOLDERS_UID_NEXT_CACHE[folderFullNameRaw] ? FOLDERS_UID_NEXT_CACHE[folderFullNameRaw] : ''; } @@ -152,7 +152,7 @@ export function setFolderUidNext(folderFullNameRaw, uidNext) { * @returns {?FolderModel} */ export function getFolderFromCacheList(folderFullNameRaw) { - return '' !== folderFullNameRaw && FOLDERS_CACHE[folderFullNameRaw] ? FOLDERS_CACHE[folderFullNameRaw] : null; + return folderFullNameRaw && FOLDERS_CACHE[folderFullNameRaw] ? FOLDERS_CACHE[folderFullNameRaw] : null; } /** diff --git a/dev/Common/Links.js b/dev/Common/Links.js index 011e86322..b87af628c 100644 --- a/dev/Common/Links.js +++ b/dev/Common/Links.js @@ -371,7 +371,7 @@ export function mailBox(folder, page = 1, search = '', threadUid = '') { let result = HASH_PREFIX + 'mailbox/'; - if ('' !== folder) { + if (folder) { const resultThreadUid = pInt(threadUid); result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : ''); } @@ -381,7 +381,7 @@ export function mailBox(folder, page = 1, search = '', threadUid = '') { result += '/p' + page; } - if ('' !== search) { + if (search) { result = result.replace(/[/]+$/, ''); result += '/' + window.encodeURI(search); } diff --git a/dev/Common/Selector.js b/dev/Common/Selector.js index 9c8828493..ad6553323 100644 --- a/dev/Common/Selector.js +++ b/dev/Common/Selector.js @@ -561,7 +561,7 @@ class Selector { const uid = this.getItemUid(item); if (event && event.shiftKey) { - if ('' !== uid && '' !== this.sLastUid && uid !== this.sLastUid) { + if (uid && this.sLastUid && uid !== this.sLastUid) { list = this.list(); checked = item.checked(); @@ -585,7 +585,7 @@ class Selector { } } - this.sLastUid = '' === uid ? '' : uid; + this.sLastUid = uid || ''; } /** @@ -598,7 +598,7 @@ class Selector { if (event) { if (event.shiftKey && !(event.ctrlKey || event.metaKey) && !event.altKey) { click = false; - if ('' === this.sLastUid) { + if (!this.sLastUid) { this.sLastUid = this.getItemUid(item); } diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index da8b41e19..a34a74ed8 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -68,7 +68,7 @@ export function isPosNumeric(value, includeZero = true) { * @returns {number} */ export function pInt(value, defaultValur = 0) { - const result = isNormal(value) && '' !== value ? window.parseInt(value, 10) : defaultValur; + const result = isNormal(value) && value ? window.parseInt(value, 10) : defaultValur; return window.isNaN(result) ? defaultValur : result; } @@ -309,7 +309,7 @@ export function replySubjectAdd(prefix, subject) { const parts = [], prefixIsRe = !fwd; - if ('' !== subject) { + if (subject) { subject.split(':').forEach(part => { const trimmedPart = trim(part); if (!drop && (/^(RE|FWD)$/i.test(trimmedPart) || /^(RE|FWD)[[(][\d]+[\])]$/i.test(trimmedPart))) { @@ -814,7 +814,7 @@ export function plainToHtml(plain, findEmailAndLinksInText = false) { aNextText.push('~~~blockquote~~~'); aNextText.push(sLine.substr(1)); } else if (!bStart && bIn) { - if ('' !== sLine) { + if (sLine) { bIn = false; aNextText.push('~~~/blockquote~~~'); aNextText.push(sLine); @@ -1191,9 +1191,9 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount) { fAdd = (index, push = true, customName = '') => { const data = { current: index === currentPage, - name: '' === customName ? index.toString() : customName.toString(), - custom: '' !== customName, - title: '' === customName ? '' : index.toString(), + name: customName ? customName.toString() : index.toString(), + custom: !!customName, + title: customName ? index.toString() : '', value: index.toString() }; diff --git a/dev/External/ko.js b/dev/External/ko.js index bafadcb55..7d2cfca8e 100644 --- a/dev/External/ko.js +++ b/dev/External/ko.js @@ -160,12 +160,12 @@ ko.bindingHandlers.tooltip = { } }); - if ('' === sValue) { + if (sValue) { + element.__opentip.activate(); + } else { element.__opentip.hide(); element.__opentip.deactivate(); element.__opentip.setContent(''); - } else { - element.__opentip.activate(); } if (isI18N) { @@ -245,11 +245,7 @@ ko.bindingHandlers.tooltipErrorTip = { openTips = element.__opentip; if (openTips) { - if ('' === value) { - openTips.hide(); - openTips.deactivate(); - openTips.setContent(''); - } else { + if (value) { setTimeout(() => { if ($el.is(':visible')) { openTips.setContent(value); @@ -261,6 +257,10 @@ ko.bindingHandlers.tooltipErrorTip = { openTips.setContent(''); } }, Magics.Time100ms); + } else { + openTips.hide(); + openTips.deactivate(); + openTips.setContent(''); } } } @@ -1087,7 +1087,7 @@ ko.observable.fn.validateEmail = function() { this.hasError = ko.observable(false); this.subscribe((value) => { - this.hasError('' !== value && !/^[^@\s]+@[^@\s]+$/.test(value)); + this.hasError(value && !/^[^@\s]+@[^@\s]+$/.test(value)); }); this.valueHasMutated(); @@ -1098,7 +1098,7 @@ ko.observable.fn.validateSimpleEmail = function() { this.hasError = ko.observable(false); this.subscribe((value) => { - this.hasError('' !== value && !/^.+@.+$/.test(value)); + this.hasError(value && !/^.+@.+$/.test(value)); }); this.valueHasMutated(); diff --git a/dev/Helper/Message.js b/dev/Helper/Message.js index d6269493f..8dd5e25e5 100644 --- a/dev/Helper/Message.js +++ b/dev/Helper/Message.js @@ -24,7 +24,7 @@ export function emailArrayToStringClear(emails) { const result = []; if (isNonEmptyArray(emails)) { emails.forEach(email => { - if (email && email.email && '' !== email.name) { + if (email && email.email && email.name) { result.push(email.email); } }); diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index 87f94fdef..88609868b 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -95,7 +95,7 @@ export function routeOn() { * @returns {?Object} */ export function screen(screenName) { - return '' !== screenName && !isUnd(SCREENS[screenName]) ? SCREENS[screenName] : null; + return screenName && !isUnd(SCREENS[screenName]) ? SCREENS[screenName] : null; } /** @@ -288,11 +288,11 @@ export function screenOnRoute(screenName, subPart) { isSameScreen = false, cross = null; - if ('' === pString(screenName)) { + if (!pString(screenName)) { screenName = defaultScreenName; } - if ('' !== screenName) { + if (screenName) { vmScreen = screen(screenName); if (!vmScreen) { vmScreen = screen(defaultScreenName); @@ -404,8 +404,8 @@ export function startScreens(screensClasses) { const vmScreen = new CScreen(), screenName = vmScreen ? vmScreen.screenName() : ''; - if (vmScreen && '' !== screenName) { - if ('' === defaultScreenName) { + if (vmScreen && screenName) { + if (!defaultScreenName) { defaultScreenName = screenName; } diff --git a/dev/Model/Attachment.js b/dev/Model/Attachment.js index 1511588e4..98db93347 100644 --- a/dev/Model/Attachment.js +++ b/dev/Model/Attachment.js @@ -361,7 +361,7 @@ class AttachmentModel extends AbstractModel { */ linkThumbnailPreviewStyle() { const link = this.linkThumbnail(); - return '' === link ? '' : 'background:url(' + link + ')'; + return link ? 'background:url(' + link + ')' : ''; } /** diff --git a/dev/Model/ComposeAttachment.js b/dev/Model/ComposeAttachment.js index f6c1342d7..e3fcf006c 100644 --- a/dev/Model/ComposeAttachment.js +++ b/dev/Model/ComposeAttachment.js @@ -46,8 +46,7 @@ class ComposeAttachmentModel extends AbstractModel { }); this.title = ko.computed(() => { - const error = this.error(); - return '' !== error ? error : this.fileName(); + return this.error() || this.fileName(); }); this.friendlySize = ko.computed(() => { diff --git a/dev/Model/Contact.js b/dev/Model/Contact.js index f9ffbcf5d..9303fa898 100644 --- a/dev/Model/Contact.js +++ b/dev/Model/Contact.js @@ -35,14 +35,14 @@ class ContactModel extends AbstractModel { name = trim(property[1] + ' ' + name); } else if (ContactPropertyType.LastName === property[0]) { name = trim(name + ' ' + property[1]); - } else if ('' === email && ContactPropertyType.Email === property[0]) { + } else if (!email && ContactPropertyType.Email === property[0]) { email = property[1]; } } }); } - return '' === email ? null : [email, name]; + return email ? [email, name] : null; } /** diff --git a/dev/Model/Email.js b/dev/Model/Email.js index 31bbf25f9..aa4d52fd5 100644 --- a/dev/Model/Email.js +++ b/dev/Model/Email.js @@ -47,7 +47,7 @@ class EmailModel { * @returns {boolean} */ validate() { - return '' !== this.name || '' !== this.email; + return this.name || this.email; } /** @@ -87,7 +87,7 @@ class EmailModel { this.dkimStatus = trim(json.DkimStatus || ''); this.dkimValue = trim(json.DkimValue || ''); - result = '' !== this.email; + result = !!this.email; this.clearDuplicateName(); } @@ -102,8 +102,8 @@ class EmailModel { */ toLine(friendlyView, wrapWithLink = false, useEncodeHtml = false) { let result = ''; - if ('' !== this.email) { - if (friendlyView && '' !== this.name) { + if (this.email) { + if (friendlyView && this.name) { result = wrapWithLink ? '' + encodeHtml(this.name) + '' : (useEncodeHtml ? encodeHtml(this.name) : this.name); } else { result = this.email; - if ('' !== this.name) { + if (this.name) { if (wrapWithLink) { result = encodeHtml('"' + this.name + '" <') + @@ -197,7 +197,7 @@ class EmailModel { */ parse(emailAddress) { emailAddress = trim(emailAddress); - if ('' === emailAddress) { + if (!emailAddress) { return false; } diff --git a/dev/Model/Filter.js b/dev/Model/Filter.js index 0c483e3da..5171f88b5 100644 --- a/dev/Model/Filter.js +++ b/dev/Model/Filter.js @@ -118,13 +118,13 @@ class FilterModel extends AbstractModel { this.regDisposables( this.name.subscribe((sValue) => { - this.name.error('' === sValue); + this.name.error(!sValue); }) ); this.regDisposables( this.actionValue.subscribe((sValue) => { - this.actionValue.error('' === sValue); + this.actionValue.error(!sValue); }) ); @@ -139,7 +139,7 @@ class FilterModel extends AbstractModel { } verify() { - if ('' === this.name()) { + if (!this.name()) { this.name.error(true); return false; } @@ -150,7 +150,7 @@ class FilterModel extends AbstractModel { } } - if ('' === this.actionValue()) { + if (!this.actionValue()) { if ([ FiltersAction.MoveTo, FiltersAction.Forward, @@ -170,7 +170,7 @@ class FilterModel extends AbstractModel { if ( FiltersAction.Vacation === this.actionType() && - '' !== this.actionValueFourth() && + this.actionValueFourth() && !this.actionValueFourth().includes('@') ) { this.actionValueFourth.error(true); diff --git a/dev/Model/FilterCondition.js b/dev/Model/FilterCondition.js index 99f4e707f..6ddcfd598 100644 --- a/dev/Model/FilterCondition.js +++ b/dev/Model/FilterCondition.js @@ -43,12 +43,12 @@ class FilterConditionModel extends AbstractModel { } verify() { - if ('' === this.value()) { + if (!this.value()) { this.value.error(true); return false; } - if (FilterConditionField.Header === this.field() && '' === this.valueSecond()) { + if (FilterConditionField.Header === this.field() && !this.valueSecond()) { this.valueSecond.error(true); return false; } diff --git a/dev/Model/Folder.js b/dev/Model/Folder.js index b7b40e423..8d876ec3f 100644 --- a/dev/Model/Folder.js +++ b/dev/Model/Folder.js @@ -210,7 +210,7 @@ class FolderModel extends AbstractModel { } } - if (('' !== suffix && '(' + name + ')' === suffix) || '(inbox)' === suffix.toLowerCase()) { + if ((suffix && '(' + name + ')' === suffix) || '(inbox)' === suffix.toLowerCase()) { suffix = ''; } @@ -224,7 +224,7 @@ class FolderModel extends AbstractModel { } }); - this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && '' !== this.printableUnreadCount()); + this.hasUnreadMessages = ko.computed(() => 0 < this.messageCountUnread() && this.printableUnreadCount()); this.hasSubScribedUnreadMessagesSubfolders = ko.computed( () => diff --git a/dev/Model/Identity.js b/dev/Model/Identity.js index 94b8fe566..d66820888 100644 --- a/dev/Model/Identity.js +++ b/dev/Model/Identity.js @@ -21,7 +21,7 @@ class IdentityModel extends AbstractModel { this.signatureInsertBefore = ko.observable(false); this.deleteAccess = ko.observable(false); - this.canBeDeleted = ko.computed(() => '' !== this.id()); + this.canBeDeleted = ko.computed(() => !!this.id()); } /** @@ -31,7 +31,7 @@ class IdentityModel extends AbstractModel { const name = this.name(), email = this.email(); - return '' !== name ? name + ' (' + email + ')' : email; + return name ? name + ' (' + email + ')' : email; } } diff --git a/dev/Model/Message.js b/dev/Model/Message.js index 403346fe9..94bb181f2 100644 --- a/dev/Model/Message.js +++ b/dev/Model/Message.js @@ -353,7 +353,7 @@ class MessageModel extends AbstractModel { attachment = AttachmentModel.newInstanceFromJson(json['@Collection'][index]); if (attachment) { if ( - '' !== attachment.cidWithOutTags && + attachment.cidWithOutTags && this.foundedCIDs.includes(attachment.cidWithOutTags) ) { attachment.isLinked = true; @@ -475,7 +475,7 @@ class MessageModel extends AbstractModel { 'important': this.isImportant(), 'withAttachments': this.hasAttachments(), 'new': this.newForAnimation(), - 'emptySubject': '' === this.subject(), + 'emptySubject': !this.subject(), // 'hasChildrenMessage': 1 < this.threadsLen(), 'hasUnseenSubMessage': this.hasUnseenSubMessage(), 'hasFlaggedSubMessage': this.hasFlaggedSubMessage() @@ -783,7 +783,7 @@ class MessageModel extends AbstractModel { $('[' + attr + ']', this.body).each(function() { const $this = $(this); // eslint-disable-line no-invalid-this let style = trim($this.attr('style')); - style = '' === style ? '' : ';' === style.substr(-1) ? style + ' ' : style + '; '; + style = style ? (';' === style.substr(-1) ? style + ' ' : style + '; ') : ''; $this.attr('style', style + $this.attr(attr)); }); @@ -840,9 +840,9 @@ class MessageModel extends AbstractModel { if (attachment && attachment.linkPreview) { name = $this.attr('data-x-style-cid-name'); - if ('' !== name) { + if (name) { style = trim($this.attr('style')); - style = '' === style ? '' : ';' === style.substr(-1) ? style + ' ' : style + '; '; + style = style ? (';' === style.substr(-1) ? style + ' ' : style + '; ') : ''; $this.attr('style', style + name + ": url('" + attachment.linkPreview() + "')"); } } diff --git a/dev/Promises/User/Populator.js b/dev/Promises/User/Populator.js index 0538a181d..ca4016d06 100644 --- a/dev/Promises/User/Populator.js +++ b/dev/Promises/User/Populator.js @@ -29,7 +29,7 @@ class PromisesUserPopulator extends AbstractBasicPromises { * @returns {string} */ normalizeFolder(sFolderFullNameRaw) { - return '' === sFolderFullNameRaw || + return !sFolderFullNameRaw || UNUSED_OPTION_VALUE === sFolderFullNameRaw || null !== Cache.getFolderFromCacheList(sFolderFullNameRaw) ? sFolderFullNameRaw @@ -144,14 +144,13 @@ class PromisesUserPopulator extends AbstractBasicPromises { if ( oData.SystemFolders && - '' === - '' + + !('' + Settings.settingsGet('SentFolder') + Settings.settingsGet('DraftFolder') + Settings.settingsGet('SpamFolder') + Settings.settingsGet('TrashFolder') + Settings.settingsGet('ArchiveFolder') + - Settings.settingsGet('NullFolder') + Settings.settingsGet('NullFolder')) ) { Settings.settingsSet('SentFolder', oData.SystemFolders[ServerFolderType.SENT] || null); Settings.settingsSet('DraftFolder', oData.SystemFolders[ServerFolderType.DRAFTS] || null); diff --git a/dev/Remote/AbstractAjax.js b/dev/Remote/AbstractAjax.js index 5c95ba2a7..db88c04bd 100644 --- a/dev/Remote/AbstractAjax.js +++ b/dev/Remote/AbstractAjax.js @@ -134,7 +134,7 @@ if (err) { */ ajaxRequest(fResultCallback, params, iTimeOut = 20000, sGetAdd = '', abortActions = []) { params = params || {}; - const isPost = '' === sGetAdd, + const isPost = !sGetAdd, start = new window.Date().getTime(), action = params.Action || ''; diff --git a/dev/Remote/User/Ajax.js b/dev/Remote/User/Ajax.js index 816af3fbf..4c072a4e1 100644 --- a/dev/Remote/User/Ajax.js +++ b/dev/Remote/User/Ajax.js @@ -313,12 +313,12 @@ class RemoteUserAjax extends AbstractAjaxRemote { useThreads = AppStore.threadsAllowed() && SettingsStore.useThreads(), inboxUidNext = getFolderInboxName() === sFolderFullNameRaw ? getFolderUidNext(sFolderFullNameRaw) : ''; - if ('' !== folderHash && ('' === sSearch || !sSearch.includes('is:'))) { + if (folderHash && (!sSearch || !sSearch.includes('is:'))) { return this.defaultRequest( fCallback, 'MessageList', {}, - '' === sSearch ? DEFAULT_AJAX_TIMEOUT : SEARCH_AJAX_TIMEOUT, + sSearch ? SEARCH_AJAX_TIMEOUT : DEFAULT_AJAX_TIMEOUT, 'MessageList/' + subQueryPrefix() + '/' + @@ -351,7 +351,7 @@ class RemoteUserAjax extends AbstractAjaxRemote { UseThreads: useThreads ? '1' : '0', ThreadUid: useThreads ? sThreadUid : '' }, - '' === sSearch ? DEFAULT_AJAX_TIMEOUT : SEARCH_AJAX_TIMEOUT, + sSearch ? SEARCH_AJAX_TIMEOUT : DEFAULT_AJAX_TIMEOUT, '', bSilent ? [] : ['MessageList'] ); diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index eec82229f..7652bf4db 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -48,10 +48,10 @@ class MailBoxUserScreen extends AbstractScreen { } getApp().setWindowTitle( - ('' === email - ? '' - : '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ') + - i18n('TITLES/MAILBOX') + (email + ? '' + (0 < foldersInboxUnreadCount ? '(' + foldersInboxUnreadCount + ') ' : ' ') + email + ' - ' + : '' + ) + i18n('TITLES/MAILBOX') ); } @@ -152,7 +152,7 @@ class MailBoxUserScreen extends AbstractScreen { vals[1] = 0 >= vals[1] ? 1 : vals[1]; vals[2] = pString(vals[2]); - if ('' === request) { + if (!request) { vals[0] = inboxFolderName; vals[1] = 1; } @@ -163,7 +163,7 @@ class MailBoxUserScreen extends AbstractScreen { vals[0] = pString(vals[0]); vals[1] = pString(vals[1]); - if ('' === request) { + if (!request) { vals[0] = inboxFolderName; } diff --git a/dev/Screen/User/Settings.js b/dev/Screen/User/Settings.js index d3e12eea4..b67d5baf4 100644 --- a/dev/Screen/User/Settings.js +++ b/dev/Screen/User/Settings.js @@ -120,7 +120,7 @@ class SettingsUserScreen extends AbstractSettingsScreen { setSettingsTitle() { const sEmail = AccountStore.email(); - getApp().setWindowTitle(('' === sEmail ? '' : sEmail + ' - ') + this.sSettingsTitle); + getApp().setWindowTitle((sEmail ? sEmail + ' - ' : '') + this.sSettingsTitle); } } diff --git a/dev/Settings/Admin/Contacts.js b/dev/Settings/Admin/Contacts.js index 8cb42cf55..029cb55f2 100644 --- a/dev/Settings/Admin/Contacts.js +++ b/dev/Settings/Admin/Contacts.js @@ -102,7 +102,7 @@ class ContactsAdminSettings { this.onTestContactsResponse = this.onTestContactsResponse.bind(this); } - @command((self) => '' !== self.pdoDsn() && '' !== self.pdoUser()) + @command((self) => self.pdoDsn() && self.pdoUser()) testContactsCommand() { this.testContactsSuccess(false); this.testContactsError(false); diff --git a/dev/Settings/Admin/Packages.js b/dev/Settings/Admin/Packages.js index ec2866fc2..e97146b7b 100644 --- a/dev/Settings/Admin/Packages.js +++ b/dev/Settings/Admin/Packages.js @@ -18,13 +18,13 @@ class PackagesAdminSettings { this.packagesMainUpdatable = PackageStore.packagesMainUpdatable; this.packagesCurrent = ko.computed(() => - this.packages().filter(item => item && '' !== item.installed && !item.compare) + this.packages().filter(item => item && item.installed && !item.compare) ); this.packagesAvailableForUpdate = ko.computed(() => - this.packages().filter(item => item && '' !== item.installed && !!item.compare) + this.packages().filter(item => item && item.installed && !!item.compare) ); this.packagesAvailableForInstallation = ko.computed(() => - this.packages().filter(item => item && '' === item.installed) + this.packages().filter(item => item && !item.installed) ); this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden')); diff --git a/dev/Settings/Admin/Plugins.js b/dev/Settings/Admin/Plugins.js index f71145de5..0e6ee6310 100644 --- a/dev/Settings/Admin/Plugins.js +++ b/dev/Settings/Admin/Plugins.js @@ -78,7 +78,7 @@ class PluginsAdminSettings { onPluginDisableRequest(result, data) { if (StorageResultType.Success === result && data) { if (!data.Result && data.ErrorCode) { - if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && '' !== data.ErrorMessage) { + if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && data.ErrorMessage) { PluginStore.plugins.error(data.ErrorMessage); } else { PluginStore.plugins.error(getNotification(data.ErrorCode)); diff --git a/dev/Settings/Admin/Security.js b/dev/Settings/Admin/Security.js index 7ba882894..9e8ec9bcf 100644 --- a/dev/Settings/Admin/Security.js +++ b/dev/Settings/Admin/Security.js @@ -76,9 +76,9 @@ class SecurityAdminSettings { this.onNewAdminPasswordResponse = this.onNewAdminPasswordResponse.bind(this); } - @command((self) => '' !== trim(self.adminLogin()) && '' !== self.adminPassword()) + @command((self) => trim(self.adminLogin()) && self.adminPassword()) saveNewAdminPasswordCommand() { - if ('' === trim(this.adminLogin())) { + if (!trim(this.adminLogin())) { this.adminLoginError(true); return false; } diff --git a/dev/Settings/User/Filters.js b/dev/Settings/User/Filters.js index 46553421f..3e8a4099a 100644 --- a/dev/Settings/User/Filters.js +++ b/dev/Settings/User/Filters.js @@ -61,7 +61,7 @@ class FiltersUserSettings { @command((self) => self.haveChanges()) saveChangesCommand() { if (!this.filters.saving()) { - if (this.filterRaw.active() && '' === trim(this.filterRaw())) { + if (this.filterRaw.active() && !trim(this.filterRaw())) { this.filterRaw.error(true); return false; } diff --git a/dev/Settings/User/Folders.js b/dev/Settings/User/Folders.js index 39f477dbb..c9aa00fb4 100644 --- a/dev/Settings/User/Folders.js +++ b/dev/Settings/User/Folders.js @@ -44,7 +44,7 @@ class FoldersUserSettings { folderEditOnEnter(folder) { const nameToEdit = folder ? trim(folder.nameForEdit()) : ''; - if ('' !== nameToEdit && folder.name() !== nameToEdit) { + if (nameToEdit && folder.name() !== nameToEdit) { Local.set(ClientSideKeyName.FoldersLashHash, ''); getApp().foldersPromisesActionHelper( diff --git a/dev/Settings/User/General.js b/dev/Settings/User/General.js index f547691d1..b3db261f1 100644 --- a/dev/Settings/User/General.js +++ b/dev/Settings/User/General.js @@ -55,7 +55,7 @@ class GeneralUserSettings { this.identityMain = ko.computed(() => { const list = this.identities(); - return isArray(list) ? list.find(item => item && '' === item.id()) : null; + return isArray(list) ? list.find(item => item && !item.id()) : null; }); this.identityMainDesc = ko.computed(() => { diff --git a/dev/Settings/User/Templates.js b/dev/Settings/User/Templates.js index 9e8aa118d..90e8f744e 100644 --- a/dev/Settings/User/Templates.js +++ b/dev/Settings/User/Templates.js @@ -16,7 +16,7 @@ class TemplatesUserSettings { this.processText = ko.computed(() => TemplateStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '' ); - this.visibility = ko.computed(() => ('' === this.processText() ? 'hidden' : 'visible')); + this.visibility = ko.computed(() => this.processText() ? 'visible' : 'hidden'); this.templateForDeletion = ko.observable(null).deleteAccessHelper(); } diff --git a/dev/Stores/User/Account.js b/dev/Stores/User/Account.js index e1d6e4d78..54615d24b 100644 --- a/dev/Stores/User/Account.js +++ b/dev/Stores/User/Account.js @@ -42,7 +42,7 @@ class AccountUserStore { * @returns {boolean} */ isRootAccount() { - return '' === this.parentEmail(); + return !this.parentEmail(); } } diff --git a/dev/Stores/User/Folder.js b/dev/Stores/User/Folder.js index 4429fd435..8ef8eced2 100644 --- a/dev/Stores/User/Folder.js +++ b/dev/Stores/User/Folder.js @@ -42,7 +42,7 @@ class FolderUserStore { computers() { this.draftFolderNotEnabled = ko.computed( - () => '' === this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder() + () => !this.draftFolder() || UNUSED_OPTION_VALUE === this.draftFolder() ); this.foldersListWithSingleInboxRootFolder = ko.computed( @@ -73,19 +73,19 @@ class FolderUserStore { archiveFolder = this.archiveFolder(); if (isArray(folders) && folders.length) { - if ('' !== sentFolder && UNUSED_OPTION_VALUE !== sentFolder) { + if (sentFolder && UNUSED_OPTION_VALUE !== sentFolder) { list.push(sentFolder); } - if ('' !== draftFolder && UNUSED_OPTION_VALUE !== draftFolder) { + if (draftFolder && UNUSED_OPTION_VALUE !== draftFolder) { list.push(draftFolder); } - if ('' !== spamFolder && UNUSED_OPTION_VALUE !== spamFolder) { + if (spamFolder && UNUSED_OPTION_VALUE !== spamFolder) { list.push(spamFolder); } - if ('' !== trashFolder && UNUSED_OPTION_VALUE !== trashFolder) { + if (trashFolder && UNUSED_OPTION_VALUE !== trashFolder) { list.push(trashFolder); } - if ('' !== archiveFolder && UNUSED_OPTION_VALUE !== archiveFolder) { + if (archiveFolder && UNUSED_OPTION_VALUE !== archiveFolder) { list.push(archiveFolder); } } diff --git a/dev/Stores/User/Message.js b/dev/Stores/User/Message.js index bef605d7c..35a60a04a 100644 --- a/dev/Stores/User/Message.js +++ b/dev/Stores/User/Message.js @@ -248,7 +248,7 @@ class MessageUserStore { } initUidNextAndNewMessages(folder, uidNext, newMessages) { - if (getFolderInboxName() === folder && isNormal(uidNext) && '' !== uidNext) { + if (getFolderInboxName() === folder && isNormal(uidNext) && uidNext) { if (isArray(newMessages) && newMessages.length) { newMessages.forEach(item => { addNewMessageCache(folder, item.Uid); @@ -305,7 +305,7 @@ class MessageUserStore { const trashFolder = FolderStore.trashFolder(), spamFolder = FolderStore.spamFolder(), fromFolder = getFolderFromCacheList(fromFolderFullNameRaw), - toFolder = '' === toFolderFullNameRaw ? null : getFolderFromCacheList(toFolderFullNameRaw || ''), + toFolder = toFolderFullNameRaw ? getFolderFromCacheList(toFolderFullNameRaw) : null, currentFolderFullNameRaw = FolderStore.currentFolderFullNameRaw(), messages = currentFolderFullNameRaw === fromFolderFullNameRaw @@ -368,15 +368,15 @@ class MessageUserStore { } } - if ('' !== fromFolderFullNameRaw) { + if (fromFolderFullNameRaw) { setFolderHash(fromFolderFullNameRaw, ''); } - if ('' !== toFolderFullNameRaw) { + if (toFolderFullNameRaw) { setFolderHash(toFolderFullNameRaw, ''); } - if ('' !== this.messageListThreadUid()) { + if (this.messageListThreadUid()) { messageList = this.messageList(); if ( @@ -448,7 +448,7 @@ class MessageUserStore { h = getRealHeight($this); } - if ('' !== trim($this.text()) && (0 === h || 100 < h)) { + if (trim($this.text()) && (0 === h || 100 < h)) { $this.addClass('rl-bq-switcher hidden-bq'); $('') .insertBefore($this) @@ -525,10 +525,10 @@ class MessageUserStore { const textBody = messagesDom.find('#' + id); if (!textBody || !textBody[0]) { let isHtml = false; - if (isNormal(data.Result.Html) && '' !== data.Result.Html) { + if (isNormal(data.Result.Html) && data.Result.Html) { isHtml = true; resultHtml = data.Result.Html.toString(); - } else if (isNormal(data.Result.Plain) && '' !== data.Result.Plain) { + } else if (isNormal(data.Result.Plain) && data.Result.Plain) { isHtml = false; resultHtml = plainToHtml(data.Result.Plain.toString(), false); diff --git a/dev/View/Admin/Login.js b/dev/View/Admin/Login.js index 715937dde..6ea21f162 100644 --- a/dev/View/Admin/Login.js +++ b/dev/View/Admin/Login.js @@ -65,8 +65,8 @@ class LoginAdminView extends AbstractViewNext { this.loginError(false); this.passwordError(false); - this.loginError('' === trim(this.login())); - this.passwordError('' === trim(this.password())); + this.loginError(!trim(this.login())); + this.passwordError(!trim(this.password())); if (this.loginError() || this.passwordError()) { return false; diff --git a/dev/View/Popup/Account.js b/dev/View/Popup/Account.js index a48eedc40..00109c2d0 100644 --- a/dev/View/Popup/Account.js +++ b/dev/View/Popup/Account.js @@ -44,8 +44,8 @@ class AccountPopupView extends AbstractViewNext { @command((self) => !self.submitRequest()) addAccountCommand() { - this.emailError('' === trim(this.email())); - this.passwordError('' === trim(this.password())); + this.emailError(!trim(this.email())); + this.passwordError(!trim(this.password())); if (this.emailError() || this.passwordError()) { return false; diff --git a/dev/View/Popup/Activate.js b/dev/View/Popup/Activate.js index fbaee33ea..c91a2aeff 100644 --- a/dev/View/Popup/Activate.js +++ b/dev/View/Popup/Activate.js @@ -47,7 +47,7 @@ class ActivatePopupView extends AbstractViewNext { } @command( - (self) => !self.activateProcess() && '' !== self.domain() && '' !== self.key() && !self.activationSuccessed() + (self) => !self.activateProcess() && self.domain() && self.key() && !self.activationSuccessed() ) activateCommand() { this.activateProcess(true); @@ -110,7 +110,7 @@ class ActivatePopupView extends AbstractViewNext { validateSubscriptionKey() { const value = this.key(); return ( - '' === value || + !value || RAINLOOP_TRIAL_KEY === value || !!/^RL[\d]+-[A-Z0-9-]+Z$/.test(trim(value).replace(/[^A-Z0-9-]/gi, '')) ); diff --git a/dev/View/Popup/AddOpenPgpKey.js b/dev/View/Popup/AddOpenPgpKey.js index 074302a89..26b6bd4c1 100644 --- a/dev/View/Popup/AddOpenPgpKey.js +++ b/dev/View/Popup/AddOpenPgpKey.js @@ -39,7 +39,7 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext { keyTrimmed = keyTrimmed.replace(/[\r]+/g, '').replace(/[\n]{2,}/g, '\n\n'); } - this.key.error('' === keyTrimmed); + this.key.error(!keyTrimmed); this.key.errorMessage(''); if (!openpgpKeyring || this.key.error()) { diff --git a/dev/View/Popup/AdvancedSearch.js b/dev/View/Popup/AdvancedSearch.js index 788a5e9f8..e6eecdf6b 100644 --- a/dev/View/Popup/AdvancedSearch.js +++ b/dev/View/Popup/AdvancedSearch.js @@ -46,7 +46,7 @@ class AdvancedSearchPopupView extends AbstractViewNext { @command() searchCommand() { const search = this.buildSearchString(); - if ('' !== search) { + if (search) { MessageStore.mainMessageListSearch(search); } @@ -87,15 +87,15 @@ class AdvancedSearchPopupView extends AbstractViewNext { isPart = [], hasPart = []; - if (from_ && '' !== from_) { + if (from_) { result.push('from:' + this.buildSearchStringValue(from_)); } - if (to && '' !== to) { + if (to) { result.push('to:' + this.buildSearchStringValue(to)); } - if (subject && '' !== subject) { + if (subject) { result.push('subject:' + this.buildSearchStringValue(subject)); } @@ -123,7 +123,7 @@ class AdvancedSearchPopupView extends AbstractViewNext { result.push('date:' + searchSubtractFormatDateHelper(this.selectedDateValue()) + '/'); } - if (text && '' !== text) { + if (text) { result.push('text:' + this.buildSearchStringValue(text)); } diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 02c7f2217..da0f7e86b 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -227,12 +227,12 @@ class ComposePopupView extends AbstractViewNext { this.attachmentsInProcess = ko.computed(() => this.attachments().filter(item => item && !item.complete())); this.attachmentsInReady = ko.computed(() => this.attachments().filter(item => item && item.complete())); - this.attachmentsInError = ko.computed(() => this.attachments().filter(item => item && '' !== item.error())); + this.attachmentsInError = ko.computed(() => this.attachments().filter(item => item && item.error())); this.attachmentsCount = ko.computed(() => this.attachments().length); this.attachmentsInErrorCount = ko.computed(() => this.attachmentsInError().length); this.attachmentsInProcessCount = ko.computed(() => this.attachmentsInProcess().length); - this.isDraftFolderMessage = ko.computed(() => '' !== this.draftFolder() && '' !== this.draftUid()); + this.isDraftFolderMessage = ko.computed(() => this.draftFolder() && this.draftUid()); this.attachmentsPlace = ko.observable(false); @@ -360,7 +360,7 @@ class ComposePopupView extends AbstractViewNext { this.attachmentsPlace(true); } - if ('' === sTo && '' === sCc && '' === sBcc) { + if (!sTo && !sCc && !sBcc) { this.emptyToError(true); } @@ -380,7 +380,7 @@ class ComposePopupView extends AbstractViewNext { sSentFolder = UNUSED_OPTION_VALUE; } - if ('' === sSentFolder) { + if (!sSentFolder) { showScreenPopup(require('View/Popup/FolderSystem'), [SetSystemFoldersNotification.Sent]); } else { this.sendError(false); @@ -564,7 +564,7 @@ class ComposePopupView extends AbstractViewNext { reloadDraftFolder() { const draftFolder = FolderStore.draftFolder(); - if ('' !== draftFolder && UNUSED_OPTION_VALUE !== draftFolder) { + if (draftFolder && UNUSED_OPTION_VALUE !== draftFolder) { setFolderHash(draftFolder, ''); if (FolderStore.currentFolderFullNameRaw() === draftFolder) { getApp().reloadMessageList(true); @@ -736,7 +736,7 @@ class ComposePopupView extends AbstractViewNext { signature = signature.replace(/[\r]/g, ''); fromLine = this.oLastMessage ? this.emailArrayToStringLineHelper(this.oLastMessage.from, true) : ''; - if ('' !== fromLine) { + if (fromLine) { signature = signature.replace(/{{FROM-FULL}}/g, fromLine); if (!fromLine.includes(' ') && 0 < fromLine.indexOf('@')) { @@ -793,7 +793,7 @@ class ComposePopupView extends AbstractViewNext { let isHtml = false, signature = identity.signature(); - if ('' !== signature) { + if (signature) { if (':HTML:' === signature.substr(0, 6)) { isHtml = true; signature = signature.substr(6); @@ -837,7 +837,7 @@ class ComposePopupView extends AbstractViewNext { this.addEmailsTo(this.cc, aCcEmails); this.addEmailsTo(this.bcc, aBccEmails); - if (isNormal(sCustomSubject) && '' !== sCustomSubject && '' === this.subject()) { + if (isNormal(sCustomSubject) && sCustomSubject && !this.subject()) { this.subject(sCustomSubject); } } @@ -862,7 +862,7 @@ class ComposePopupView extends AbstractViewNext { values = emails.map(item => item ? item.toLine(false) : null) .filter((value, index, self) => !!value && self.indexOf(value) == index); - fKoValue(value + ('' === value ? '' : ', ') + trim(values.join(', '))); + fKoValue(value + (value ? ', ' : '') + trim(values.join(', '))); } } @@ -939,7 +939,7 @@ class ComposePopupView extends AbstractViewNext { this.bcc(this.emailArrayToStringLineHelper(aBccEmails)); } - if ('' !== lineComposeType && message) { + if (lineComposeType && message) { sDate = momentorFormat(message.dateTimeStampInUTC(), 'FULL'); sSubject = message.subject(); aDraftInfo = message.aDraftInfo; @@ -1171,7 +1171,7 @@ class ComposePopupView extends AbstractViewNext { setFocusInPopup() { if (!bMobileDevice) { setTimeout(() => { - if ('' === this.to()) { + if (!this.to()) { this.to.focused(true); } else if (this.oEditor) { if (!this.to.focused()) { @@ -1379,7 +1379,7 @@ class ComposePopupView extends AbstractViewNext { } if (attachment) { - if ('' !== error && error.length) { + if (error && error.length) { attachment .waiting(false) .uploading(false) @@ -1413,7 +1413,7 @@ class ComposePopupView extends AbstractViewNext { prepearAttachmentsForSendOrSave() { const result = {}; this.attachmentsInReady().forEach(item => { - if (item && '' !== item.tempName() && item.enabled()) { + if (item && item.tempName() && item.enabled()) { result[item.tempName()] = [item.fileName(), item.isInline ? '1' : '0', item.CID, item.contentLocation]; } }); @@ -1552,7 +1552,7 @@ class ComposePopupView extends AbstractViewNext { !this.replyTo().length && !this.subject().length && withoutAttachment && - (!this.oEditor || '' === this.oEditor.getData()) + (!this.oEditor || !this.oEditor.getData()) ); } @@ -1606,7 +1606,7 @@ class ComposePopupView extends AbstractViewNext { * @returns {Array} */ getAttachmentsDownloadsForUpload() { - return this.attachments().filter(item => item && '' === item.tempName()).map( + return this.attachments().filter(item => item && !item.tempName()).map( item => item.id ); } diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index 91b9d6a93..56b973d6c 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -345,15 +345,15 @@ class ComposeOpenPgpPopupView extends AbstractViewNext { this.resultCallback = fCallback; - if ('' !== sTo) { + if (sTo) { rec.push(sTo); } - if ('' !== sCc) { + if (sCc) { rec.push(sCc); } - if ('' !== sBcc) { + if (sBcc) { rec.push(sBcc); } @@ -361,7 +361,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext { rec = rec.map(value => { email.clear(); email.parse(trim(value)); - return '' === email.email ? false : email.email; + return email.email || false; }).filter(value => !!value); if (identity && identity.email()) { diff --git a/dev/View/Popup/Contacts.js b/dev/View/Popup/Contacts.js index 0f39dd410..a0f8036e7 100644 --- a/dev/View/Popup/Contacts.js +++ b/dev/View/Popup/Contacts.js @@ -116,7 +116,7 @@ class ContactsPopupView extends AbstractViewNext { this.viewHasNonEmptyRequiredProperties = ko.computed(() => { const names = this.viewPropertiesNames(), emails = this.viewPropertiesEmails(), - fFilter = (property) => '' !== trim(property.value()); + fFilter = (property) => !!trim(property.value()); return !!(names.find(fFilter) || emails.find(fFilter)); }); @@ -126,12 +126,12 @@ class ContactsPopupView extends AbstractViewNext { ); this.viewPropertiesEmailsNonEmpty = ko.computed(() => - this.viewPropertiesNames().filter(property => '' !== trim(property.value())) + this.viewPropertiesNames().filter(property => !!trim(property.value())) ); const propertyFocused = (property) => { const focused = property.focused(); - return '' === trim(property.value()) && !focused; + return !trim(property.value()) && !focused; }; this.viewPropertiesEmailsEmptyAndOnFocused = ko.computed(() => @@ -303,7 +303,7 @@ class ContactsPopupView extends AbstractViewNext { properties = []; this.viewProperties().forEach(oItem => { - if (oItem.type() && oItem.type() !== ContactPropertyType.FullName && '' !== trim(oItem.value())) { + if (oItem.type() && oItem.type() !== ContactPropertyType.FullName && trim(oItem.value())) { properties.push([oItem.type(), oItem.value(), oItem.typeStr()]); } }); @@ -320,7 +320,7 @@ class ContactsPopupView extends AbstractViewNext { oData.Result.RequestUid === requestUid && 0 < pInt(oData.Result.ResultID) ) { - if ('' === this.viewID()) { + if (!this.viewID()) { this.viewID(pInt(oData.Result.ResultID)); } @@ -610,7 +610,7 @@ class ContactsPopupView extends AbstractViewNext { this.contacts(list); this.contacts.loading(false); - this.viewClearSearch('' !== this.search()); + this.viewClearSearch(!!this.search()); }, offset, CONTACTS_PER_PAGE, diff --git a/dev/View/Popup/Domain.js b/dev/View/Popup/Domain.js index 09cde5976..e63b14e12 100644 --- a/dev/View/Popup/Domain.js +++ b/dev/View/Popup/Domain.js @@ -97,10 +97,9 @@ class DomainPopupView extends AbstractViewNext { result += ' ← ' + aliasName; } } else { - result = - '' === name - ? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN') - : i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { 'NAME': name }); + result = name + ? i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN_WITH_NAME', { 'NAME': name }) + : i18n('POPUPS_DOMAIN/TITLE_ADD_DOMAIN'); } return result; @@ -117,11 +116,11 @@ class DomainPopupView extends AbstractViewNext { useSieve = this.useSieve(); return ( - '' !== this.name() && - '' !== this.imapServer() && - '' !== this.imapPort() && - (allowSieve && useSieve ? '' !== this.sieveServer() && '' !== this.sievePort() : true) && - (('' !== this.smtpServer() && '' !== this.smtpPort()) || usePhpMail) + this.name() && + this.imapServer() && + this.imapPort() && + (allowSieve && useSieve ? this.sieveServer() && this.sievePort() : true) && + ((this.smtpServer() && this.smtpPort()) || usePhpMail) ); }); @@ -134,19 +133,19 @@ class DomainPopupView extends AbstractViewNext { // smart form improvements this.imapServerFocus.subscribe((value) => { - if (value && '' !== this.name() && '' === this.imapServer()) { + if (value && this.name() && !this.imapServer()) { this.imapServer(this.name().replace(/[.]?[*][.]?/g, '')); } }); this.sieveServerFocus.subscribe((value) => { - if (value && '' !== this.imapServer() && '' === this.sieveServer()) { + if (value && this.imapServer() && !this.sieveServer()) { this.sieveServer(this.imapServer()); } }); this.smtpServerFocus.subscribe((value) => { - if (value && '' !== this.imapServer() && '' === this.smtpServer()) { + if (value && this.imapServer() && !this.smtpServer()) { this.smtpServer(this.imapServer().replace(/imap/gi, 'smtp')); } }); @@ -381,7 +380,7 @@ class DomainPopupView extends AbstractViewNext { } onShowWithDelay() { - if ('' === this.name() && !bMobileDevice) { + if (!this.name() && !bMobileDevice) { this.name.focused(true); } } diff --git a/dev/View/Popup/DomainAlias.js b/dev/View/Popup/DomainAlias.js index 70b8b7fca..1dd8e9a3c 100644 --- a/dev/View/Popup/DomainAlias.js +++ b/dev/View/Popup/DomainAlias.js @@ -35,7 +35,7 @@ class DomainAliasPopupView extends AbstractViewNext { this.domains().map(item => ({ optValue: item.name, optText: item.name })) ); - this.canBeSaved = ko.computed(() => !this.saving() && '' !== this.name() && '' !== this.alias()); + this.canBeSaved = ko.computed(() => !this.saving() && this.name() && this.alias()); this.onDomainAliasCreateOrSaveResponse = this.onDomainAliasCreateOrSaveResponse.bind(this); } @@ -65,7 +65,7 @@ class DomainAliasPopupView extends AbstractViewNext { } onShowWithDelay() { - if ('' === this.name() && !bMobileDevice) { + if (!this.name() && !bMobileDevice) { this.name.focused(true); } } diff --git a/dev/View/Popup/FolderCreate.js b/dev/View/Popup/FolderCreate.js index f4187ada7..04f16eb35 100644 --- a/dev/View/Popup/FolderCreate.js +++ b/dev/View/Popup/FolderCreate.js @@ -36,7 +36,7 @@ class FolderCreateView extends AbstractViewNext { top.push(['', '']); let fDisableCallback = null; - if ('' !== FolderStore.namespace) { + if (FolderStore.namespace) { fDisableCallback = (item) => FolderStore.namespace !== item.fullNameRaw.substr(0, FolderStore.namespace.length); } @@ -49,7 +49,7 @@ class FolderCreateView extends AbstractViewNext { @command((self) => self.simpleFolderNameValidation(self.folderName())) createFolderCommand() { let parentFolderName = this.selectedParentValue(); - if ('' === parentFolderName && 1 < FolderStore.namespace.length) { + if (!parentFolderName && 1 < FolderStore.namespace.length) { parentFolderName = FolderStore.namespace.substr(0, FolderStore.namespace.length - 1); } diff --git a/dev/View/Popup/Identity.js b/dev/View/Popup/Identity.js index fe22d5b46..e8a42cb40 100644 --- a/dev/View/Popup/Identity.js +++ b/dev/View/Popup/Identity.js @@ -62,7 +62,7 @@ class IdentityPopupView extends AbstractViewNext { } if (!this.email.hasError()) { - this.email.hasError('' === trim(this.email())); + this.email.hasError(!trim(this.email())); } if (this.email.hasError()) { @@ -151,7 +151,7 @@ class IdentityPopupView extends AbstractViewNext { this.signature(identity.signature()); this.signatureInsertBefore(identity.signatureInsertBefore()); - this.owner('' === this.id); + this.owner(!this.id); } else { this.id = fakeMd5(); } diff --git a/dev/View/Popup/NewOpenPgpKey.js b/dev/View/Popup/NewOpenPgpKey.js index b7abe824d..f114e0fd9 100644 --- a/dev/View/Popup/NewOpenPgpKey.js +++ b/dev/View/Popup/NewOpenPgpKey.js @@ -39,13 +39,13 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext { const userId = {}, openpgpKeyring = PgpStore.openpgpKeyring; - this.email.error('' === trim(this.email())); + this.email.error(!trim(this.email())); if (!openpgpKeyring || this.email.error()) { return false; } userId.email = this.email(); - if ('' !== this.name()) { + if (this.name()) { userId.name = this.name(); } diff --git a/dev/View/Popup/Plugin.js b/dev/View/Popup/Plugin.js index 3cdfaab7f..48847c6d3 100644 --- a/dev/View/Popup/Plugin.js +++ b/dev/View/Popup/Plugin.js @@ -28,7 +28,7 @@ class PluginPopupView extends AbstractViewNext { this.configures = ko.observableArray([]); - this.hasReadme = ko.computed(() => '' !== this.readme()); + this.hasReadme = ko.computed(() => !!this.readme()); this.hasConfiguration = ko.computed(() => 0 < this.configures().length); this.readmePopoverConf = { diff --git a/dev/View/Popup/Template.js b/dev/View/Popup/Template.js index bfa4fb1fe..cc049c20f 100644 --- a/dev/View/Popup/Template.js +++ b/dev/View/Popup/Template.js @@ -49,8 +49,8 @@ class TemplatePopupView extends AbstractViewNext { addTemplateCommand() { this.populateBodyFromEditor(); - this.name.error('' === trim(this.name())); - this.body.error('' === trim(this.body()) || ':HTML:' === trim(this.body())); + this.name.error(!trim(this.name())); + this.body.error(!trim(this.body()) || ':HTML:' === trim(this.body())); if (this.name.error() || this.body.error()) { return false; diff --git a/dev/View/Popup/TwoFactorTest.js b/dev/View/Popup/TwoFactorTest.js index f2e502950..9de270cfe 100644 --- a/dev/View/Popup/TwoFactorTest.js +++ b/dev/View/Popup/TwoFactorTest.js @@ -25,7 +25,7 @@ class TwoFactorTestPopupView extends AbstractViewNext { this.testing = ko.observable(false); } - @command((self) => '' !== self.code() && !self.testing()) + @command((self) => self.code() && !self.testing()) testCodeCommand() { this.testing(true); Remote.testTwoFactor((result, data) => { diff --git a/dev/View/User/Login.js b/dev/View/User/Login.js index f53d5a6db..33c35912d 100644 --- a/dev/View/User/Login.js +++ b/dev/View/User/Login.js @@ -115,7 +115,7 @@ class LoginUserView extends AbstractViewNext { this.submitErrorAddidional = ko.observable(''); this.submitError.subscribe((value) => { - if ('' === value) { + if (!value) { this.submitErrorAddidional(''); } }); @@ -154,12 +154,12 @@ class LoginUserView extends AbstractViewNext { this.emailError(false); this.passwordError(false); - this.emailError('' === trim(this.email())); - this.passwordError('' === trim(this.password())); + this.emailError(!trim(this.email())); + this.passwordError(!trim(this.password())); if (this.additionalCode.visibility()) { this.additionalCode.error(false); - this.additionalCode.error('' === trim(this.additionalCode())); + this.additionalCode.error(!trim(this.additionalCode())); } if ( @@ -195,7 +195,7 @@ class LoginUserView extends AbstractViewNext { if (0 < pluginResultCode) { this.submitError(getNotification(pluginResultCode)); return false; - } else if ('' !== pluginResultMessage) { + } else if (pluginResultMessage) { this.submitError(pluginResultMessage); return false; } @@ -230,7 +230,7 @@ class LoginUserView extends AbstractViewNext { this.submitError(getNotificationFromResponse(oData)); - if ('' === this.submitError()) { + if (!this.submitError()) { this.submitError(getNotification(Notification.UnknownError)); } else if (oData.ErrorMessageAdditional) { this.submitErrorAddidional(oData.ErrorMessageAdditional); @@ -269,11 +269,11 @@ class LoginUserView extends AbstractViewNext { } onShowWithDelay() { - if ('' !== this.email() && '' !== this.password()) { + if (this.email() && this.password()) { this.passwordFocus(true); - } else if ('' === this.email()) { + } else if (!this.email()) { this.emailFocus(true); - } else if ('' === this.password()) { + } else if (!this.password()) { this.passwordFocus(true); } else { this.emailFocus(true); diff --git a/dev/View/User/MailBox/FolderList.js b/dev/View/User/MailBox/FolderList.js index bf491365d..f6f6c701f 100644 --- a/dev/View/User/MailBox/FolderList.js +++ b/dev/View/User/MailBox/FolderList.js @@ -245,7 +245,7 @@ class FolderListMailBoxUserView extends AbstractViewNext { copy = $htmlCL.contains('rl-ctrl-key-pressed'), uids = ui.helper.data('rl-uids'); - if (isNormal(fromFolderFullNameRaw) && '' !== fromFolderFullNameRaw && isArray(uids)) { + if (fromFolderFullNameRaw && isNormal(fromFolderFullNameRaw) && isArray(uids)) { getApp().moveMessagesToFolder(fromFolderFullNameRaw, uids, toFolder.fullNameRaw, copy); } } diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index 3d113842f..88c59b299 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -135,7 +135,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { this.messageListSearchDesc = ko.computed(() => { const value = MessageStore.messageListEndSearch(); - return '' === value ? '' : i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }); + return value ? i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', { 'SEARCH': value }) : ''; }); this.messageListPagenator = ko.computed( @@ -172,25 +172,25 @@ class MessageListMailBoxUserView extends AbstractViewNext { this.hasCheckedOrSelectedLines = ko.computed(() => 0 < this.messageListCheckedOrSelected().length); this.isSpamFolder = ko.computed( - () => FolderStore.spamFolder() === this.messageListEndFolder() && '' !== FolderStore.spamFolder() + () => FolderStore.spamFolder() === this.messageListEndFolder() && FolderStore.spamFolder() ); this.isSpamDisabled = ko.computed(() => UNUSED_OPTION_VALUE === FolderStore.spamFolder()); this.isTrashFolder = ko.computed( - () => FolderStore.trashFolder() === this.messageListEndFolder() && '' !== FolderStore.trashFolder() + () => FolderStore.trashFolder() === this.messageListEndFolder() && FolderStore.trashFolder() ); this.isDraftFolder = ko.computed( - () => FolderStore.draftFolder() === this.messageListEndFolder() && '' !== FolderStore.draftFolder() + () => FolderStore.draftFolder() === this.messageListEndFolder() && FolderStore.draftFolder() ); this.isSentFolder = ko.computed( - () => FolderStore.sentFolder() === this.messageListEndFolder() && '' !== FolderStore.sentFolder() + () => FolderStore.sentFolder() === this.messageListEndFolder() && FolderStore.sentFolder() ); this.isArchiveFolder = ko.computed( - () => FolderStore.archiveFolder() === this.messageListEndFolder() && '' !== FolderStore.archiveFolder() + () => FolderStore.archiveFolder() === this.messageListEndFolder() && FolderStore.archiveFolder() ); this.isArchiveDisabled = ko.computed(() => UNUSED_OPTION_VALUE === FolderStore.archiveFolder()); @@ -538,7 +538,7 @@ class MessageListMailBoxUserView extends AbstractViewNext { * @returns {void} */ setActionForAll(sFolderFullNameRaw, iSetAction, sThreadUid = '') { - if ('' !== sFolderFullNameRaw) { + if (sFolderFullNameRaw) { let cnt = 0; const uids = []; @@ -728,9 +728,9 @@ class MessageListMailBoxUserView extends AbstractViewNext { clearListIsVisible() { return ( - '' === this.messageListSearchDesc() && - '' === this.messageListError() && - '' === this.messageListEndThreadUid() && + !this.messageListSearchDesc() && + !this.messageListError() && + !this.messageListEndThreadUid() && this.messageList().length && (this.isSpamFolder() || this.isTrashFolder()) ); @@ -910,10 +910,10 @@ class MessageListMailBoxUserView extends AbstractViewNext { // cancel search key('esc', KeyState.MessageList, () => { - if ('' !== this.messageListSearchDesc()) { + if (this.messageListSearchDesc()) { this.cancelSearch(); return false; - } else if ('' !== this.messageListEndThreadUid()) { + } else if (this.messageListEndThreadUid()) { this.cancelThreadUid(); return false; } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index 4379ee5a3..25dc4563f 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -297,7 +297,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { if (pic !== this.viewUserPic() && lastEmail === email) { this.viewUserPicVisible(false); this.viewUserPic(DATA_IMAGE_USER_DOT_PIC); - if ('' !== pic) { + if (pic) { this.viewUserPicVisible(true); this.viewUserPic(pic); } @@ -386,7 +386,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { if (dom && 1 === dom.length) { let aC = dom; - while ('' === result) { + while (!result) { limit -= 1; if (0 >= limit) { break; @@ -456,7 +456,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { // return sLine ? [window.decodeURIComponent(sLine)].map(sItem => { // var oEmailModel = new EmailModel(); // oEmailModel.parse(sItem); - // return '' !== oEmailModel.email ? oEmailModel : null; + // return oEmailModel.email ? oEmailModel : null; // }).filter(value => !!value) : null; // } // ; @@ -930,7 +930,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext { * @returns {void} */ readReceipt(oMessage) { - if (oMessage && '' !== oMessage.readReceipt()) { + if (oMessage && oMessage.readReceipt()) { Remote.sendReadReceiptMessage( noop, oMessage.folderFullNameRaw, diff --git a/vendors/ckeditor-plugins/signature/plugin.js b/vendors/ckeditor-plugins/signature/plugin.js index feffc4dd4..9a0510099 100644 --- a/vendors/ckeditor-plugins/signature/plugin.js +++ b/vendors/ckeditor-plugins/signature/plugin.js @@ -1,5 +1,5 @@ -(function(CKEDITOR, $, undefined) { +(function(CKEDITOR, $) { 'use strict'; @@ -13,10 +13,10 @@ return $.trim(editor.__textUtils.htmlToPlain(html)); }; - isEmptyText = '' === $.trim(text); + isEmptyText = !$.trim(text); if (!isEmptyText && isHtml) { - isEmptyText = '' === clearHtmlLine(text); + isEmptyText = !clearHtmlLine(text); } if (editor.__previos_signature && !isEmptyText) diff --git a/vendors/jua/jua.js b/vendors/jua/jua.js index 8fa19e381..55d1497bb 100644 --- a/vendors/jua/jua.js +++ b/vendors/jua/jua.js @@ -190,7 +190,7 @@ sFileName = sFileName.substr(1); } - if ('' === sType && 0 === iSize) + if (!sType && 0 === iSize) { return null; // Folder }