diff options
Diffstat (limited to 'recipes/basecamp')
-rw-r--r-- | recipes/basecamp/webview.js | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/recipes/basecamp/webview.js b/recipes/basecamp/webview.js index 16eced3..9d8e677 100644 --- a/recipes/basecamp/webview.js +++ b/recipes/basecamp/webview.js | |||
@@ -4,6 +4,14 @@ function _interopRequireDefault(obj) { | |||
4 | return obj && obj.__esModule ? obj : { default: obj }; | 4 | return obj && obj.__esModule ? obj : { default: obj }; |
5 | } | 5 | } |
6 | 6 | ||
7 | function show(element) { | ||
8 | element.style.display = 'inherit'; | ||
9 | } | ||
10 | |||
11 | function hide(element) { | ||
12 | element.style.display = 'none'; | ||
13 | } | ||
14 | |||
7 | module.exports = Ferdi => { | 15 | module.exports = Ferdi => { |
8 | const modal = document.createElement('div'); | 16 | const modal = document.createElement('div'); |
9 | 17 | ||
@@ -16,12 +24,21 @@ module.exports = Ferdi => { | |||
16 | }; | 24 | }; |
17 | function showModal(text) { | 25 | function showModal(text) { |
18 | show(modal); | 26 | show(modal); |
19 | modal.querySelector('p').innerHTML = text; | 27 | |
28 | let p = modal.querySelector('p'); | ||
29 | |||
30 | if (p) { | ||
31 | p.textContent = text; | ||
32 | } | ||
20 | } | 33 | } |
21 | 34 | ||
22 | function hideModal() { | 35 | function hideModal() { |
23 | hide(modal); | 36 | hide(modal); |
24 | modal.querySelector('p').innerHTML = ''; | 37 | let p = modal.querySelector('p'); |
38 | |||
39 | if (p) { | ||
40 | p.textContent = ''; | ||
41 | } | ||
25 | } | 42 | } |
26 | 43 | ||
27 | // Replace window.alert to hide alerts in Ferdi | 44 | // Replace window.alert to hide alerts in Ferdi |
@@ -31,21 +48,17 @@ module.exports = Ferdi => { | |||
31 | showModal.apply(oldAlert, arguments); | 48 | showModal.apply(oldAlert, arguments); |
32 | }; | 49 | }; |
33 | 50 | ||
34 | function show(element) { | ||
35 | element.style.display = 'inherit'; | ||
36 | } | ||
37 | |||
38 | function hide(element) { | ||
39 | element.style.display = 'none'; | ||
40 | } | ||
41 | |||
42 | modal.id = 'franz-modal'; | 51 | modal.id = 'franz-modal'; |
43 | modal.innerHTML = | 52 | modal.textContent = |
44 | '<div class="modal-content"><span class="close">×</span><p></p></div>'; | 53 | '<div class="modal-content"><span class="close">×</span><p></p></div>'; |
45 | modal.querySelector('.close').addEventListener('click', hideModal); | 54 | |
55 | let close = modal.querySelector('.close'); | ||
56 | if (close) { | ||
57 | close.addEventListener('click', hideModal); | ||
58 | } | ||
46 | waitFor( | 59 | waitFor( |
47 | () => document.body, | 60 | () => document.body, |
48 | () => document.body.appendChild(modal), | 61 | () => document.body.append(modal), |
49 | ); | 62 | ); |
50 | 63 | ||
51 | document.addEventListener('keydown', e => { | 64 | document.addEventListener('keydown', e => { |