Browse Source

Format abea666

pull/3163/head
prettifier[bot] 4 years ago committed by GitHub
parent
commit
92a4ee0745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 588
      app/Application.js
  2. 69
      app/store/ServicesList.js
  3. 380
      app/ux/Auth0.js
  4. 1019
      app/ux/WebView.js
  5. 733
      app/view/main/MainController.js
  6. 750
      app/view/preferences/Preferences.js
  7. 62
      electron/main.js
  8. 16
      resources/js/darkreader.js
  9. 9
      resources/js/rambox-service-api.js
  10. 253
      resources/languages/en.js

588
app/Application.js

@ -1,334 +1,444 @@
Ext.define('Rambox.Application', { Ext.define("Rambox.Application", {
extend: 'Ext.app.Application' extend: "Ext.app.Application",
,name: 'Rambox' name: "Rambox",
,requires: [ requires: [
'Rambox.ux.Auth0' "Rambox.ux.Auth0",
,'Rambox.util.MD5' "Rambox.util.MD5",
,'Ext.window.Toast' "Ext.window.Toast",
,'Ext.util.Cookies' "Ext.util.Cookies",
] ],
,stores: [
'ServicesList'
,'Services'
]
,profiles: [ stores: ["ServicesList", "Services"],
'Offline'
,'Online'
]
,config: { profiles: ["Offline", "Online"],
totalServicesLoaded: 0
,totalNotifications: 0
,googleURLs: []
}
,launch: function () { config: {
totalServicesLoaded: 0,
totalNotifications: 0,
googleURLs: [],
},
const isOnline = require('is-online'); launch: function () {
const Mousetrap = require('mousetrap'); const isOnline = require("is-online");
const Mousetrap = require("mousetrap");
(async () => { (async () => {
await isOnline().then(res => { await isOnline().then((res) => {
var hideNoConnection = ipc.sendSync('getConfig').hideNoConnectionDialog var hideNoConnection = ipc.sendSync("getConfig").hideNoConnectionDialog;
if ( !res && !hideNoConnection ) { if (!res && !hideNoConnection) {
Ext.get('spinner') ? Ext.get('spinner').destroy() : null; Ext.get("spinner") ? Ext.get("spinner").destroy() : null;
Ext.get('background') ? Ext.get('background').destroy() : null; Ext.get("background") ? Ext.get("background").destroy() : null;
Ext.Msg.show({ Ext.Msg.show({
title: 'No Internet Connection' title: "No Internet Connection",
,msg: 'Please, check your internet connection. If you use a Proxy, please go to Preferences to configure it. Rambox will try to re-connect in 10 seconds' msg:
,width: 300 "Please, check your internet connection. If you use a Proxy, please go to Preferences to configure it. Rambox will try to re-connect in 10 seconds",
,closable: false width: 300,
,buttons: Ext.Msg.YESNO closable: false,
,buttonText: { buttons: Ext.Msg.YESNO,
yes: 'Ok' buttonText: {
,no: 'Never show this again' yes: "Ok",
} no: "Never show this again",
,multiline: false },
,fn: function(buttonValue, inputText, showConfig) { multiline: false,
if ( buttonValue === 'no' ) { fn: function (buttonValue, inputText, showConfig) {
ipc.send('sConfig', { hideNoConnectionDialog: true }); if (buttonValue === "no") {
ipc.send("sConfig", { hideNoConnectionDialog: true });
hideNoConnection = true; hideNoConnection = true;
} }
} },
,icon: Ext.Msg.QUESTION icon: Ext.Msg.QUESTION,
}); });
setTimeout(function() { setTimeout(function () {
if ( !hideNoConnection ) ipc.send('reloadApp') if (!hideNoConnection) ipc.send("reloadApp");
}, 10000) }, 10000);
} }
}) });
})(); })();
if ( !localStorage.getItem('hideMacPermissions') && process.platform === 'darwin' && (require('electron').remote.systemPreferences.getMediaAccessStatus('microphone') !== 'granted' || require('electron').remote.systemPreferences.getMediaAccessStatus('camera') !== 'granted') ) { if (
console.info('Checking mac permissions...'); !localStorage.getItem("hideMacPermissions") &&
Ext.cq1('app-main').addDocked({ process.platform === "darwin" &&
xtype: 'toolbar' (require("electron").remote.systemPreferences.getMediaAccessStatus(
,dock: 'top' "microphone"
,style: {background: '#30BBF3'} ) !== "granted" ||
,items: [ require("electron").remote.systemPreferences.getMediaAccessStatus(
'->' "camera"
,{ ) !== "granted")
xtype: 'label' ) {
,html: '<b>Rambox CE needs permissions to use Microphone and Camera for the apps.</b>' console.info("Checking mac permissions...");
} Ext.cq1("app-main").addDocked({
,{ xtype: "toolbar",
xtype: 'button' dock: "top",
,text: 'Grant permissions' style: { background: "#30BBF3" },
,ui: 'decline' items: [
,handler: async function(btn) { "->",
await require('electron').remote.systemPreferences.askForMediaAccess('microphone'); {
await require('electron').remote.systemPreferences.askForMediaAccess('camera'); xtype: "label",
Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); html:
} "<b>Rambox CE needs permissions to use Microphone and Camera for the apps.</b>",
} },
,{ {
xtype: 'button' xtype: "button",
,text: 'Never ask again' text: "Grant permissions",
,ui: 'decline' ui: "decline",
,handler: function(btn) { handler: async function (btn) {
Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); await require("electron").remote.systemPreferences.askForMediaAccess(
localStorage.setItem('hideMacPermissions', true); "microphone"
} );
} await require("electron").remote.systemPreferences.askForMediaAccess(
,'->' "camera"
,{ );
glyph: 'xf00d@FontAwesome' Ext.cq1("app-main").removeDocked(btn.up("toolbar"), true);
,baseCls: '' },
,style: 'cursor:pointer;' },
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); } {
} xtype: "button",
] text: "Never ask again",
ui: "decline",
handler: function (btn) {
Ext.cq1("app-main").removeDocked(btn.up("toolbar"), true);
localStorage.setItem("hideMacPermissions", true);
},
},
"->",
{
glyph: "xf00d@FontAwesome",
baseCls: "",
style: "cursor:pointer;",
handler: function (btn) {
Ext.cq1("app-main").removeDocked(btn.up("toolbar"), true);
},
},
],
}); });
} }
Ext.getStore("ServicesList").load(function (records, operations, success) {
Ext.getStore('ServicesList').load(function (records, operations, success) {
if (!success) { if (!success) {
Ext.cq1('app-main').addDocked({ Ext.cq1("app-main").addDocked({
xtype: 'toolbar' xtype: "toolbar",
,dock: 'top' dock: "top",
,ui: 'servicesnotloaded' ui: "servicesnotloaded",
,style: { background: '#efef6d' } style: { background: "#efef6d" },
,items: [ items: [
'->' "->",
,{ {
xtype: 'label' xtype: "label",
,html: '<b>Services couldn\'t be loaded, some Rambox features will not be available.</b>' html:
} "<b>Services couldn't be loaded, some Rambox features will not be available.</b>",
,{ },
xtype: 'button' {
,text: 'Reload' xtype: "button",
,handler: function() { ipc.send('reloadApp'); } text: "Reload",
} handler: function () {
,'->' ipc.send("reloadApp");
,{ },
glyph: 'xf00d@FontAwesome' },
,baseCls: '' "->",
,style: 'cursor:pointer;' {
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); } glyph: "xf00d@FontAwesome",
} baseCls: "",
] style: "cursor:pointer;",
handler: function (btn) {
Ext.cq1("app-main").removeDocked(btn.up("toolbar"), true);
},
},
],
}); });
} }
// Prevent track if the user have disabled this option (default: false) // Prevent track if the user have disabled this option (default: false)
if ( !ipc.sendSync('sendStatistics') ) { if (!ipc.sendSync("sendStatistics")) {
ga_storage = { ga_storage = {
_enableSSL: Ext.emptyFn _enableSSL: Ext.emptyFn,
,_disableSSL: Ext.emptyFn _disableSSL: Ext.emptyFn,
,_setAccount: Ext.emptyFn _setAccount: Ext.emptyFn,
,_setDomain: Ext.emptyFn _setDomain: Ext.emptyFn,
,_setLocale: Ext.emptyFn _setLocale: Ext.emptyFn,
,_setCustomVar: Ext.emptyFn _setCustomVar: Ext.emptyFn,
,_deleteCustomVar: Ext.emptyFn _deleteCustomVar: Ext.emptyFn,
,_trackPageview: Ext.emptyFn _trackPageview: Ext.emptyFn,
,_trackEvent: Ext.emptyFn _trackEvent: Ext.emptyFn,
} };
} }
// Set Google Analytics events // Set Google Analytics events
ga_storage._setAccount('UA-80680424-1'); ga_storage._setAccount("UA-80680424-1");
ga_storage._trackPageview('/index.html', 'main'); ga_storage._trackPageview("/index.html", "main");
ga_storage._trackEvent('Versions', require('electron').remote.app.getVersion()); ga_storage._trackEvent(
"Versions",
require("electron").remote.app.getVersion()
);
// Load language for Ext JS library // Load language for Ext JS library
Ext.Loader.loadScript({url: Ext.util.Format.format("ext/packages/ext-locale/build/ext-locale-{0}.js", localStorage.getItem('locale-auth0') || 'en')}); Ext.Loader.loadScript({
url: Ext.util.Format.format(
"ext/packages/ext-locale/build/ext-locale-{0}.js",
localStorage.getItem("locale-auth0") || "en"
),
});
// Initialize Auth0 // Initialize Auth0
if ( auth0Cfg.clientID !== '' && auth0Cfg.domain !== '' ) Rambox.ux.Auth0.init(); if (auth0Cfg.clientID !== "" && auth0Cfg.domain !== "")
Rambox.ux.Auth0.init();
// Set cookies to help Tooltip.io messages segmentation // Set cookies to help Tooltip.io messages segmentation
Ext.util.Cookies.set('version', require('electron').remote.app.getVersion()); Ext.util.Cookies.set(
if ( Ext.util.Cookies.get('auth0') === null ) Ext.util.Cookies.set('auth0', false); "version",
require("electron").remote.app.getVersion()
);
if (Ext.util.Cookies.get("auth0") === null)
Ext.util.Cookies.set("auth0", false);
// Check for updates // Check for updates
if ( require('electron').remote.process.argv.indexOf('--without-update') === -1 ) Rambox.app.checkUpdate(true); if (
require("electron").remote.process.argv.indexOf("--without-update") ===
-1
)
Rambox.app.checkUpdate(true);
// Get Google URLs // Get Google URLs
Ext.Ajax.request({ Ext.Ajax.request({
url: 'https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/google.json' url:
,method: 'GET' "https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/google.json",
,success: function(response) { method: "GET",
success: function (response) {
Rambox.app.config.googleURLs = Ext.decode(response.responseText); Rambox.app.config.googleURLs = Ext.decode(response.responseText);
} },
}); });
// Shortcuts // Shortcuts
const platform = require('electron').remote.process.platform; const platform = require("electron").remote.process.platform;
// Prevents default behaviour of Mousetrap, that prevents shortcuts in textareas // Prevents default behaviour of Mousetrap, that prevents shortcuts in textareas
Mousetrap.prototype.stopCallback = function(e, element, combo) { Mousetrap.prototype.stopCallback = function (e, element, combo) {
return false; return false;
}; };
// Add shortcuts to switch services using CTRL + Number // Add shortcuts to switch services using CTRL + Number
Mousetrap.bind(platform === 'darwin' ? ["command+1","command+2","command+3","command+4","command+5","command+6","command+7","command+8","command+9"] : ["ctrl+1","ctrl+2","ctrl+3","ctrl+4","ctrl+5","ctrl+6","ctrl+7","ctrl+8","ctrl+9"], function(e, combo) { // GROUPS Mousetrap.bind(
var tabPanel = Ext.cq1('app-main'); platform === "darwin"
? [
"command+1",
"command+2",
"command+3",
"command+4",
"command+5",
"command+6",
"command+7",
"command+8",
"command+9",
]
: [
"ctrl+1",
"ctrl+2",
"ctrl+3",
"ctrl+4",
"ctrl+5",
"ctrl+6",
"ctrl+7",
"ctrl+8",
"ctrl+9",
],
function (e, combo) {
// GROUPS
var tabPanel = Ext.cq1("app-main");
var arg = parseInt(e.key); var arg = parseInt(e.key);
if ( arg >= tabPanel.items.indexOf(Ext.getCmp('tbfill')) ) arg++; if (arg >= tabPanel.items.indexOf(Ext.getCmp("tbfill"))) arg++;
tabPanel.setActiveTab(arg); tabPanel.setActiveTab(arg);
}); }
);
// Add shortcut to main tab (ctrl+,) // Add shortcut to main tab (ctrl+,)
Mousetrap.bind(platform === 'darwin' ? 'command+,' : 'ctrl+,', (e, combo) => { Mousetrap.bind(
Ext.cq1('app-main').setActiveTab(0); platform === "darwin" ? "command+," : "ctrl+,",
}); (e, combo) => {
Ext.cq1("app-main").setActiveTab(0);
}
);
// Add shortcuts to navigate through services // Add shortcuts to navigate through services
Mousetrap.bind(['ctrl+tab', 'ctrl+pagedown'], (e, combo) => { Mousetrap.bind(["ctrl+tab", "ctrl+pagedown"], (e, combo) => {
var tabPanel = Ext.cq1('app-main'); var tabPanel = Ext.cq1("app-main");
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab());
var i = activeIndex + 1; var i = activeIndex + 1;
// "cycle" (go to the start) when the end is reached or the end is the spacer "tbfill" // "cycle" (go to the start) when the end is reached or the end is the spacer "tbfill"
if (i === tabPanel.items.items.length || i === tabPanel.items.items.length - 1 && tabPanel.items.items[i].id === 'tbfill') i = 0; if (
i === tabPanel.items.items.length ||
(i === tabPanel.items.items.length - 1 &&
tabPanel.items.items[i].id === "tbfill")
)
i = 0;
// skip spacer // skip spacer
while (tabPanel.items.items[i].id === 'tbfill') i++; while (tabPanel.items.items[i].id === "tbfill") i++;
tabPanel.setActiveTab(i); tabPanel.setActiveTab(i);
}); });
Mousetrap.bind(['ctrl+shift+tab', 'ctrl+pageup'], (e, combo) => { Mousetrap.bind(["ctrl+shift+tab", "ctrl+pageup"], (e, combo) => {
var tabPanel = Ext.cq1('app-main'); var tabPanel = Ext.cq1("app-main");
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab());
var i = activeIndex - 1; var i = activeIndex - 1;
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--;
tabPanel.setActiveTab(i); tabPanel.setActiveTab(i);
}); });
// Add shortcut to search inside a service // Add shortcut to search inside a service
Mousetrap.bind(process.platform === 'darwin' ? ['command+alt+f'] : ['shift+alt+f'], (e, combo) => { Mousetrap.bind(
var currentTab = Ext.cq1('app-main').getActiveTab(); process.platform === "darwin" ? ["command+alt+f"] : ["shift+alt+f"],
if ( currentTab.getWebView ) currentTab.showSearchBox(true); (e, combo) => {
}); var currentTab = Ext.cq1("app-main").getActiveTab();
if (currentTab.getWebView) currentTab.showSearchBox(true);
}
);
// Add shortcut to Do Not Disturb // Add shortcut to Do Not Disturb
Mousetrap.bind(platform === 'darwin' ? ["command+alt+d"] : ["shift+alt+d"], function(e, combo) { Mousetrap.bind(
var btn = Ext.getCmp('disturbBtn'); platform === "darwin" ? ["command+alt+d"] : ["shift+alt+d"],
function (e, combo) {
var btn = Ext.getCmp("disturbBtn");
btn.toggle(); btn.toggle();
Ext.cq1('app-main').getController().dontDisturb(btn, true); Ext.cq1("app-main").getController().dontDisturb(btn, true);
}); }
);
// Add shortcut to Lock Rambox // Add shortcut to Lock Rambox
Mousetrap.bind(platform === 'darwin' ? ['command+alt+l'] : ['shift+alt+l'], (e, combo) => { Mousetrap.bind(
var btn = Ext.getCmp('lockRamboxBtn'); platform === "darwin" ? ["command+alt+l"] : ["shift+alt+l"],
Ext.cq1('app-main').getController().lockRambox(btn); (e, combo) => {
}); var btn = Ext.getCmp("lockRamboxBtn");
Ext.cq1("app-main").getController().lockRambox(btn);
}
);
// 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))); var delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail));
var tabPanel = Ext.cq1('app-main'); var 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
tabPanel.getActiveTab().zoomIn(); tabPanel.getActiveTab().zoomIn();
} else { // Zoom Out } else {
// Zoom Out
tabPanel.getActiveTab().zoomOut(); tabPanel.getActiveTab().zoomOut();
} }
} }
}); });
// Define default value // Define default value
if ( localStorage.getItem('dontDisturb') === null ) localStorage.setItem('dontDisturb', false); if (localStorage.getItem("dontDisturb") === null)
ipc.send('setDontDisturb', localStorage.getItem('dontDisturb')); // We store it in config localStorage.setItem("dontDisturb", false);
ipc.send("setDontDisturb", localStorage.getItem("dontDisturb")); // We store it in config
if ( localStorage.getItem('locked') ) { if (localStorage.getItem("locked")) {
console.info('Lock Rambox:', 'Enabled'); console.info("Lock Rambox:", "Enabled");
Ext.cq1('app-main').getController().showLockWindow(); Ext.cq1("app-main").getController().showLockWindow();
} }
Ext.getStore('Services').load(); Ext.getStore("Services").load();
}); });
} },
,updateTotalNotifications: function( newValue, oldValue ) { updateTotalNotifications: function (newValue, oldValue) {
newValue = parseInt(newValue); newValue = parseInt(newValue);
if ( newValue > 0 ) { if (newValue > 0) {
if ( Ext.cq1('app-main').getActiveTab().record ) { if (Ext.cq1("app-main").getActiveTab().record) {
document.title = 'Rambox (' + Rambox.util.Format.formatNumber(newValue) + ') - '+Ext.cq1('app-main').getActiveTab().record.get('name'); document.title =
"Rambox (" +
Rambox.util.Format.formatNumber(newValue) +
") - " +
Ext.cq1("app-main").getActiveTab().record.get("name");
} else { } else {
document.title = 'Rambox (' + Rambox.util.Format.formatNumber(newValue) + ')'; document.title =
"Rambox (" + Rambox.util.Format.formatNumber(newValue) + ")";
} }
} else { } else {
if ( Ext.cq1('app-main') && Ext.cq1('app-main').getActiveTab().record ) { if (Ext.cq1("app-main") && Ext.cq1("app-main").getActiveTab().record) {
document.title = 'Rambox - '+Ext.cq1('app-main').getActiveTab().record.get('name'); document.title =
"Rambox - " + Ext.cq1("app-main").getActiveTab().record.get("name");
} else { } else {
document.title = 'Rambox'; document.title = "Rambox";
}
} }
} }
},
,checkUpdate: function(silence) { checkUpdate: function (silence) {
console.info('Checking for updates...'); console.info("Checking for updates...");
Ext.Ajax.request({ Ext.Ajax.request({
url: 'https://api.github.com/repos/ramboxapp/community-edition/releases/latest' url:
,method: 'GET' "https://api.github.com/repos/ramboxapp/community-edition/releases/latest",
,success: function(response) { method: "GET",
success: function (response) {
var json = Ext.decode(response.responseText); var json = Ext.decode(response.responseText);
var appVersion = new Ext.Version(require('electron').remote.app.getVersion()); var appVersion = new Ext.Version(
if ( appVersion.isLessThan(json.name) && !json.draft && !json.prerelease ) { require("electron").remote.app.getVersion()
console.info('New version is available', json.version); );
Ext.cq1('app-main').addDocked({ if (
xtype: 'toolbar' appVersion.isLessThan(json.name) &&
,dock: 'top' !json.draft &&
,ui: 'newversion' !json.prerelease
,items: [ ) {
'->' console.info("New version is available", json.version);
,{ Ext.cq1("app-main").addDocked({
xtype: 'label' xtype: "toolbar",
,html: '<b>'+locale['app.update[0]']+'</b> ('+json.version+')' + ( process.platform === 'win32' ? ' is downloading in the background and you will be notified when it is ready to be installed.' : '' ) dock: "top",
} ui: "newversion",
,{ items: [
xtype: 'button' "->",
,text: locale['app.update[1]'] {
,href: process.platform === 'darwin' ? 'https://getrambox.herokuapp.com/download/'+process.platform+'_'+process.arch : 'https://github.com/ramboxapp/community-edition/releases/latest' xtype: "label",
,hidden: process.platform === 'win32' html:
} "<b>" +
,{ locale["app.update[0]"] +
xtype: 'button' "</b> (" +
,text: locale['app.update[2]'] json.version +
,ui: 'decline' ")" +
,tooltip: 'Click here to see more information about the new version.' (process.platform === "win32"
,href: 'https://github.com/ramboxapp/community-edition/releases/tag/'+json.version ? " is downloading in the background and you will be notified when it is ready to be installed."
} : ""),
,'->' },
,{ {
glyph: 'xf00d@FontAwesome' xtype: "button",
,baseCls: '' text: locale["app.update[1]"],
,style: 'cursor:pointer;' href:
,handler: function(btn) { Ext.cq1('app-main').removeDocked(btn.up('toolbar'), true); } process.platform === "darwin"
} ? "https://getrambox.herokuapp.com/download/" +
] process.platform +
"_" +
process.arch
: "https://github.com/ramboxapp/community-edition/releases/latest",
hidden: process.platform === "win32",
},
{
xtype: "button",
text: locale["app.update[2]"],
ui: "decline",
tooltip:
"Click here to see more information about the new version.",
href:
"https://github.com/ramboxapp/community-edition/releases/tag/" +
json.version,
},
"->",
{
glyph: "xf00d@FontAwesome",
baseCls: "",
style: "cursor:pointer;",
handler: function (btn) {
Ext.cq1("app-main").removeDocked(btn.up("toolbar"), true);
},
},
],
}); });
ipc.send('autoUpdater:check-for-updates'); ipc.send("autoUpdater:check-for-updates");
return; return;
} else if ( !silence ) { } else if (!silence) {
Ext.Msg.show({ Ext.Msg.show({
title: locale['app.update[3]'] title: locale["app.update[3]"],
,message: locale['app.update[4]'] message: locale["app.update[4]"],
,icon: Ext.Msg.INFO icon: Ext.Msg.INFO,
,buttons: Ext.Msg.OK buttons: Ext.Msg.OK,
}); });
} }
console.info('Your version is the latest. No need to update.'); console.info("Your version is the latest. No need to update.");
} },
}); });
} },
}); });

69
app/store/ServicesList.js

@ -1,42 +1,43 @@
Ext.define('Rambox.store.ServicesList', { Ext.define("Rambox.store.ServicesList", {
extend: 'Ext.data.Store' extend: "Ext.data.Store",
,alias: 'store.serviceslist' alias: "store.serviceslist",
,requires: [ requires: ["Ext.data.proxy.LocalStorage"],
'Ext.data.proxy.LocalStorage'
]
,model: 'Rambox.model.ServiceList' model: "Rambox.model.ServiceList",
,proxy: { proxy: {
type: 'ajax', type: "ajax",
url: 'https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/services.json', url:
"https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/services.json",
reader: { reader: {
type: 'json', type: "json",
rootProperty: 'responseText' rootProperty: "responseText",
} },
} },
,listeners: { listeners: {
load: function () { load: function () {
Ext.get('spinner') ? Ext.get('spinner').destroy() : null; Ext.get("spinner") ? Ext.get("spinner").destroy() : null;
Ext.get('background') ? Ext.get('background').destroy() : null; Ext.get("background") ? Ext.get("background").destroy() : null;
this.add({ this.add({
id: 'custom' id: "custom",
,logo: 'custom.png' logo: "custom.png",
,name: '_Custom Service' name: "_Custom Service",
,description: locale['services[38]'] description: locale["services[38]"],
,url: '___' url: "___",
,type: 'custom' type: "custom",
,allow_popups: true allow_popups: true,
}) });
} },
} },
,sorters: [{ sorters: [
property: 'name' {
,direction: 'ASC' property: "name",
}] direction: "ASC",
},
],
,autoLoad: true autoLoad: true,
,autoSync: true autoSync: true,
,pageSize: 100000 pageSize: 100000,
}); });

380
app/ux/Auth0.js

@ -1,94 +1,103 @@
Ext.define('Rambox.ux.Auth0', { Ext.define("Rambox.ux.Auth0", {
singleton: true singleton: true,
// private // private
,lock: null lock: null,
,auth0: null auth0: null,
,authService: null authService: null,
,backupCurrent: false backupCurrent: false,
,init: function() { init: function () {
var me = this; var me = this;
var Auth0 = require('auth0-js'); var Auth0 = require("auth0-js");
var _AuthService = require('./resources/js/AuthService'); var _AuthService = require("./resources/js/AuthService");
me.authService = new _AuthService.default({ me.authService = new _AuthService.default({
clientId: auth0Cfg.clientID, clientId: auth0Cfg.clientID,
authorizeEndpoint: 'https://'+auth0Cfg.domain+'/authorize', authorizeEndpoint: "https://" + auth0Cfg.domain + "/authorize",
audience: 'https://'+auth0Cfg.domain+'/userinfo', audience: "https://" + auth0Cfg.domain + "/userinfo",
scope: 'openid profile offline_access', scope: "openid profile offline_access",
redirectUri: 'https://'+auth0Cfg.domain+'/mobile', redirectUri: "https://" + auth0Cfg.domain + "/mobile",
tokenEndpoint: 'https://'+auth0Cfg.domain+'/oauth/token' tokenEndpoint: "https://" + auth0Cfg.domain + "/oauth/token",
}); });
me.auth0 = new Auth0.WebAuth({ clientID: auth0Cfg.clientID, domain : auth0Cfg.domain }); me.auth0 = new Auth0.WebAuth({
clientID: auth0Cfg.clientID,
domain: auth0Cfg.domain,
});
//me.defineEvents(); //me.defineEvents();
} },
,onLogin: function(token, authWindow) { onLogin: function (token, authWindow) {
var me = this; var me = this;
authWindow.close(); authWindow.close();
me.auth0.client.userInfo(token.access_token, function(err, profile) { me.auth0.client.userInfo(token.access_token, function (err, profile) {
if ( err ) { if (err) {
if ( err.error === 401 || err.error === 'Unauthorized' ) return me.renewToken(me.checkConfiguration); if (err.error === 401 || err.error === "Unauthorized")
return me.renewToken(me.checkConfiguration);
Ext.Msg.hide(); Ext.Msg.hide();
return Ext.Msg.show({ return Ext.Msg.show({
title: 'Error' title: "Error",
,message: 'There was an error getting the profile: ' + err.error_description message:
,icon: Ext.Msg.ERROR "There was an error getting the profile: " + err.error_description,
,buttons: Ext.Msg.OK icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
}); });
} }
profile.user_metadata = profile['https://rambox.pro/user_metadata']; profile.user_metadata = profile["https://rambox.pro/user_metadata"];
delete profile['https://rambox.pro/user_metadata']; delete profile["https://rambox.pro/user_metadata"];
// Display a spinner while waiting // Display a spinner while waiting
Ext.Msg.wait(locale['app.window[29]'], locale['app.window[28]']); Ext.Msg.wait(locale["app.window[29]"], locale["app.window[28]"]);
// Google Analytics Event // Google Analytics Event
ga_storage._trackEvent('Users', 'loggedIn'); ga_storage._trackEvent("Users", "loggedIn");
// Set cookies to help Tooltip.io messages segmentation // Set cookies to help Tooltip.io messages segmentation
Ext.util.Cookies.set('auth0', true); Ext.util.Cookies.set("auth0", true);
// User is logged in // User is logged in
// Save the profile and JWT. // Save the profile and JWT.
localStorage.setItem('profile', JSON.stringify(profile)); localStorage.setItem("profile", JSON.stringify(profile));
localStorage.setItem('access_token', token.access_token); localStorage.setItem("access_token", token.access_token);
localStorage.setItem('id_token', token.id_token); localStorage.setItem("id_token", token.id_token);
localStorage.setItem('refresh_token', token.refresh_token); localStorage.setItem("refresh_token", token.refresh_token);
if ( !Ext.isEmpty(profile.user_metadata) && !Ext.isEmpty(profile.user_metadata.services) && !me.backupCurrent ) { if (
Ext.each(profile.user_metadata.services, function(s) { !Ext.isEmpty(profile.user_metadata) &&
var service = Ext.create('Rambox.model.Service', s); !Ext.isEmpty(profile.user_metadata.services) &&
!me.backupCurrent
) {
Ext.each(profile.user_metadata.services, function (s) {
var service = Ext.create("Rambox.model.Service", s);
service.save(); service.save();
Ext.getStore('Services').add(service); Ext.getStore("Services").add(service);
}); });
require('electron').remote.app.relaunch(); require("electron").remote.app.relaunch();
require('electron').remote.app.exit(); require("electron").remote.app.exit();
} }
Ext.Msg.hide(); Ext.Msg.hide();
Ext.cq1('app-main').getViewModel().set('username', profile.name); Ext.cq1("app-main").getViewModel().set("username", profile.name);
Ext.cq1('app-main').getViewModel().set('avatar', profile.picture); Ext.cq1("app-main").getViewModel().set("avatar", profile.picture);
}); });
} },
,backupConfiguration: function(callback) { backupConfiguration: function (callback) {
var me = this; var me = this;
Ext.Msg.wait('Saving backup...', 'Please wait...'); Ext.Msg.wait("Saving backup...", "Please wait...");
// Getting all services // Getting all services
var lastupdate = (new Date()).toJSON(); var lastupdate = new Date().toJSON();
var services = []; var services = [];
Ext.getStore('Services').each(function(service) { Ext.getStore("Services").each(function (service) {
var s = Ext.clone(service); var s = Ext.clone(service);
delete s.data.id; delete s.data.id;
delete s.data.zoomLevel; delete s.data.zoomLevel;
@ -96,203 +105,240 @@ Ext.define('Rambox.ux.Auth0', {
}); });
Ext.Ajax.request({ Ext.Ajax.request({
url: 'https://rambox.auth0.com/api/v2/users/'+Ext.decode(localStorage.getItem('profile')).sub url:
,method: 'PATCH' "https://rambox.auth0.com/api/v2/users/" +
,headers: { authorization: "Bearer " + localStorage.getItem('id_token') } Ext.decode(localStorage.getItem("profile")).sub,
,jsonData: { user_metadata: { services: services, services_lastupdate: lastupdate } } method: "PATCH",
,success: function(response) { headers: { authorization: "Bearer " + localStorage.getItem("id_token") },
jsonData: {
user_metadata: { services: services, services_lastupdate: lastupdate },
},
success: function (response) {
Ext.Msg.hide(); Ext.Msg.hide();
// Save the last update in localStorage // Save the last update in localStorage
var profile = Ext.decode(localStorage.getItem('profile')); var profile = Ext.decode(localStorage.getItem("profile"));
if ( !profile.user_metadata ) profile.user_metadata = {}; if (!profile.user_metadata) profile.user_metadata = {};
profile.user_metadata.services_lastupdate = lastupdate; profile.user_metadata.services_lastupdate = lastupdate;
localStorage.setItem('profile', Ext.encode(profile)); localStorage.setItem("profile", Ext.encode(profile));
Ext.cq1('app-main').getViewModel().set('last_sync', new Date(lastupdate).toUTCString()); Ext.cq1("app-main")
.getViewModel()
.set("last_sync", new Date(lastupdate).toUTCString());
Ext.toast({ Ext.toast({
html: '<i class="fa fa-check fa-3x fa-pull-left" aria-hidden="true"></i> Your configuration were successfully backed up.' html:
,title: 'Synchronize Configuration' '<i class="fa fa-check fa-3x fa-pull-left" aria-hidden="true"></i> Your configuration were successfully backed up.',
,width: 300 title: "Synchronize Configuration",
,align: 't' width: 300,
,closable: false align: "t",
closable: false,
}); });
if ( Ext.isFunction(callback) ) callback.bind(me)(); if (Ext.isFunction(callback)) callback.bind(me)();
} },
,failure: function(response) { failure: function (response) {
if ( response.status === 401 ) return me.renewToken(me.backupConfiguration); if (response.status === 401)
return me.renewToken(me.backupConfiguration);
Ext.Msg.hide(); Ext.Msg.hide();
Ext.toast({ Ext.toast({
html: '<i class="fa fa-times fa-3x fa-pull-left" aria-hidden="true"></i> Error occurred when trying to backup your configuration.' html:
,title: 'Synchronize Configuration' '<i class="fa fa-times fa-3x fa-pull-left" aria-hidden="true"></i> Error occurred when trying to backup your configuration.',
,width: 300 title: "Synchronize Configuration",
,align: 't' width: 300,
,closable: false align: "t",
closable: false,
}); });
if ( Ext.isFunction(callback) ) callback.bind(me)(); if (Ext.isFunction(callback)) callback.bind(me)();
console.error(response); console.error(response);
} },
}); });
} },
,restoreConfiguration: function() { restoreConfiguration: function () {
var me = this; var me = this;
me.auth0.client.userInfo(localStorage.getItem('access_token'), function(err, profile) { me.auth0.client.userInfo(
if ( err ) { localStorage.getItem("access_token"),
if ( err.code === 401 ) return me.renewToken(me.restoreConfiguration); function (err, profile) {
if (err) {
if (err.code === 401) return me.renewToken(me.restoreConfiguration);
return Ext.Msg.show({ return Ext.Msg.show({
title: 'Error' title: "Error",
,message: 'There was an error getting the profile: ' + err.description message:
,icon: Ext.Msg.ERROR "There was an error getting the profile: " + err.description,
,buttons: Ext.Msg.OK icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
}); });
} }
profile.user_metadata = profile['https://rambox.pro/user_metadata']; profile.user_metadata = profile["https://rambox.pro/user_metadata"];
delete profile['https://rambox.pro/user_metadata']; delete profile["https://rambox.pro/user_metadata"];
// First we remove all current services // First we remove all current services
Ext.cq1('app-main').getController().removeAllServices(false, function() { Ext.cq1("app-main")
if ( !profile.user_metadata || !profile.user_metadata.services ) return; .getController()
Ext.each(profile.user_metadata.services, function(s) { .removeAllServices(false, function () {
var service = Ext.create('Rambox.model.Service', s); if (!profile.user_metadata || !profile.user_metadata.services)
return;
Ext.each(profile.user_metadata.services, function (s) {
var service = Ext.create("Rambox.model.Service", s);
service.save(); service.save();
Ext.getStore('Services').add(service); Ext.getStore("Services").add(service);
}); });
require('electron').remote.getCurrentWindow().reload(); require("electron").remote.getCurrentWindow().reload();
});
}); });
} }
);
},
,checkConfiguration: function() { checkConfiguration: function () {
var me = this; var me = this;
me.auth0.client.userInfo(localStorage.getItem('access_token'), function(err, profile) { me.auth0.client.userInfo(
if ( err ) { localStorage.getItem("access_token"),
if ( err.code === 401 ) return me.renewToken(me.checkConfiguration); function (err, profile) {
if (err) {
if (err.code === 401) return me.renewToken(me.checkConfiguration);
return Ext.Msg.show({ return Ext.Msg.show({
title: 'Error' title: "Error",
,message: 'There was an error getting the profile: ' + err.description message:
,icon: Ext.Msg.ERROR "There was an error getting the profile: " + err.description,
,buttons: Ext.Msg.OK icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
}); });
} }
profile.user_metadata = profile['https://rambox.pro/user_metadata']; profile.user_metadata = profile["https://rambox.pro/user_metadata"];
delete profile['https://rambox.pro/user_metadata']; delete profile["https://rambox.pro/user_metadata"];
if ( !profile.user_metadata ) { if (!profile.user_metadata) {
Ext.toast({ Ext.toast({
html: 'You don\'t have any backup yet.' html: "You don't have any backup yet.",
,title: 'Synchronize Configuration' title: "Synchronize Configuration",
,width: 300 width: 300,
,align: 't' align: "t",
,closable: false closable: false,
}); });
return; return;
} }
if ( Math.floor(new Date(profile.user_metadata.services_lastupdate) / 1000) > Math.floor(new Date(Ext.decode(localStorage.getItem('profile')).user_metadata.services_lastupdate) / 1000) ) { if (
Math.floor(
new Date(profile.user_metadata.services_lastupdate) / 1000
) >
Math.floor(
new Date(
Ext.decode(
localStorage.getItem("profile")
).user_metadata.services_lastupdate
) / 1000
)
) {
Ext.toast({ Ext.toast({
html: 'Your settings are out of date.' html: "Your settings are out of date.",
,title: 'Synchronize Configuration' title: "Synchronize Configuration",
,width: 300 width: 300,
,align: 't' align: "t",
,closable: false closable: false,
}); });
} else { } else {
Ext.toast({ Ext.toast({
html: '<i class="fa fa-check fa-3x fa-pull-left" aria-hidden="true"></i> Latest backup is already applied.' html:
,title: 'Synchronize Configuration' '<i class="fa fa-check fa-3x fa-pull-left" aria-hidden="true"></i> Latest backup is already applied.',
,width: 300 title: "Synchronize Configuration",
,align: 't' width: 300,
,closable: false align: "t",
closable: false,
}); });
} }
});
} }
);
},
,renewToken: function(callback) { renewToken: function (callback) {
var me = this; var me = this;
Ext.Ajax.request({ Ext.Ajax.request({
url: 'https://rambox.auth0.com/oauth/token' url: "https://rambox.auth0.com/oauth/token",
,method: 'POST' method: "POST",
,jsonData: { jsonData: {
grant_type: 'refresh_token' grant_type: "refresh_token",
,client_id: auth0Cfg.clientID client_id: auth0Cfg.clientID,
,client_secret: auth0Cfg.clientSecret client_secret: auth0Cfg.clientSecret,
,refresh_token: localStorage.getItem('refresh_token') refresh_token: localStorage.getItem("refresh_token"),
,api_type: 'app' api_type: "app",
} },
,success: function(response) { success: function (response) {
var json = Ext.decode(response.responseText); var json = Ext.decode(response.responseText);
localStorage.setItem('access_token', json.access_token); localStorage.setItem("access_token", json.access_token);
localStorage.setItem('id_token', json.id_token); localStorage.setItem("id_token", json.id_token);
if ( Ext.isFunction(callback) ) callback.bind(me)(); if (Ext.isFunction(callback)) callback.bind(me)();
} },
,failure: function(response) { failure: function (response) {
console.error(response); console.error(response);
} },
}); });
} },
,login: function() { login: function () {
var me = this; var me = this;
var electron = require('electron').remote; var electron = require("electron").remote;
var authWindow = new electron.BrowserWindow({ var authWindow = new electron.BrowserWindow({
title: 'Rambox - Login' title: "Rambox - Login",
,width: 400 width: 400,
,height: 600 height: 600,
,maximizable: false maximizable: false,
,minimizable: false minimizable: false,
,resizable: true resizable: true,
,closable: true closable: true,
,center: true center: true,
,autoHideMenuBar: true autoHideMenuBar: true,
,skipTaskbar: true skipTaskbar: true,
,fullscreenable: false fullscreenable: false,
,parent: require('electron').remote.getCurrentWindow() parent: require("electron").remote.getCurrentWindow(),
,webPreferences: { webPreferences: {
partition: 'persist:rambox' partition: "persist:rambox",
} },
}); });
authWindow.on('closed', function() { authWindow.on("closed", function () {
authWindow = null; authWindow = null;
}); });
authWindow.loadURL(me.authService.requestAuthCode()); authWindow.loadURL(me.authService.requestAuthCode());
authWindow.webContents.on('did-start-loading', function(e) { authWindow.webContents.on("did-start-loading", function (e) {
authWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => { authWindow.webContents.session.webRequest.onBeforeSendHeaders(
(details, callback) => {
Rambox.app.config.googleURLs.forEach((loginURL) => { Rambox.app.config.googleURLs.forEach((loginURL) => {
if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0' }) if (details.url.indexOf(loginURL) > -1)
callback({ cancel: false, requestHeaders: details.requestHeaders }); details.requestHeaders["User-Agent"] =
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0";
}); });
callback({ cancel: false, requestHeaders: details.requestHeaders });
}
);
}); });
authWindow.webContents.on('did-navigate', function(e, url) { authWindow.webContents.on("did-navigate", function (e, url) {
me.authService.requestAccessCode(url, me.onLogin.bind(me), authWindow); me.authService.requestAccessCode(url, me.onLogin.bind(me), authWindow);
}); });
} },
,logout: function() { logout: function () {
var me = this; var me = this;
localStorage.removeItem('profile'); localStorage.removeItem("profile");
localStorage.removeItem('id_token'); localStorage.removeItem("id_token");
localStorage.removeItem('refresh_token'); localStorage.removeItem("refresh_token");
localStorage.removeItem('access_token'); localStorage.removeItem("access_token");
// Set cookies to help Tooltip.io messages segmentation // Set cookies to help Tooltip.io messages segmentation
Ext.util.Cookies.set('auth0', false); Ext.util.Cookies.set("auth0", false);
} },
}); });

1019
app/ux/WebView.js

File diff suppressed because it is too large Load Diff

733
app/view/main/MainController.js

@ -1,12 +1,12 @@
const darkreader = require('darkreader'); const darkreader = require("darkreader");
Ext.define('Rambox.view.main.MainController', { Ext.define("Rambox.view.main.MainController", {
extend: 'Ext.app.ViewController' extend: "Ext.app.ViewController",
,alias: 'controller.main' alias: "controller.main",
,initialize: function( tabPanel ) { initialize: function (tabPanel) {
const config = ipc.sendSync('getConfig'); const config = ipc.sendSync("getConfig");
if (config.darkreader) { if (config.darkreader) {
darkreader.enable(); darkreader.enable();
@ -16,157 +16,186 @@ Ext.define('Rambox.view.main.MainController', {
tabPanel.setTabPosition(config.tabbar_location); tabPanel.setTabPosition(config.tabbar_location);
tabPanel.setTabRotation(0); tabPanel.setTabRotation(0);
var reorderer = tabPanel.plugins.find(function(plugin) { return plugin.ptype == "tabreorderer"}); var reorderer = tabPanel.plugins.find(function (plugin) {
return plugin.ptype == "tabreorderer";
});
if ( reorderer !== undefined ) { if (reorderer !== undefined) {
const names = reorderer.container.getLayout().names; const names = reorderer.container.getLayout().names;
reorderer.dd.dim = names.width; reorderer.dd.dim = names.width;
reorderer.dd.startAttr = names.beforeX; reorderer.dd.startAttr = names.beforeX;
reorderer.dd.endAttr = names.afterX; reorderer.dd.endAttr = names.afterX;
} }
} },
// 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: function( tabPanel, newTab, oldTab ) { onTabChange: function (tabPanel, newTab, oldTab) {
var me = this; var me = this;
// Set Google Analytics event // Set Google Analytics event
ga_storage._trackPageview('/index.html', 'main'); ga_storage._trackPageview("/index.html", "main");
localStorage.setItem('last_active_service', newTab.id); localStorage.setItem("last_active_service", newTab.id);
if ( newTab.id === 'ramboxTab' ) { if (newTab.id === "ramboxTab") {
if ( Rambox.app.getTotalNotifications() > 0 ) { if (Rambox.app.getTotalNotifications() > 0) {
document.title = 'Rambox ('+ Rambox.app.getTotalNotifications() +')'; document.title = "Rambox (" + Rambox.app.getTotalNotifications() + ")";
} else { } else {
document.title = 'Rambox'; document.title = "Rambox";
} }
return; return;
} }
if (!newTab.record.get('enabled') ) { if (!newTab.record.get("enabled")) {
return; return;
} }
var webview = newTab.down('component').el.dom; var webview = newTab.down("component").el.dom;
setTimeout(function () { setTimeout(function () {
if ( webview ) { if (webview) {
tabPanel.getActiveTab().getWebView().blur(); tabPanel.getActiveTab().getWebView().blur();
tabPanel.getActiveTab().getWebView().focus(); tabPanel.getActiveTab().getWebView().focus();
} }
}, 300); }, 300);
// Update the main window so it includes the active tab title. // Update the main window so it includes the active tab title.
if ( Rambox.app.getTotalNotifications() > 0 ) { if (Rambox.app.getTotalNotifications() > 0) {
document.title = 'Rambox ('+ Rambox.app.getTotalNotifications() +') - ' + newTab.record.get('name'); document.title =
"Rambox (" +
Rambox.app.getTotalNotifications() +
") - " +
newTab.record.get("name");
} else { } else {
document.title = 'Rambox - ' + newTab.record.get('name'); document.title = "Rambox - " + newTab.record.get("name");
} }
} },
,updatePositions: function(tabPanel, tab) { updatePositions: function (tabPanel, tab) {
if ( tab.id === 'ramboxTab' || tab.id === 'tbfill' ) return true; if (tab.id === "ramboxTab" || tab.id === "tbfill") return true;
console.log('Updating Tabs positions...'); console.log("Updating Tabs positions...");
var store = Ext.getStore('Services'); var store = Ext.getStore("Services");
var align = 'left'; var align = "left";
store.suspendEvent('remove'); store.suspendEvent("remove");
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 (
var rec = store.getById(t.record.get('id')); t.id !== "ramboxTab" &&
if ( align === 'right' ) i--; t.id !== "tbfill" &&
rec.set('align', align); t.record.get("enabled")
rec.set('position', i); ) {
var rec = store.getById(t.record.get("id"));
if (align === "right") i--;
rec.set("align", align);
rec.set("position", i);
rec.save(); rec.save();
} else if (t.id === "tbfill") {
align = "right";
} }
else if ( t.id === 'tbfill' ) {
align = 'right';
}
}); });
store.load(); store.load();
store.resumeEvent('remove'); store.resumeEvent("remove");
} },
,showServiceTab: function( grid, record, tr, rowIndex, e ) { showServiceTab: function (grid, record, tr, rowIndex, e) {
if ( e.position.colIdx === 0 ) { // Service Logo if (e.position.colIdx === 0) {
Ext.getCmp('tab_'+record.get('id')).show(); // Service Logo
} Ext.getCmp("tab_" + record.get("id")).show();
} }
},
,onRenameService: function(editor, e) { onRenameService: function (editor, e) {
var me = this; var me = this;
e.record.commit(); e.record.commit();
// Change the title of the Tab // Change the title of the Tab
Ext.getCmp('tab_'+e.record.get('id')).setTitle(e.record.get('name')); Ext.getCmp("tab_" + e.record.get("id")).setTitle(e.record.get("name"));
} },
,onEnableDisableService: function(cc, rowIndex, checked, obj, hideTab) { onEnableDisableService: function (cc, rowIndex, checked, obj, hideTab) {
var rec = Ext.getStore('Services').getAt(rowIndex); var rec = Ext.getStore("Services").getAt(rowIndex);
if ( !checked ) { if (!checked) {
Ext.getCmp('tab_'+rec.get('id')).destroy(); Ext.getCmp("tab_" + rec.get("id")).destroy();
} else { } else {
Ext.cq1('app-main').insert(rec.get('align') === 'left' ? rec.get('position') : rec.get('position')+1, { Ext.cq1("app-main").insert(
xtype: 'webview' rec.get("align") === "left"
,id: 'tab_'+rec.get('id') ? rec.get("position")
,title: rec.get('name') : rec.get("position") + 1,
,icon: rec.get('type') !== 'custom' ? 'resources/icons/'+rec.get('logo') : ( rec.get('logo') === '' ? 'resources/icons/custom.png' : rec.get('logo')) {
,src: rec.get('url') xtype: "webview",
,type: rec.get('type') id: "tab_" + rec.get("id"),
,muted: rec.get('muted') title: rec.get("name"),
,includeInGlobalUnreadCounter: rec.get('includeInGlobalUnreadCounter') icon:
,displayTabUnreadCounter: rec.get('displayTabUnreadCounter') rec.get("type") !== "custom"
,enabled: rec.get('enabled') ? "resources/icons/" + rec.get("logo")
,record: rec : rec.get("logo") === ""
,useragent: ipc.sendSync('getConfig').user_agent ? "resources/icons/custom.png"
,hidden: hideTab : rec.get("logo"),
,tabConfig: { src: rec.get("url"),
service: rec type: rec.get("type"),
} muted: rec.get("muted"),
}); includeInGlobalUnreadCounter: rec.get("includeInGlobalUnreadCounter"),
displayTabUnreadCounter: rec.get("displayTabUnreadCounter"),
enabled: rec.get("enabled"),
record: rec,
useragent: ipc.sendSync("getConfig").user_agent,
hidden: hideTab,
tabConfig: {
service: rec,
},
} }
);
} }
},
,onNewServiceSelect: function( view, record, item, index, e ) { onNewServiceSelect: function (view, record, item, index, e) {
Ext.create('Rambox.view.add.Add', { Ext.create("Rambox.view.add.Add", {
record: record record: record,
}); });
} },
,removeServiceFn: function(serviceId, total, actual, callback) { removeServiceFn: function (serviceId, total, actual, callback) {
var me = this; var me = this;
if ( !serviceId ) return false; if (!serviceId) return false;
// Get Record // Get Record
var rec = Ext.getStore('Services').getById(serviceId); var rec = Ext.getStore("Services").getById(serviceId);
if ( !rec.get('enabled') ) { if (!rec.get("enabled")) {
rec.set('enabled', true); rec.set("enabled", true);
me.onEnableDisableService(null, Ext.getStore('Services').indexOf(rec), true, null, true); me.onEnableDisableService(
null,
Ext.getStore("Services").indexOf(rec),
true,
null,
true
);
// Get Tab // Get Tab
var tab = Ext.getCmp('tab_'+serviceId); var tab = Ext.getCmp("tab_" + serviceId);
// Clear all trash data // Clear all trash data
const webview = tab.getWebView(); const webview = tab.getWebView();
webview.addEventListener("did-start-loading", function() { webview.addEventListener("did-start-loading", function () {
clearData(webview, tab); clearData(webview, tab);
}); });
} else { } else {
// Get Tab // Get Tab
var tab = Ext.getCmp('tab_'+serviceId); var tab = Ext.getCmp("tab_" + serviceId);
// Clear all trash data // Clear all trash data
const webview = tab.getWebView(); const webview = tab.getWebView();
clearData(webview, tab); clearData(webview, tab);
} }
const config = ipc.sendSync('getConfig'); const config = ipc.sendSync("getConfig");
if ( config.default_service === rec.get('id') ) ipc.send('setConfig', Ext.apply(config, { default_service: 'ramboxTab' })); if (config.default_service === rec.get("id"))
ipc.send(
"setConfig",
Ext.apply(config, { default_service: "ramboxTab" })
);
function clearData(webview, tab) { function clearData(webview, tab) {
const currentWebView = require("electron").remote.webContents.fromId( const currentWebView = require("electron").remote.webContents.fromId(
@ -175,372 +204,472 @@ Ext.define('Rambox.view.main.MainController', {
currentWebView.clearHistory(); currentWebView.clearHistory();
currentWebView.session.flushStorageData(); currentWebView.session.flushStorageData();
currentWebView.session.clearCache().then(() => { currentWebView.session
currentWebView.session.clearStorageData().then(() => { .clearCache()
currentWebView.session.cookies.flushStore().then(() => { .then(() => {
currentWebView.session
.clearStorageData()
.then(() => {
currentWebView.session.cookies
.flushStore()
.then(() => {
// Remove record from localStorage // Remove record from localStorage
Ext.getStore('Services').remove(rec); Ext.getStore("Services").remove(rec);
// Close tab // Close tab
tab.close(); tab.close();
// Close waiting message // Close waiting message
if ( total === actual ) { if (total === actual) {
Ext.Msg.hide(); Ext.Msg.hide();
if ( Ext.isFunction(callback) ) callback(); if (Ext.isFunction(callback)) callback();
}
}).catch(err => { console.log(err) })
}).catch(err => { console.log(err) })
}).catch(err => { console.log(err) })
} }
})
.catch((err) => {
console.log(err);
});
})
.catch((err) => {
console.log(err);
});
})
.catch((err) => {
console.log(err);
});
} }
},
,removeService: function( gridView, rowIndex, colIndex, col, e, rec, rowEl ) { removeService: function (gridView, rowIndex, colIndex, col, e, rec, rowEl) {
var me = this; var me = this;
Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[13]']+' <b>'+rec.get('name')+'</b>?', function(btnId) { Ext.Msg.confirm(
if ( btnId === 'yes' ) { locale["app.window[12]"],
Ext.Msg.wait('Please wait until we clear all.', 'Removing...'); locale["app.window[13]"] + " <b>" + rec.get("name") + "</b>?",
me.removeServiceFn(rec.get('id'), 1, 1); function (btnId) {
if (btnId === "yes") {
Ext.Msg.wait("Please wait until we clear all.", "Removing...");
me.removeServiceFn(rec.get("id"), 1, 1);
} }
});
} }
);
},
,removeAllServices: function(btn, callback) { removeAllServices: function (btn, callback) {
var me = this; var me = this;
if ( btn ) { if (btn) {
Ext.Msg.confirm(locale['app.window[12]'], locale['app.window[14]'], function(btnId) { Ext.Msg.confirm(
if ( btnId === 'yes' ) { locale["app.window[12]"],
locale["app.window[14]"],
function (btnId) {
if (btnId === "yes") {
// Clear counter for unread messaging // Clear counter for unread messaging
document.title = 'Rambox'; document.title = "Rambox";
Ext.cq1('app-main').suspendEvent('remove'); Ext.cq1("app-main").suspendEvent("remove");
Ext.getStore('Services').load(); Ext.getStore("Services").load();
Ext.Msg.wait('Please wait until we clear all.', 'Removing...'); Ext.Msg.wait("Please wait until we clear all.", "Removing...");
const count = Ext.getStore('Services').getCount(); const count = Ext.getStore("Services").getCount();
var i = 1; var i = 1;
Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) { Ext.Array.each(
Ext.getStore("Services").collect("id"),
function (serviceId) {
me.removeServiceFn(serviceId, count, i++, callback || false); me.removeServiceFn(serviceId, count, i++, callback || false);
});
if ( count === 0 && Ext.isFunction(callback) ) callback();
Ext.cq1('app-main').resumeEvent('remove');
} }
}); );
if (count === 0 && Ext.isFunction(callback)) callback();
Ext.cq1("app-main").resumeEvent("remove");
}
}
);
} else { } else {
Ext.cq1('app-main').suspendEvent('remove'); Ext.cq1("app-main").suspendEvent("remove");
Ext.getStore('Services').load(); Ext.getStore("Services").load();
const count = Ext.getStore('Services').getCount(); const count = Ext.getStore("Services").getCount();
var i = 1; var i = 1;
Ext.Array.each(Ext.getStore('Services').collect('id'), function(serviceId) { Ext.Array.each(
Ext.getStore("Services").collect("id"),
function (serviceId) {
me.removeServiceFn(serviceId, count, i++, callback || false); me.removeServiceFn(serviceId, count, i++, callback || false);
});
if ( count === 0 && Ext.isFunction(callback) ) callback();
Ext.cq1('app-main').resumeEvent('remove');
} }
} );
if (count === 0 && Ext.isFunction(callback)) callback();
,configureService: function( gridView, rowIndex, colIndex, col, e, rec, rowEl ) { Ext.cq1("app-main").resumeEvent("remove");
Ext.create('Rambox.view.add.Add', { }
record: rec },
,service: Ext.getStore('ServicesList').getById(rec.get('type'))
,edit: true configureService: function (
gridView,
rowIndex,
colIndex,
col,
e,
rec,
rowEl
) {
Ext.create("Rambox.view.add.Add", {
record: rec,
service: Ext.getStore("ServicesList").getById(rec.get("type")),
edit: true,
}); });
} },
,onSearchRender: function( field ) { onSearchRender: function (field) {
field.focus(false, 1000); field.focus(false, 1000);
} },
,onSearchEnter: function( field, e ) { onSearchEnter: function (field, e) {
var me = this; var me = this;
if ( e.getKey() == e.ENTER && Ext.getStore('ServicesList').getCount() === 2 ) { // Two because we always shows Custom Service option if (
me.onNewServiceSelect(field.up().down('dataview'), Ext.getStore('ServicesList').getAt(0)); 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.onClearClick(field); me.onClearClick(field);
} }
} },
,doTypeFilter: function( cg, newValue, oldValue ) { doTypeFilter: function (cg, newValue, oldValue) {
var me = this; var me = this;
Ext.getStore('ServicesList').getFilters().replaceAll({ Ext.getStore("ServicesList")
fn: function(record) { .getFilters()
return Ext.Array.contains(Ext.Object.getKeys(cg.getValue()), record.get('type')) || record.get('type') === 'custom'; .replaceAll({
} fn: function (record) {
return (
Ext.Array.contains(
Ext.Object.getKeys(cg.getValue()),
record.get("type")
) || record.get("type") === "custom"
);
},
}); });
} },
,onSearchServiceChange: function(field, newValue, oldValue) { onSearchServiceChange: function (field, newValue, oldValue) {
var me = this; var me = this;
var cg = field.up().down('checkboxgroup'); var 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();
Ext.getStore('ServicesList').getFilters().replaceAll({ Ext.getStore("ServicesList")
fn: function(record) { .getFilters()
if ( record.get('type') === 'custom' ) return true; .replaceAll({
if ( !Ext.Array.contains(Ext.Object.getKeys(cg.getValue()), record.get('type')) ) return false; fn: function (record) {
return record.get('name').toLowerCase().indexOf(newValue.toLowerCase()) > -1 ? true : false; if (record.get("type") === "custom") return true;
} if (
!Ext.Array.contains(
Ext.Object.getKeys(cg.getValue()),
record.get("type")
)
)
return false;
return record
.get("name")
.toLowerCase()
.indexOf(newValue.toLowerCase()) > -1
? true
: false;
},
}); });
} else { } else {
field.getTrigger('clear').hide(); field.getTrigger("clear").hide();
Ext.getStore('ServicesList').getFilters().removeAll(); Ext.getStore("ServicesList").getFilters().removeAll();
me.doTypeFilter(cg); me.doTypeFilter(cg);
} }
field.updateLayout(); field.updateLayout();
} },
,onClearClick: function(field, trigger, e) { onClearClick: function (field, trigger, e) {
var me = this; var me = this;
var cg = field.up().down('checkboxgroup'); var cg = field.up().down("checkboxgroup");
field.reset(); field.reset();
field.getTrigger('clear').hide(); field.getTrigger("clear").hide();
field.updateLayout(); field.updateLayout();
Ext.getStore('ServicesList').getFilters().removeAll(); Ext.getStore("ServicesList").getFilters().removeAll();
me.doTypeFilter(cg); me.doTypeFilter(cg);
} },
,dontDisturb: function(btn, e, called) { dontDisturb: function (btn, e, called) {
console.info('Dont Disturb:', btn.pressed ? 'Enabled' : 'Disabled'); console.info("Dont Disturb:", btn.pressed ? "Enabled" : "Disabled");
// Google Analytics Event // Google Analytics Event
if ( !called ) ga_storage._trackEvent('Usability', 'dontDisturb', ( btn.pressed ? 'on' : 'off' )); if (!called)
ga_storage._trackEvent(
"Usability",
"dontDisturb",
btn.pressed ? "on" : "off"
);
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); var tab = Ext.getCmp("tab_" + serviceId);
if ( !tab ) return; // Skip disabled services if (!tab) return; // Skip disabled services
// Mute sounds // Mute sounds
tab.setAudioMuted(btn.pressed ? true : tab.record.get('muted'), true); tab.setAudioMuted(btn.pressed ? true : tab.record.get("muted"), true);
// Prevent Notifications // Prevent Notifications
tab.setNotifications(btn.pressed ? false : tab.record.get('notifications'), true); tab.setNotifications(
}); btn.pressed ? false : tab.record.get("notifications"),
true
);
}
);
localStorage.setItem('dontDisturb', btn.pressed); localStorage.setItem("dontDisturb", btn.pressed);
ipc.send('setDontDisturb', btn.pressed); ipc.send("setDontDisturb", btn.pressed);
btn.setText(locale['app.main[16]']+': ' + ( btn.pressed ? locale['app.window[20]'] : locale['app.window[21]'] )); btn.setText(
locale["app.main[16]"] +
": " +
(btn.pressed ? locale["app.window[20]"] : locale["app.window[21]"])
);
// var btn_icon = document.getElementById('disturbBtn-btnIconEl'); // var btn_icon = document.getElementById('disturbBtn-btnIconEl');
// btn_icon.innerHTML = btn.pressed ? "" : ""; // btn_icon.innerHTML = btn.pressed ? "" : "";
btn.pressed ? btn.setGlyph('xf1f7@FontAwesome') : btn.setGlyph('xf0f3@FontAwesome'); btn.pressed
? btn.setGlyph("xf1f7@FontAwesome")
: btn.setGlyph("xf0f3@FontAwesome");
Ext.getCmp('mainTabBar').getEl().toggleCls('dontdisturb'); Ext.getCmp("mainTabBar").getEl().toggleCls("dontdisturb");
// If this method is called from Lock method, prevent showing toast // If this method is called from Lock method, prevent showing toast
if ( !e ) return; if (!e) return;
Ext.toast({ Ext.toast({
html: btn.pressed ? 'ENABLED' : 'DISABLED' html: btn.pressed ? "ENABLED" : "DISABLED",
,title: 'Don\'t Disturb' title: "Don't Disturb",
,width: 200 width: 200,
,align: 't' align: "t",
,closable: false closable: false,
}); });
} },
,lockRambox: function(btn) { lockRambox: function (btn) {
var me = this; var 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(
if ( btnId === 'yes' ) { locale["app.main[19]"],
setLock(ipc.sendSync('getConfig').master_password); "Do you want to use the Master Password as your temporal password?",
function (btnId) {
if (btnId === "yes") {
setLock(ipc.sendSync("getConfig").master_password);
} else { } else {
showTempPass(); showTempPass();
} }
}); }
);
} else { } else {
showTempPass(); showTempPass();
} }
function showTempPass() { function showTempPass() {
var msgbox = Ext.Msg.prompt(locale['app.main[19]'], locale['app.window[22]'], function(btnId, text) { var msgbox = Ext.Msg.prompt(
if ( btnId === 'ok' ) { locale["app.main[19]"],
var msgbox2 = Ext.Msg.prompt(locale['app.main[19]'], locale['app.window[23]'], function(btnId, text2) { locale["app.window[22]"],
if ( btnId === 'ok' ) { function (btnId, text) {
if ( text !== text2 ) { if (btnId === "ok") {
var msgbox2 = Ext.Msg.prompt(
locale["app.main[19]"],
locale["app.window[23]"],
function (btnId, text2) {
if (btnId === "ok") {
if (text !== text2) {
Ext.Msg.show({ Ext.Msg.show({
title: locale['app.window[24]'] title: locale["app.window[24]"],
,message: locale['app.window[25]'] message: locale["app.window[25]"],
,icon: Ext.Msg.WARNING icon: Ext.Msg.WARNING,
,buttons: Ext.Msg.OK buttons: Ext.Msg.OK,
,fn: me.lockRambox fn: me.lockRambox,
}); });
return false; return false;
} }
setLock(Rambox.util.MD5.encypt(text)); setLock(Rambox.util.MD5.encypt(text));
} }
});
msgbox2.textField.inputEl.dom.type = 'password';
} }
}); );
msgbox.textField.inputEl.dom.type = 'password'; msgbox2.textField.inputEl.dom.type = "password";
}
}
);
msgbox.textField.inputEl.dom.type = "password";
} }
function setLock(text) { function setLock(text) {
var ramboxTab = Ext.cq1('#ramboxTab'); var ramboxTab = Ext.cq1("#ramboxTab");
// Related to issue #2065. Focusing in an sub frame is a workaround // Related to issue #2065. Focusing in an sub frame is a workaround
if (ramboxTab.getWebView) { if (ramboxTab.getWebView) {
ramboxTab.down('component').el.dom.executeJavaScript(` ramboxTab.down("component").el.dom.executeJavaScript(`
var iframeFix = document.createElement('iframe'); var iframeFix = document.createElement('iframe');
document.body.appendChild(iframeFix); document.body.appendChild(iframeFix);
iframeFix.focus(); iframeFix.focus();
document.body.removeChild(iframeFix); document.body.removeChild(iframeFix);
`); `);
} }
console.info('Lock Rambox:', 'Enabled'); console.info("Lock Rambox:", "Enabled");
// Save encrypted password in localStorage to show locked when app is reopen // Save encrypted password in localStorage to show locked when app is reopen
localStorage.setItem('locked', text); localStorage.setItem("locked", text);
// Google Analytics Event // Google Analytics Event
ga_storage._trackEvent('Usability', 'locked'); ga_storage._trackEvent("Usability", "locked");
me.lookupReference('disturbBtn').setPressed(true); me.lookupReference("disturbBtn").setPressed(true);
me.dontDisturb(me.lookupReference('disturbBtn'), false, true); me.dontDisturb(me.lookupReference("disturbBtn"), false, true);
me.showLockWindow(); me.showLockWindow();
} }
} },
,showLockWindow: function() { showLockWindow: function () {
var me = this; var me = this;
var validateFn = function() { var validateFn = function () {
if ( localStorage.getItem('locked') === Rambox.util.MD5.encypt(winLock.down('textfield').getValue()) ) { if (
console.info('Lock Rambox:', 'Disabled'); localStorage.getItem("locked") ===
localStorage.removeItem('locked'); Rambox.util.MD5.encypt(winLock.down("textfield").getValue())
) {
console.info("Lock Rambox:", "Disabled");
localStorage.removeItem("locked");
winLock.close(); winLock.close();
me.lookupReference('disturbBtn').setPressed(false); me.lookupReference("disturbBtn").setPressed(false);
me.dontDisturb(me.lookupReference('disturbBtn'), false); me.dontDisturb(me.lookupReference("disturbBtn"), false);
} else { } else {
winLock.down('textfield').reset(); winLock.down("textfield").reset();
winLock.down('textfield').markInvalid('Unlock password is invalid'); winLock.down("textfield").markInvalid("Unlock password is invalid");
} }
}; };
var winLock = Ext.create('Ext.window.Window', { var winLock = Ext.create("Ext.window.Window", {
maximized: true maximized: true,
,closable: false closable: false,
,resizable: false resizable: false,
,minimizable: false minimizable: false,
,maximizable: false maximizable: false,
,draggable: false draggable: false,
,onEsc: Ext.emptyFn onEsc: Ext.emptyFn,
,layout: 'center' layout: "center",
,bodyStyle: 'background-color:#2e658e;' bodyStyle: "background-color:#2e658e;",
,items: [ items: [
{
xtype: "container",
layout: "vbox",
items: [
{
xtype: "image",
src: "resources/Icon.png",
width: 256,
height: 256,
},
{ {
xtype: 'container' xtype: "component",
,layout: 'vbox' autoEl: {
,items: [ tag: "h1",
html: locale["app.window[26]"],
style: "text-align:center;width:256px;",
},
},
{ {
xtype: 'image' xtype: "textfield",
,src: 'resources/Icon.png' inputType: "password",
,width: 256 width: 256,
,height: 256 listeners: {
} specialkey: function (field, e) {
,{ if (e.getKey() == e.ENTER) {
xtype: 'component'
,autoEl: {
tag: 'h1'
,html: locale['app.window[26]']
,style: 'text-align:center;width:256px;'
}
}
,{
xtype: 'textfield'
,inputType: 'password'
,width: 256
,listeners: {
specialkey: function(field, e){
if ( e.getKey() == e.ENTER ) {
validateFn(); validateFn();
} }
} },
} },
} },
,{ {
xtype: 'button' xtype: "button",
,text: locale['app.window[27]'] text: locale["app.window[27]"],
,glyph: 'xf13e@FontAwesome' glyph: "xf13e@FontAwesome",
,width: 256 width: 256,
,scale: 'large' scale: "large",
,handler: validateFn handler: validateFn,
} },
] ],
} },
] ],
,listeners: { listeners: {
render: function(win) { render: function (win) {
win.getEl().on('click', function() { win.getEl().on("click", function () {
win.down('textfield').focus(100); win.down("textfield").focus(100);
}); });
} },
} },
}).show(); }).show();
winLock.down('textfield').focus(1000); winLock.down("textfield").focus(1000);
} },
,openPreferences: function( btn ) { openPreferences: function (btn) {
var me = this; var me = this;
Ext.create('Rambox.view.preferences.Preferences').show(); Ext.create("Rambox.view.preferences.Preferences").show();
} },
,login: function(btn) { login: function (btn) {
var me = this; var me = this;
Rambox.ux.Auth0.login(); Rambox.ux.Auth0.login();
} },
,logout: function(btn) { logout: function (btn) {
var me = this; var me = this;
var logoutFn = function(callback) { var logoutFn = function (callback) {
Ext.Msg.wait(locale['app.window[37]'], locale['app.main[21]']); Ext.Msg.wait(locale["app.window[37]"], locale["app.main[21]"]);
// Google Analytics Event // Google Analytics Event
ga_storage._trackEvent('Users', 'loggedOut'); ga_storage._trackEvent("Users", "loggedOut");
// Logout from Auth0 // Logout from Auth0
Rambox.ux.Auth0.logout(); Rambox.ux.Auth0.logout();
Ext.cq1('app-main').getViewModel().set('username', ''); Ext.cq1("app-main").getViewModel().set("username", "");
Ext.cq1('app-main').getViewModel().set('avatar', ''); Ext.cq1("app-main").getViewModel().set("avatar", "");
if ( Ext.isFunction(callback) ) { if (Ext.isFunction(callback)) {
callback(false, function() { callback(false, function () {
Ext.Msg.hide(); Ext.Msg.hide();
}); });
} else { } else {
Ext.Msg.hide(); Ext.Msg.hide();
} }
} };
if ( btn ) { if (btn) {
Ext.Msg.confirm(locale['app.main[21]'], locale['app.window[38]'], function(btnId) { Ext.Msg.confirm(
if ( btnId === 'yes' ) { locale["app.main[21]"],
locale["app.window[38]"],
function (btnId) {
if (btnId === "yes") {
logoutFn(me.removeAllServices.bind(me)); logoutFn(me.removeAllServices.bind(me));
} }
}); }
);
} else { } else {
logoutFn(); logoutFn();
} }
} },
,showDonate: function( btn ) { showDonate: function (btn) {
Signalayer.API.show('tChaoq3PwSG9wswhn'); Signalayer.API.show("tChaoq3PwSG9wswhn");
} },
}); });

750
app/view/preferences/Preferences.js

@ -1,382 +1,412 @@
Ext.define('Rambox.view.preferences.Preferences',{ Ext.define("Rambox.view.preferences.Preferences", {
extend: 'Ext.window.Window' extend: "Ext.window.Window",
,xtype: 'preferences' xtype: "preferences",
,requires: [ requires: [
'Rambox.view.preferences.PreferencesController' "Rambox.view.preferences.PreferencesController",
,'Rambox.view.preferences.PreferencesModel' "Rambox.view.preferences.PreferencesModel",
,'Ext.form.field.ComboBox' "Ext.form.field.ComboBox",
,'Ext.form.field.Checkbox' "Ext.form.field.Checkbox",
] ],
,controller: 'preferences-preferences' controller: "preferences-preferences",
,viewModel: { viewModel: {
type: 'preferences-preferences' type: "preferences-preferences",
} },
,title: locale['preferences[0]'] title: locale["preferences[0]"],
,width: 420 width: 420,
,height: 500 height: 500,
,modal: true modal: true,
,closable: true closable: true,
,minimizable: false minimizable: false,
,maximizable: false maximizable: false,
,draggable: true draggable: true,
,resizable: false resizable: false,
,scrollable: 'vertical' scrollable: "vertical",
,bodyStyle: 'margin-right:15px;' bodyStyle: "margin-right:15px;",
,buttons: [ buttons: [
{ {
text: locale['button[1]'] text: locale["button[1]"],
,ui: 'decline' ui: "decline",
,handler: 'cancel' handler: "cancel",
} },
,'->' "->",
,{ {
text: locale['button[4]'] text: locale["button[4]"],
,handler: 'save' handler: "save",
} },
] ],
,initComponent: function() { initComponent: function () {
var config = ipc.sendSync('getConfig'); var config = ipc.sendSync("getConfig");
var defaultServiceOptions = []; var defaultServiceOptions = [];
defaultServiceOptions.push({ value: 'ramboxTab', label: 'Rambox Tab' }); defaultServiceOptions.push({ value: "ramboxTab", label: "Rambox 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) {
defaultServiceOptions.push({ defaultServiceOptions.push({
value: rec.get('id') value: rec.get("id"),
,label: rec.get('name') label: rec.get("name"),
}); });
}); });
this.items = [ this.items = [
{ {
xtype: 'form' xtype: "form",
,bodyPadding: 20 bodyPadding: 20,
,items: [ items: [
{ {
xtype: 'container' xtype: "container",
,layout: 'hbox' layout: "hbox",
,items: [ items: [
{ {
xtype: 'combo' xtype: "combo",
,name: 'locale' name: "locale",
,fieldLabel: 'Language' fieldLabel: "Language",
,labelAlign: 'left' labelAlign: "left",
,flex: 1 flex: 1,
,labelWidth: 80 labelWidth: 80,
,value: config.locale value: config.locale,
,displayField: 'label' displayField: "label",
,valueField: 'value' valueField: "value",
,editable: false editable: false,
,store: Ext.create('Ext.data.Store', { store: Ext.create("Ext.data.Store", {
fields: ['value', 'label'] fields: ["value", "label"],
,data: [ data: [
{ 'value': 'af', 'auth0': 'af', 'label': 'Afrikaans' } { value: "af", auth0: "af", label: "Afrikaans" },
,{ 'value': 'ar', 'auth0': 'en', 'label': 'Arabic' } { value: "ar", auth0: "en", label: "Arabic" },
,{ 'value': 'bs2', 'auth0': 'en', 'label': 'Barndutsch, Switzerland' } {
,{ 'value': 'bn', 'auth0': 'en', 'label': 'Bengali' } value: "bs2",
,{ 'value': 'bg', 'auth0': 'en', 'label': 'Bulgarian' } auth0: "en",
,{ 'value': 'ca', 'auth0': 'ca', 'label': 'Catalan' } label: "Barndutsch, Switzerland",
,{ 'value': 'ceb', 'auth0': 'en', 'label': 'Cebuano' } },
,{ 'value': 'zh-CN', 'auth0': 'zh', 'label': 'Chinese Simplified' } { value: "bn", auth0: "en", label: "Bengali" },
,{ 'value': 'zh-TW', 'auth0': 'zh-tw', 'label': 'Chinese Traditional' } { value: "bg", auth0: "en", label: "Bulgarian" },
,{ 'value': 'hr', 'auth0': 'en', 'label': 'Croatian' } { value: "ca", auth0: "ca", label: "Catalan" },
,{ 'value': 'cs', 'auth0': 'cs', 'label': 'Czech' } { value: "ceb", auth0: "en", label: "Cebuano" },
,{ 'value': 'da', 'auth0': 'da', 'label': 'Danish' } {
,{ 'value': 'nl', 'auth0': 'nl', 'label': 'Dutch' } value: "zh-CN",
,{ 'value': 'en', 'auth0': 'en', 'label': 'English' } auth0: "zh",
,{ 'value': 'fi', 'auth0': 'fi', 'label': 'Finnish' } label: "Chinese Simplified",
,{ 'value': 'fil', 'auth0': 'en', 'label': 'Filipino' } },
,{ 'value': 'fr', 'auth0': 'fr', 'label': 'French' } {
,{ 'value': 'de', 'auth0': 'de', 'label': 'German' } value: "zh-TW",
,{ 'value': 'de-CH', 'auth0': 'de', 'label': 'German, Switzerland' } auth0: "zh-tw",
,{ 'value': 'el', 'auth0': 'el', 'label': 'Greek' } label: "Chinese Traditional",
,{ 'value': 'he', 'auth0': 'en', 'label': 'Hebrew' } },
,{ 'value': 'hi', 'auth0': 'en', 'label': 'Hindi' } { value: "hr", auth0: "en", label: "Croatian" },
,{ 'value': 'hu', 'auth0': 'hu', 'label': 'Hungarian' } { value: "cs", auth0: "cs", label: "Czech" },
,{ 'value': 'id', 'auth0': 'en', 'label': 'Indonesian' } { value: "da", auth0: "da", label: "Danish" },
,{ 'value': 'it', 'auth0': 'it', 'label': 'Italian' } { value: "nl", auth0: "nl", label: "Dutch" },
,{ 'value': 'ja', 'auth0': 'ja', 'label': 'Japanese' } { value: "en", auth0: "en", label: "English" },
,{ 'value': 'ko', 'auth0': 'ko', 'label': 'Korean' } { value: "fi", auth0: "fi", label: "Finnish" },
,{ 'value': 'no', 'auth0': 'no', 'label': 'Norwegian' } { value: "fil", auth0: "en", label: "Filipino" },
,{ 'value': 'fa', 'auth0': 'fa', 'label': 'Persian' } { value: "fr", auth0: "fr", label: "French" },
,{ 'value': 'pl', 'auth0': 'pl', 'label': 'Polish' } { value: "de", auth0: "de", label: "German" },
,{ 'value': 'pt-PT', 'auth0': 'pt-br', 'label': 'Portuguese' } {
,{ 'value': 'pt-BR', 'auth0': 'pt-br', 'label': 'Portuguese (Brazilian)' } value: "de-CH",
,{ 'value': 'ro', 'auth0': 'ro', 'label': 'Romanian' } auth0: "de",
,{ 'value': 'ru', 'auth0': 'ru', 'label': 'Russian' } label: "German, Switzerland",
,{ 'value': 'sr', 'auth0': 'en', 'label': 'Serbian (Cyrillic)' } },
,{ 'value': 'sk', 'auth0': 'sk', 'label': 'Slovak' } { value: "el", auth0: "el", label: "Greek" },
,{ 'value': 'es-ES', 'auth0': 'es', 'label': 'Spanish' } { value: "he", auth0: "en", label: "Hebrew" },
,{ 'value': 'sv-SE', 'auth0': 'sv', 'label': 'Swedish' } { value: "hi", auth0: "en", label: "Hindi" },
,{ 'value': 'tl', 'auth0': 'en', 'label': 'Tagalog' } { value: "hu", auth0: "hu", label: "Hungarian" },
,{ 'value': 'th', 'auth0': 'en', 'label': 'Thai' } { value: "id", auth0: "en", label: "Indonesian" },
,{ 'value': 'tr', 'auth0': 'tr', 'label': 'Turkish' } { value: "it", auth0: "it", label: "Italian" },
,{ 'value': 'uk', 'auth0': 'en', 'label': 'Ukrainian' } { value: "ja", auth0: "ja", label: "Japanese" },
,{ 'value': 'ur-PK', 'auth0': 'en', 'label': 'Urdu (Pakistan)' } { value: "ko", auth0: "ko", label: "Korean" },
,{ 'value': 'vi', 'auth0': 'en', 'label': 'Vietnamese' } { value: "no", auth0: "no", label: "Norwegian" },
] { value: "fa", auth0: "fa", label: "Persian" },
}) { value: "pl", auth0: "pl", label: "Polish" },
} { value: "pt-PT", auth0: "pt-br", label: "Portuguese" },
,{ {
xtype: 'button' value: "pt-BR",
,text: 'Help us Translate' auth0: "pt-br",
,style: 'border-top-left-radius:0;border-bottom-left-radius:0;' label: "Portuguese (Brazilian)",
,href: 'https://crowdin.com/project/rambox/invite' },
} { value: "ro", auth0: "ro", label: "Romanian" },
] { value: "ru", auth0: "ru", label: "Russian" },
} { value: "sr", auth0: "en", label: "Serbian (Cyrillic)" },
,{ { value: "sk", auth0: "sk", label: "Slovak" },
xtype: 'label' { value: "es-ES", auth0: "es", label: "Spanish" },
,text: 'English is the only language that has full translation. We are working with all the others, help us!' { value: "sv-SE", auth0: "sv", label: "Swedish" },
,style: 'display:block;font-size:10px;line-height:15px;' { value: "tl", auth0: "en", label: "Tagalog" },
,margin: '0 0 10 0' { value: "th", auth0: "en", label: "Thai" },
} { value: "tr", auth0: "tr", label: "Turkish" },
,{ { value: "uk", auth0: "en", label: "Ukrainian" },
xtype: 'checkbox' { value: "ur-PK", auth0: "en", label: "Urdu (Pakistan)" },
,name: 'auto_launch' { value: "vi", auth0: "en", label: "Vietnamese" },
,boxLabel: locale['preferences[5]'] ],
,value: config.auto_launch }),
} },
,{ {
xtype: 'checkbox' xtype: "button",
,name: 'start_minimized' text: "Help us Translate",
,boxLabel: locale['preferences[4]'] style: "border-top-left-radius:0;border-bottom-left-radius:0;",
,value: config.start_minimized href: "https://crowdin.com/project/rambox/invite",
} },
,{ ],
xtype: 'checkbox' },
,name: 'darkreader' {
,boxLabel: locale['preferences[29]'] xtype: "label",
,value: config.darkreader text:
} "English is the only language that has full translation. We are working with all the others, help us!",
,{ style: "display:block;font-size:10px;line-height:15px;",
xtype: 'checkbox' margin: "0 0 10 0",
,name: 'hide_menu_bar' },
,boxLabel: locale['preferences[1]']+' (<code>Alt</code> key to display)' {
,value: config.hide_menu_bar xtype: "checkbox",
,hidden: process.platform === 'darwin' name: "auto_launch",
} boxLabel: locale["preferences[5]"],
,{ value: config.auto_launch,
xtype: 'combo' },
,name: 'tabbar_location' {
,fieldLabel: locale['preferences[11]'] xtype: "checkbox",
,labelAlign: 'left' name: "start_minimized",
,width: 380 boxLabel: locale["preferences[4]"],
,labelWidth: 180 value: config.start_minimized,
,value: config.tabbar_location },
,displayField: 'label' {
,valueField: 'value' xtype: "checkbox",
,editable: false name: "darkreader",
,store: Ext.create('Ext.data.Store', { boxLabel: locale["preferences[29]"],
fields: ['value', 'label'] value: config.darkreader,
,data: [ },
{ 'value': 'top', 'label': 'Top' } {
,{ 'value': 'left', 'label': 'Left' } xtype: "checkbox",
,{ 'value': 'bottom', 'label': 'Bottom' } name: "hide_menu_bar",
,{ 'value': 'right', 'label': 'Right' } boxLabel:
] locale["preferences[1]"] + " (<code>Alt</code> key to display)",
}) value: config.hide_menu_bar,
} hidden: process.platform === "darwin",
,{ },
xtype: 'checkbox' {
,name: 'hide_tabbar_labels' xtype: "combo",
,boxLabel: locale['preferences[28]'] name: "tabbar_location",
,value: config.hide_tabbar_labels fieldLabel: locale["preferences[11]"],
} labelAlign: "left",
,{ width: 380,
xtype: 'combo' labelWidth: 180,
,name: 'default_service' value: config.tabbar_location,
,fieldLabel: locale['preferences[12]'] displayField: "label",
,labelAlign: 'top' valueField: "value",
editable: false,
store: Ext.create("Ext.data.Store", {
fields: ["value", "label"],
data: [
{ value: "top", label: "Top" },
{ value: "left", label: "Left" },
{ value: "bottom", label: "Bottom" },
{ value: "right", label: "Right" },
],
}),
},
{
xtype: "checkbox",
name: "hide_tabbar_labels",
boxLabel: locale["preferences[28]"],
value: config.hide_tabbar_labels,
},
{
xtype: "combo",
name: "default_service",
fieldLabel: locale["preferences[12]"],
labelAlign: "top",
//,width: 380 //,width: 380
//,labelWidth: 105 //,labelWidth: 105
,value: config.default_service value: config.default_service,
,displayField: 'label' displayField: "label",
,valueField: 'value' valueField: "value",
,editable: false editable: false,
,store: Ext.create('Ext.data.Store', { store: Ext.create("Ext.data.Store", {
fields: ['value', 'label'] fields: ["value", "label"],
,data: defaultServiceOptions data: defaultServiceOptions,
}) }),
} },
,{ {
xtype: 'combo' xtype: "combo",
,name: 'window_display_behavior' name: "window_display_behavior",
,fieldLabel: locale['preferences[13]'] fieldLabel: locale["preferences[13]"],
,labelAlign: 'left' labelAlign: "left",
,width: 380 width: 380,
,labelWidth: 105 labelWidth: 105,
,value: config.window_display_behavior value: config.window_display_behavior,
,displayField: 'label' displayField: "label",
,valueField: 'value' valueField: "value",
,editable: false editable: false,
,store: Ext.create('Ext.data.Store', { store: Ext.create("Ext.data.Store", {
fields: ['value', 'label'] fields: ["value", "label"],
,data: [ data: [
{ 'value': 'show_taskbar', 'label': locale['preferences[14]'] } { value: "show_taskbar", label: locale["preferences[14]"] },
,{ 'value': 'show_trayIcon', 'label': locale['preferences[15]'] } { value: "show_trayIcon", label: locale["preferences[15]"] },
,{ 'value': 'taskbar_tray', 'label': locale['preferences[16]'] } { value: "taskbar_tray", label: locale["preferences[16]"] },
] ],
}) }),
,hidden: process.platform === 'darwin' hidden: process.platform === "darwin",
} },
,{ {
xtype: 'combo' xtype: "combo",
,name: 'window_close_behavior' name: "window_close_behavior",
,fieldLabel: locale['preferences[17]'] fieldLabel: locale["preferences[17]"],
,labelAlign: 'left' labelAlign: "left",
,width: 380 width: 380,
,labelWidth: 180 labelWidth: 180,
,value: config.window_close_behavior value: config.window_close_behavior,
,displayField: 'label' displayField: "label",
,valueField: 'value' valueField: "value",
,editable: false editable: false,
,store: Ext.create('Ext.data.Store', { store: Ext.create("Ext.data.Store", {
fields: ['value', 'label'] fields: ["value", "label"],
,data: [ data: [
{ 'value': 'keep_in_tray', 'label': locale['preferences[18]'] } { value: "keep_in_tray", label: locale["preferences[18]"] },
,{ 'value': 'keep_in_tray_and_taskbar', 'label': locale['preferences[19]'] } {
,{ 'value': 'quit', 'label': locale['preferences[20]'] } value: "keep_in_tray_and_taskbar",
] label: locale["preferences[19]"],
}) },
,hidden: process.platform === 'darwin' { value: "quit", label: locale["preferences[20]"] },
} ],
,{ }),
xtype: 'checkbox' hidden: process.platform === "darwin",
,name: 'always_on_top' },
,boxLabel: locale['preferences[21]'] {
,value: config.always_on_top xtype: "checkbox",
} name: "always_on_top",
,{ boxLabel: locale["preferences[21]"],
xtype: 'checkbox' value: config.always_on_top,
,name: 'systemtray_indicator' },
,boxLabel: locale['preferences[22]'] {
,value: config.systemtray_indicator xtype: "checkbox",
,hidden: process.platform === 'darwin' name: "systemtray_indicator",
} boxLabel: locale["preferences[22]"],
,{ value: config.systemtray_indicator,
xtype: 'checkbox' hidden: process.platform === "darwin",
,name: 'flash_frame' },
,boxLabel: process.platform === 'darwin' ? locale['preferences[10]'] : locale['preferences[9]'] {
,value: config.flash_frame xtype: "checkbox",
} name: "flash_frame",
,{ boxLabel:
xtype: 'checkbox' process.platform === "darwin"
,name: 'disable_gpu' ? locale["preferences[10]"]
,boxLabel: locale['preferences[23]'] : locale["preferences[9]"],
,value: config.disable_gpu value: config.flash_frame,
} },
,{ {
xtype: 'checkbox' xtype: "checkbox",
,name: 'enable_hidpi_support' name: "disable_gpu",
,boxLabel: locale['preferences[8]'] boxLabel: locale["preferences[23]"],
,value: config.enable_hidpi_support value: config.disable_gpu,
,hidden: process.platform !== 'win32' },
}, {
{ xtype: "checkbox",
xtype: 'textfield' name: "enable_hidpi_support",
,fieldLabel: 'Override User-Agent for all services (needs to relaunch)' boxLabel: locale["preferences[8]"],
,labelAlign: 'top' value: config.enable_hidpi_support,
,name: 'user_agent' hidden: process.platform !== "win32",
,value: config.user_agent },
,width: 360 {
,emptyText: 'Leave blank for default user agent' xtype: "textfield",
} fieldLabel:
,{ "Override User-Agent for all services (needs to relaunch)",
xtype: 'fieldset' labelAlign: "top",
,title: locale['preferences[24]'] name: "user_agent",
,collapsed: !config.master_password value: config.user_agent,
,checkboxToggle: true width: 360,
,checkboxName: 'master_password' emptyText: "Leave blank for default user agent",
,margin: '10 0 0 0' },
,padding: 10 {
,layout: 'hbox' xtype: "fieldset",
,defaults: { labelAlign: 'top' } title: locale["preferences[24]"],
,items: [ collapsed: !config.master_password,
{ checkboxToggle: true,
xtype: 'textfield' checkboxName: "master_password",
,inputType: 'password' margin: "10 0 0 0",
,fieldLabel: locale['preferences[25]'] padding: 10,
,name: 'master_password1' layout: "hbox",
,itemId: 'pass' defaults: { labelAlign: "top" },
,flex: 1 items: [
,listeners: { {
validitychange: function(field) { xtype: "textfield",
inputType: "password",
fieldLabel: locale["preferences[25]"],
name: "master_password1",
itemId: "pass",
flex: 1,
listeners: {
validitychange: function (field) {
field.next().validate(); field.next().validate();
}, },
blur: function(field) { blur: function (field) {
field.next().validate(); field.next().validate();
} },
} },
} },
,{ {
xtype: 'textfield' xtype: "textfield",
,inputType: 'password' inputType: "password",
,fieldLabel: locale['preferences[26]'] fieldLabel: locale["preferences[26]"],
,name: 'master_password2' name: "master_password2",
,margin: '0 0 0 10' margin: "0 0 0 10",
,vtype: 'password' vtype: "password",
,initialPassField: 'pass' initialPassField: "pass",
,flex: 1 flex: 1,
} },
] ],
} },
,{ {
xtype: 'fieldset' xtype: "fieldset",
,title: 'Proxy (needs to relaunch) - <a href="https://github.com/saenzramiro/rambox/wiki/FREE-PROXY-SERVERS" target="_blank">Free Proxy Servers</a>' title:
,collapsed: !config.proxy 'Proxy (needs to relaunch) - <a href="https://github.com/saenzramiro/rambox/wiki/FREE-PROXY-SERVERS" target="_blank">Free Proxy Servers</a>',
,checkboxToggle: true collapsed: !config.proxy,
,checkboxName: 'proxy' checkboxToggle: true,
,margin: '10 0 0 0' checkboxName: "proxy",
,padding: 10 margin: "10 0 0 0",
,layout: 'vbox' padding: 10,
,defaults: { labelAlign: 'left' } layout: "vbox",
,items: [ defaults: { labelAlign: "left" },
{ items: [
xtype: 'textfield' {
,vtype: 'url' xtype: "textfield",
,fieldLabel: 'Host' vtype: "url",
,name: 'proxyHost' fieldLabel: "Host",
,value: config.proxyHost name: "proxyHost",
value: config.proxyHost,
//,flex: 1 //,flex: 1
} },
,{ {
xtype: 'numberfield' xtype: "numberfield",
,fieldLabel: 'Port' fieldLabel: "Port",
,name: 'proxyPort' name: "proxyPort",
,value: config.proxyPort value: config.proxyPort,
} },
,{ {
xtype: 'textfield' xtype: "textfield",
,fieldLabel: 'Login' fieldLabel: "Login",
,name: 'proxyLogin' name: "proxyLogin",
,value: config.proxyLogin value: config.proxyLogin,
,emptyText: 'Optional' emptyText: "Optional",
} },
,{ {
xtype: 'textfield' xtype: "textfield",
,fieldLabel: 'Password' fieldLabel: "Password",
,name: 'proxyPassword' name: "proxyPassword",
,value: config.proxyPassword value: config.proxyPassword,
,emptyText: 'Optional' emptyText: "Optional",
,inputType: 'password' inputType: "password",
} },
] ],
} },
,{ {
xtype: 'checkbox' xtype: "checkbox",
,name: 'sendStatistics' name: "sendStatistics",
,boxLabel: locale['preferences[27]'] boxLabel: locale["preferences[27]"],
,value: config.sendStatistics value: config.sendStatistics,
} },
] ],
} },
]; ];
this.callParent(); this.callParent();
} },
}); });

62
electron/main.js

@ -34,37 +34,37 @@ if (isDev)
// Initial Config // Initial Config
const config = new Config({ const config = new Config({
defaults: { defaults: {
always_on_top: false always_on_top: false,
,hide_menu_bar: false hide_menu_bar: false,
,tabbar_location: 'top' tabbar_location: "top",
,hide_tabbar_labels: false hide_tabbar_labels: false,
,window_display_behavior: 'taskbar_tray' window_display_behavior: "taskbar_tray",
,auto_launch: !isDev auto_launch: !isDev,
,flash_frame: true flash_frame: true,
,window_close_behavior: 'keep_in_tray' window_close_behavior: "keep_in_tray",
,start_minimized: false start_minimized: false,
,darkreader: true darkreader: true,
,systemtray_indicator: true systemtray_indicator: true,
,master_password: false master_password: false,
,dont_disturb: false dont_disturb: false,
,disable_gpu: process.platform === 'linux' disable_gpu: process.platform === "linux",
,proxy: false proxy: false,
,proxyHost: '' proxyHost: "",
,proxyPort: '' proxyPort: "",
,proxyLogin: '' proxyLogin: "",
,proxyPassword: '' proxyPassword: "",
,locale: 'en' locale: "en",
,enable_hidpi_support: false enable_hidpi_support: false,
,user_agent: '' user_agent: "",
,default_service: 'ramboxTab' default_service: "ramboxTab",
,sendStatistics: false sendStatistics: false,
,x: undefined x: undefined,
,y: undefined y: undefined,
,width: 1000 width: 1000,
,height: 800 height: 800,
,maximized: false maximized: false,
} },
}); });
// Fix issues with HiDPI scaling on Windows platform // Fix issues with HiDPI scaling on Windows platform

16
resources/js/darkreader.js

@ -1,14 +1,14 @@
const { ipcRenderer } = require('electron'); const { ipcRenderer } = require("electron");
const darkreader = require('darkreader'); const darkreader = require("darkreader");
darkreader.setFetchMethod(window.fetch); darkreader.setFetchMethod(window.fetch);
const getIsEnabled = () => ipcRenderer.sendSync("getConfig").darkreader;
const canEnable = () =>
document.readyState === "complete" || document.readyState === "interactive";
const getIsEnabled = () => ipcRenderer.sendSync('getConfig').darkreader; document.addEventListener("readystatechange", () => {
const canEnable = () => document.readyState === 'complete' || document.readyState === 'interactive'; console.log(document.readyState);
document.addEventListener('readystatechange', () => {
console.log(document.readyState)
if (canEnable()) { if (canEnable()) {
getIsEnabled()? darkreader.enable(): darkreader.disable(); getIsEnabled() ? darkreader.enable() : darkreader.disable();
} }
}); });

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

@ -3,9 +3,12 @@
*/ */
const { desktopCapturer, ipcRenderer } = require("electron"); const { desktopCapturer, ipcRenderer } = require("electron");
require("./darkreader.js") require("./darkreader.js");
const { ipcRenderer } = require('electron'); const { ipcRenderer } = require("electron");
const { ContextMenuBuilder, ContextMenuListener } = require('electron-contextmenu-wrapper'); const {
ContextMenuBuilder,
ContextMenuListener,
} = require("electron-contextmenu-wrapper");
/** /**
* Make the Rambox API available via a global "rambox" variable. * Make the Rambox API available via a global "rambox" variable.

253
resources/languages/en.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save