aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/google-calendar/webview-unsafe.js
diff options
context:
space:
mode:
authorLibravatar MCMXC <16797721+mcmxcdev@users.noreply.github.com>2023-07-26 06:29:03 -0600
committerLibravatar GitHub <noreply@github.com>2023-07-26 17:59:03 +0530
commit9b8f01716774a960073e944823ab727cc867a8f6 (patch)
tree732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/google-calendar/webview-unsafe.js
parentAdd Excalidraw recipe (#393) (diff)
downloadferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz
ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst
ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip
chore: improve lint setup (#397)
- update eslint config to closely mirror the ones from ferdium-app - add .eslintignore - opt in to eslint `reportUnusedDisableDirectives` config option - remove `trailingComma: all` from `prettier` config which is default in `prettier` v3 - autofix or disable a lot of lint issues throughout codebase - add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions - upgrade all `eslint` and `prettier` related dependencies to latest - update lint:fix npm script - reformat touched files with prettier - bumped up minor version for all recipes that have changes - introduced injection of 'service.css' where it was missing in many recipes --------- Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/google-calendar/webview-unsafe.js')
-rw-r--r--recipes/google-calendar/webview-unsafe.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/recipes/google-calendar/webview-unsafe.js b/recipes/google-calendar/webview-unsafe.js
new file mode 100644
index 0000000..0f4833e
--- /dev/null
+++ b/recipes/google-calendar/webview-unsafe.js
@@ -0,0 +1,46 @@
1let modal;
2let updates = 0;
3
4const waitFor = (condition, callback) => {
5 if (condition()) {
6 callback();
7 } else {
8 window.setTimeout(waitFor.bind(null, condition, callback), 100);
9 }
10};
11
12const showModal = text => {
13 modal.querySelector('p').textContent = text;
14 updates += 1;
15 window.ferdium.setBadge(updates);
16 modal.classList.add('open');
17};
18
19const hideModal = () => {
20 modal.querySelector('p').textContent = '';
21 updates -= 1;
22 window.ferdium.setBadge(updates);
23 modal.classList.remove('open');
24};
25
26const createModal = () => {
27 const modalDialog = document.createElement('div');
28 modalDialog.setAttribute('id', 'franz-modal');
29 modalDialog.textContent =
30 '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
31 modalDialog.querySelector('.close').addEventListener('click', hideModal);
32
33 return modalDialog;
34};
35
36window.alert = showModal;
37
38modal = createModal();
39waitFor(
40 () => document.body,
41 () => document.body.append(modal),
42);
43document.addEventListener(
44 'keydown',
45 event => event.key === 'Escape' && hideModal(),
46);