Skip to content

Commit

Permalink
Basecamp Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
friedow committed Oct 19, 2016
1 parent 0d05c82 commit 891f857
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 0 deletions.
37 changes: 37 additions & 0 deletions basecamp/css/modal.css
@@ -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 basecamp/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions basecamp/icon.svg
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 basecamp/index.js
@@ -0,0 +1,2 @@
// just pass through Franz
module.exports = Franz => Franz;
23 changes: 23 additions & 0 deletions basecamp/package.json
@@ -0,0 +1,23 @@
{
"name": "meetfranz-basecamp-plugin",
"version": "1.0.0",
"description": "Basecamp plugin for meetfranz.",
"main": "index.js",
"author": "",
"license": "MIT",
"config": {
"serviceURL": "https://launchpad.37signals.com/",
"serviceName": "Basecamp",
"message": "Basecamp plugin for meetfranz.",
"popup": [],
"hasNotificationSound": false,
"hasIndirectMessages": false,
"hasTeamID": false,
"customURL": false,
"hostedOnly": false,
"webviewOptions": {
"disablewebsecurity": ""
},
"openDevTools": false
}
}
59 changes: 59 additions & 0 deletions 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 = '<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);
};

0 comments on commit 891f857

Please sign in to comment.