Browse Source

Replace var with let or const as appropriate.

pull/3202/head
TheGoddessInari 6 years ago
parent
commit
97837a7e92
No known key found for this signature in database
GPG Key ID: 1209B1B7632D69A
  1. 32
      app.js
  2. 8
      app/Application.js
  3. 6
      app/store/Services.js
  4. 2
      app/store/ServicesList.js
  5. 40
      app/util/MD5.js
  6. 6
      app/util/Notifier.js
  7. 4
      app/util/UnreadCounter.js
  8. 4
      app/ux/FileBackup.js
  9. 76
      app/ux/WebView.js
  10. 4
      app/ux/mixin/Badge.js
  11. 2
      app/view/add/Add.js
  12. 22
      app/view/add/AddController.js
  13. 2
      app/view/main/About.js
  14. 48
      app/view/main/MainController.js
  15. 4
      app/view/preferences/Preferences.js
  16. 6
      app/view/preferences/PreferencesController.js
  17. 10
      electron/main.js
  18. 2
      electron/tray.js
  19. 2
      index.html
  20. 8
      overrides/form/field/VTypes.js
  21. 6
      overrides/grid/column/Action.js
  22. 45
      resources/js/loadscreen.js
  23. 6
      resources/js/rambox-service-api.js
  24. 6
      test/helpers/RamboxTestHelper.js
  25. 8
      test/tests/app/example.spec.js

32
app.js

@ -76,10 +76,10 @@ ipc.on('autoUpdater:update-downloaded', function(e, releaseNotes, releaseName, r
// Set Badge in taskbar for Windows // Set Badge in taskbar for Windows
ipc.on('setBadge', function(event, messageCount) { ipc.on('setBadge', function(event, messageCount) {
messageCount = messageCount.toString(); messageCount = messageCount.toString();
var canvas = document.createElement("canvas"); const canvas = document.createElement("canvas");
canvas.height = 140; canvas.height = 140;
canvas.width = 140; canvas.width = 140;
var ctx = canvas.getContext("2d"); const ctx = canvas.getContext("2d");
ctx.fillStyle = "red"; ctx.fillStyle = "red";
ctx.beginPath(); ctx.beginPath();
ctx.ellipse(70, 70, 70, 70, 0, 0, 2 * Math.PI); 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.textAlign = "center";
ctx.fillStyle = "white"; ctx.fillStyle = "white";
var ranges = [ const ranges = [
{ divider: 1e18 , suffix: 'P' }, { divider: 1e18 , suffix: 'P' },
{ divider: 1e15 , suffix: 'E' }, { divider: 1e15 , suffix: 'E' },
{ divider: 1e12 , suffix: 'T' }, { divider: 1e12 , suffix: 'T' },
@ -98,7 +98,7 @@ ipc.on('setBadge', function(event, messageCount) {
function formatNumber(n) { function formatNumber(n) {
n = parseInt(n); n = parseInt(n);
for (let i of ranges) { for (const i of ranges) {
if (n >= i.divider) { if (n >= i.divider) {
return Math.round(n / i.divider).toString() + i.suffix; return Math.round(n / i.divider).toString() + i.suffix;
} }
@ -124,14 +124,14 @@ ipc.on('setBadge', function(event, messageCount) {
}); });
// Reload Current Service // Reload Current Service
ipc.on('reloadCurrentService', function(e) { 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(); if ( tab.id !== 'ramboxTab' ) tab.reloadService();
}); });
ipc.on('tabFocusNext', function() { ipc.on('tabFocusNext', function() {
var tabPanel = Ext.cq1('app-main'); const tabPanel = Ext.cq1('app-main');
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); const activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab());
var i = activeIndex + 1; let i = activeIndex + 1;
tabPanel.getActiveTab().blur(); tabPanel.getActiveTab().blur();
@ -146,9 +146,9 @@ ipc.on('tabFocusNext', function() {
}); });
ipc.on('tabFocusPrevious', function() { ipc.on('tabFocusPrevious', function() {
var tabPanel = Ext.cq1('app-main'); const tabPanel = Ext.cq1('app-main');
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); const activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab());
var i = activeIndex - 1; let i = activeIndex - 1;
tabPanel.getActiveTab().blur(); tabPanel.getActiveTab().blur();
if ( i < 0 ) i = tabPanel.items.items.length - 1; if ( i < 0 ) i = tabPanel.items.items.length - 1;
while ( tabPanel.items.items[i].id === 'tbfill' || i < 0 ) i--; while ( tabPanel.items.items[i].id === 'tbfill' || i < 0 ) i--;
@ -157,31 +157,31 @@ ipc.on('tabFocusPrevious', function() {
}); });
ipc.on('tabZoomIn', 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; if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().zoomIn(); tabPanel.getActiveTab().zoomIn();
}); });
ipc.on('tabZoomOut', function() { 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; if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().zoomOut(); tabPanel.getActiveTab().zoomOut();
}); });
ipc.on('tabResetZoom', function() { 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; if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
tabPanel.getActiveTab().resetZoom(); tabPanel.getActiveTab().resetZoom();
}); });
ipc.on('toggleDoNotDisturb', function(key) { ipc.on('toggleDoNotDisturb', function(key) {
var btn = Ext.getCmp('disturbBtn'); const btn = Ext.getCmp('disturbBtn');
btn.toggle(); btn.toggle();
Ext.cq1('app-main').getController().dontDisturb(btn, true); Ext.cq1('app-main').getController().dontDisturb(btn, true);
}); });
ipc.on('lockWindow', function(key) { ipc.on('lockWindow', function(key) {
var btn = Ext.getCmp('lockRamboxBtn'); const btn = Ext.getCmp('lockRamboxBtn');
Ext.cq1('app-main').getController().lockRambox(btn); Ext.cq1('app-main').getController().lockRambox(btn);
}); });

8
app/Application.js

@ -34,9 +34,9 @@ Ext.define('Rambox.Application', {
// Mouse Wheel zooming // Mouse Wheel zooming
document.addEventListener('mousewheel', function(e) { document.addEventListener('mousewheel', function(e) {
if( e.ctrlKey ) { 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 ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false;
if ( delta === 1 ) { // Zoom In if ( delta === 1 ) { // Zoom In
@ -83,8 +83,8 @@ Ext.define('Rambox.Application', {
url: 'https://api.github.com/repos/TheGoddessInari/rambox/releases/latest' url: 'https://api.github.com/repos/TheGoddessInari/rambox/releases/latest'
,method: 'GET' ,method: 'GET'
,success(response) { ,success(response) {
var json = JSON.parse(response.responseText); const json = JSON.parse(response.responseText);
var appVersion = new Ext.Version(require('electron').remote.app.getVersion()); const appVersion = new Ext.Version(require('electron').remote.app.getVersion());
if ( appVersion.isLessThan(json.version) ) { if ( appVersion.isLessThan(json.version) ) {
console.info('New version is available', json.version); console.info('New version is available', json.version);
Ext.cq1('app-main').addDocked({ Ext.cq1('app-main').addDocked({

6
app/store/Services.js

@ -23,13 +23,13 @@ Ext.define('Rambox.store.Services', {
load( store, records, successful ) { load( store, records, successful ) {
Ext.cq1('app-main').suspendEvent('add'); Ext.cq1('app-main').suspendEvent('add');
var servicesLeft = []; let servicesLeft = [];
var servicesRight = []; let servicesRight = [];
store.each(function(service) { store.each(function(service) {
// If the service is disabled, we dont add it to tab bar // If the service is disabled, we dont add it to tab bar
if ( !service.get('enabled') ) return; if ( !service.get('enabled') ) return;
var cfg = { const cfg = {
xtype: 'webview' xtype: 'webview'
,id: 'tab_'+service.get('id') ,id: 'tab_'+service.get('id')
,title: service.get('name') ,title: service.get('name')

2
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.' ,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/' ,url: 'https://web.flock.co/'
,type: 'messaging' ,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);`
}, },
{ {

40
app/util/MD5.js

@ -7,8 +7,8 @@ Ext.define('Rambox.util.MD5', {
chrsz = chrsz || 8; chrsz = chrsz || 8;
function safe_add(x, y){ function safe_add(x, y){
var lsw = (x & 0xFFFF) + (y & 0xFFFF); const lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16); const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF); return (msw << 16) | (lsw & 0xFFFF);
} }
function bit_rol(num, cnt){ function bit_rol(num, cnt){
@ -33,15 +33,15 @@ Ext.define('Rambox.util.MD5', {
function core_md5(x, len){ function core_md5(x, len){
x[len >> 5] |= 0x80 << ((len) % 32); x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len; x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193; let a = 1732584193;
var b = -271733879; let b = -271733879;
var c = -1732584194; let c = -1732584194;
var d = 271733878; let d = 271733878;
for(var i = 0; i < x.length; i += 16){ for(let i = 0; i < x.length; i += 16){
var olda = a; const olda = a;
var oldb = b; const oldb = b;
var oldc = c; const oldc = c;
var oldd = d; const oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819); 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]; return [a, b, c, d];
} }
function str2binl(str){ function str2binl(str){
var bin = []; let bin = [];
var mask = (1 << chrsz) - 1; const mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz) { for(let i = 0; i < str.length * chrsz; i += chrsz) {
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32); bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
} }
return bin; return bin;
} }
function binl2str(bin){ function binl2str(bin){
var str = ""; let str = "";
var mask = (1 << chrsz) - 1; const mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz) { for(let i = 0; i < bin.length * 32; i += chrsz) {
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask); str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
} }
return str; return str;
} }
function binl2hex(binarray){ function binl2hex(binarray){
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; const hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = ""; let str = "";
for(var i = 0; i < binarray.length * 4; i++) { 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); str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) + hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
} }
return str; return str;

6
app/util/Notifier.js

@ -18,7 +18,7 @@ Ext.define('Rambox.util.Notifier', {
* @return {*} * @return {*}
*/ */
function getNotificationText(view, count) { function getNotificationText(view, count) {
var text; let text;
switch (Ext.getStore('ServicesList').getById(view.type).get('type')) { switch (Ext.getStore('ServicesList').getById(view.type).get('type')) {
case 'messaging': case 'messaging':
text = 'You have ' + Ext.util.Format.plural(count, 'new message', 'new messages') + '.'; 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 * @param {number} count The unread count
*/ */
this.dispatchNotification = function(view, 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, body: text,
icon: view.icon, icon: view.icon,
silent: view.record.get('muted') silent: view.record.get('muted')

4
app/util/UnreadCounter.js

@ -15,14 +15,14 @@ Ext.define('Rambox.util.UnreadCounter', {
* *
* @type {Map} * @type {Map}
*/ */
var unreadCountByService = new Map(); let unreadCountByService = new Map();
/** /**
* Holds the global unread count for internal usage. * Holds the global unread count for internal usage.
* *
* @type {number} * @type {number}
*/ */
var totalUnreadCount = 0; let totalUnreadCount = 0;
/** /**
* Sets the application's unread count to tracked unread count. * Sets the application's unread count to tracked unread count.

4
app/ux/FileBackup.js

@ -11,7 +11,7 @@ Ext.define('Rambox.ux.FileBackup', {
me.myDefaultPath = me.userPath + me.path.sep + me.defaultFileName; me.myDefaultPath = me.userPath + me.path.sep + me.defaultFileName;
}, },
backupConfiguration(callback) { backupConfiguration(callback) {
var me = this; const me = this;
let services = []; let services = [];
Ext.getStore('Services').each(function(service) { Ext.getStore('Services').each(function(service) {
const s = Ext.clone(service); const s = Ext.clone(service);
@ -34,7 +34,7 @@ Ext.define('Rambox.ux.FileBackup', {
if (Ext.isFunction(callback)) callback.bind(me)(); if (Ext.isFunction(callback)) callback.bind(me)();
}, },
restoreConfiguration() { restoreConfiguration() {
var me = this; const me = this;
me.remote.dialog.showOpenDialog({ me.remote.dialog.showOpenDialog({
defaultPath: me.myDefaultPath, defaultPath: me.myDefaultPath,
properties: ['openFile'] properties: ['openFile']

76
app/ux/WebView.js

@ -19,10 +19,10 @@ Ext.define('Rambox.ux.WebView',{
// CONFIG // CONFIG
,hideMode: 'offsets' ,hideMode: 'offsets'
,initComponent(config) { ,initComponent(config) {
var me = this; const me = this;
function getLocation(href) { function getLocation(href) {
var match = href.match(/^(https?):\/\/([-.\w]*)(\/[^#?]*)(\?[^#]*|)(#.*|)$/); const match = href.match(/^(https?):\/\/([-.\w]*)(\/[^#?]*)(\?[^#]*|)(#.*|)$/);
return match && { return match && {
protocol: match[1], protocol: match[1],
host: match[2], host: match[2],
@ -136,15 +136,15 @@ Ext.define('Rambox.ux.WebView',{
} }
,onBeforeDestroy() { ,onBeforeDestroy() {
var me = this; const me = this;
me.setUnreadCount(0); me.setUnreadCount(0);
} }
,webViewConstructor( enabled ) { ,webViewConstructor( enabled ) {
var me = this; const me = this;
var cfg; let cfg;
enabled = enabled || me.record.get('enabled'); enabled = enabled || me.record.get('enabled');
if ( !enabled ) { if ( !enabled ) {
@ -181,7 +181,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,statusBarConstructor(floating) { ,statusBarConstructor(floating) {
var me = this; const me = this;
return { return {
xtype: 'statusbar' xtype: 'statusbar'
@ -217,11 +217,11 @@ Ext.define('Rambox.ux.WebView',{
} }
,onAfterRender() { ,onAfterRender() {
var me = this; const me = this;
if ( !me.record.get('enabled') ) return; if ( !me.record.get('enabled') ) return;
var webview = me.getWebView(); const webview = me.getWebView();
// Notifications in Webview // Notifications in Webview
me.setNotifications(localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ? false : me.record.get('notifications')); 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) { show(win) {
const webview = win.down('#webview').el.dom; const webview = win.down('#webview').el.dom;
webview.addEventListener('ipc-message', function(event) { webview.addEventListener('ipc-message', function(event) {
var channel = event.channel; const channel = event.channel;
switch (channel) { switch (channel) {
case 'close': case 'close':
win.close(); win.close();
@ -413,8 +413,8 @@ Ext.define('Rambox.ux.WebView',{
// Mute Webview // Mute Webview
if ( me.record.get('muted') || localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ) me.setAudioMuted(true, true); if ( me.record.get('muted') || localStorage.getItem('locked') || JSON.parse(localStorage.getItem('dontDisturb')) ) me.setAudioMuted(true, true);
var js_inject = ''; let js_inject = '';
var css_inject = ''; let css_inject = '';
// Injected code to detect new messages // Injected code to detect new messages
if ( me.record ) { if ( me.record ) {
let js_unread = me.record.get('js_unread'); 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" // 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') ) { 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; js_inject += js_preventBlink;
} }
@ -511,7 +511,7 @@ Ext.define('Rambox.ux.WebView',{
}); });
webview.addEventListener('ipc-message', function(event) { webview.addEventListener('ipc-message', function(event) {
var channel = event.channel; const channel = event.channel;
switch (channel) { switch (channel) {
case 'rambox.setUnreadCount': case 'rambox.setUnreadCount':
handleSetUnreadCount(event); handleSetUnreadCount(event);
@ -584,7 +584,7 @@ Ext.define('Rambox.ux.WebView',{
if (Ext.getStore('ServicesList').getById(me.record.get('type')).get('js_unread') === '' && if (Ext.getStore('ServicesList').getById(me.record.get('type')).get('js_unread') === '' &&
me.record.get('js_unread') === '') { me.record.get('js_unread') === '') {
webview.addEventListener("page-title-updated", function(e) { 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[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 === '•' ? 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; count = count === null ? '0' : count;
@ -603,7 +603,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,setUnreadCount(newUnreadCount) { ,setUnreadCount(newUnreadCount) {
var me = this; const me = this;
if ( !isNaN(newUnreadCount) && (function(x) { return (x | 0) === x; })(parseFloat(newUnreadCount)) && me.record.get('includeInGlobalUnreadCounter') === true) { 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); Rambox.util.UnreadCounter.setUnreadCountForService(me.record.get('id'), newUnreadCount);
@ -630,7 +630,7 @@ Ext.define('Rambox.ux.WebView',{
* @param {int} count * @param {int} count
*/ */
,doManualNotification(count) { ,doManualNotification(count) {
var me = this; const me = this;
if (Ext.getStore('ServicesList').getById(me.type).get('manual_notifications') && if (Ext.getStore('ServicesList').getById(me.type).get('manual_notifications') &&
me.currentUnreadCount < count && me.currentUnreadCount < count &&
@ -648,7 +648,7 @@ Ext.define('Rambox.ux.WebView',{
* @param {string} badgeText * @param {string} badgeText
*/ */
,setTabBadgeText(badgeText) { ,setTabBadgeText(badgeText) {
var me = this; const me = this;
if (me.record.get('displayTabUnreadCounter') === true) { if (me.record.get('displayTabUnreadCounter') === true) {
me.tab.setBadgeText(badgeText); me.tab.setBadgeText(badgeText);
} else { } else {
@ -662,14 +662,14 @@ Ext.define('Rambox.ux.WebView',{
* clears the global unread counter * clears the global unread counter
*/ */
,clearUnreadCounter() { ,clearUnreadCounter() {
var me = this; const me = this;
me.tab.setBadgeText(''); me.tab.setBadgeText('');
Rambox.util.UnreadCounter.clearUnreadCountForService(me.record.get('id')); Rambox.util.UnreadCounter.clearUnreadCountForService(me.record.get('id'));
} }
,reloadService(btn) { ,reloadService(btn) {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
if ( me.record.get('enabled') ) { if ( me.record.get('enabled') ) {
me.clearUnreadCounter(); me.clearUnreadCounter();
@ -678,8 +678,8 @@ Ext.define('Rambox.ux.WebView',{
} }
,toggleDevTools(btn) { ,toggleDevTools(btn) {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
if ( me.record.get('enabled')) { if ( me.record.get('enabled')) {
if (webview.isDevToolsOpened()) { if (webview.isDevToolsOpened()) {
@ -691,8 +691,8 @@ Ext.define('Rambox.ux.WebView',{
} }
,setURL(url) { ,setURL(url) {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
me.src = url; me.src = url;
@ -700,8 +700,8 @@ Ext.define('Rambox.ux.WebView',{
} }
,setAudioMuted(muted, calledFromDisturb) { ,setAudioMuted(muted, calledFromDisturb) {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
me.muted = muted; me.muted = muted;
@ -711,7 +711,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,closeStatusBar() { ,closeStatusBar() {
var me = this; const me = this;
me.down('statusbar').hide(); me.down('statusbar').hide();
me.down('statusbar').closed = true; me.down('statusbar').closed = true;
@ -719,7 +719,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,setStatusBar(keep) { ,setStatusBar(keep) {
var me = this; const me = this;
me.removeDocked(me.down('statusbar'), true); me.removeDocked(me.down('statusbar'), true);
@ -732,8 +732,8 @@ Ext.define('Rambox.ux.WebView',{
} }
,setNotifications(notification, calledFromDisturb) { ,setNotifications(notification, calledFromDisturb) {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
me.notifications = notification; me.notifications = notification;
@ -743,7 +743,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,setEnabled(enabled) { ,setEnabled(enabled) {
var me = this; const me = this;
me.clearUnreadCounter(); me.clearUnreadCounter();
@ -761,15 +761,15 @@ Ext.define('Rambox.ux.WebView',{
} }
,goBack() { ,goBack() {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
if ( me.record.get('enabled') ) webview.goBack(); if ( me.record.get('enabled') ) webview.goBack();
} }
,goForward() { ,goForward() {
var me = this; const me = this;
var webview = me.getWebView(); const webview = me.getWebView();
if ( me.record.get('enabled') ) webview.goForward(); if ( me.record.get('enabled') ) webview.goForward();
} }
@ -779,7 +779,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,zoomIn() { ,zoomIn() {
var me = this; const me = this;
me.zoomLevel = me.zoomLevel + 1; me.zoomLevel = me.zoomLevel + 1;
if ( me.record.get('enabled') ) { if ( me.record.get('enabled') ) {
@ -789,7 +789,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,zoomOut() { ,zoomOut() {
var me = this; const me = this;
me.zoomLevel = me.zoomLevel - 1; me.zoomLevel = me.zoomLevel - 1;
if ( me.record.get('enabled') ) { if ( me.record.get('enabled') ) {
@ -799,7 +799,7 @@ Ext.define('Rambox.ux.WebView',{
} }
,resetZoom() { ,resetZoom() {
var me = this; const me = this;
me.zoomLevel = 0; me.zoomLevel = 0;
if ( me.record.get('enabled') ) { if ( me.record.get('enabled') ) {

4
app/ux/mixin/Badge.js

@ -21,7 +21,7 @@ Ext.define('Rambox.ux.mixin.Badge', {
}, },
renderBadgeText() { renderBadgeText() {
var badgeText = this.getBadgeText(); const badgeText = this.getBadgeText();
if (badgeText) { if (badgeText) {
this.updateBadgeText(badgeText); this.updateBadgeText(badgeText);
@ -29,7 +29,7 @@ Ext.define('Rambox.ux.mixin.Badge', {
}, },
updateBadgeText(badgeText, oldBadgeText) { updateBadgeText(badgeText, oldBadgeText) {
var me = this, const me = this,
el = me.el; el = me.el;
if (me.rendered) { if (me.rendered) {

2
app/view/add/Add.js

@ -26,7 +26,7 @@ Ext.define('Rambox.view.add.Add',{
,bodyPadding: 20 ,bodyPadding: 20
,initComponent() { ,initComponent() {
var me = this; const me = this;
me.title = (!me.edit ? locale['app.window[0]'] : locale['app.window[1]']) + ' ' + me.record.get('name'); 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'); 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');

22
app/view/add/AddController.js

@ -7,18 +7,18 @@ Ext.define('Rambox.view.add.AddController', {
], ],
doCancel( btn ) { doCancel( btn ) {
var me = this; const me = this;
me.getView().close(); me.getView().close();
} }
,doSave( btn ) { ,doSave( btn ) {
var me = this; const me = this;
var win = me.getView(); const win = me.getView();
if ( !win.down('form').isValid() ) return false; if ( !win.down('form').isValid() ) return false;
var formValues = win.down('form').getValues(); const formValues = win.down('form').getValues();
if ( win.edit ) { if ( win.edit ) {
// Format data // 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; 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({ win.record.set({
logo: formValues.logo logo: formValues.logo
,name: formValues.serviceName ,name: formValues.serviceName
@ -46,7 +46,7 @@ Ext.define('Rambox.view.add.AddController', {
,slowed_timers: formValues.slowed_timers ,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 // Change the title of the Tab
view.setTitle( formValues.tabname ? formValues.serviceName : '' ); 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; 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') type: win.record.get('id')
,logo: formValues.logo ,logo: formValues.logo
,name: formValues.serviceName ,name: formValues.serviceName
@ -105,7 +105,7 @@ Ext.define('Rambox.view.add.AddController', {
service.save(); service.save();
Ext.getStore('Services').add(service); Ext.getStore('Services').add(service);
var tabData = { const tabData = {
xtype: 'webview' xtype: 'webview'
,id: 'tab_'+service.get('id') ,id: 'tab_'+service.get('id')
/* /*
@ -124,7 +124,7 @@ Ext.define('Rambox.view.add.AddController', {
}; };
if ( formValues.align === 'left' ) { 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(); Ext.cq1('app-main').insert(Ext.cq1('app-main').getTabBar().items.indexOf(tbfill), tabData).show();
} else { } else {
Ext.cq1('app-main').add(tabData).show(); Ext.cq1('app-main').add(tabData).show();
@ -135,13 +135,13 @@ Ext.define('Rambox.view.add.AddController', {
} }
,onEnter(field, e) { ,onEnter(field, e) {
var me = this; const me = this;
if ( e.getKey() === e.ENTER && field.up('form').isValid() ) me.doSave(); if ( e.getKey() === e.ENTER && field.up('form').isValid() ) me.doSave();
} }
,onShow(win) { ,onShow(win) {
var me = this; const me = this;
// Make focus to the name field // Make focus to the name field
win.down('textfield[name="serviceName"]').focus(true, 100); win.down('textfield[name="serviceName"]').focus(true, 100);

2
app/view/main/About.js

@ -10,7 +10,7 @@ Ext.define('Rambox.view.main.About', {
,height: 450 ,height: 450
,bodyPadding: 10 ,bodyPadding: 10
,initComponent() { ,initComponent() {
var me = this; const me = this;
me.callParent(arguments); me.callParent(arguments);
me.data.buildversion = require('fs').readFileSync( __dirname + '/BUILDVERSION', 'utf8'); me.data.buildversion = require('fs').readFileSync( __dirname + '/BUILDVERSION', 'utf8');
} }

48
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 // Make focus on webview every time the user change tabs, to enable the autofocus in websites
,onTabChange( tabPanel, newTab, oldTab ) { ,onTabChange( tabPanel, newTab, oldTab ) {
var me = this; const me = this;
localStorage.setItem('last_active_service', newTab.id); localStorage.setItem('last_active_service', newTab.id);
@ -40,7 +40,7 @@ Ext.define('Rambox.view.main.MainController', {
return; return;
} }
var webview = newTab.getWebView(); const webview = newTab.getWebView();
if ( webview ) webview.focus(); if ( webview ) webview.focus();
// Update the main window so it includes the active tab title. // 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...'); console.log('Updating Tabs positions...');
var store = Ext.getStore('Services'); const store = Ext.getStore('Services');
var align = 'left'; let align = 'left';
store.suspendEvent('childmove'); store.suspendEvent('childmove');
Ext.each(tabPanel.items.items, function(t, i) { Ext.each(tabPanel.items.items, function(t, i) {
if ( t.id !== 'ramboxTab' && t.id !== 'tbfill' && t.record.get('enabled') ) { 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--; if ( align === 'right' ) i--;
rec.set('align', align); rec.set('align', align);
rec.set('position', i); rec.set('position', i);
@ -84,7 +84,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,onRenameService(editor, e) { ,onRenameService(editor, e) {
var me = this; const me = this;
e.record.commit(); e.record.commit();
@ -93,7 +93,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,onEnableDisableService(cc, rowIndex, checked, obj, hideTab) { ,onEnableDisableService(cc, rowIndex, checked, obj, hideTab) {
var rec = Ext.getStore('Services').getAt(rowIndex); const rec = Ext.getStore('Services').getAt(rowIndex);
if ( !checked ) { if ( !checked ) {
Ext.getCmp('tab_'+rec.get('id')).destroy(); Ext.getCmp('tab_'+rec.get('id')).destroy();
@ -128,7 +128,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,removeServiceFn(serviceId, total, actual, resolve) { ,removeServiceFn(serviceId, total, actual, resolve) {
var me = this; const me = this;
if ( !serviceId ) return false; if ( !serviceId ) return false;
// Get Record // Get Record
@ -174,7 +174,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,removeService( gridView, rowIndex, colIndex, col, e, rec, rowEl ) { ,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]']+' <b>'+rec.get('name')+'</b>?', function(btnId) { Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[13]']+' <b>'+rec.get('name')+'</b>?', function(btnId) {
if ( btnId === 'yes' ) { if ( btnId === 'yes' ) {
@ -185,7 +185,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,removeAllServices(btn, callback) { ,removeAllServices(btn, callback) {
var me = this; const me = this;
// Clear counter for unread messaging // Clear counter for unread messaging
document.title = 'Rambox-OS'; document.title = 'Rambox-OS';
@ -245,7 +245,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,onSearchEnter( field, e ) { ,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 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)); 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 ) { ,doTypeFilter( cg, newValue, oldValue ) {
var me = this; const me = this;
Ext.getStore('ServicesList').getFilters().replaceAll({ Ext.getStore('ServicesList').getFilters().replaceAll({
fn(record) { fn(record) {
@ -264,9 +264,9 @@ Ext.define('Rambox.view.main.MainController', {
} }
,onSearchServiceChange(field, newValue, oldValue) { ,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 ) { if ( !Ext.isEmpty(newValue) && newValue.length > 0 ) {
field.getTrigger('clear').show(); field.getTrigger('clear').show();
@ -286,9 +286,9 @@ Ext.define('Rambox.view.main.MainController', {
} }
,onClearClick(field, trigger, e) { ,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.reset();
field.getTrigger('clear').hide(); field.getTrigger('clear').hide();
@ -303,7 +303,7 @@ Ext.define('Rambox.view.main.MainController', {
Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) { Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) {
// Get Tab // Get Tab
var tab = Ext.getCmp('tab_'+serviceId); const tab = Ext.getCmp('tab_'+serviceId);
if ( !tab ) return; // Skip disabled services if ( !tab ) return; // Skip disabled services
@ -332,7 +332,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,lockRambox(btn) { ,lockRambox(btn) {
var me = this; const me = this;
if ( ipc.sendSync('getConfig').master_password ) { 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) { 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() { 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' ) { 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 ( btnId === 'ok' ) {
if ( text !== text2 ) { if ( text !== text2 ) {
Ext.Msg.show({ Ext.Msg.show({
@ -385,9 +385,9 @@ Ext.define('Rambox.view.main.MainController', {
} }
,showLockWindow() { ,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()) ) { if ( localStorage.getItem('locked') === Rambox.util.MD5.encypt(winLock.down('textfield').getValue()) ) {
console.info('Lock Rambox:', 'Disabled'); console.info('Lock Rambox:', 'Disabled');
localStorage.removeItem('locked'); 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 maximized: true
,closable: false ,closable: false
,resizable: false ,resizable: false
@ -464,7 +464,7 @@ Ext.define('Rambox.view.main.MainController', {
} }
,openPreferences( btn ) { ,openPreferences( btn ) {
var me = this; const me = this;
Ext.create('Rambox.view.preferences.Preferences').show(); Ext.create('Rambox.view.preferences.Preferences').show();
} }

4
app/view/preferences/Preferences.js

@ -36,9 +36,9 @@ Ext.define('Rambox.view.preferences.Preferences',{
] ]
,initComponent() { ,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: 'ramboxTab', label: 'Rambox-OS Tab' });
defaultServiceOptions.push({ value: 'last', label: 'Last Active Service' }); defaultServiceOptions.push({ value: 'last', label: 'Last Active Service' });
Ext.getStore('Services').each(function(rec) { Ext.getStore('Services').each(function(rec) {

6
app/view/preferences/PreferencesController.js

@ -3,15 +3,15 @@ Ext.define('Rambox.view.preferences.PreferencesController', {
,alias: 'controller.preferences-preferences' ,alias: 'controller.preferences-preferences'
,cancel( btn ) { ,cancel( btn ) {
var me = this; const me = this;
me.getView().close(); me.getView().close();
} }
,save( btn ) { ,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 // master password activated and only one of the fields "password" or "password confirmation" filled
if (values.master_password === true && if (values.master_password === true &&

10
electron/main.js

@ -4,7 +4,7 @@ const {app, protocol, BrowserWindow, dialog, shell, Menu, ipcMain, nativeImage,
// Tray // Tray
const tray = require('./tray'); const tray = require('./tray');
// AutoLaunch // AutoLaunch
var AutoLaunch = require('auto-launch-patched'); const AutoLaunch = require('auto-launch-patched');
// Configuration // Configuration
const Config = require('electron-store'); const Config = require('electron-store');
// Development // Development
@ -12,7 +12,7 @@ const isDev = require('electron-is-dev');
// Updater // Updater
const updater = require('./updater'); const updater = require('./updater');
// File System // File System
var fs = require("fs"); const fs = require("fs");
const path = require('path'); const path = require('path');
// Initial Config // Initial Config
@ -219,7 +219,7 @@ function createMasterPasswordWindow() {
function updateBadge(title) { function updateBadge(title) {
title = title.split(" - ")[0]; //Discard service name if present, could also contain digits 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; messageCount = isNaN(messageCount) ? 0 : messageCount;
tray.setBadge(messageCount, config.get('systemtray_indicator')); tray.setBadge(messageCount, config.get('systemtray_indicator'));
@ -239,7 +239,7 @@ function updateBadge(title) {
} }
ipcMain.on('setBadge', function(event, messageCount, value) { ipcMain.on('setBadge', function(event, messageCount, value) {
var img = nativeImage.createFromDataURL(value); const img = nativeImage.createFromDataURL(value);
mainWindow.setOverlayIcon(img, messageCount.toString()); mainWindow.setOverlayIcon(img, messageCount.toString());
}); });
@ -336,7 +336,7 @@ if (!haveLock) {
// Code for downloading images as temporal files // Code for downloading images as temporal files
// Credit: Ghetto Skype (https://github.com/stanfieldr/ghetto-skype) // Credit: Ghetto Skype (https://github.com/stanfieldr/ghetto-skype)
var imageCache = {}; let imageCache = {};
ipcMain.on('image:download', function(event, url, partition) { ipcMain.on('image:download', function(event, url, partition) {
const tmp = require('tmp'); const tmp = require('tmp');
const mime = require('mime'); const mime = require('mime');

2
electron/tray.js

@ -2,7 +2,7 @@ const path = require('path');
const {app, electron, nativeImage, Menu, MenuItem, Tray} = require('electron'); const {app, electron, nativeImage, Menu, MenuItem, Tray} = require('electron');
// Module to create tray icon // Module to create tray icon
var appIcon = null; let appIcon = null;
exports.create = function(win, config) { exports.create = function(win, config) {
if (process.platform === 'darwin' || appIcon || config.get('window_display_behavior') === 'show_taskbar' ) return; if (process.platform === 'darwin' || appIcon || config.get('window_display_behavior') === 'show_taskbar' ) return;

2
index.html

@ -14,7 +14,7 @@
<!--- Localization --> <!--- Localization -->
<script id="localization" type="text/javascript"> <script id="localization" type="text/javascript">
(function (d, s) { (function (d, s) {
var t = d.createElement(s), const t = d.createElement(s),
e = d.getElementsByTagName(s)[0]; e = d.getElementsByTagName(s)[0];
t.type = "text/javascript"; t.type = "text/javascript";
e.parentNode.insertBefore(t, e); e.parentNode.insertBefore(t, e);

8
overrides/form/field/VTypes.js

@ -1,17 +1,17 @@
Ext.apply(Ext.form.field.VTypes, { Ext.apply(Ext.form.field.VTypes, {
daterange(val, field) { daterange(val, field) {
var date = field.parseDate(val); const date = field.parseDate(val);
if (!date) { if (!date) {
return false; return false;
} }
if (field.startDateField && (!this.dateRangeMax || (date.getTime() !== this.dateRangeMax.getTime()))) { if (field.startDateField && (!this.dateRangeMax || (date.getTime() !== this.dateRangeMax.getTime()))) {
var start = field.up('form').down('#' + field.startDateField); const start = field.up('form').down('#' + field.startDateField);
start.setMaxValue(date); start.setMaxValue(date);
start.validate(); start.validate();
this.dateRangeMax = date; this.dateRangeMax = date;
} else if (field.endDateField && (!this.dateRangeMin || (date.getTime() !== this.dateRangeMin.getTime()))) { } else if (field.endDateField && (!this.dateRangeMin || (date.getTime() !== this.dateRangeMin.getTime()))) {
var end = field.up('form').down('#' + field.endDateField); const end = field.up('form').down('#' + field.endDateField);
end.setMinValue(date); end.setMinValue(date);
end.validate(); end.validate();
this.dateRangeMin = date; this.dateRangeMin = date;
@ -27,7 +27,7 @@ Ext.apply(Ext.form.field.VTypes, {
password(val, field) { password(val, field) {
if (field.initialPassField) { if (field.initialPassField) {
var pwd = field.up('form').down('#' + field.initialPassField); const pwd = field.up('form').down('#' + field.initialPassField);
return (val === pwd.getValue()); return (val === pwd.getValue());
} }
return true; return true;

6
overrides/grid/column/Action.js

@ -3,12 +3,12 @@ Ext.define('Rambox.overrides.grid.column.Action', {
// overridden to implement // overridden to implement
defaultRenderer(v, cellValues, record, rowIdx, colIdx, store, view) { defaultRenderer(v, cellValues, record, rowIdx, colIdx, store, view) {
var me = this, const me = this,
prefix = Ext.baseCSSPrefix, prefix = Ext.baseCSSPrefix,
scope = me.origScope || me, scope = me.origScope || me,
items = me.items, items = me.items,
len = items.length, len = items.length;
i = 0, let i = 0,
item, ret, disabled, tooltip,glyph, glyphParts, glyphFontFamily; item, ret, disabled, tooltip,glyph, glyphParts, glyphFontFamily;
// Allow a configured renderer to create initial value (And set the other values in the "metadata" argument!) // Allow a configured renderer to create initial value (And set the other values in the "metadata" argument!)

45
resources/js/loadscreen.js

@ -21,21 +21,21 @@
*/ */
// from http://stackoverflow.com/a/25273333 // from http://stackoverflow.com/a/25273333
var bezier = function(x1, y1, x2, y2, epsilon) { const bezier = function(x1, y1, x2, y2, epsilon) {
var curveX = function(t){ const curveX = function(t){
var v = 1 - t; const v = 1 - t;
return 3 * v * v * t * x1 + 3 * v * t * t * x2 + t * t * t; return 3 * v * v * t * x1 + 3 * v * t * t * x2 + t * t * t;
}; };
var curveY = function(t){ const curveY = function(t){
var v = 1 - t; const v = 1 - t;
return 3 * v * v * t * y1 + 3 * v * t * t * y2 + t * t * t; return 3 * v * v * t * y1 + 3 * v * t * t * y2 + t * t * t;
}; };
var derivativeCurveX = function(t){ const derivativeCurveX = function(t){
var v = 1 - t; const v = 1 - t;
return 3 * (2 * (t - 1) * t + v * v) * x1 + 3 * (- t * t * t + 2 * v * t) * x2; return 3 * (2 * (t - 1) * t + v * v) * x1 + 3 * (- t * t * t + 2 * v * t) * x2;
}; };
return function(t){ return function(x){
var x = t, t0, t1, t2, x2, d2, i; let t0, t1, t2, x2, d2, i;
// First try a few iterations of Newton's method -- normally very fast. // First try a few iterations of Newton's method -- normally very fast.
for (t2 = x, i = 0; i < 8; i++){ for (t2 = x, i = 0; i < 8; i++){
x2 = curveX(t2) - x; x2 = curveX(t2) - x;
@ -66,7 +66,7 @@
return Math.floor(Math.random() * (max - min + 1)) + min; return Math.floor(Math.random() * (max - min + 1)) + min;
}, },
throttle = function(fn, delay) { throttle = function(fn, delay) {
var allowSample = true; let allowSample = true;
return function(e) { return function(e) {
if (allowSample) { if (allowSample) {
@ -78,7 +78,7 @@
}, },
// from https://davidwalsh.name/vendor-prefix // from https://davidwalsh.name/vendor-prefix
prefix = (function () { prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''), const styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']))[1], pre = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']))[1],
dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1]; dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
@ -90,11 +90,11 @@
}; };
})(); })();
var support = {transitions : Modernizr.csstransitions}, const support = {transitions : Modernizr.csstransitions},
transEndEventNames = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' }, transEndEventNames = { 'WebkitTransition': 'webkitTransitionEnd', 'MozTransition': 'transitionend', 'OTransition': 'oTransitionEnd', 'msTransition': 'MSTransitionEnd', 'transition': 'transitionend' },
transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ], transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
onEndTransition = function( el, callback, propTest ) { onEndTransition = function( el, callback, propTest ) {
var onEndCallbackFn = function( ev ) { const onEndCallbackFn = function( ev ) {
if( support.transitions ) { if( support.transitions ) {
if( ev.target != this || propTest && ev.propertyName !== propTest && ev.propertyName !== prefix.css + propTest ) return; if( ev.target != this || propTest && ev.propertyName !== propTest && ev.propertyName !== prefix.css + propTest ) return;
this.removeEventListener( transEndEventName, onEndCallbackFn ); this.removeEventListener( transEndEventName, onEndCallbackFn );
@ -113,9 +113,9 @@
// the initial button // the initial button
shzCtrl = shzEl.querySelector('div.button--start'), shzCtrl = shzEl.querySelector('div.button--start'),
// total number of notes/symbols moving towards the listen button // total number of notes/symbols moving towards the listen button
totalNotes = 50, totalNotes = 50;
// the notes elements // the notes elements
notes, let notes,
// the note´s speed factor relative to the distance from the note element to the button. // the note´s speed factor relative to the distance from the note element to the button.
// if notesSpeedFactor = 1, then the speed equals the distance (in ms) // if notesSpeedFactor = 1, then the speed equals the distance (in ms)
notesSpeedFactor = 4.5, notesSpeedFactor = 4.5,
@ -143,11 +143,12 @@
* creates [totalNotes] note elements (the musical symbols that will animate/move towards the listen button) * creates [totalNotes] note elements (the musical symbols that will animate/move towards the listen button)
*/ */
function createNotes() { function createNotes() {
var notesEl = document.createElement('div'), notesElContent = ''; const notesEl = document.createElement('div');
let notesElContent = '';
notesEl.className = 'notes'; notesEl.className = 'notes';
for(var i = 0; i < totalNotes; ++i) { for(let i = 0; i < totalNotes; ++i) {
// we have 6 different types of symbols (icon--note1, icon--note2 ... icon--note6) // we have 6 different types of symbols (icon--note1, icon--note2 ... icon--note6)
var j = (i + 1) - 6 * Math.floor(i/6); const j = (i + 1) - 6 * Math.floor(i/6);
notesElContent += '<div class="note icon icon--note' + j + '"></div>'; notesElContent += '<div class="note icon icon--note' + j + '"></div>';
} }
notesEl.innerHTML = notesElContent; notesEl.innerHTML = notesElContent;
@ -202,8 +203,8 @@
*/ */
function positionNote(note) { function positionNote(note) {
// we want to position the notes randomly (translation and rotation) outside of the viewport // we want to position the notes randomly (translation and rotation) outside of the viewport
var x = getRandomNumber(-2*(shzCtrlOffset.left + shzCtrlSize.width/2), 2*(winsize.width - (shzCtrlOffset.left + shzCtrlSize.width/2))), y, const x = getRandomNumber(-2*(shzCtrlOffset.left + shzCtrlSize.width/2), 2*(winsize.width - (shzCtrlOffset.left + shzCtrlSize.width/2)));
rotation = getRandomNumber(-30, 30); let y, rotation = getRandomNumber(-30, 30);
if( x > -1*(shzCtrlOffset.top + shzCtrlSize.height/2) && x < shzCtrlOffset.top + shzCtrlSize.height/2 ) { if( x > -1*(shzCtrlOffset.top + shzCtrlSize.height/2) && x < shzCtrlOffset.top + shzCtrlSize.height/2 ) {
y = getRandomNumber(0,1) > 0 ? getRandomNumber(-2*(shzCtrlOffset.top + shzCtrlSize.height/2), -1*(shzCtrlOffset.top + shzCtrlSize.height/2)) : getRandomNumber(winsize.height - (shzCtrlOffset.top + shzCtrlSize.height/2), winsize.height + winsize.height - (shzCtrlOffset.top + shzCtrlSize.height/2)); y = getRandomNumber(0,1) > 0 ? getRandomNumber(-2*(shzCtrlOffset.top + shzCtrlSize.height/2), -1*(shzCtrlOffset.top + shzCtrlSize.height/2)) : getRandomNumber(winsize.height - (shzCtrlOffset.top + shzCtrlSize.height/2), winsize.height + winsize.height - (shzCtrlOffset.top + shzCtrlSize.height/2));
@ -232,7 +233,7 @@
if(!isListening) return; if(!isListening) return;
// the transition speed of each note will be proportional to the its distance to the button // the transition speed of each note will be proportional to the its distance to the button
// speed = notesSpeedFactor * distance // speed = notesSpeedFactor * distance
var noteSpeed = notesSpeedFactor * Math.sqrt(Math.pow(note.getAttribute('data-tx'),2) + Math.pow(note.getAttribute('data-ty'),2)); const noteSpeed = notesSpeedFactor * Math.sqrt(Math.pow(note.getAttribute('data-tx'),2) + Math.pow(note.getAttribute('data-ty'),2));
// apply the transition // apply the transition
note.style.WebkitTransition = '-webkit-transform ' + noteSpeed + 'ms ease, opacity 0.8s'; note.style.WebkitTransition = '-webkit-transform ' + noteSpeed + 'ms ease, opacity 0.8s';
@ -243,7 +244,7 @@
note.style.opacity = 1; note.style.opacity = 1;
// after the animation is finished, // after the animation is finished,
var onEndTransitionCallback = function() { const onEndTransitionCallback = function() {
// reset transitions and styles // reset transitions and styles
note.style.WebkitTransition = note.style.transition = 'none'; note.style.WebkitTransition = note.style.transition = 'none';
note.style.opacity = 0; note.style.opacity = 0;

6
resources/js/rambox-service-api.js

@ -49,16 +49,16 @@ window.rambox.contextMenuListener = new ContextMenuListener(function(event, info
/** /**
* Override to add notification click event to display Rambox window and activate service tab * Override to add notification click event to display Rambox window and activate service tab
*/ */
var NativeNotification = Notification; const NativeNotification = Notification;
Notification = function(title, options) { Notification = function(title, options) {
var notification = new NativeNotification(title, options); const notification = new NativeNotification(title, options);
notification.addEventListener('click', function() { notification.addEventListener('click', function() {
ipcRenderer.sendToHost('rambox.showWindowAndActivateTab'); ipcRenderer.sendToHost('rambox.showWindowAndActivateTab');
}); });
return notification; return notification;
} };
Notification.prototype = NativeNotification.prototype; Notification.prototype = NativeNotification.prototype;
Notification.permission = NativeNotification.permission; Notification.permission = NativeNotification.permission;

6
test/helpers/RamboxTestHelper.js

@ -1,13 +1,13 @@
var Application = require('spectron').Application; const Application = require('spectron').Application;
var electron = require('electron-prebuilt'); const electron = require('electron');
/** /**
* The RamboxTestHelper contains common stuff for tests. * The RamboxTestHelper contains common stuff for tests.
*/ */
module.exports = function() { module.exports = function() {
var self = this; const self = this;
/** /**
* Makes the Rambox Application available. * Makes the Rambox Application available.

8
test/tests/app/example.spec.js

@ -2,9 +2,9 @@
* This is an example test. * This is an example test.
*/ */
var chai = require('chai'); const chai = require('chai');
var expect = chai.expect; const expect = chai.expect;
var RamboxTestHelper = require('../../helpers/RamboxTestHelper'); const RamboxTestHelper = require('../../helpers/RamboxTestHelper');
describe('Rambox window', function() { describe('Rambox window', function() {
@ -13,7 +13,7 @@ describe('Rambox window', function() {
* *
* @type {module.exports} * @type {module.exports}
*/ */
var ramboxTestHelper = new RamboxTestHelper(); const ramboxTestHelper = new RamboxTestHelper();
it('should have "Rambox-OS" in the title', function () { it('should have "Rambox-OS" in the title', function () {
return ramboxTestHelper.app.client.browserWindow.getTitle().then(function(title) { return ramboxTestHelper.app.client.browserWindow.getTitle().then(function(title) {

Loading…
Cancel
Save