*
This commit is contained in:
parent
cd6c3ff0cc
commit
864e82e67b
@ -25,7 +25,7 @@ app.on('ready', () => {
|
|||||||
app.win.webContents.removeAllListeners('devtools-reload-page')
|
app.win.webContents.removeAllListeners('devtools-reload-page')
|
||||||
|
|
||||||
app.win.loadURL(`file://${__dirname}/sources/index.html`)
|
app.win.loadURL(`file://${__dirname}/sources/index.html`)
|
||||||
app.inspect()
|
// app.inspect()
|
||||||
|
|
||||||
app.win.on('closed', () => {
|
app.win.on('closed', () => {
|
||||||
win = null
|
win = null
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
ronin.start()
|
ronin.start()
|
||||||
ronin.acels.inject()
|
ronin.acels.inject('Ronin')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -27,7 +27,7 @@ function Acels () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.convert = (event) => {
|
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) {
|
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
|
||||||
return `CmdOrCtrl+Shift+${accelerator}`
|
return `CmdOrCtrl+Shift+${accelerator}`
|
||||||
}
|
}
|
||||||
@ -77,8 +77,25 @@ function Acels () {
|
|||||||
return text.trim()
|
return text.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inject = () => {
|
// Electron specifics
|
||||||
|
|
||||||
|
this.inject = (name = 'Untitled') => {
|
||||||
|
const app = require('electron').remote.app
|
||||||
const injection = []
|
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()
|
const sorted = this.sort()
|
||||||
for (const cat of Object.keys(sorted)) {
|
for (const cat of Object.keys(sorted)) {
|
||||||
const submenu = []
|
const submenu = []
|
||||||
@ -93,6 +110,6 @@ function Acels () {
|
|||||||
}
|
}
|
||||||
injection.push({ label: cat, submenu: submenu })
|
injection.push({ label: cat, submenu: submenu })
|
||||||
}
|
}
|
||||||
require('electron').remote.app.injectMenu(injection)
|
app.injectMenu(injection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,14 +55,14 @@ function Source () {
|
|||||||
reader.readAsText(file, 'UTF-8')
|
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})`)
|
console.info('Source', `Downloading ${name}(${type})`)
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.setAttribute('download', name)
|
link.setAttribute('download', name)
|
||||||
if (type === 'image/png' || type === 'image/jpeg') {
|
if (type === 'image/png' || type === 'image/jpeg') {
|
||||||
link.setAttribute('href', content)
|
link.setAttribute('href', content)
|
||||||
} else {
|
} 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 }))
|
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
function Theme () {
|
function Theme () {
|
||||||
const themer = this
|
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.active = {}
|
||||||
|
|
||||||
this.el = document.createElement('style')
|
this.el = document.createElement('style')
|
||||||
@ -17,8 +18,8 @@ function Theme () {
|
|||||||
this.callback = callback
|
this.callback = callback
|
||||||
}
|
}
|
||||||
|
|
||||||
this.start = (defaultTheme) => {
|
this.start = () => {
|
||||||
this.active = defaultTheme
|
this.active = this.default
|
||||||
console.log('Theme', 'Starting..')
|
console.log('Theme', 'Starting..')
|
||||||
if (isJson(localStorage.theme)) {
|
if (isJson(localStorage.theme)) {
|
||||||
const storage = JSON.parse(localStorage.theme)
|
const storage = JSON.parse(localStorage.theme)
|
||||||
@ -44,7 +45,7 @@ function Theme () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.reset = () => {
|
this.reset = () => {
|
||||||
this.load(_default)
|
this.load(this.default)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.get = (key) => {
|
this.get = (key) => {
|
||||||
|
@ -17,6 +17,7 @@ function Ronin () {
|
|||||||
this.acels = new Acels()
|
this.acels = new Acels()
|
||||||
this.theme = new Theme()
|
this.theme = new Theme()
|
||||||
this.source = new Source()
|
this.source = new Source()
|
||||||
|
|
||||||
this.commander = new Commander(this)
|
this.commander = new Commander(this)
|
||||||
this.surface = new Surface(this)
|
this.surface = new Surface(this)
|
||||||
this.library = new Library(this)
|
this.library = new Library(this)
|
||||||
@ -55,17 +56,7 @@ function Ronin () {
|
|||||||
this.start = function () {
|
this.start = function () {
|
||||||
console.log('Ronin', 'Starting..')
|
console.log('Ronin', 'Starting..')
|
||||||
console.info(`${this.acels}`)
|
console.info(`${this.acels}`)
|
||||||
this.theme.start({
|
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.source.start()
|
this.source.start()
|
||||||
this.commander.start()
|
this.commander.start()
|
||||||
this.surface.start()
|
this.surface.start()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user