This commit is contained in:
neauoire 2019-11-03 14:50:35 -05:00
parent cd6c3ff0cc
commit 864e82e67b
6 changed files with 30 additions and 21 deletions

View File

@ -25,7 +25,7 @@ app.on('ready', () => {
app.win.webContents.removeAllListeners('devtools-reload-page')
app.win.loadURL(`file://${__dirname}/sources/index.html`)
app.inspect()
// app.inspect()
app.win.on('closed', () => {
win = null

View File

@ -23,7 +23,7 @@
window.addEventListener('load', () => {
ronin.start()
ronin.acels.inject()
ronin.acels.inject('Ronin')
})
</script>
</body>

View File

@ -27,7 +27,7 @@ function Acels () {
}
this.convert = (event) => {
const accelerator = event.accelerator.substr(0, 1).toUpperCase() + event.accelerator.substr(1)
const accelerator = event.key.substr(0, 1).toUpperCase() + event.key.substr(1)
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
return `CmdOrCtrl+Shift+${accelerator}`
}
@ -77,8 +77,25 @@ function Acels () {
return text.trim()
}
this.inject = () => {
// Electron specifics
this.inject = (name = 'Untitled') => {
const app = require('electron').remote.app
const injection = []
injection.push({
label: name,
submenu: [
{ label: 'About', click: () => { require('electron').shell.openExternal('https://github.com/hundredrabbits/' + name) } },
{ label: 'Download Themes', click: () => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes') } },
{ label: 'Fullscreen', accelerator: 'CmdOrCtrl+Enter', click: () => { app.toggleFullscreen() } },
{ label: 'Hide', accelerator: 'CmdOrCtrl+H', click: () => { app.toggleVisible() } },
{ label: 'Toggle Menubar', accelerator: 'Alt+H', click: () => { app.toggleMenubar() } },
{ label: 'Inspect', accelerator: 'CmdOrCtrl+.', click: () => { app.inspect() } },
{ label: 'Quit', accelerator: 'CmdOrCtrl+Q', click: () => { app.exit() } }
]
})
const sorted = this.sort()
for (const cat of Object.keys(sorted)) {
const submenu = []
@ -93,6 +110,6 @@ function Acels () {
}
injection.push({ label: cat, submenu: submenu })
}
require('electron').remote.app.injectMenu(injection)
app.injectMenu(injection)
}
}

View File

@ -55,14 +55,14 @@ function Source () {
reader.readAsText(file, 'UTF-8')
}
this.download = (name, content, type) => {
this.download = (name, content, type, settings = 'charset=utf-8') => {
console.info('Source', `Downloading ${name}(${type})`)
const link = document.createElement('a')
link.setAttribute('download', name)
if (type === 'image/png' || type === 'image/jpeg') {
link.setAttribute('href', content)
} else {
link.setAttribute('href', 'data:' + type + ';charset=utf-8,' + encodeURIComponent(content))
link.setAttribute('href', 'data:' + type + ';' + settings + ',' + encodeURIComponent(content))
}
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
}

View File

@ -7,6 +7,7 @@
function Theme () {
const themer = this
this.default = { background: '#eee', f_high: '#000', f_med: '#999', f_low: '#ccc', f_inv: '#000', b_high: '#000', b_med: '#888', b_low: '#aaa', b_inv: '#ffb545' }
this.active = {}
this.el = document.createElement('style')
@ -17,8 +18,8 @@ function Theme () {
this.callback = callback
}
this.start = (defaultTheme) => {
this.active = defaultTheme
this.start = () => {
this.active = this.default
console.log('Theme', 'Starting..')
if (isJson(localStorage.theme)) {
const storage = JSON.parse(localStorage.theme)
@ -44,7 +45,7 @@ function Theme () {
}
this.reset = () => {
this.load(_default)
this.load(this.default)
}
this.get = (key) => {

View File

@ -17,6 +17,7 @@ function Ronin () {
this.acels = new Acels()
this.theme = new Theme()
this.source = new Source()
this.commander = new Commander(this)
this.surface = new Surface(this)
this.library = new Library(this)
@ -55,17 +56,7 @@ function Ronin () {
this.start = function () {
console.log('Ronin', 'Starting..')
console.info(`${this.acels}`)
this.theme.start({
background: '#111',
f_high: '#fff',
f_med: '#999',
f_low: '#444',
f_inv: '#000',
b_high: '#ffffff',
b_med: '#72dec2',
b_low: '#aaaaaa',
b_inv: '#ffb545'
})
this.theme.start()
this.source.start()
this.commander.start()
this.surface.start()