diff --git a/app.js b/app.js index 4b1ec7d1..f6b8f1d5 100644 --- a/app.js +++ b/app.js @@ -76,10 +76,10 @@ ipc.on('autoUpdater:update-downloaded', function(e, releaseNotes, releaseName, r // Set Badge in taskbar for Windows ipc.on('setBadge', function(event, messageCount) { messageCount = messageCount.toString(); - var canvas = document.createElement("canvas"); + const canvas = document.createElement("canvas"); canvas.height = 140; canvas.width = 140; - var ctx = canvas.getContext("2d"); + const ctx = canvas.getContext("2d"); ctx.fillStyle = "red"; ctx.beginPath(); ctx.ellipse(70, 70, 70, 70, 0, 0, 2 * Math.PI); @@ -87,7 +87,7 @@ ipc.on('setBadge', function(event, messageCount) { ctx.textAlign = "center"; ctx.fillStyle = "white"; - var ranges = [ + const ranges = [ { divider: 1e18 , suffix: 'P' }, { divider: 1e15 , suffix: 'E' }, { divider: 1e12 , suffix: 'T' }, @@ -98,7 +98,7 @@ ipc.on('setBadge', function(event, messageCount) { function formatNumber(n) { n = parseInt(n); - for (let i of ranges) { + for (const i of ranges) { if (n >= i.divider) { return Math.round(n / i.divider).toString() + i.suffix; } @@ -124,14 +124,14 @@ ipc.on('setBadge', function(event, messageCount) { }); // Reload Current Service ipc.on('reloadCurrentService', function(e) { - var tab = Ext.cq1('app-main').getActiveTab(); + const tab = Ext.cq1('app-main').getActiveTab(); if ( tab.id !== 'ramboxTab' ) tab.reloadService(); }); ipc.on('tabFocusNext', function() { - var tabPanel = Ext.cq1('app-main'); - var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); - var i = activeIndex + 1; + const tabPanel = Ext.cq1('app-main'); + const activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); + let i = activeIndex + 1; tabPanel.getActiveTab().blur(); @@ -146,9 +146,9 @@ ipc.on('tabFocusNext', function() { }); ipc.on('tabFocusPrevious', function() { - var tabPanel = Ext.cq1('app-main'); - var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); - var i = activeIndex - 1; + const tabPanel = Ext.cq1('app-main'); + const activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); + let i = activeIndex - 1; tabPanel.getActiveTab().blur(); if ( i < 0 ) i = tabPanel.items.items.length - 1; while ( tabPanel.items.items[i].id === 'tbfill' || i < 0 ) i--; @@ -157,31 +157,31 @@ ipc.on('tabFocusPrevious', function() { }); ipc.on('tabZoomIn', function() { - var tabPanel = Ext.cq1('app-main'); + const tabPanel = Ext.cq1('app-main'); if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; tabPanel.getActiveTab().zoomIn(); }); ipc.on('tabZoomOut', function() { - var tabPanel = Ext.cq1('app-main'); + const tabPanel = Ext.cq1('app-main'); if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; tabPanel.getActiveTab().zoomOut(); }); ipc.on('tabResetZoom', function() { - var tabPanel = Ext.cq1('app-main'); + const tabPanel = Ext.cq1('app-main'); if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; tabPanel.getActiveTab().resetZoom(); }); ipc.on('toggleDoNotDisturb', function(key) { - var btn = Ext.getCmp('disturbBtn'); + const btn = Ext.getCmp('disturbBtn'); btn.toggle(); Ext.cq1('app-main').getController().dontDisturb(btn, true); }); ipc.on('lockWindow', function(key) { - var btn = Ext.getCmp('lockRamboxBtn'); + const btn = Ext.getCmp('lockRamboxBtn'); Ext.cq1('app-main').getController().lockRambox(btn); }); diff --git a/app/Application.js b/app/Application.js index 2eebc241..6faf0c70 100644 --- a/app/Application.js +++ b/app/Application.js @@ -34,9 +34,9 @@ Ext.define('Rambox.Application', { // Mouse Wheel zooming document.addEventListener('mousewheel', function(e) { if( e.ctrlKey ) { - var delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail)); + const delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail)); - var tabPanel = Ext.cq1('app-main'); + const tabPanel = Ext.cq1('app-main'); if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; if ( delta === 1 ) { // Zoom In @@ -83,8 +83,8 @@ Ext.define('Rambox.Application', { url: 'https://api.github.com/repos/TheGoddessInari/rambox/releases/latest' ,method: 'GET' ,success(response) { - var json = JSON.parse(response.responseText); - var appVersion = new Ext.Version(require('electron').remote.app.getVersion()); + const json = JSON.parse(response.responseText); + const appVersion = new Ext.Version(require('electron').remote.app.getVersion()); if ( appVersion.isLessThan(json.version) ) { console.info('New version is available', json.version); Ext.cq1('app-main').addDocked({ diff --git a/app/store/Services.js b/app/store/Services.js index 1ab89584..2940b811 100644 --- a/app/store/Services.js +++ b/app/store/Services.js @@ -23,13 +23,13 @@ Ext.define('Rambox.store.Services', { load( store, records, successful ) { Ext.cq1('app-main').suspendEvent('add'); - var servicesLeft = []; - var servicesRight = []; + let servicesLeft = []; + let servicesRight = []; store.each(function(service) { // If the service is disabled, we dont add it to tab bar if ( !service.get('enabled') ) return; - var cfg = { + const cfg = { xtype: 'webview' ,id: 'tab_'+service.get('id') ,title: service.get('name') diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index 1e308ed6..929c9f48 100644 --- a/app/store/ServicesList.js +++ b/app/store/ServicesList.js @@ -627,7 +627,7 @@ Ext.define('Rambox.store.ServicesList', { ,description: 'Flock is a free enterprise tool for business communication. Packed with tons of productivity features, Flock drives efficiency and boosts speed of execution.' ,url: 'https://web.flock.co/' ,type: 'messaging' - ,js_unread: `let checkUnread=()=>{var a=document.getElementsByClassName("unreadMessages no-unread-mentions has-unread");let b=0;for(let i of a)b+=parseInt(i.innerHTML.trim());rambox.updateBadge(b)};setInterval(checkUnread,3e3);` + ,js_unread: `let checkUnread=()=>{const a=document.getElementsByClassName("unreadMessages no-unread-mentions has-unread");let b=0;for(const i of a)b+=parseInt(i.innerHTML.trim());rambox.updateBadge(b)};setInterval(checkUnread,3e3);` }, { diff --git a/app/util/MD5.js b/app/util/MD5.js index e54ff687..139c85db 100644 --- a/app/util/MD5.js +++ b/app/util/MD5.js @@ -7,8 +7,8 @@ Ext.define('Rambox.util.MD5', { chrsz = chrsz || 8; function safe_add(x, y){ - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + const lsw = (x & 0xFFFF) + (y & 0xFFFF); + const msw = (x >> 16) + (y >> 16) + (lsw >> 16); return (msw << 16) | (lsw & 0xFFFF); } function bit_rol(num, cnt){ @@ -33,15 +33,15 @@ Ext.define('Rambox.util.MD5', { function core_md5(x, len){ x[len >> 5] |= 0x80 << ((len) % 32); x[(((len + 64) >>> 9) << 4) + 14] = len; - var a = 1732584193; - var b = -271733879; - var c = -1732584194; - var d = 271733878; - for(var i = 0; i < x.length; i += 16){ - var olda = a; - var oldb = b; - var oldc = c; - var oldd = d; + let a = 1732584193; + let b = -271733879; + let c = -1732584194; + let d = 271733878; + for(let i = 0; i < x.length; i += 16){ + const olda = a; + const oldb = b; + const oldc = c; + const oldd = d; a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); @@ -114,26 +114,26 @@ Ext.define('Rambox.util.MD5', { return [a, b, c, d]; } function str2binl(str){ - var bin = []; - var mask = (1 << chrsz) - 1; - for(var i = 0; i < str.length * chrsz; i += chrsz) { + let bin = []; + const mask = (1 << chrsz) - 1; + for(let i = 0; i < str.length * chrsz; i += chrsz) { bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); } return bin; } function binl2str(bin){ - var str = ""; - var mask = (1 << chrsz) - 1; - for(var i = 0; i < bin.length * 32; i += chrsz) { + let str = ""; + const mask = (1 << chrsz) - 1; + for(let i = 0; i < bin.length * 32; i += chrsz) { str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); } return str; } function binl2hex(binarray){ - var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; - var str = ""; - for(var i = 0; i < binarray.length * 4; i++) { + const hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; + let str = ""; + for(let i = 0; i < binarray.length * 4; i++) { str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF); } return str; diff --git a/app/util/Notifier.js b/app/util/Notifier.js index e288481c..a7c36044 100644 --- a/app/util/Notifier.js +++ b/app/util/Notifier.js @@ -18,7 +18,7 @@ Ext.define('Rambox.util.Notifier', { * @return {*} */ function getNotificationText(view, count) { - var text; + let text; switch (Ext.getStore('ServicesList').getById(view.type).get('type')) { case 'messaging': text = 'You have ' + Ext.util.Format.plural(count, 'new message', 'new messages') + '.'; @@ -40,9 +40,9 @@ Ext.define('Rambox.util.Notifier', { * @param {number} count The unread count */ this.dispatchNotification = function(view, count) { - var text = getNotificationText(view, count); + const text = getNotificationText(view, count); - var notification = new Notification(view.record.get('name'), { + const notification = new Notification(view.record.get('name'), { body: text, icon: view.icon, silent: view.record.get('muted') diff --git a/app/util/UnreadCounter.js b/app/util/UnreadCounter.js index 4948ef3d..6433dba6 100644 --- a/app/util/UnreadCounter.js +++ b/app/util/UnreadCounter.js @@ -15,14 +15,14 @@ Ext.define('Rambox.util.UnreadCounter', { * * @type {Map} */ - var unreadCountByService = new Map(); + let unreadCountByService = new Map(); /** * Holds the global unread count for internal usage. * * @type {number} */ - var totalUnreadCount = 0; + let totalUnreadCount = 0; /** * Sets the application's unread count to tracked unread count. diff --git a/app/ux/FileBackup.js b/app/ux/FileBackup.js index bcc3493d..dcf6c570 100644 --- a/app/ux/FileBackup.js +++ b/app/ux/FileBackup.js @@ -11,7 +11,7 @@ Ext.define('Rambox.ux.FileBackup', { me.myDefaultPath = me.userPath + me.path.sep + me.defaultFileName; }, backupConfiguration(callback) { - var me = this; + const me = this; let services = []; Ext.getStore('Services').each(function(service) { const s = Ext.clone(service); @@ -34,7 +34,7 @@ Ext.define('Rambox.ux.FileBackup', { if (Ext.isFunction(callback)) callback.bind(me)(); }, restoreConfiguration() { - var me = this; + const me = this; me.remote.dialog.showOpenDialog({ defaultPath: me.myDefaultPath, properties: ['openFile'] diff --git a/app/ux/WebView.js b/app/ux/WebView.js index 2a241415..cc900675 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -19,10 +19,10 @@ Ext.define('Rambox.ux.WebView',{ // CONFIG ,hideMode: 'offsets' ,initComponent(config) { - var me = this; + const me = this; function getLocation(href) { - var match = href.match(/^(https?):\/\/([-.\w]*)(\/[^#?]*)(\?[^#]*|)(#.*|)$/); + const match = href.match(/^(https?):\/\/([-.\w]*)(\/[^#?]*)(\?[^#]*|)(#.*|)$/); return match && { protocol: match[1], host: match[2], @@ -136,15 +136,15 @@ Ext.define('Rambox.ux.WebView',{ } ,onBeforeDestroy() { - var me = this; + const me = this; me.setUnreadCount(0); } ,webViewConstructor( enabled ) { - var me = this; + const me = this; - var cfg; + let cfg; enabled = enabled || me.record.get('enabled'); if ( !enabled ) { @@ -181,7 +181,7 @@ Ext.define('Rambox.ux.WebView',{ } ,statusBarConstructor(floating) { - var me = this; + const me = this; return { xtype: 'statusbar' @@ -217,11 +217,11 @@ Ext.define('Rambox.ux.WebView',{ } ,onAfterRender() { - var me = this; + const me = this; if ( !me.record.get('enabled') ) return; - var webview = me.getWebView(); + const webview = me.getWebView(); // Notifications in Webview me.setNotifications(localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ? false : me.record.get('notifications')); @@ -352,7 +352,7 @@ Ext.define('Rambox.ux.WebView',{ show(win) { const webview = win.down('#webview').el.dom; webview.addEventListener('ipc-message', function(event) { - var channel = event.channel; + const channel = event.channel; switch (channel) { case 'close': win.close(); @@ -413,8 +413,8 @@ Ext.define('Rambox.ux.WebView',{ // Mute Webview if ( me.record.get('muted') || localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ) me.setAudioMuted(true, true); - var js_inject = ''; - var css_inject = ''; + let js_inject = ''; + let css_inject = ''; // Injected code to detect new messages if ( me.record ) { let js_unread = me.record.get('js_unread'); @@ -473,7 +473,7 @@ Ext.define('Rambox.ux.WebView',{ // Prevent Title blinking (some services have) and only allow when the title have an unread regex match: "(3) Title" if ( Ext.getStore('ServicesList').getById(me.record.get('type')).get('titleBlink') ) { - var js_preventBlink = 'var originalTitle=document.title;Object.defineProperty(document,"title",{configurable:!0,set:function(a){null===a.match(new RegExp("[(]([0-9•]+)[)][ ](.*)","g"))&&a!==originalTitle||(document.getElementsByTagName("title")[0].innerHTML=a)},get:function(){return document.getElementsByTagName("title")[0].innerHTML}});'; + const js_preventBlink = `const originalTitle=document.title;Object.defineProperty(document,"title",{configurable:!0,set(a){null===a.match(new RegExp("[(]([0-9•]+)[)][ ](.*)","g"))&&a!==originalTitle||(document.getElementsByTagName("title")[0].innerHTML=a)},get:()=>document.getElementsByTagName("title")[0].innerHTML});`; js_inject += js_preventBlink; } @@ -511,7 +511,7 @@ Ext.define('Rambox.ux.WebView',{ }); webview.addEventListener('ipc-message', function(event) { - var channel = event.channel; + const channel = event.channel; switch (channel) { case 'rambox.setUnreadCount': handleSetUnreadCount(event); @@ -584,7 +584,7 @@ Ext.define('Rambox.ux.WebView',{ if (Ext.getStore('ServicesList').getById(me.record.get('type')).get('js_unread') === '' && me.record.get('js_unread') === '') { webview.addEventListener("page-title-updated", function(e) { - var count = e.title.match(/\(([^)]+)\)/); // Get text between (...) + let count = e.title.match(/\(([^)]+)\)/); // Get text between (...) count = count ? count[1] : '0'; count = count === '•' ? count : Ext.isArray(count.match(/\d+/g)) ? count.match(/\d+/g).join("") : count.match(/\d+/g); // Some services have special characters. Example: (•) count = count === null ? '0' : count; @@ -603,7 +603,7 @@ Ext.define('Rambox.ux.WebView',{ } ,setUnreadCount(newUnreadCount) { - var me = this; + const me = this; if ( !isNaN(newUnreadCount) && (function(x) { return (x | 0) === x; })(parseFloat(newUnreadCount)) && me.record.get('includeInGlobalUnreadCounter') === true) { Rambox.util.UnreadCounter.setUnreadCountForService(me.record.get('id'), newUnreadCount); @@ -630,7 +630,7 @@ Ext.define('Rambox.ux.WebView',{ * @param {int} count */ ,doManualNotification(count) { - var me = this; + const me = this; if (Ext.getStore('ServicesList').getById(me.type).get('manual_notifications') && me.currentUnreadCount < count && @@ -648,7 +648,7 @@ Ext.define('Rambox.ux.WebView',{ * @param {string} badgeText */ ,setTabBadgeText(badgeText) { - var me = this; + const me = this; if (me.record.get('displayTabUnreadCounter') === true) { me.tab.setBadgeText(badgeText); } else { @@ -662,14 +662,14 @@ Ext.define('Rambox.ux.WebView',{ * • clears the global unread counter */ ,clearUnreadCounter() { - var me = this; + const me = this; me.tab.setBadgeText(''); Rambox.util.UnreadCounter.clearUnreadCountForService(me.record.get('id')); } ,reloadService(btn) { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); if ( me.record.get('enabled') ) { me.clearUnreadCounter(); @@ -678,8 +678,8 @@ Ext.define('Rambox.ux.WebView',{ } ,toggleDevTools(btn) { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); if ( me.record.get('enabled')) { if (webview.isDevToolsOpened()) { @@ -691,8 +691,8 @@ Ext.define('Rambox.ux.WebView',{ } ,setURL(url) { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); me.src = url; @@ -700,8 +700,8 @@ Ext.define('Rambox.ux.WebView',{ } ,setAudioMuted(muted, calledFromDisturb) { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); me.muted = muted; @@ -711,7 +711,7 @@ Ext.define('Rambox.ux.WebView',{ } ,closeStatusBar() { - var me = this; + const me = this; me.down('statusbar').hide(); me.down('statusbar').closed = true; @@ -719,7 +719,7 @@ Ext.define('Rambox.ux.WebView',{ } ,setStatusBar(keep) { - var me = this; + const me = this; me.removeDocked(me.down('statusbar'), true); @@ -732,8 +732,8 @@ Ext.define('Rambox.ux.WebView',{ } ,setNotifications(notification, calledFromDisturb) { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); me.notifications = notification; @@ -743,7 +743,7 @@ Ext.define('Rambox.ux.WebView',{ } ,setEnabled(enabled) { - var me = this; + const me = this; me.clearUnreadCounter(); @@ -761,15 +761,15 @@ Ext.define('Rambox.ux.WebView',{ } ,goBack() { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); if ( me.record.get('enabled') ) webview.goBack(); } ,goForward() { - var me = this; - var webview = me.getWebView(); + const me = this; + const webview = me.getWebView(); if ( me.record.get('enabled') ) webview.goForward(); } @@ -779,7 +779,7 @@ Ext.define('Rambox.ux.WebView',{ } ,zoomIn() { - var me = this; + const me = this; me.zoomLevel = me.zoomLevel + 1; if ( me.record.get('enabled') ) { @@ -789,7 +789,7 @@ Ext.define('Rambox.ux.WebView',{ } ,zoomOut() { - var me = this; + const me = this; me.zoomLevel = me.zoomLevel - 1; if ( me.record.get('enabled') ) { @@ -799,7 +799,7 @@ Ext.define('Rambox.ux.WebView',{ } ,resetZoom() { - var me = this; + const me = this; me.zoomLevel = 0; if ( me.record.get('enabled') ) { diff --git a/app/ux/mixin/Badge.js b/app/ux/mixin/Badge.js index fae47ea7..caf6234a 100644 --- a/app/ux/mixin/Badge.js +++ b/app/ux/mixin/Badge.js @@ -21,7 +21,7 @@ Ext.define('Rambox.ux.mixin.Badge', { }, renderBadgeText() { - var badgeText = this.getBadgeText(); + const badgeText = this.getBadgeText(); if (badgeText) { this.updateBadgeText(badgeText); @@ -29,7 +29,7 @@ Ext.define('Rambox.ux.mixin.Badge', { }, updateBadgeText(badgeText, oldBadgeText) { - var me = this, + const me = this, el = me.el; if (me.rendered) { diff --git a/app/view/add/Add.js b/app/view/add/Add.js index 84f1c787..c69e2ccd 100644 --- a/app/view/add/Add.js +++ b/app/view/add/Add.js @@ -26,7 +26,7 @@ Ext.define('Rambox.view.add.Add',{ ,bodyPadding: 20 ,initComponent() { - var me = this; + const me = this; me.title = (!me.edit ? locale['app.window[0]'] : locale['app.window[1]']) + ' ' + me.record.get('name'); me.icon = me.record.get('type') === 'custom' ? (!me.edit ? 'resources/icons/custom.png' : (me.record.get('logo') === '' ? 'resources/icons/custom.png' : me.record.get('logo'))) : 'resources/icons/'+me.record.get('logo'); diff --git a/app/view/add/AddController.js b/app/view/add/AddController.js index d74e832f..ae613973 100644 --- a/app/view/add/AddController.js +++ b/app/view/add/AddController.js @@ -7,18 +7,18 @@ Ext.define('Rambox.view.add.AddController', { ], doCancel( btn ) { - var me = this; + const me = this; me.getView().close(); } ,doSave( btn ) { - var me = this; + const me = this; - var win = me.getView(); + const win = me.getView(); if ( !win.down('form').isValid() ) return false; - var formValues = win.down('form').getValues(); + const formValues = win.down('form').getValues(); if ( win.edit ) { // Format data @@ -26,7 +26,7 @@ Ext.define('Rambox.view.add.AddController', { formValues.url = formValues.cycleValue === '1' ? win.service.get('url').replace('___', formValues.url) : formValues.url; } - var oldData = win.record.getData(); + const oldData = win.record.getData(); win.record.set({ logo: formValues.logo ,name: formValues.serviceName @@ -46,7 +46,7 @@ Ext.define('Rambox.view.add.AddController', { ,slowed_timers: formValues.slowed_timers }); - var view = Ext.getCmp('tab_'+win.record.get('id')); + const view = Ext.getCmp('tab_'+win.record.get('id')); // Change the title of the Tab view.setTitle( formValues.tabname ? formValues.serviceName : '' ); @@ -83,7 +83,7 @@ Ext.define('Rambox.view.add.AddController', { formValues.url = formValues.cycleValue === '1' ? win.record.get('url').replace('___', formValues.url) : formValues.url; } - var service = Ext.create('Rambox.model.Service', { + const service = Ext.create('Rambox.model.Service', { type: win.record.get('id') ,logo: formValues.logo ,name: formValues.serviceName @@ -105,7 +105,7 @@ Ext.define('Rambox.view.add.AddController', { service.save(); Ext.getStore('Services').add(service); - var tabData = { + const tabData = { xtype: 'webview' ,id: 'tab_'+service.get('id') /* @@ -124,7 +124,7 @@ Ext.define('Rambox.view.add.AddController', { }; if ( formValues.align === 'left' ) { - var tbfill = Ext.cq1('app-main').getTabBar().down('tbfill'); + const tbfill = Ext.cq1('app-main').getTabBar().down('tbfill'); Ext.cq1('app-main').insert(Ext.cq1('app-main').getTabBar().items.indexOf(tbfill), tabData).show(); } else { Ext.cq1('app-main').add(tabData).show(); @@ -135,13 +135,13 @@ Ext.define('Rambox.view.add.AddController', { } ,onEnter(field, e) { - var me = this; + const me = this; if ( e.getKey() === e.ENTER && field.up('form').isValid() ) me.doSave(); } ,onShow(win) { - var me = this; + const me = this; // Make focus to the name field win.down('textfield[name="serviceName"]').focus(true, 100); diff --git a/app/view/main/About.js b/app/view/main/About.js index e88767ee..f9cab0f3 100644 --- a/app/view/main/About.js +++ b/app/view/main/About.js @@ -10,7 +10,7 @@ Ext.define('Rambox.view.main.About', { ,height: 450 ,bodyPadding: 10 ,initComponent() { - var me = this; + const me = this; me.callParent(arguments); me.data.buildversion = require('fs').readFileSync( __dirname + '/BUILDVERSION', 'utf8'); } diff --git a/app/view/main/MainController.js b/app/view/main/MainController.js index f183b614..595925fe 100644 --- a/app/view/main/MainController.js +++ b/app/view/main/MainController.js @@ -23,7 +23,7 @@ Ext.define('Rambox.view.main.MainController', { // Make focus on webview every time the user change tabs, to enable the autofocus in websites ,onTabChange( tabPanel, newTab, oldTab ) { - var me = this; + const me = this; localStorage.setItem('last_active_service', newTab.id); @@ -40,7 +40,7 @@ Ext.define('Rambox.view.main.MainController', { return; } - var webview = newTab.getWebView(); + const webview = newTab.getWebView(); if ( webview ) webview.focus(); // Update the main window so it includes the active tab title. @@ -56,12 +56,12 @@ Ext.define('Rambox.view.main.MainController', { console.log('Updating Tabs positions...'); - var store = Ext.getStore('Services'); - var align = 'left'; + const store = Ext.getStore('Services'); + let align = 'left'; store.suspendEvent('childmove'); Ext.each(tabPanel.items.items, function(t, i) { if ( t.id !== 'ramboxTab' && t.id !== 'tbfill' && t.record.get('enabled') ) { - var rec = store.getById(t.record.get('id')); + const rec = store.getById(t.record.get('id')); if ( align === 'right' ) i--; rec.set('align', align); rec.set('position', i); @@ -84,7 +84,7 @@ Ext.define('Rambox.view.main.MainController', { } ,onRenameService(editor, e) { - var me = this; + const me = this; e.record.commit(); @@ -93,7 +93,7 @@ Ext.define('Rambox.view.main.MainController', { } ,onEnableDisableService(cc, rowIndex, checked, obj, hideTab) { - var rec = Ext.getStore('Services').getAt(rowIndex); + const rec = Ext.getStore('Services').getAt(rowIndex); if ( !checked ) { Ext.getCmp('tab_'+rec.get('id')).destroy(); @@ -128,7 +128,7 @@ Ext.define('Rambox.view.main.MainController', { } ,removeServiceFn(serviceId, total, actual, resolve) { - var me = this; + const me = this; if ( !serviceId ) return false; // Get Record @@ -174,7 +174,7 @@ Ext.define('Rambox.view.main.MainController', { } ,removeService( gridView, rowIndex, colIndex, col, e, rec, rowEl ) { - var me = this; + const me = this; Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[13]']+' '+rec.get('name')+'?', function(btnId) { if ( btnId === 'yes' ) { @@ -185,7 +185,7 @@ Ext.define('Rambox.view.main.MainController', { } ,removeAllServices(btn, callback) { - var me = this; + const me = this; // Clear counter for unread messaging document.title = 'Rambox-OS'; @@ -245,7 +245,7 @@ Ext.define('Rambox.view.main.MainController', { } ,onSearchEnter( field, e ) { - var me = this; + const me = this; if ( e.getKey() === e.ENTER && Ext.getStore('ServicesList').getCount() === 2 ) { // Two because we always shows Custom Service option me.onNewServiceSelect(field.up().down('dataview'), Ext.getStore('ServicesList').getAt(0)); @@ -254,7 +254,7 @@ Ext.define('Rambox.view.main.MainController', { } ,doTypeFilter( cg, newValue, oldValue ) { - var me = this; + const me = this; Ext.getStore('ServicesList').getFilters().replaceAll({ fn(record) { @@ -264,9 +264,9 @@ Ext.define('Rambox.view.main.MainController', { } ,onSearchServiceChange(field, newValue, oldValue) { - var me = this; + const me = this; - var cg = field.up().down('checkboxgroup'); + const cg = field.up().down('checkboxgroup'); if ( !Ext.isEmpty(newValue) && newValue.length > 0 ) { field.getTrigger('clear').show(); @@ -286,9 +286,9 @@ Ext.define('Rambox.view.main.MainController', { } ,onClearClick(field, trigger, e) { - var me = this; + const me = this; - var cg = field.up().down('checkboxgroup'); + const cg = field.up().down('checkboxgroup'); field.reset(); field.getTrigger('clear').hide(); @@ -303,7 +303,7 @@ Ext.define('Rambox.view.main.MainController', { Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) { // Get Tab - var tab = Ext.getCmp('tab_'+serviceId); + const tab = Ext.getCmp('tab_'+serviceId); if ( !tab ) return; // Skip disabled services @@ -332,7 +332,7 @@ Ext.define('Rambox.view.main.MainController', { } ,lockRambox(btn) { - var me = this; + const me = this; if ( ipc.sendSync('getConfig').master_password ) { Ext.Msg.confirm(locale['app.main[19]'], 'Do you want to use the Master Password as your temporal password?', function(btnId) { @@ -347,9 +347,9 @@ Ext.define('Rambox.view.main.MainController', { } function showTempPass() { - var msgbox = Ext.Msg.prompt(locale['app.main[19]'], locale['app.window[22]'], function(btnId, text) { + const msgbox = Ext.Msg.prompt(locale['app.main[19]'], locale['app.window[22]'], function(btnId, text) { if ( btnId === 'ok' ) { - var msgbox2 = Ext.Msg.prompt(locale['app.main[19]'], locale['app.window[23]'], function(btnId, text2) { + const msgbox2 = Ext.Msg.prompt(locale['app.main[19]'], locale['app.window[23]'], function(btnId, text2) { if ( btnId === 'ok' ) { if ( text !== text2 ) { Ext.Msg.show({ @@ -385,9 +385,9 @@ Ext.define('Rambox.view.main.MainController', { } ,showLockWindow() { - var me = this; + const me = this; - var validateFn = function() { + const validateFn = function() { if ( localStorage.getItem('locked') === Rambox.util.MD5.encypt(winLock.down('textfield').getValue()) ) { console.info('Lock Rambox:', 'Disabled'); localStorage.removeItem('locked'); @@ -400,7 +400,7 @@ Ext.define('Rambox.view.main.MainController', { } }; - var winLock = Ext.create('Ext.window.Window', { + const winLock = Ext.create('Ext.window.Window', { maximized: true ,closable: false ,resizable: false @@ -464,7 +464,7 @@ Ext.define('Rambox.view.main.MainController', { } ,openPreferences( btn ) { - var me = this; + const me = this; Ext.create('Rambox.view.preferences.Preferences').show(); } diff --git a/app/view/preferences/Preferences.js b/app/view/preferences/Preferences.js index 0200189f..174c4c17 100644 --- a/app/view/preferences/Preferences.js +++ b/app/view/preferences/Preferences.js @@ -36,9 +36,9 @@ Ext.define('Rambox.view.preferences.Preferences',{ ] ,initComponent() { - var config = ipc.sendSync('getConfig'); + const config = ipc.sendSync('getConfig'); - var defaultServiceOptions = []; + let defaultServiceOptions = []; defaultServiceOptions.push({ value: 'ramboxTab', label: 'Rambox-OS Tab' }); defaultServiceOptions.push({ value: 'last', label: 'Last Active Service' }); Ext.getStore('Services').each(function(rec) { diff --git a/app/view/preferences/PreferencesController.js b/app/view/preferences/PreferencesController.js index 71bc124a..ec99e38c 100644 --- a/app/view/preferences/PreferencesController.js +++ b/app/view/preferences/PreferencesController.js @@ -3,15 +3,15 @@ Ext.define('Rambox.view.preferences.PreferencesController', { ,alias: 'controller.preferences-preferences' ,cancel( btn ) { - var me = this; + const me = this; me.getView().close(); } ,save( btn ) { - var me = this; + const me = this; - var values = me.getView().down('form').getForm().getFieldValues(); + const values = me.getView().down('form').getForm().getFieldValues(); // master password activated and only one of the fields "password" or "password confirmation" filled if (values.master_password === true && diff --git a/electron/main.js b/electron/main.js index f2068a5f..f94daa06 100644 --- a/electron/main.js +++ b/electron/main.js @@ -4,7 +4,7 @@ const {app, protocol, BrowserWindow, dialog, shell, Menu, ipcMain, nativeImage, // Tray const tray = require('./tray'); // AutoLaunch -var AutoLaunch = require('auto-launch-patched'); +const AutoLaunch = require('auto-launch-patched'); // Configuration const Config = require('electron-store'); // Development @@ -12,7 +12,7 @@ const isDev = require('electron-is-dev'); // Updater const updater = require('./updater'); // File System -var fs = require("fs"); +const fs = require("fs"); const path = require('path'); // Initial Config @@ -219,7 +219,7 @@ function createMasterPasswordWindow() { function updateBadge(title) { title = title.split(" - ")[0]; //Discard service name if present, could also contain digits - var messageCount = title.match(/\d+/g) ? parseInt(title.match(/\d+/g).join("")) : 0; + let messageCount = title.match(/\d+/g) ? parseInt(title.match(/\d+/g).join("")) : 0; messageCount = isNaN(messageCount) ? 0 : messageCount; tray.setBadge(messageCount, config.get('systemtray_indicator')); @@ -239,7 +239,7 @@ function updateBadge(title) { } ipcMain.on('setBadge', function(event, messageCount, value) { - var img = nativeImage.createFromDataURL(value); + const img = nativeImage.createFromDataURL(value); mainWindow.setOverlayIcon(img, messageCount.toString()); }); @@ -336,7 +336,7 @@ if (!haveLock) { // Code for downloading images as temporal files // Credit: Ghetto Skype (https://github.com/stanfieldr/ghetto-skype) -var imageCache = {}; +let imageCache = {}; ipcMain.on('image:download', function(event, url, partition) { const tmp = require('tmp'); const mime = require('mime'); diff --git a/electron/tray.js b/electron/tray.js index 83f1da77..7b7b0735 100644 --- a/electron/tray.js +++ b/electron/tray.js @@ -2,7 +2,7 @@ const path = require('path'); const {app, electron, nativeImage, Menu, MenuItem, Tray} = require('electron'); // Module to create tray icon -var appIcon = null; +let appIcon = null; exports.create = function(win, config) { if (process.platform === 'darwin' || appIcon || config.get('window_display_behavior') === 'show_taskbar' ) return; diff --git a/index.html b/index.html index 8f250bd9..fa4835ff 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@