diff options
author | neauoire <[email protected]> | 2019-10-24 21:42:28 -0400 |
---|---|---|
committer | neauoire <[email protected]> | 2019-10-24 21:42:28 -0400 |
commit | 56ce6604ae28b9fbdfe8394a52253075addd2e81 (patch) | |
tree | 844b00c73a6f91f7019babac9636d6064345a3f9 | |
parent | 22e6fc0a43b1903ca64cfa9bb014f2b0a99593e5 (diff) | |
download | Orca-56ce6604ae28b9fbdfe8394a52253075addd2e81.tar.gz Orca-56ce6604ae28b9fbdfe8394a52253075addd2e81.zip |
Improved open dialogs
-rw-r--r-- | desktop/core/operator.js | 2 | ||||
-rw-r--r-- | desktop/sources/scripts/lib/theme.js | 18 | ||||
-rw-r--r-- | desktop/sources/scripts/source.js | 4 |
3 files changed, 11 insertions, 13 deletions
diff --git a/desktop/core/operator.js b/desktop/core/operator.js index bb118b3..58a6d5c 100644 --- a/desktop/core/operator.js +++ b/desktop/core/operator.js @@ -56,7 +56,7 @@ export default function Operator (orca, x, y, glyph = '.', passive = false) { } this.operation = function () { - + // Used in individual operators } // Helpers diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js index 43b6790..a2777fe 100644 --- a/desktop/sources/scripts/lib/theme.js +++ b/desktop/sources/scripts/lib/theme.js @@ -3,7 +3,6 @@ export default function Theme (_default) { const fs = require('fs') const url = require('url') - const themer = this this.active = _default @@ -67,28 +66,27 @@ export default function Theme (_default) { e.dataTransfer.dropEffect = 'copy' } - this.drop = function (e) { + this.drop = (e) => { e.preventDefault() e.stopPropagation() const file = e.dataTransfer.files[0] if (!file || !file.name) { console.warn('Theme', 'Unnamed file.'); return } if (file.name.indexOf('.thm') < 0 && file.name.indexOf('.svg') < 0) { console.warn('Theme', 'Skipped, not a theme'); return } const reader = new FileReader() - reader.onload = function (e) { - themer.load(e.target.result) + reader.onload = (e) => { + this.load(e.target.result) } reader.readAsText(file) } - this.open = function () { + this.open = () => { const fs = require('fs') const { dialog, app } = require('electron').remote - const paths = dialog.showOpenDialog(app.win, { properties: ['openFile'], filters: [{ name: 'Themes', extensions: ['svg'] }] }) + const paths = dialog.showOpenDialogSync(app.win, { properties: ['openFile'], filters: [{ name: 'Themes', extensions: ['svg'] }] }) if (!paths) { console.log('Nothing to load'); return } - fs.readFile(paths[0], 'utf8', function (err, data) { - if (err) throw err - themer.load(data) - }) + const data = fs.readFileSync(paths[0], 'utf8') + if (!data) { return } + this.load(data) } window.addEventListener('dragover', this.drag) diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js index 1836afa..3847491 100644 --- a/desktop/sources/scripts/source.js +++ b/desktop/sources/scripts/source.js @@ -21,12 +21,12 @@ export default function Source (terminal) { terminal.resize() terminal.history.reset() terminal.cursor.reset() - // terminal.clock.play() + terminal.clock.play() } this.open = function () { console.log('Source', 'Open a file..') - const paths = dialog.showOpenDialog(app.win, { properties: ['openFile'], filters: [{ name: 'Orca Machines', extensions: ['orca'] }] }) + const paths = dialog.showOpenDialogSync(app.win, { properties: ['openFile'], filters: [{ name: 'Orca Machines', extensions: ['orca'] }] }) if (!paths) { console.log('Nothing to load'); return } this.read(paths[0]) } |