From b3411bfca0dd166995d33760feb4ab2c89537c46 Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Sun, 12 Sep 2021 18:06:39 +0530 Subject: Add indirect count for 'teamleader' recipe. (#703) --- recipes/teamleader/package.json | 2 +- recipes/teamleader/service.css | 5 +++++ recipes/teamleader/webview.js | 26 ++++++++++++++++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 recipes/teamleader/service.css (limited to 'recipes') diff --git a/recipes/teamleader/package.json b/recipes/teamleader/package.json index 83a8521..60f917a 100644 --- a/recipes/teamleader/package.json +++ b/recipes/teamleader/package.json @@ -1,7 +1,7 @@ { "id": "teamleader", "name": "teamleader", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "config": { "serviceURL": "https://app.teamleader.eu/?gotologin", diff --git a/recipes/teamleader/service.css b/recipes/teamleader/service.css new file mode 100644 index 0000000..2d8c1a6 --- /dev/null +++ b/recipes/teamleader/service.css @@ -0,0 +1,5 @@ +.app-wrapper-web .app { + width: 100% !important; + height: 100% !important; + top: 0 !important; +} diff --git a/recipes/teamleader/webview.js b/recipes/teamleader/webview.js index 7eff414..d341016 100644 --- a/recipes/teamleader/webview.js +++ b/recipes/teamleader/webview.js @@ -3,11 +3,29 @@ const _path = _interopRequireDefault(require('path')); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } module.exports = (Ferdi) => { - const getMessages = () => { - Ferdi.setBadge(document.getElementById('notifications_amount').innerHTML); + const getMessages = function getMessages() { + let notifications = 0; + let indirectNotifications = 0; + + const notification_element = document.getElementById('notifications_amount'); + const ticket_element = document.querySelector("a[href='tickets.php'] > span"); + const call_element = document.getElementById('queue_amount'); + + if (notification_element) { + notifications = Ferdi.safeParseInt(notification_element.getAttribute("datacount")); + } + + if (ticket_element != null) { + indirectNotifications = Ferdi.safeParseInt(ticket_element.innerHTML); + } + + if (call_element) { + indirectNotifications += Ferdi.safeParseInt(call_element.getAttribute("datacount")); + } + + Ferdi.setBadge(notifications, indirectNotifications); }; Ferdi.loop(getMessages); - - Ferdi.injectCSS(_path.default.join(__dirname, 'css', 'franz.css')); + Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); }; -- cgit v1.2.3-54-g00ecf