aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/basecamp/webview.js
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-06-20 11:08:00 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-06-20 05:47:40 +0000
commit8a0971ff9f41fdaa1af15e88740ce9479e1ec6ea (patch)
treedbbc5d0bf44f56a1024eae1d9799c47853401e0d /recipes/basecamp/webview.js
parentRenamed 'glowingbear' --> 'glowing-bear' and 'ex-google-voice' --> 'google-vo... (diff)
downloadferdium-recipes-8a0971ff9f41fdaa1af15e88740ce9479e1ec6ea.tar.gz
ferdium-recipes-8a0971ff9f41fdaa1af15e88740ce9479e1ec6ea.tar.zst
ferdium-recipes-8a0971ff9f41fdaa1af15e88740ce9479e1ec6ea.zip
Added new services
- 'air-droid' - 'basecamp' - 'box' - 'buffer' - 'chatra' - 'easy-redmine' - 'feedbin' - 'iCloud' - 'jollor' - 'nomadlist' - 'paymo' - 'pivotal-tracker' - 'plan' - 'podio' - 'protonet' - 'teamleader'
Diffstat (limited to 'recipes/basecamp/webview.js')
-rw-r--r--recipes/basecamp/webview.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/recipes/basecamp/webview.js b/recipes/basecamp/webview.js
new file mode 100644
index 0000000..2158d0b
--- /dev/null
+++ b/recipes/basecamp/webview.js
@@ -0,0 +1,59 @@
1const path = require('path');
2
3module.exports = (Franz, options) => {
4 let updates = 0;
5 const modal = document.createElement('div');
6
7 function showModal (text) {
8 show(modal);
9 modal.querySelector('p').innerHTML = text;
10 updates += 1;
11 }
12
13 function hideModal () {
14 hide(modal);
15 modal.querySelector('p').innerHTML = '';
16 updates -= 1;
17 }
18
19 // Replace window.alert to hide alerts in Franz
20 const oldAlert = window.alert;
21 window.alert = function () {
22 // when Google Calendar displays an alert notify the user
23 showModal.apply(oldAlert, arguments);
24 };
25
26 function show (element) {
27 element.style.display = 'inherit';
28 }
29
30 function hide (element) {
31 element.style.display = 'none';
32 }
33
34 const getMessages = () => {
35 // get unread messages
36 //const updates = document.getElementById('franz').getAttribute('data-unread');
37
38 // get conversations in 'My Inbox'
39 //const inbox = document.getElementById('franz').getAttribute('data-inbox');
40
41 // set Franz badge
42 // updates => passive unread count
43 // inbox => active unread count
44 Franz.setBadge(0, updates);
45 };
46
47 modal.id = 'franz-modal';
48 modal.innerHTML = '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
49 modal.querySelector('.close').addEventListener('click', hideModal);
50 document.body.appendChild(modal);
51
52 document.addEventListener('keydown', function(e) { if (e.keyCode === 27) { hideModal(); } })
53
54 // inject franz.css stylesheet
55 Franz.injectCSS(path.join(__dirname, 'css', 'modal.css'));
56
57 // check for new messages every second and update Franz badge
58 Franz.loop(getMessages);
59};