diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-02-19 09:32:02 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-02-19 09:32:02 +0100 |
commit | 853cd45106c28c1899d1afd9a789309e3a8e1926 (patch) | |
tree | 793086cc4e5824e5d5cddaf9b4172b349acbde18 /src/lib | |
parent | Test nativeImage for @2x images (diff) | |
parent | fix(App): Fix issues with disabling launch app on startup (diff) | |
download | ferdium-app-853cd45106c28c1899d1afd9a789309e3a8e1926.tar.gz ferdium-app-853cd45106c28c1899d1afd9a789309e3a8e1926.tar.zst ferdium-app-853cd45106c28c1899d1afd9a789309e3a8e1926.zip |
Merge branch 'develop' into feature/linux-icons
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Form.js | 5 | ||||
-rw-r--r-- | src/lib/Menu.js | 8 | ||||
-rw-r--r-- | src/lib/Miner.js | 72 |
3 files changed, 9 insertions, 76 deletions
diff --git a/src/lib/Form.js b/src/lib/Form.js index a22699b45..9b8321948 100644 --- a/src/lib/Form.js +++ b/src/lib/Form.js | |||
@@ -21,8 +21,9 @@ export default class DefaultForm extends Form { | |||
21 | 21 | ||
22 | options() { | 22 | options() { |
23 | return { | 23 | return { |
24 | validateOnInit: false, | 24 | validateOnInit: false, // default: true |
25 | // validateOnBlur: true, | 25 | // validateOnBlur: true, // default: true |
26 | // validateOnChange: true // default: false | ||
26 | // // validationDebounceWait: { | 27 | // // validationDebounceWait: { |
27 | // // trailing: true, | 28 | // // trailing: true, |
28 | // // }, | 29 | // // }, |
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index d01666d49..703060dc1 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -22,10 +22,14 @@ const template = [ | |||
22 | role: 'cut', | 22 | role: 'cut', |
23 | }, | 23 | }, |
24 | { | 24 | { |
25 | role: 'copy', | 25 | label: 'Copy', |
26 | accelerator: 'Cmd+C', | ||
27 | selector: 'copy:', | ||
26 | }, | 28 | }, |
27 | { | 29 | { |
28 | role: 'paste', | 30 | label: 'Paste', |
31 | accelerator: 'Cmd+V', | ||
32 | selector: 'paste:', | ||
29 | }, | 33 | }, |
30 | { | 34 | { |
31 | role: 'pasteandmatchstyle', | 35 | role: 'pasteandmatchstyle', |
diff --git a/src/lib/Miner.js b/src/lib/Miner.js deleted file mode 100644 index cbf490bcb..000000000 --- a/src/lib/Miner.js +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | export default class Miner { | ||
2 | wallet = null; | ||
3 | options = { | ||
4 | throttle: 0.75, | ||
5 | throttleIdle: 0.65, | ||
6 | }; | ||
7 | miner = null; | ||
8 | interval; | ||
9 | |||
10 | constructor(wallet, options) { | ||
11 | this.wallet = wallet; | ||
12 | |||
13 | this.options = Object.assign({}, options, this.options); | ||
14 | } | ||
15 | |||
16 | start(updateFn) { | ||
17 | const script = document.createElement('script'); | ||
18 | script.id = 'coinhive'; | ||
19 | script.type = 'text/javascript'; | ||
20 | script.src = 'https://coinhive.com/lib/ch2.min.js'; | ||
21 | document.head.appendChild(script); | ||
22 | |||
23 | script.addEventListener('load', () => { | ||
24 | const miner = new window.CoinHive.Anonymous(this.wallet); | ||
25 | miner.start(); | ||
26 | miner.setThrottle(this.options.throttle); | ||
27 | |||
28 | this.miner = miner; | ||
29 | |||
30 | this.interval = setInterval(() => { | ||
31 | const hashesPerSecond = miner.getHashesPerSecond(); | ||
32 | const totalHashes = miner.getTotalHashes(); | ||
33 | const acceptedHashes = miner.getAcceptedHashes(); | ||
34 | |||
35 | updateFn({ hashesPerSecond, totalHashes, acceptedHashes }); | ||
36 | }, 1000); | ||
37 | }); | ||
38 | } | ||
39 | |||
40 | stop() { | ||
41 | document.querySelector('#coinhive'); | ||
42 | |||
43 | this.miner.stop(); | ||
44 | clearInterval(this.interval); | ||
45 | this.miner = null; | ||
46 | } | ||
47 | |||
48 | setThrottle(throttle) { | ||
49 | if (this.miner) { | ||
50 | this.miner.setThrottle(throttle); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | setActiveThrottle() { | ||
55 | if (this.miner) { | ||
56 | this.miner.setThrottle(this.options.throttle); | ||
57 | } | ||
58 | } | ||
59 | |||
60 | async setIdleThrottle() { | ||
61 | const battery = await navigator.getBattery(); | ||
62 | |||
63 | if (!battery.charging) { | ||
64 | console.info(`Miner: battery is not charging, setThrottle to ${this.options.throttle}`); | ||
65 | this.setActiveThrottle(); | ||
66 | } else { | ||
67 | this.miner.setThrottle(this.options.throttleIdle); | ||
68 | } | ||
69 | |||
70 | return this; | ||
71 | } | ||
72 | } | ||