aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/basecamp
diff options
context:
space:
mode:
authorLibravatar Markus Hatvan <markus_hatvan@aon.at>2021-10-05 17:04:09 +0200
committerLibravatar GitHub <noreply@github.com>2021-10-05 17:04:09 +0200
commitd3841b766f9d37d557646003899f67525c5f755f (patch)
tree1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes/basecamp
parentchore: repo maintenance (#732) (diff)
downloadferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.gz
ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.zst
ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.zip
chore: add eslint-plugin-unicorn (#733)
Diffstat (limited to 'recipes/basecamp')
-rw-r--r--recipes/basecamp/webview.js39
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
7function show(element) {
8 element.style.display = 'inherit';
9}
10
11function hide(element) {
12 element.style.display = 'none';
13}
14
7module.exports = Ferdi => { 15module.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">&times;</span><p></p></div>'; 53 '<div class="modal-content"><span class="close">&times;</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 => {