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
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);
});

8
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({

6
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')

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.'
,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);`
},
{

40
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;

6
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')

4
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.

4
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']

76
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') ) {

4
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) {

2
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');

22
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);

2
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');
}

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
,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]']+' <b>'+rec.get('name')+'</b>?', 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();
}

4
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) {

6
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 &&

10
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');

2
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;

2
index.html

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

8
overrides/form/field/VTypes.js

@ -1,17 +1,17 @@
Ext.apply(Ext.form.field.VTypes, {
daterange(val, field) {
var date = field.parseDate(val);
const date = field.parseDate(val);
if (!date) {
return false;
}
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.validate();
this.dateRangeMax = date;
} 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.validate();
this.dateRangeMin = date;
@ -27,7 +27,7 @@ Ext.apply(Ext.form.field.VTypes, {
password(val, field) {
if (field.initialPassField) {
var pwd = field.up('form').down('#' + field.initialPassField);
const pwd = field.up('form').down('#' + field.initialPassField);
return (val === pwd.getValue());
}
return true;

6
overrides/grid/column/Action.js

@ -3,12 +3,12 @@ Ext.define('Rambox.overrides.grid.column.Action', {
// overridden to implement
defaultRenderer(v, cellValues, record, rowIdx, colIdx, store, view) {
var me = this,
const me = this,
prefix = Ext.baseCSSPrefix,
scope = me.origScope || me,
items = me.items,
len = items.length,
i = 0,
len = items.length;
let i = 0,
item, ret, disabled, tooltip,glyph, glyphParts, glyphFontFamily;
// 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
var bezier = function(x1, y1, x2, y2, epsilon) {
var curveX = function(t){
var v = 1 - t;
const bezier = function(x1, y1, x2, y2, epsilon) {
const curveX = function(t){
const v = 1 - t;
return 3 * v * v * t * x1 + 3 * v * t * t * x2 + t * t * t;
};
var curveY = function(t){
var v = 1 - t;
const curveY = function(t){
const v = 1 - t;
return 3 * v * v * t * y1 + 3 * v * t * t * y2 + t * t * t;
};
var derivativeCurveX = function(t){
var v = 1 - t;
const derivativeCurveX = function(t){
const v = 1 - t;
return 3 * (2 * (t - 1) * t + v * v) * x1 + 3 * (- t * t * t + 2 * v * t) * x2;
};
return function(t){
var x = t, t0, t1, t2, x2, d2, i;
return function(x){
let t0, t1, t2, x2, d2, i;
// First try a few iterations of Newton's method -- normally very fast.
for (t2 = x, i = 0; i < 8; i++){
x2 = curveX(t2) - x;
@ -66,7 +66,7 @@
return Math.floor(Math.random() * (max - min + 1)) + min;
},
throttle = function(fn, delay) {
var allowSample = true;
let allowSample = true;
return function(e) {
if (allowSample) {
@ -78,7 +78,7 @@
},
// from https://davidwalsh.name/vendor-prefix
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],
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' },
transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
onEndTransition = function( el, callback, propTest ) {
var onEndCallbackFn = function( ev ) {
const onEndCallbackFn = function( ev ) {
if( support.transitions ) {
if( ev.target != this || propTest && ev.propertyName !== propTest && ev.propertyName !== prefix.css + propTest ) return;
this.removeEventListener( transEndEventName, onEndCallbackFn );
@ -113,9 +113,9 @@
// the initial button
shzCtrl = shzEl.querySelector('div.button--start'),
// total number of notes/symbols moving towards the listen button
totalNotes = 50,
totalNotes = 50;
// the notes elements
notes,
let notes,
// 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)
notesSpeedFactor = 4.5,
@ -143,11 +143,12 @@
* creates [totalNotes] note elements (the musical symbols that will animate/move towards the listen button)
*/
function createNotes() {
var notesEl = document.createElement('div'), notesElContent = '';
const notesEl = document.createElement('div');
let notesElContent = '';
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)
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>';
}
notesEl.innerHTML = notesElContent;
@ -202,8 +203,8 @@
*/
function positionNote(note) {
// 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,
rotation = getRandomNumber(-30, 30);
const x = getRandomNumber(-2*(shzCtrlOffset.left + shzCtrlSize.width/2), 2*(winsize.width - (shzCtrlOffset.left + shzCtrlSize.width/2)));
let y, rotation = getRandomNumber(-30, 30);
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));
@ -232,7 +233,7 @@
if(!isListening) return;
// the transition speed of each note will be proportional to the its distance to the button
// 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
note.style.WebkitTransition = '-webkit-transform ' + noteSpeed + 'ms ease, opacity 0.8s';
@ -243,7 +244,7 @@
note.style.opacity = 1;
// after the animation is finished,
var onEndTransitionCallback = function() {
const onEndTransitionCallback = function() {
// reset transitions and styles
note.style.WebkitTransition = note.style.transition = 'none';
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
*/
var NativeNotification = Notification;
const NativeNotification = Notification;
Notification = function(title, options) {
var notification = new NativeNotification(title, options);
const notification = new NativeNotification(title, options);
notification.addEventListener('click', function() {
ipcRenderer.sendToHost('rambox.showWindowAndActivateTab');
});
return notification;
}
};
Notification.prototype = NativeNotification.prototype;
Notification.permission = NativeNotification.permission;

6
test/helpers/RamboxTestHelper.js

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

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

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

Loading…
Cancel
Save