diff options
author | Kevin Papst <kevinpapst@users.noreply.github.com> | 2021-04-29 16:26:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 14:26:26 +0000 |
commit | efbd0b22d14011ed09ab9df4da90f2195136945a (patch) | |
tree | 5c09655ba71b949ce473e12e8235f19ab732ca1b /recipes/kimai-cloud/webview.js | |
parent | Fixing issue with image preview not working in gChat. (#476) (diff) | |
download | ferdium-recipes-efbd0b22d14011ed09ab9df4da90f2195136945a.tar.gz ferdium-recipes-efbd0b22d14011ed09ab9df4da90f2195136945a.tar.zst ferdium-recipes-efbd0b22d14011ed09ab9df4da90f2195136945a.zip |
Added recipe for Kimai time-tracking instances (#478)
Diffstat (limited to 'recipes/kimai-cloud/webview.js')
-rw-r--r-- | recipes/kimai-cloud/webview.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/recipes/kimai-cloud/webview.js b/recipes/kimai-cloud/webview.js new file mode 100644 index 0000000..8baf008 --- /dev/null +++ b/recipes/kimai-cloud/webview.js | |||
@@ -0,0 +1,27 @@ | |||
1 | module.exports = (Franz) => { | ||
2 | const getMessages = function getMessages() { | ||
3 | let count = 0; | ||
4 | |||
5 | // get amount of running timesheets | ||
6 | let label = document.querySelector('.main-header .navbar .dropdown.messages-menu .ticktac span.label'); | ||
7 | if (label !== undefined) { | ||
8 | count = label.textContent; | ||
9 | } | ||
10 | |||
11 | // set Franz badge | ||
12 | Franz.setBadge(count); | ||
13 | }; | ||
14 | |||
15 | document.addEventListener('click', (e) => { | ||
16 | const { tagName, target, href } = e.target; | ||
17 | |||
18 | if (tagName === 'A' && target === '_blank') { | ||
19 | e.preventDefault(); | ||
20 | e.stopImmediatePropagation(); | ||
21 | window.open(href); | ||
22 | } | ||
23 | }); | ||
24 | |||
25 | // check for new messages every second and update Franz badge | ||
26 | Franz.loop(getMessages); | ||
27 | }; | ||