Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

googlecloud integration #313

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions googlecloud/css/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#franz-modal {
display: none;
position: fixed;
z-index: 9999;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.8);
}

#franz-modal .modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 30%;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}

#franz-modal .close {
color: #aaa;
float: right;
margin-top: -10px;
font-size: 20px;
font-weight: bold;
}

#franz-modal .close:hover,
#franz-modal .close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
Binary file added googlecloud/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions googlecloud/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions googlecloud/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// just pass through Franz
module.exports = Franz => Franz;
23 changes: 23 additions & 0 deletions googlecloud/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "googlecloud",
"version": "1.0.0",
"description": "With Google's free online calendar, it's easy to keep track of life's important events all in one place.",
"main": "index.js",
"author": "joao.carabetta <[email protected]>",
"license": "MIT",
"config": {
"serviceURL": "https://console.cloud.google.com/",
"serviceName": "Google Cloud",
"message": "With Google's free online calendar, it's easy to keep track of life's important events all in one place.",
"popup": [],
"hasNotificationSound": false,
"hasIndirectMessages": false,
"hasTeamID": false,
"customURL": false,
"hostedOnly": false,
"webviewOptions": {
"disablewebsecurity": ""
},
"openDevTools": false
}
}
59 changes: 59 additions & 0 deletions googlecloud/webview.js
Original file line number Diff line number Diff line change
@@ -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 = '<div class="modal-content"><span class="close">&times;</span><p></p></div>';
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);
};