-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrenderer.js
70 lines (63 loc) · 2.1 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* Example usage of jQuery Terminal in Electron app
* Copyright (c) 2018 Jakub Jankewicz <http://jcubic.pl/me>
* Released under MIT license
*/
/* global require, module */
const {ipcRenderer} = require('electron');
require('devtron').install();
var $ = require('jquery');
require('jquery.terminal')($);
$('body').terminal(function(command) {
if (command.match(/^\s*exit\*$/)) {
ipcRenderer.send('terminal', {
method: 'exit',
args: []
});
} else if (command !== '') {
try {
var result = window.eval(command);
if (result !== undefined) {
this.echo(new String(result));
}
} catch(e) {
this.error(new String(e));
}
}
}, {
exit: false,
greetings: function(set) {
set(function() {
var version = 'v. ' + process.versions.electron;
var re = new RegExp('.{' + version.length + '}$');
var ascii_art = [
' ______ __',
' / __/ /__ ____/ /________ ___',
' / _// / -_) __/ __/ __/ _ \\/ _ \\',
'/___/_/\\__/\\__/\\__/_/ \\___/_//_/',
' '.replace(re, '') + version
].join('\n');
var cols = this.cols();
var signature = [];
if (cols >= 33) {
signature.push(ascii_art);
signature.push('');
} else {
signature.push('Electron');
}
if (cols >= 57) {
signature.push('Copyright (C) 2018 Jakub Jankiewicz <http://jcubic.pl/me>');
} else if (cols >= 47) {
signature.push('(C) 2018 Jakub Jankiewicz <http://jcubic.pl/me>');
} else if (cols >= 25) {
signature.push('(C) 2018 Jakub Jankiewicz');
} else if (cols >= 15) {
signature.push('(C) 2018 jcubic');
}
return signature.join('\n') + '\n';
});
},
name: 'electron',
prompt: '[[;#D72424;]js]> '
});
module.exports = $;