aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/kimai-cloud/webview.js
diff options
context:
space:
mode:
authorLibravatar Kevin Papst <kevinpapst@users.noreply.github.com>2021-04-29 16:26:26 +0200
committerLibravatar GitHub <noreply@github.com>2021-04-29 14:26:26 +0000
commitefbd0b22d14011ed09ab9df4da90f2195136945a (patch)
tree5c09655ba71b949ce473e12e8235f19ab732ca1b /recipes/kimai-cloud/webview.js
parentFixing issue with image preview not working in gChat. (#476) (diff)
downloadferdium-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.js27
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 @@
1module.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};