11 changed files with 3388 additions and 2647 deletions
@ -1,334 +1,444 @@
|
||||
Ext.define('Rambox.Application', { |
||||
extend: 'Ext.app.Application' |
||||
Ext.define("Rambox.Application", { |
||||
extend: "Ext.app.Application", |
||||
|
||||
,name: 'Rambox' |
||||
name: "Rambox", |
||||
|
||||
,requires: [ |
||||
'Rambox.ux.Auth0' |
||||
,'Rambox.util.MD5' |
||||
,'Ext.window.Toast' |
||||
,'Ext.util.Cookies' |
||||
] |
||||
|
||||
,stores: [ |
||||
'ServicesList' |
||||
,'Services' |
||||
] |
||||
requires: [ |
||||
"Rambox.ux.Auth0", |
||||
"Rambox.util.MD5", |
||||
"Ext.window.Toast", |
||||
"Ext.util.Cookies", |
||||
], |
||||
|
||||
,profiles: [ |
||||
'Offline' |
||||
,'Online' |
||||
] |
||||
stores: ["ServicesList", "Services"], |
||||
|
||||
,config: { |
||||
totalServicesLoaded: 0 |
||||
,totalNotifications: 0 |
||||
,googleURLs: [] |
||||
} |
||||
profiles: ["Offline", "Online"], |
||||
|
||||
,launch: function () { |
||||
config: { |
||||
totalServicesLoaded: 0, |
||||
totalNotifications: 0, |
||||
googleURLs: [], |
||||
}, |
||||
|
||||
const isOnline = require('is-online'); |
||||
const Mousetrap = require('mousetrap'); |
||||
launch: function () { |
||||
const isOnline = require("is-online"); |
||||
const Mousetrap = require("mousetrap"); |
||||
(async () => { |
||||
await isOnline().then(res => { |
||||
var hideNoConnection = ipc.sendSync('getConfig').hideNoConnectionDialog |
||||
if ( !res && !hideNoConnection ) { |
||||
Ext.get('spinner') ? Ext.get('spinner').destroy() : null; |
||||
Ext.get('background') ? Ext.get('background').destroy() : null; |
||||
await isOnline().then((res) => { |
||||
var hideNoConnection = ipc.sendSync("getConfig").hideNoConnectionDialog; |
||||
if (!res && !hideNoConnection) { |
||||
Ext.get("spinner") ? Ext.get("spinner").destroy() : null; |
||||
Ext.get("background") ? Ext.get("background").destroy() : null; |
||||
Ext.Msg.show({ |
||||
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' |
||||
,width: 300 |
||||
,closable: false |
||||
,buttons: Ext.Msg.YESNO |
||||
,buttonText: { |
||||
yes: 'Ok' |
||||
,no: 'Never show this again' |
||||
} |
||||
,multiline: false |
||||
,fn: function(buttonValue, inputText, showConfig) { |
||||
if ( buttonValue === 'no' ) { |
||||
ipc.send('sConfig', { hideNoConnectionDialog: true }); |
||||
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", |
||||
width: 300, |
||||
closable: false, |
||||
buttons: Ext.Msg.YESNO, |
||||
buttonText: { |
||||
yes: "Ok", |
||||
no: "Never show this again", |
||||
}, |
||||
multiline: false, |
||||
fn: function (buttonValue, inputText, showConfig) { |
||||
if (buttonValue === "no") { |
||||
ipc.send("sConfig", { hideNoConnectionDialog: true }); |
||||
hideNoConnection = true; |
||||
} |
||||
} |
||||
,icon: Ext.Msg.QUESTION |
||||
}, |
||||
icon: Ext.Msg.QUESTION, |
||||
}); |
||||
setTimeout(function() { |
||||
if ( !hideNoConnection ) ipc.send('reloadApp') |
||||
}, 10000) |
||||
setTimeout(function () { |
||||
if (!hideNoConnection) ipc.send("reloadApp"); |
||||
}, 10000); |
||||
} |
||||
}) |
||||
}); |
||||
})(); |
||||
|
||||
if ( !localStorage.getItem('hideMacPermissions') && process.platform === 'darwin' && (require('electron').remote.systemPreferences.getMediaAccessStatus('microphone') !== 'granted' || require('electron').remote.systemPreferences.getMediaAccessStatus('camera') !== 'granted') ) { |
||||
console.info('Checking mac permissions...'); |
||||
Ext.cq1('app-main').addDocked({ |
||||
xtype: 'toolbar' |
||||
,dock: 'top' |
||||
,style: {background: '#30BBF3'} |
||||
,items: [ |
||||
'->' |
||||
,{ |
||||
xtype: 'label' |
||||
,html: '<b>Rambox CE needs permissions to use Microphone and Camera for the apps.</b>' |
||||
} |
||||
,{ |
||||
xtype: 'button' |
||||
,text: 'Grant permissions' |
||||
,ui: 'decline' |
||||
,handler: async function(btn) { |
||||
await require('electron').remote.systemPreferences.askForMediaAccess('microphone'); |
||||
await require('electron').remote.systemPreferences.askForMediaAccess('camera'); |
||||
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); } |
||||
} |
||||
] |
||||
if ( |
||||
!localStorage.getItem("hideMacPermissions") && |
||||
process.platform === "darwin" && |
||||
(require("electron").remote.systemPreferences.getMediaAccessStatus( |
||||
"microphone" |
||||
) !== "granted" || |
||||
require("electron").remote.systemPreferences.getMediaAccessStatus( |
||||
"camera" |
||||
) !== "granted") |
||||
) { |
||||
console.info("Checking mac permissions..."); |
||||
Ext.cq1("app-main").addDocked({ |
||||
xtype: "toolbar", |
||||
dock: "top", |
||||
style: { background: "#30BBF3" }, |
||||
items: [ |
||||
"->", |
||||
{ |
||||
xtype: "label", |
||||
html: |
||||
"<b>Rambox CE needs permissions to use Microphone and Camera for the apps.</b>", |
||||
}, |
||||
{ |
||||
xtype: "button", |
||||
text: "Grant permissions", |
||||
ui: "decline", |
||||
handler: async function (btn) { |
||||
await require("electron").remote.systemPreferences.askForMediaAccess( |
||||
"microphone" |
||||
); |
||||
await require("electron").remote.systemPreferences.askForMediaAccess( |
||||
"camera" |
||||
); |
||||
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) { |
||||
Ext.cq1('app-main').addDocked({ |
||||
xtype: 'toolbar' |
||||
,dock: 'top' |
||||
,ui: 'servicesnotloaded' |
||||
,style: { background: '#efef6d' } |
||||
,items: [ |
||||
'->' |
||||
,{ |
||||
xtype: 'label' |
||||
,html: '<b>Services couldn\'t be loaded, some Rambox features will not be available.</b>' |
||||
} |
||||
,{ |
||||
xtype: 'button' |
||||
,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); } |
||||
} |
||||
] |
||||
Ext.cq1("app-main").addDocked({ |
||||
xtype: "toolbar", |
||||
dock: "top", |
||||
ui: "servicesnotloaded", |
||||
style: { background: "#efef6d" }, |
||||
items: [ |
||||
"->", |
||||
{ |
||||
xtype: "label", |
||||
html: |
||||
"<b>Services couldn't be loaded, some Rambox features will not be available.</b>", |
||||
}, |
||||
{ |
||||
xtype: "button", |
||||
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); |
||||
}, |
||||
}, |
||||
], |
||||
}); |
||||
} |
||||
// Prevent track if the user have disabled this option (default: false)
|
||||
if ( !ipc.sendSync('sendStatistics') ) { |
||||
if (!ipc.sendSync("sendStatistics")) { |
||||
ga_storage = { |
||||
_enableSSL: Ext.emptyFn |
||||
,_disableSSL: Ext.emptyFn |
||||
,_setAccount: Ext.emptyFn |
||||
,_setDomain: Ext.emptyFn |
||||
,_setLocale: Ext.emptyFn |
||||
,_setCustomVar: Ext.emptyFn |
||||
,_deleteCustomVar: Ext.emptyFn |
||||
,_trackPageview: Ext.emptyFn |
||||
,_trackEvent: Ext.emptyFn |
||||
} |
||||
_enableSSL: Ext.emptyFn, |
||||
_disableSSL: Ext.emptyFn, |
||||
_setAccount: Ext.emptyFn, |
||||
_setDomain: Ext.emptyFn, |
||||
_setLocale: Ext.emptyFn, |
||||
_setCustomVar: Ext.emptyFn, |
||||
_deleteCustomVar: Ext.emptyFn, |
||||
_trackPageview: Ext.emptyFn, |
||||
_trackEvent: Ext.emptyFn, |
||||
}; |
||||
} |
||||
|
||||
// Set Google Analytics events
|
||||
ga_storage._setAccount('UA-80680424-1'); |
||||
ga_storage._trackPageview('/index.html', 'main'); |
||||
ga_storage._trackEvent('Versions', require('electron').remote.app.getVersion()); |
||||
ga_storage._setAccount("UA-80680424-1"); |
||||
ga_storage._trackPageview("/index.html", "main"); |
||||
ga_storage._trackEvent( |
||||
"Versions", |
||||
require("electron").remote.app.getVersion() |
||||
); |
||||
|
||||
// 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
|
||||
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
|
||||
Ext.util.Cookies.set('version', require('electron').remote.app.getVersion()); |
||||
if ( Ext.util.Cookies.get('auth0') === null ) Ext.util.Cookies.set('auth0', false); |
||||
Ext.util.Cookies.set( |
||||
"version", |
||||
require("electron").remote.app.getVersion() |
||||
); |
||||
if (Ext.util.Cookies.get("auth0") === null) |
||||
Ext.util.Cookies.set("auth0", false); |
||||
|
||||
// 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
|
||||
Ext.Ajax.request({ |
||||
url: 'https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/google.json' |
||||
,method: 'GET' |
||||
,success: function(response) { |
||||
url: |
||||
"https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/google.json", |
||||
method: "GET", |
||||
success: function (response) { |
||||
Rambox.app.config.googleURLs = Ext.decode(response.responseText); |
||||
} |
||||
}, |
||||
}); |
||||
|
||||
// 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
|
||||
Mousetrap.prototype.stopCallback = function(e, element, combo) { |
||||
Mousetrap.prototype.stopCallback = function (e, element, combo) { |
||||
return false; |
||||
}; |
||||
// 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
|
||||
var tabPanel = Ext.cq1('app-main'); |
||||
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
|
||||
var tabPanel = Ext.cq1("app-main"); |
||||
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); |
||||
}); |
||||
} |
||||
); |
||||
// Add shortcut to main tab (ctrl+,)
|
||||
Mousetrap.bind(platform === 'darwin' ? 'command+,' : 'ctrl+,', (e, combo) => { |
||||
Ext.cq1('app-main').setActiveTab(0); |
||||
}); |
||||
Mousetrap.bind( |
||||
platform === "darwin" ? "command+," : "ctrl+,", |
||||
(e, combo) => { |
||||
Ext.cq1("app-main").setActiveTab(0); |
||||
} |
||||
); |
||||
// Add shortcuts to navigate through services
|
||||
Mousetrap.bind(['ctrl+tab', 'ctrl+pagedown'], (e, combo) => { |
||||
var tabPanel = Ext.cq1('app-main'); |
||||
Mousetrap.bind(["ctrl+tab", "ctrl+pagedown"], (e, combo) => { |
||||
var tabPanel = Ext.cq1("app-main"); |
||||
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); |
||||
var i = activeIndex + 1; |
||||
// "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
|
||||
while (tabPanel.items.items[i].id === 'tbfill') i++; |
||||
while (tabPanel.items.items[i].id === "tbfill") i++; |
||||
tabPanel.setActiveTab(i); |
||||
}); |
||||
Mousetrap.bind(['ctrl+shift+tab', 'ctrl+pageup'], (e, combo) => { |
||||
var tabPanel = Ext.cq1('app-main'); |
||||
Mousetrap.bind(["ctrl+shift+tab", "ctrl+pageup"], (e, combo) => { |
||||
var tabPanel = Ext.cq1("app-main"); |
||||
var activeIndex = tabPanel.items.indexOf(tabPanel.getActiveTab()); |
||||
var i = activeIndex - 1; |
||||
if ( i < 0 ) i = tabPanel.items.items.length - 1; |
||||
while ( tabPanel.items.items[i].id === 'tbfill' || i < 0 ) i--; |
||||
if (i < 0) i = tabPanel.items.items.length - 1; |
||||
while (tabPanel.items.items[i].id === "tbfill" || i < 0) i--; |
||||
tabPanel.setActiveTab(i); |
||||
}); |
||||
// Add shortcut to search inside a service
|
||||
Mousetrap.bind(process.platform === 'darwin' ? ['command+alt+f'] : ['shift+alt+f'], (e, combo) => { |
||||
var currentTab = Ext.cq1('app-main').getActiveTab(); |
||||
if ( currentTab.getWebView ) currentTab.showSearchBox(true); |
||||
}); |
||||
Mousetrap.bind( |
||||
process.platform === "darwin" ? ["command+alt+f"] : ["shift+alt+f"], |
||||
(e, combo) => { |
||||
var currentTab = Ext.cq1("app-main").getActiveTab(); |
||||
if (currentTab.getWebView) currentTab.showSearchBox(true); |
||||
} |
||||
); |
||||
// Add shortcut to Do Not Disturb
|
||||
Mousetrap.bind(platform === 'darwin' ? ["command+alt+d"] : ["shift+alt+d"], function(e, combo) { |
||||
var btn = Ext.getCmp('disturbBtn'); |
||||
Mousetrap.bind( |
||||
platform === "darwin" ? ["command+alt+d"] : ["shift+alt+d"], |
||||
function (e, combo) { |
||||
var btn = Ext.getCmp("disturbBtn"); |
||||
btn.toggle(); |
||||
Ext.cq1('app-main').getController().dontDisturb(btn, true); |
||||
}); |
||||
Ext.cq1("app-main").getController().dontDisturb(btn, true); |
||||
} |
||||
); |
||||
// Add shortcut to Lock Rambox
|
||||
Mousetrap.bind(platform === 'darwin' ? ['command+alt+l'] : ['shift+alt+l'], (e, combo) => { |
||||
var btn = Ext.getCmp('lockRamboxBtn'); |
||||
Ext.cq1('app-main').getController().lockRambox(btn); |
||||
}); |
||||
Mousetrap.bind( |
||||
platform === "darwin" ? ["command+alt+l"] : ["shift+alt+l"], |
||||
(e, combo) => { |
||||
var btn = Ext.getCmp("lockRamboxBtn"); |
||||
Ext.cq1("app-main").getController().lockRambox(btn); |
||||
} |
||||
); |
||||
|
||||
// Mouse Wheel zooming
|
||||
document.addEventListener('mousewheel', function(e) { |
||||
if( e.ctrlKey ) { |
||||
var delta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); |
||||
document.addEventListener("mousewheel", function (e) { |
||||
if (e.ctrlKey) { |
||||
var delta = Math.max(-1, Math.min(1, e.wheelDelta || -e.detail)); |
||||
|
||||
var tabPanel = Ext.cq1('app-main'); |
||||
if ( tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0 ) return false; |
||||
var tabPanel = Ext.cq1("app-main"); |
||||
if (tabPanel.items.indexOf(tabPanel.getActiveTab()) === 0) |
||||
return false; |
||||
|
||||
if ( delta === 1 ) { // Zoom In
|
||||
if (delta === 1) { |
||||
// Zoom In
|
||||
tabPanel.getActiveTab().zoomIn(); |
||||
} else { // Zoom Out
|
||||
} else { |
||||
// Zoom Out
|
||||
tabPanel.getActiveTab().zoomOut(); |
||||
} |
||||
} |
||||
}); |
||||
|
||||
// Define default value
|
||||
if ( localStorage.getItem('dontDisturb') === null ) localStorage.setItem('dontDisturb', false); |
||||
ipc.send('setDontDisturb', localStorage.getItem('dontDisturb')); // We store it in config
|
||||
if (localStorage.getItem("dontDisturb") === null) |
||||
localStorage.setItem("dontDisturb", false); |
||||
ipc.send("setDontDisturb", localStorage.getItem("dontDisturb")); // We store it in config
|
||||
|
||||
if ( localStorage.getItem('locked') ) { |
||||
console.info('Lock Rambox:', 'Enabled'); |
||||
Ext.cq1('app-main').getController().showLockWindow(); |
||||
if (localStorage.getItem("locked")) { |
||||
console.info("Lock Rambox:", "Enabled"); |
||||
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); |
||||
if ( newValue > 0 ) { |
||||
if ( Ext.cq1('app-main').getActiveTab().record ) { |
||||
document.title = 'Rambox (' + Rambox.util.Format.formatNumber(newValue) + ') - '+Ext.cq1('app-main').getActiveTab().record.get('name'); |
||||
if (newValue > 0) { |
||||
if (Ext.cq1("app-main").getActiveTab().record) { |
||||
document.title = |
||||
"Rambox (" + |
||||
Rambox.util.Format.formatNumber(newValue) + |
||||
") - " + |
||||
Ext.cq1("app-main").getActiveTab().record.get("name"); |
||||
} else { |
||||
document.title = 'Rambox (' + Rambox.util.Format.formatNumber(newValue) + ')'; |
||||
document.title = |
||||
"Rambox (" + Rambox.util.Format.formatNumber(newValue) + ")"; |
||||
} |
||||
} else { |
||||
if ( Ext.cq1('app-main') && Ext.cq1('app-main').getActiveTab().record ) { |
||||
document.title = 'Rambox - '+Ext.cq1('app-main').getActiveTab().record.get('name'); |
||||
if (Ext.cq1("app-main") && Ext.cq1("app-main").getActiveTab().record) { |
||||
document.title = |
||||
"Rambox - " + Ext.cq1("app-main").getActiveTab().record.get("name"); |
||||
} else { |
||||
document.title = 'Rambox'; |
||||
} |
||||
document.title = "Rambox"; |
||||
} |
||||
} |
||||
}, |
||||
|
||||
,checkUpdate: function(silence) { |
||||
console.info('Checking for updates...'); |
||||
checkUpdate: function (silence) { |
||||
console.info("Checking for updates..."); |
||||
Ext.Ajax.request({ |
||||
url: 'https://api.github.com/repos/ramboxapp/community-edition/releases/latest' |
||||
,method: 'GET' |
||||
,success: function(response) { |
||||
url: |
||||
"https://api.github.com/repos/ramboxapp/community-edition/releases/latest", |
||||
method: "GET", |
||||
success: function (response) { |
||||
var json = Ext.decode(response.responseText); |
||||
var appVersion = new Ext.Version(require('electron').remote.app.getVersion()); |
||||
if ( appVersion.isLessThan(json.name) && !json.draft && !json.prerelease ) { |
||||
console.info('New version is available', json.version); |
||||
Ext.cq1('app-main').addDocked({ |
||||
xtype: 'toolbar' |
||||
,dock: 'top' |
||||
,ui: 'newversion' |
||||
,items: [ |
||||
'->' |
||||
,{ |
||||
xtype: 'label' |
||||
,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.' : '' ) |
||||
} |
||||
,{ |
||||
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' |
||||
,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); } |
||||
} |
||||
] |
||||
var appVersion = new Ext.Version( |
||||
require("electron").remote.app.getVersion() |
||||
); |
||||
if ( |
||||
appVersion.isLessThan(json.name) && |
||||
!json.draft && |
||||
!json.prerelease |
||||
) { |
||||
console.info("New version is available", json.version); |
||||
Ext.cq1("app-main").addDocked({ |
||||
xtype: "toolbar", |
||||
dock: "top", |
||||
ui: "newversion", |
||||
items: [ |
||||
"->", |
||||
{ |
||||
xtype: "label", |
||||
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." |
||||
: ""), |
||||
}, |
||||
{ |
||||
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", |
||||
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; |
||||
} else if ( !silence ) { |
||||
} else if (!silence) { |
||||
Ext.Msg.show({ |
||||
title: locale['app.update[3]'] |
||||
,message: locale['app.update[4]'] |
||||
,icon: Ext.Msg.INFO |
||||
,buttons: Ext.Msg.OK |
||||
title: locale["app.update[3]"], |
||||
message: locale["app.update[4]"], |
||||
icon: Ext.Msg.INFO, |
||||
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."); |
||||
}, |
||||
}); |
||||
} |
||||
}, |
||||
}); |
||||
|
@ -1,42 +1,43 @@
|
||||
Ext.define('Rambox.store.ServicesList', { |
||||
extend: 'Ext.data.Store' |
||||
,alias: 'store.serviceslist' |
||||
Ext.define("Rambox.store.ServicesList", { |
||||
extend: "Ext.data.Store", |
||||
alias: "store.serviceslist", |
||||
|
||||
,requires: [ |
||||
'Ext.data.proxy.LocalStorage' |
||||
] |
||||
requires: ["Ext.data.proxy.LocalStorage"], |
||||
|
||||
,model: 'Rambox.model.ServiceList' |
||||
model: "Rambox.model.ServiceList", |
||||
|
||||
,proxy: { |
||||
type: 'ajax', |
||||
url: 'https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/services.json', |
||||
proxy: { |
||||
type: "ajax", |
||||
url: |
||||
"https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/services.json", |
||||
reader: { |
||||
type: 'json', |
||||
rootProperty: 'responseText' |
||||
} |
||||
} |
||||
,listeners: { |
||||
type: "json", |
||||
rootProperty: "responseText", |
||||
}, |
||||
}, |
||||
listeners: { |
||||
load: function () { |
||||
Ext.get('spinner') ? Ext.get('spinner').destroy() : null; |
||||
Ext.get('background') ? Ext.get('background').destroy() : null; |
||||
Ext.get("spinner") ? Ext.get("spinner").destroy() : null; |
||||
Ext.get("background") ? Ext.get("background").destroy() : null; |
||||
this.add({ |
||||
id: 'custom' |
||||
,logo: 'custom.png' |
||||
,name: '_Custom Service' |
||||
,description: locale['services[38]'] |
||||
,url: '___' |
||||
,type: 'custom' |
||||
,allow_popups: true |
||||
}) |
||||
} |
||||
} |
||||
,sorters: [{ |
||||
property: 'name' |
||||
,direction: 'ASC' |
||||
}] |
||||
id: "custom", |
||||
logo: "custom.png", |
||||
name: "_Custom Service", |
||||
description: locale["services[38]"], |
||||
url: "___", |
||||
type: "custom", |
||||
allow_popups: true, |
||||
}); |
||||
}, |
||||
}, |
||||
sorters: [ |
||||
{ |
||||
property: "name", |
||||
direction: "ASC", |
||||
}, |
||||
], |
||||
|
||||
,autoLoad: true |
||||
,autoSync: true |
||||
,pageSize: 100000 |
||||
autoLoad: true, |
||||
autoSync: true, |
||||
pageSize: 100000, |
||||
}); |
||||
|
@ -1,382 +1,412 @@
|
||||
Ext.define('Rambox.view.preferences.Preferences',{ |
||||
extend: 'Ext.window.Window' |
||||
,xtype: 'preferences' |
||||
Ext.define("Rambox.view.preferences.Preferences", { |
||||
extend: "Ext.window.Window", |
||||
xtype: "preferences", |
||||
|
||||
,requires: [ |
||||
'Rambox.view.preferences.PreferencesController' |
||||
,'Rambox.view.preferences.PreferencesModel' |
||||
,'Ext.form.field.ComboBox' |
||||
,'Ext.form.field.Checkbox' |
||||
] |
||||
requires: [ |
||||
"Rambox.view.preferences.PreferencesController", |
||||
"Rambox.view.preferences.PreferencesModel", |
||||
"Ext.form.field.ComboBox", |
||||
"Ext.form.field.Checkbox", |
||||
], |
||||
|
||||
,controller: 'preferences-preferences' |
||||
,viewModel: { |
||||
type: 'preferences-preferences' |
||||
} |
||||
controller: "preferences-preferences", |
||||
viewModel: { |
||||
type: "preferences-preferences", |
||||
}, |
||||
|
||||
,title: locale['preferences[0]'] |
||||
,width: 420 |
||||
,height: 500 |
||||
,modal: true |
||||
,closable: true |
||||
,minimizable: false |
||||
,maximizable: false |
||||
,draggable: true |
||||
,resizable: false |
||||
,scrollable: 'vertical' |
||||
,bodyStyle: 'margin-right:15px;' |
||||
,buttons: [ |
||||
{ |
||||
text: locale['button[1]'] |
||||
,ui: 'decline' |
||||
,handler: 'cancel' |
||||
} |
||||
,'->' |
||||
,{ |
||||
text: locale['button[4]'] |
||||
,handler: 'save' |
||||
} |
||||
] |
||||
title: locale["preferences[0]"], |
||||
width: 420, |
||||
height: 500, |
||||
modal: true, |
||||
closable: true, |
||||
minimizable: false, |
||||
maximizable: false, |
||||
draggable: true, |
||||
resizable: false, |
||||
scrollable: "vertical", |
||||
bodyStyle: "margin-right:15px;", |
||||
buttons: [ |
||||
{ |
||||
text: locale["button[1]"], |
||||
ui: "decline", |
||||
handler: "cancel", |
||||
}, |
||||
"->", |
||||
{ |
||||
text: locale["button[4]"], |
||||
handler: "save", |
||||
}, |
||||
], |
||||
|
||||
,initComponent: function() { |
||||
var config = ipc.sendSync('getConfig'); |
||||
initComponent: function () { |
||||
var config = ipc.sendSync("getConfig"); |
||||
|
||||
var defaultServiceOptions = []; |
||||
defaultServiceOptions.push({ value: 'ramboxTab', label: 'Rambox Tab' }); |
||||
defaultServiceOptions.push({ value: 'last', label: 'Last Active Service' }); |
||||
Ext.getStore('Services').each(function(rec) { |
||||
defaultServiceOptions.push({ value: "ramboxTab", label: "Rambox Tab" }); |
||||
defaultServiceOptions.push({ value: "last", label: "Last Active Service" }); |
||||
Ext.getStore("Services").each(function (rec) { |
||||
defaultServiceOptions.push({ |
||||
value: rec.get('id') |
||||
,label: rec.get('name') |
||||
value: rec.get("id"), |
||||
label: rec.get("name"), |
||||
}); |
||||
}); |
||||
|
||||
this.items = [ |
||||
{ |
||||
xtype: 'form' |
||||
,bodyPadding: 20 |
||||
,items: [ |
||||
{ |
||||
xtype: 'container' |
||||
,layout: 'hbox' |
||||
,items: [ |
||||
{ |
||||
xtype: 'combo' |
||||
,name: 'locale' |
||||
,fieldLabel: 'Language' |
||||
,labelAlign: 'left' |
||||
,flex: 1 |
||||
,labelWidth: 80 |
||||
,value: config.locale |
||||
,displayField: 'label' |
||||
,valueField: 'value' |
||||
,editable: false |
||||
,store: Ext.create('Ext.data.Store', { |
||||
fields: ['value', 'label'] |
||||
,data: [ |
||||
{ 'value': 'af', 'auth0': 'af', 'label': 'Afrikaans' } |
||||
,{ 'value': 'ar', 'auth0': 'en', 'label': 'Arabic' } |
||||
,{ 'value': 'bs2', 'auth0': 'en', 'label': 'Barndutsch, Switzerland' } |
||||
,{ 'value': 'bn', 'auth0': 'en', 'label': 'Bengali' } |
||||
,{ 'value': 'bg', 'auth0': 'en', 'label': 'Bulgarian' } |
||||
,{ 'value': 'ca', 'auth0': 'ca', 'label': 'Catalan' } |
||||
,{ 'value': 'ceb', 'auth0': 'en', 'label': 'Cebuano' } |
||||
,{ 'value': 'zh-CN', 'auth0': 'zh', 'label': 'Chinese Simplified' } |
||||
,{ 'value': 'zh-TW', 'auth0': 'zh-tw', 'label': 'Chinese Traditional' } |
||||
,{ 'value': 'hr', 'auth0': 'en', 'label': 'Croatian' } |
||||
,{ 'value': 'cs', 'auth0': 'cs', 'label': 'Czech' } |
||||
,{ 'value': 'da', 'auth0': 'da', 'label': 'Danish' } |
||||
,{ 'value': 'nl', 'auth0': 'nl', 'label': 'Dutch' } |
||||
,{ 'value': 'en', 'auth0': 'en', 'label': 'English' } |
||||
,{ 'value': 'fi', 'auth0': 'fi', 'label': 'Finnish' } |
||||
,{ 'value': 'fil', 'auth0': 'en', 'label': 'Filipino' } |
||||
,{ 'value': 'fr', 'auth0': 'fr', 'label': 'French' } |
||||
,{ 'value': 'de', 'auth0': 'de', 'label': 'German' } |
||||
,{ 'value': 'de-CH', 'auth0': 'de', 'label': 'German, Switzerland' } |
||||
,{ 'value': 'el', 'auth0': 'el', 'label': 'Greek' } |
||||
,{ 'value': 'he', 'auth0': 'en', 'label': 'Hebrew' } |
||||
,{ 'value': 'hi', 'auth0': 'en', 'label': 'Hindi' } |
||||
,{ 'value': 'hu', 'auth0': 'hu', 'label': 'Hungarian' } |
||||
,{ 'value': 'id', 'auth0': 'en', 'label': 'Indonesian' } |
||||
,{ 'value': 'it', 'auth0': 'it', 'label': 'Italian' } |
||||
,{ 'value': 'ja', 'auth0': 'ja', 'label': 'Japanese' } |
||||
,{ 'value': 'ko', 'auth0': 'ko', 'label': 'Korean' } |
||||
,{ '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' } |
||||
,{ 'value': 'pt-BR', 'auth0': 'pt-br', 'label': 'Portuguese (Brazilian)' } |
||||
,{ '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' } |
||||
,{ 'value': 'es-ES', 'auth0': 'es', 'label': 'Spanish' } |
||||
,{ 'value': 'sv-SE', 'auth0': 'sv', 'label': 'Swedish' } |
||||
,{ 'value': 'tl', 'auth0': 'en', 'label': 'Tagalog' } |
||||
,{ 'value': 'th', 'auth0': 'en', 'label': 'Thai' } |
||||
,{ 'value': 'tr', 'auth0': 'tr', 'label': 'Turkish' } |
||||
,{ 'value': 'uk', 'auth0': 'en', 'label': 'Ukrainian' } |
||||
,{ 'value': 'ur-PK', 'auth0': 'en', 'label': 'Urdu (Pakistan)' } |
||||
,{ 'value': 'vi', 'auth0': 'en', 'label': 'Vietnamese' } |
||||
] |
||||
}) |
||||
} |
||||
,{ |
||||
xtype: 'button' |
||||
,text: 'Help us Translate' |
||||
,style: 'border-top-left-radius:0;border-bottom-left-radius:0;' |
||||
,href: 'https://crowdin.com/project/rambox/invite' |
||||
} |
||||
] |
||||
} |
||||
,{ |
||||
xtype: 'label' |
||||
,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;' |
||||
,margin: '0 0 10 0' |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'auto_launch' |
||||
,boxLabel: locale['preferences[5]'] |
||||
,value: config.auto_launch |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'start_minimized' |
||||
,boxLabel: locale['preferences[4]'] |
||||
,value: config.start_minimized |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'darkreader' |
||||
,boxLabel: locale['preferences[29]'] |
||||
,value: config.darkreader |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'hide_menu_bar' |
||||
,boxLabel: locale['preferences[1]']+' (<code>Alt</code> key to display)' |
||||
,value: config.hide_menu_bar |
||||
,hidden: process.platform === 'darwin' |
||||
} |
||||
,{ |
||||
xtype: 'combo' |
||||
,name: 'tabbar_location' |
||||
,fieldLabel: locale['preferences[11]'] |
||||
,labelAlign: 'left' |
||||
,width: 380 |
||||
,labelWidth: 180 |
||||
,value: config.tabbar_location |
||||
,displayField: 'label' |
||||
,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' |
||||
xtype: "form", |
||||
bodyPadding: 20, |
||||
items: [ |
||||
{ |
||||
xtype: "container", |
||||
layout: "hbox", |
||||
items: [ |
||||
{ |
||||
xtype: "combo", |
||||
name: "locale", |
||||
fieldLabel: "Language", |
||||
labelAlign: "left", |
||||
flex: 1, |
||||
labelWidth: 80, |
||||
value: config.locale, |
||||
displayField: "label", |
||||
valueField: "value", |
||||
editable: false, |
||||
store: Ext.create("Ext.data.Store", { |
||||
fields: ["value", "label"], |
||||
data: [ |
||||
{ value: "af", auth0: "af", label: "Afrikaans" }, |
||||
{ value: "ar", auth0: "en", label: "Arabic" }, |
||||
{ |
||||
value: "bs2", |
||||
auth0: "en", |
||||
label: "Barndutsch, Switzerland", |
||||
}, |
||||
{ value: "bn", auth0: "en", label: "Bengali" }, |
||||
{ value: "bg", auth0: "en", label: "Bulgarian" }, |
||||
{ value: "ca", auth0: "ca", label: "Catalan" }, |
||||
{ value: "ceb", auth0: "en", label: "Cebuano" }, |
||||
{ |
||||
value: "zh-CN", |
||||
auth0: "zh", |
||||
label: "Chinese Simplified", |
||||
}, |
||||
{ |
||||
value: "zh-TW", |
||||
auth0: "zh-tw", |
||||
label: "Chinese Traditional", |
||||
}, |
||||
{ value: "hr", auth0: "en", label: "Croatian" }, |
||||
{ value: "cs", auth0: "cs", label: "Czech" }, |
||||
{ value: "da", auth0: "da", label: "Danish" }, |
||||
{ value: "nl", auth0: "nl", label: "Dutch" }, |
||||
{ value: "en", auth0: "en", label: "English" }, |
||||
{ value: "fi", auth0: "fi", label: "Finnish" }, |
||||
{ value: "fil", auth0: "en", label: "Filipino" }, |
||||
{ value: "fr", auth0: "fr", label: "French" }, |
||||
{ value: "de", auth0: "de", label: "German" }, |
||||
{ |
||||
value: "de-CH", |
||||
auth0: "de", |
||||
label: "German, Switzerland", |
||||
}, |
||||
{ value: "el", auth0: "el", label: "Greek" }, |
||||
{ value: "he", auth0: "en", label: "Hebrew" }, |
||||
{ value: "hi", auth0: "en", label: "Hindi" }, |
||||
{ value: "hu", auth0: "hu", label: "Hungarian" }, |
||||
{ value: "id", auth0: "en", label: "Indonesian" }, |
||||
{ value: "it", auth0: "it", label: "Italian" }, |
||||
{ value: "ja", auth0: "ja", label: "Japanese" }, |
||||
{ value: "ko", auth0: "ko", label: "Korean" }, |
||||
{ 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" }, |
||||
{ |
||||
value: "pt-BR", |
||||
auth0: "pt-br", |
||||
label: "Portuguese (Brazilian)", |
||||
}, |
||||
{ 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" }, |
||||
{ value: "es-ES", auth0: "es", label: "Spanish" }, |
||||
{ value: "sv-SE", auth0: "sv", label: "Swedish" }, |
||||
{ value: "tl", auth0: "en", label: "Tagalog" }, |
||||
{ value: "th", auth0: "en", label: "Thai" }, |
||||
{ value: "tr", auth0: "tr", label: "Turkish" }, |
||||
{ value: "uk", auth0: "en", label: "Ukrainian" }, |
||||
{ value: "ur-PK", auth0: "en", label: "Urdu (Pakistan)" }, |
||||
{ value: "vi", auth0: "en", label: "Vietnamese" }, |
||||
], |
||||
}), |
||||
}, |
||||
{ |
||||
xtype: "button", |
||||
text: "Help us Translate", |
||||
style: "border-top-left-radius:0;border-bottom-left-radius:0;", |
||||
href: "https://crowdin.com/project/rambox/invite", |
||||
}, |
||||
], |
||||
}, |
||||
{ |
||||
xtype: "label", |
||||
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;", |
||||
margin: "0 0 10 0", |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "auto_launch", |
||||
boxLabel: locale["preferences[5]"], |
||||
value: config.auto_launch, |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "start_minimized", |
||||
boxLabel: locale["preferences[4]"], |
||||
value: config.start_minimized, |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "darkreader", |
||||
boxLabel: locale["preferences[29]"], |
||||
value: config.darkreader, |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "hide_menu_bar", |
||||
boxLabel: |
||||
locale["preferences[1]"] + " (<code>Alt</code> key to display)", |
||||
value: config.hide_menu_bar, |
||||
hidden: process.platform === "darwin", |
||||
}, |
||||
{ |
||||
xtype: "combo", |
||||
name: "tabbar_location", |
||||
fieldLabel: locale["preferences[11]"], |
||||
labelAlign: "left", |
||||
width: 380, |
||||
labelWidth: 180, |
||||
value: config.tabbar_location, |
||||
displayField: "label", |
||||
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
|
||||
//,labelWidth: 105
|
||||
,value: config.default_service |
||||
,displayField: 'label' |
||||
,valueField: 'value' |
||||
,editable: false |
||||
,store: Ext.create('Ext.data.Store', { |
||||
fields: ['value', 'label'] |
||||
,data: defaultServiceOptions |
||||
}) |
||||
} |
||||
,{ |
||||
xtype: 'combo' |
||||
,name: 'window_display_behavior' |
||||
,fieldLabel: locale['preferences[13]'] |
||||
,labelAlign: 'left' |
||||
,width: 380 |
||||
,labelWidth: 105 |
||||
,value: config.window_display_behavior |
||||
,displayField: 'label' |
||||
,valueField: 'value' |
||||
,editable: false |
||||
,store: Ext.create('Ext.data.Store', { |
||||
fields: ['value', 'label'] |
||||
,data: [ |
||||
{ 'value': 'show_taskbar', 'label': locale['preferences[14]'] } |
||||
,{ 'value': 'show_trayIcon', 'label': locale['preferences[15]'] } |
||||
,{ 'value': 'taskbar_tray', 'label': locale['preferences[16]'] } |
||||
] |
||||
}) |
||||
,hidden: process.platform === 'darwin' |
||||
} |
||||
,{ |
||||
xtype: 'combo' |
||||
,name: 'window_close_behavior' |
||||
,fieldLabel: locale['preferences[17]'] |
||||
,labelAlign: 'left' |
||||
,width: 380 |
||||
,labelWidth: 180 |
||||
,value: config.window_close_behavior |
||||
,displayField: 'label' |
||||
,valueField: 'value' |
||||
,editable: false |
||||
,store: Ext.create('Ext.data.Store', { |
||||
fields: ['value', 'label'] |
||||
,data: [ |
||||
{ 'value': 'keep_in_tray', 'label': locale['preferences[18]'] } |
||||
,{ 'value': 'keep_in_tray_and_taskbar', 'label': locale['preferences[19]'] } |
||||
,{ 'value': 'quit', 'label': locale['preferences[20]'] } |
||||
] |
||||
}) |
||||
,hidden: process.platform === 'darwin' |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'always_on_top' |
||||
,boxLabel: locale['preferences[21]'] |
||||
,value: config.always_on_top |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'systemtray_indicator' |
||||
,boxLabel: locale['preferences[22]'] |
||||
,value: config.systemtray_indicator |
||||
,hidden: process.platform === 'darwin' |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'flash_frame' |
||||
,boxLabel: process.platform === 'darwin' ? locale['preferences[10]'] : locale['preferences[9]'] |
||||
,value: config.flash_frame |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'disable_gpu' |
||||
,boxLabel: locale['preferences[23]'] |
||||
,value: config.disable_gpu |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'enable_hidpi_support' |
||||
,boxLabel: locale['preferences[8]'] |
||||
,value: config.enable_hidpi_support |
||||
,hidden: process.platform !== 'win32' |
||||
}, |
||||
{ |
||||
xtype: 'textfield' |
||||
,fieldLabel: 'Override User-Agent for all services (needs to relaunch)' |
||||
,labelAlign: 'top' |
||||
,name: 'user_agent' |
||||
,value: config.user_agent |
||||
,width: 360 |
||||
,emptyText: 'Leave blank for default user agent' |
||||
} |
||||
,{ |
||||
xtype: 'fieldset' |
||||
,title: locale['preferences[24]'] |
||||
,collapsed: !config.master_password |
||||
,checkboxToggle: true |
||||
,checkboxName: 'master_password' |
||||
,margin: '10 0 0 0' |
||||
,padding: 10 |
||||
,layout: 'hbox' |
||||
,defaults: { labelAlign: 'top' } |
||||
,items: [ |
||||
{ |
||||
xtype: 'textfield' |
||||
,inputType: 'password' |
||||
,fieldLabel: locale['preferences[25]'] |
||||
,name: 'master_password1' |
||||
,itemId: 'pass' |
||||
,flex: 1 |
||||
,listeners: { |
||||
validitychange: function(field) { |
||||
value: config.default_service, |
||||
displayField: "label", |
||||
valueField: "value", |
||||
editable: false, |
||||
store: Ext.create("Ext.data.Store", { |
||||
fields: ["value", "label"], |
||||
data: defaultServiceOptions, |
||||
}), |
||||
}, |
||||
{ |
||||
xtype: "combo", |
||||
name: "window_display_behavior", |
||||
fieldLabel: locale["preferences[13]"], |
||||
labelAlign: "left", |
||||
width: 380, |
||||
labelWidth: 105, |
||||
value: config.window_display_behavior, |
||||
displayField: "label", |
||||
valueField: "value", |
||||
editable: false, |
||||
store: Ext.create("Ext.data.Store", { |
||||
fields: ["value", "label"], |
||||
data: [ |
||||
{ value: "show_taskbar", label: locale["preferences[14]"] }, |
||||
{ value: "show_trayIcon", label: locale["preferences[15]"] }, |
||||
{ value: "taskbar_tray", label: locale["preferences[16]"] }, |
||||
], |
||||
}), |
||||
hidden: process.platform === "darwin", |
||||
}, |
||||
{ |
||||
xtype: "combo", |
||||
name: "window_close_behavior", |
||||
fieldLabel: locale["preferences[17]"], |
||||
labelAlign: "left", |
||||
width: 380, |
||||
labelWidth: 180, |
||||
value: config.window_close_behavior, |
||||
displayField: "label", |
||||
valueField: "value", |
||||
editable: false, |
||||
store: Ext.create("Ext.data.Store", { |
||||
fields: ["value", "label"], |
||||
data: [ |
||||
{ value: "keep_in_tray", label: locale["preferences[18]"] }, |
||||
{ |
||||
value: "keep_in_tray_and_taskbar", |
||||
label: locale["preferences[19]"], |
||||
}, |
||||
{ value: "quit", label: locale["preferences[20]"] }, |
||||
], |
||||
}), |
||||
hidden: process.platform === "darwin", |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "always_on_top", |
||||
boxLabel: locale["preferences[21]"], |
||||
value: config.always_on_top, |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "systemtray_indicator", |
||||
boxLabel: locale["preferences[22]"], |
||||
value: config.systemtray_indicator, |
||||
hidden: process.platform === "darwin", |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "flash_frame", |
||||
boxLabel: |
||||
process.platform === "darwin" |
||||
? locale["preferences[10]"] |
||||
: locale["preferences[9]"], |
||||
value: config.flash_frame, |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "disable_gpu", |
||||
boxLabel: locale["preferences[23]"], |
||||
value: config.disable_gpu, |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "enable_hidpi_support", |
||||
boxLabel: locale["preferences[8]"], |
||||
value: config.enable_hidpi_support, |
||||
hidden: process.platform !== "win32", |
||||
}, |
||||
{ |
||||
xtype: "textfield", |
||||
fieldLabel: |
||||
"Override User-Agent for all services (needs to relaunch)", |
||||
labelAlign: "top", |
||||
name: "user_agent", |
||||
value: config.user_agent, |
||||
width: 360, |
||||
emptyText: "Leave blank for default user agent", |
||||
}, |
||||
{ |
||||
xtype: "fieldset", |
||||
title: locale["preferences[24]"], |
||||
collapsed: !config.master_password, |
||||
checkboxToggle: true, |
||||
checkboxName: "master_password", |
||||
margin: "10 0 0 0", |
||||
padding: 10, |
||||
layout: "hbox", |
||||
defaults: { labelAlign: "top" }, |
||||
items: [ |
||||
{ |
||||
xtype: "textfield", |
||||
inputType: "password", |
||||
fieldLabel: locale["preferences[25]"], |
||||
name: "master_password1", |
||||
itemId: "pass", |
||||
flex: 1, |
||||
listeners: { |
||||
validitychange: function (field) { |
||||
field.next().validate(); |
||||
}, |
||||
blur: function(field) { |
||||
blur: function (field) { |
||||
field.next().validate(); |
||||
} |
||||
} |
||||
} |
||||
,{ |
||||
xtype: 'textfield' |
||||
,inputType: 'password' |
||||
,fieldLabel: locale['preferences[26]'] |
||||
,name: 'master_password2' |
||||
,margin: '0 0 0 10' |
||||
,vtype: 'password' |
||||
,initialPassField: 'pass' |
||||
,flex: 1 |
||||
} |
||||
] |
||||
} |
||||
,{ |
||||
xtype: 'fieldset' |
||||
,title: 'Proxy (needs to relaunch) - <a href="https://github.com/saenzramiro/rambox/wiki/FREE-PROXY-SERVERS" target="_blank">Free Proxy Servers</a>' |
||||
,collapsed: !config.proxy |
||||
,checkboxToggle: true |
||||
,checkboxName: 'proxy' |
||||
,margin: '10 0 0 0' |
||||
,padding: 10 |
||||
,layout: 'vbox' |
||||
,defaults: { labelAlign: 'left' } |
||||
,items: [ |
||||
{ |
||||
xtype: 'textfield' |
||||
,vtype: 'url' |
||||
,fieldLabel: 'Host' |
||||
,name: 'proxyHost' |
||||
,value: config.proxyHost |
||||
}, |
||||
}, |
||||
}, |
||||
{ |
||||
xtype: "textfield", |
||||
inputType: "password", |
||||
fieldLabel: locale["preferences[26]"], |
||||
name: "master_password2", |
||||
margin: "0 0 0 10", |
||||
vtype: "password", |
||||
initialPassField: "pass", |
||||
flex: 1, |
||||
}, |
||||
], |
||||
}, |
||||
{ |
||||
xtype: "fieldset", |
||||
title: |
||||
'Proxy (needs to relaunch) - <a href="https://github.com/saenzramiro/rambox/wiki/FREE-PROXY-SERVERS" target="_blank">Free Proxy Servers</a>', |
||||
collapsed: !config.proxy, |
||||
checkboxToggle: true, |
||||
checkboxName: "proxy", |
||||
margin: "10 0 0 0", |
||||
padding: 10, |
||||
layout: "vbox", |
||||
defaults: { labelAlign: "left" }, |
||||
items: [ |
||||
{ |
||||
xtype: "textfield", |
||||
vtype: "url", |
||||
fieldLabel: "Host", |
||||
name: "proxyHost", |
||||
value: config.proxyHost, |
||||
//,flex: 1
|
||||
} |
||||
,{ |
||||
xtype: 'numberfield' |
||||
,fieldLabel: 'Port' |
||||
,name: 'proxyPort' |
||||
,value: config.proxyPort |
||||
} |
||||
,{ |
||||
xtype: 'textfield' |
||||
,fieldLabel: 'Login' |
||||
,name: 'proxyLogin' |
||||
,value: config.proxyLogin |
||||
,emptyText: 'Optional' |
||||
} |
||||
,{ |
||||
xtype: 'textfield' |
||||
,fieldLabel: 'Password' |
||||
,name: 'proxyPassword' |
||||
,value: config.proxyPassword |
||||
,emptyText: 'Optional' |
||||
,inputType: 'password' |
||||
} |
||||
] |
||||
} |
||||
,{ |
||||
xtype: 'checkbox' |
||||
,name: 'sendStatistics' |
||||
,boxLabel: locale['preferences[27]'] |
||||
,value: config.sendStatistics |
||||
} |
||||
] |
||||
} |
||||
}, |
||||
{ |
||||
xtype: "numberfield", |
||||
fieldLabel: "Port", |
||||
name: "proxyPort", |
||||
value: config.proxyPort, |
||||
}, |
||||
{ |
||||
xtype: "textfield", |
||||
fieldLabel: "Login", |
||||
name: "proxyLogin", |
||||
value: config.proxyLogin, |
||||
emptyText: "Optional", |
||||
}, |
||||
{ |
||||
xtype: "textfield", |
||||
fieldLabel: "Password", |
||||
name: "proxyPassword", |
||||
value: config.proxyPassword, |
||||
emptyText: "Optional", |
||||
inputType: "password", |
||||
}, |
||||
], |
||||
}, |
||||
{ |
||||
xtype: "checkbox", |
||||
name: "sendStatistics", |
||||
boxLabel: locale["preferences[27]"], |
||||
value: config.sendStatistics, |
||||
}, |
||||
], |
||||
}, |
||||
]; |
||||
|
||||
this.callParent(); |
||||
} |
||||
}, |
||||
}); |
||||
|
@ -1,14 +1,14 @@
|
||||
const { ipcRenderer } = require('electron'); |
||||
const darkreader = require('darkreader'); |
||||
const { ipcRenderer } = require("electron"); |
||||
const darkreader = require("darkreader"); |
||||
darkreader.setFetchMethod(window.fetch); |
||||
|
||||
const getIsEnabled = () => ipcRenderer.sendSync("getConfig").darkreader; |
||||
const canEnable = () => |
||||
document.readyState === "complete" || document.readyState === "interactive"; |
||||
|
||||
const getIsEnabled = () => ipcRenderer.sendSync('getConfig').darkreader;
|
||||
const canEnable = () => document.readyState === 'complete' || document.readyState === 'interactive'; |
||||
|
||||
document.addEventListener('readystatechange', () => { |
||||
console.log(document.readyState) |
||||
document.addEventListener("readystatechange", () => { |
||||
console.log(document.readyState); |
||||
if (canEnable()) { |
||||
getIsEnabled()? darkreader.enable(): darkreader.disable(); |
||||
getIsEnabled() ? darkreader.enable() : darkreader.disable(); |
||||
} |
||||
}); |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue