From 8a0971ff9f41fdaa1af15e88740ce9479e1ec6ea Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 20 Jun 2021 11:08:00 +0530 Subject: Added new services - 'air-droid' - 'basecamp' - 'box' - 'buffer' - 'chatra' - 'easy-redmine' - 'feedbin' - 'iCloud' - 'jollor' - 'nomadlist' - 'paymo' - 'pivotal-tracker' - 'plan' - 'podio' - 'protonet' - 'teamleader' --- recipes/basecamp/webview.js | 59 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 recipes/basecamp/webview.js (limited to 'recipes/basecamp/webview.js') 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 @@ +const path = require('path'); + +module.exports = (Franz, options) => { + let updates = 0; + const modal = document.createElement('div'); + + function showModal (text) { + show(modal); + modal.querySelector('p').innerHTML = text; + updates += 1; + } + + function hideModal () { + hide(modal); + modal.querySelector('p').innerHTML = ''; + updates -= 1; + } + + // Replace window.alert to hide alerts in Franz + const oldAlert = window.alert; + window.alert = function () { + // when Google Calendar displays an alert notify the user + showModal.apply(oldAlert, arguments); + }; + + function show (element) { + element.style.display = 'inherit'; + } + + function hide (element) { + element.style.display = 'none'; + } + + const getMessages = () => { + // get unread messages + //const updates = document.getElementById('franz').getAttribute('data-unread'); + + // get conversations in 'My Inbox' + //const inbox = document.getElementById('franz').getAttribute('data-inbox'); + + // set Franz badge + // updates => passive unread count + // inbox => active unread count + Franz.setBadge(0, updates); + }; + + modal.id = 'franz-modal'; + modal.innerHTML = ''; + modal.querySelector('.close').addEventListener('click', hideModal); + document.body.appendChild(modal); + + document.addEventListener('keydown', function(e) { if (e.keyCode === 27) { hideModal(); } }) + + // inject franz.css stylesheet + Franz.injectCSS(path.join(__dirname, 'css', 'modal.css')); + + // check for new messages every second and update Franz badge + Franz.loop(getMessages); +}; -- cgit v1.2.3-54-g00ecf