aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--desktop/sources/scripts/commander.js2
-rw-r--r--desktop/sources/scripts/lib/acels.js11
-rw-r--r--desktop/sources/scripts/lib/source.js2
-rw-r--r--desktop/sources/scripts/lib/theme.js28
-rw-r--r--desktop/sources/scripts/terminal.js15
-rw-r--r--index.html8
6 files changed, 43 insertions, 23 deletions
diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js
index f227aa4..59f7eed 100644
--- a/desktop/sources/scripts/commander.js
+++ b/desktop/sources/scripts/commander.js
@@ -145,7 +145,7 @@ function Commander (terminal) {
}
this.onKeyUp = (e) => {
- // terminal.update()
+ terminal.update()
}
// UI
diff --git a/desktop/sources/scripts/lib/acels.js b/desktop/sources/scripts/lib/acels.js
index a0d19d6..40320bc 100644
--- a/desktop/sources/scripts/lib/acels.js
+++ b/desktop/sources/scripts/lib/acels.js
@@ -1,6 +1,6 @@
'use strict'
-function Acels () {
+function Acels (client) {
this.all = {}
this.roles = {}
this.pipe = null
@@ -100,7 +100,14 @@ function Acels () {
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: 'Theme',
+ submenu: [
+ { label: 'Download Themes', click: () => { require('electron').shell.openExternal('https://github.com/hundredrabbits/Themes') } },
+ { label: 'Open Theme', click: () => { client.theme.open() } },
+ { label: 'Reset Theme', click: () => { client.theme.reset() } }
+ ]
+ },
{ 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() } },
diff --git a/desktop/sources/scripts/lib/source.js b/desktop/sources/scripts/lib/source.js
index edf0738..5de3ace 100644
--- a/desktop/sources/scripts/lib/source.js
+++ b/desktop/sources/scripts/lib/source.js
@@ -3,7 +3,7 @@
/* global FileReader */
/* global MouseEvent */
-function Source () {
+function Source (client) {
this.cache = {}
this.install = () => {
diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js
index 5c1d536..6ee6ecf 100644
--- a/desktop/sources/scripts/lib/theme.js
+++ b/desktop/sources/scripts/lib/theme.js
@@ -4,7 +4,7 @@
/* global FileReader */
/* global DOMParser */
-function Theme () {
+function Theme (client) {
this.el = document.createElement('style')
this.el.type = 'text/css'
@@ -40,6 +40,16 @@ function Theme () {
this.load(this.default)
}
+ this.open = () => {
+ console.log('Theme', 'Open theme..')
+ const input = document.createElement('input')
+ input.type = 'file'
+ input.onchange = (e) => {
+ this.read(e.target.files[0], this.load)
+ }
+ input.click()
+ }
+
this.load = (data) => {
const theme = this.parse(data)
if (!isValid(theme)) { console.warn('Theme', 'Invalid format'); return }
@@ -84,16 +94,20 @@ function Theme () {
this.drop = (e) => {
e.preventDefault()
const file = e.dataTransfer.files[0]
- if (!file || !file.name) { console.warn('Theme', 'Could not read file.'); return }
- if (file.name.indexOf('.svg') < 0) { console.warn('Theme', 'Not a SVG file.'); return }
- const reader = new FileReader()
- reader.onload = (e) => {
- this.load(e.target.result)
+ if (file.name.indexOf('.svg') > -1) {
+ this.read(file, this.load)
}
- reader.readAsText(file)
e.stopPropagation()
}
+ this.read = (file, callback) => {
+ const reader = new FileReader()
+ reader.onload = (event) => {
+ callback(event.target.result)
+ }
+ reader.readAsText(file, 'UTF-8')
+ }
+
// Helpers
function extract (xml) {
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js
index 52b19c5..88e1df5 100644
--- a/desktop/sources/scripts/terminal.js
+++ b/desktop/sources/scripts/terminal.js
@@ -15,10 +15,10 @@ function Terminal () {
this.version = 147
this.library = library
- this.theme = new Theme()
- this.acels = new Acels()
- this.source = new Source()
- this.history = new History()
+ this.theme = new Theme(this)
+ this.acels = new Acels(this)
+ this.source = new Source(this)
+ this.history = new History(this)
this.orca = new Orca(this.library)
this.io = new IO(this)
@@ -465,8 +465,11 @@ function Terminal () {
window.addEventListener('drop', (e) => {
e.preventDefault()
e.stopPropagation()
- this.toggleGuide(false)
- this.source.read(e.dataTransfer.files[0], this.whenOpen)
+ const file = e.dataTransfer.files[0]
+ if (file.name.indexOf('.orca') > -1) {
+ this.toggleGuide(false)
+ this.source.read(file, this.whenOpen)
+ }
})
window.onresize = (event) => {
diff --git a/index.html b/index.html
index d0ebccb..1713c8e 100644
--- a/index.html
+++ b/index.html
@@ -3,11 +3,7 @@
<meta charset='utf-8'>
<link rel="stylesheet" type="text/css" href="desktop/sources/links/style.css"/>
- <script type="text/javascript">
- function require(name){
- console.warn('Failed to require '+name)
- }
- </script>
+ <script type="text/javascript">function require(name){ console.warn('Failed to require '+name) }</script>
<script type="text/javascript" src="desktop/sources/scripts/lib/acels.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/lib/theme.js"></script>
@@ -31,7 +27,7 @@
<script type="text/javascript" src="desktop/sources/scripts/cursor.js"></script>
<script type="text/javascript" src="desktop/sources/scripts/terminal.js"></script>
- <title>Orca — Web</title>
+ <title>Orca</title>
</head>
<body>
<script>