Fixing up the electron build

This commit is contained in:
neauoire
2019-11-03 11:10:37 -05:00
parent de586b699b
commit cd6c3ff0cc
6 changed files with 648 additions and 1084 deletions

View File

@@ -8,36 +8,36 @@ function Acels () {
host.addEventListener('keyup', this.onKeyUp, false)
}
this.set = (type, name, key, downfn, upfn) => {
if (this.all[key]) { console.warn('Acels', `Trying to overwrite ${this.all[key].name}, with ${name}.`) }
this.all[key] = { type, name, downfn, upfn, key }
this.set = (cat, name, accelerator, downfn, upfn) => {
if (this.all[accelerator]) { console.warn('Acels', `Trying to overwrite ${this.all[accelerator].name}, with ${name}.`) }
this.all[accelerator] = { cat, name, downfn, upfn, accelerator }
}
this.get = (key) => {
return this.all[key]
this.get = (accelerator) => {
return this.all[accelerator]
}
this.sort = () => {
const h = {}
for (const item of Object.values(this.all)) {
if (!h[item.type]) { h[item.type] = [] }
h[item.type].push(item)
if (!h[item.cat]) { h[item.cat] = [] }
h[item.cat].push(item)
}
return h
}
this.convert = (event) => {
const key = event.key.substr(0, 1).toUpperCase() + event.key.substr(1)
const accelerator = event.accelerator.substr(0, 1).toUpperCase() + event.accelerator.substr(1)
if ((event.ctrlKey || event.metaKey) && event.shiftKey) {
return `CmdOrCtrl+Shift+${key}`
return `CmdOrCtrl+Shift+${accelerator}`
}
if (event.shiftKey) {
return `Shift+${key}`
return `Shift+${accelerator}`
}
if (event.ctrlKey || event.metaKey) {
return `CmdOrCtrl+${key}`
return `CmdOrCtrl+${accelerator}`
}
return key
return accelerator
}
this.onKeyDown = (e) => {
@@ -55,25 +55,44 @@ function Acels () {
}
this.toMarkdown = () => {
const types = this.sort()
const cats = this.sort()
let text = ''
for (const type in types) {
text += `\n### ${type}\n\n`
for (const item of types[type]) {
text += `- \`${item.key}\`: ${item.info}\n`
for (const cat in cats) {
text += `\n### ${cat}\n\n`
for (const item of cats[cat]) {
text += `- \`${item.accelerator}\`: ${item.info}\n`
}
}
return text.trim()
}
this.toString = () => {
const types = this.sort()
const cats = this.sort()
let text = ''
for (const type in types) {
for (const item of types[type]) {
text += `${type}: ${item.name} | ${item.key}\n`
for (const cat in cats) {
for (const item of cats[cat]) {
text += `${cat}: ${item.name} | ${item.accelerator}\n`
}
}
return text.trim()
}
this.inject = () => {
const injection = []
const sorted = this.sort()
for (const cat of Object.keys(sorted)) {
const submenu = []
for (const option of sorted[cat]) {
if (option.role) {
submenu.push({ role: option.role })
} else if (option.type) {
submenu.push({ type: option.type })
} else {
submenu.push({ label: option.name, accelerator: option.accelerator, click: option.downfn })
}
}
injection.push({ label: cat, submenu: submenu })
}
require('electron').remote.app.injectMenu(injection)
}
}

View File

@@ -4,10 +4,10 @@
/* global FileReader */
/* global DOMParser */
function Theme (_default) {
function Theme () {
const themer = this
this.active = _default
this.active = {}
this.el = document.createElement('style')
this.el.type = 'text/css'
@@ -17,7 +17,8 @@ function Theme (_default) {
this.callback = callback
}
this.start = () => {
this.start = (defaultTheme) => {
this.active = defaultTheme
console.log('Theme', 'Starting..')
if (isJson(localStorage.theme)) {
const storage = JSON.parse(localStorage.theme)
@@ -27,7 +28,7 @@ function Theme (_default) {
return
}
}
this.load(_default)
this.load(this.active)
}
this.load = (data) => {