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

Bump y18n from 4.0.0 to 4.0.1 #33

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
67eb853
Mongo DB communication working
jargetz Sep 13, 2020
ff5404e
Add Twilio Connect Button that hits create-account Twilio Function an…
jargetz Sep 15, 2020
9c37201
Add Twilio Connect Button that hits create-account Twilio Function an…
jargetz Sep 15, 2020
96bdf68
Refactor callbacks intro promise chain
jargetz Sep 18, 2020
161af85
Small cleanup in final then
jargetz Sep 18, 2020
c786857
Add separate create account page and link off of options #22 #19
jargetz Sep 18, 2020
fed8e1c
Rework verify caller ID and access token to support multi tenant mode…
jargetz Sep 21, 2020
a0c7403
Remove Capability token twilio function #19
jargetz Sep 21, 2020
679fa7a
Redirect getAccessToken to master account
jargetz Sep 21, 2020
3071333
Access token changes
jargetz Sep 24, 2020
f9e2be5
Use capability token for calls
jargetz Sep 24, 2020
0d693fc
Debugging access token
jargetz Sep 26, 2020
176dbf5
Rewrite to use auth token and access code from accounts directly, no …
jargetz Sep 28, 2020
5b48741
Add email
jargetz Sep 28, 2020
b11ba8e
end to end working ,add testing
jargetz Sep 29, 2020
233fefa
Modifications after review by Michael
jargetz Sep 29, 2020
73df838
Make campaign code and access code unique, and handle duplicates
jargetz Sep 29, 2020
bb4c3fa
make small ux improvements for account creation
michaelrkn Sep 30, 2020
4abdaa8
Merge pull request #28 from michaelrkn/jg_no_connect
jargetz Sep 30, 2020
30d4e2c
Merge pull request #30 from michaelrkn/ux
michaelrkn Sep 30, 2020
6f1a3cf
remove unnecessary permission from manifest
michaelrkn Sep 30, 2020
7c936d9
Make client-voice public by default
jargetz Oct 5, 2020
3cdc4fc
Fix syntax error in check caller id function and add params check
jargetz Oct 27, 2020
ebefe7d
Fix null access code issue
jargetz Oct 28, 2020
4ac6690
bump extension version
michaelrkn Oct 29, 2020
a7b6f82
add initial nationbuilder support
michaelrkn Feb 13, 2021
2d01a09
add option to disable loading next contact in development
michaelrkn Feb 14, 2021
c00a7de
bump version
michaelrkn Feb 14, 2021
d4313d5
Bump y18n from 4.0.0 to 4.0.1
dependabot[bot] Apr 1, 2021
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
18 changes: 14 additions & 4 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (!inDevelopmentEnvironment()) {
}

var activeTabs = {};
const TWILIO_BASE_URL = "vpb-dialer-5062";

chrome.browserAction.onClicked.addListener(function(tab) {
showInstructions(tab);
Expand Down Expand Up @@ -56,6 +57,10 @@ function getControls(url) {
return 'controls-van.js';
} else if (url.includes('https://phonebank.bluevote.com/Home/PhoneBank?pt=')) {
return 'controls-pdi.js';
} else if (url.includes('nationbuilder.com/admin/custom_lists/')) {
return 'controls-nb.js';
} else if (inDevelopmentEnvironment()) {
return "test-dial.js";
}
}

Expand Down Expand Up @@ -93,8 +98,8 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
var tab = sender.tab.id;
if (message.getCallOnLoad) {
sendResponse(JSON.parse(localStorage.getItem('callOnLoad')));
} else if (message.getDevelopment) {
sendResponse(inDevelopmentEnvironment());
} else if (message.getDisableLoadNextContact) {
sendResponse(disableLoadNextContact());
} else if (message.hangup) {
hangup();
} else if (message.sendDigit) {
Expand Down Expand Up @@ -134,6 +139,7 @@ function authenticateAndSetup(number, tab) {
device.on('ready', prepareToConnect);
device.on('offline', handleOffline);
device.on('error', ((error) => {
chrome.extension.getBackgroundPage().console.log(error);
if (error.code === 31205 || error.code === 31202) { // access token expired
localStorage.removeItem('accessToken');
device.removeListener('ready', prepareToConnect);
Expand All @@ -152,7 +158,7 @@ function getAccessToken() {
var campaignCode = localStorage.getItem('campaignCode');
var accessCode = localStorage.getItem('accessCode');

return fetch('https://' + campaignCode + '.twil.io/access-token?accessCode=' + accessCode)
return fetch('https://' + TWILIO_BASE_URL + '.twil.io/access-token?campaignCode=' + campaignCode + '&accessCode=' + accessCode)
.then((response) => {
return response.json();
})
Expand Down Expand Up @@ -225,6 +231,10 @@ function sendDigit(digit) {
}
}

function disableLoadNextContact() {
return JSON.parse(localStorage.getItem('disableLoadNextContact'));
}

function inDevelopmentEnvironment() {
return chrome.runtime.getManifest().update_url === undefined;
return chrome.runtime.getManifest().update_url !== undefined;
}
126 changes: 126 additions & 0 deletions extension/controls-nb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
scrollToFirstContact();
setupCallInterface();
handleCallResponses();
setupKeyboardShortcuts();
watchForResultsSubmission();
hangupBeforeUnload();

function scrollToFirstContact() {
document.querySelector('.custom_listing').scrollIntoView();
}

function setupCallInterface() {
if (phoneLink()) {
phoneLink().addEventListener('click', (event) => {
event.preventDefault();
confirmCall(formattedPhone());
});

chrome.runtime.sendMessage({ getCallOnLoad: true }, (callOnLoad) => {
if (callOnLoad && formattedPhone()) {
confirmCall(formattedPhone());
}
});
}
}

function phoneLink() {
return document.querySelector("a[href^='tel:']");
}

function formattedPhone() {
return phoneLink().innerText.slice(0, 14);
}

function confirmCall(formattedPhone) {
var dial = confirm('Call ' + formattedPhone + '? Press Enter or click OK to call.');
if (dial) {
var phone = formattedPhone.replace(/\D/g,'');
chrome.runtime.sendMessage({ dial: phone });
}
}

function handleCallResponses() {
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message === 'unanswered') {
notHomeOption().click();
chrome.runtime.sendMessage({ getDisableLoadNextContact: true }, (disableLoadNextContact) => {
if (!disableLoadNextContact) {
goToNextContact();
}
});
} else if (message === 'noCampaignCode') {
alert("You haven't set up the Preview Dialer. Right-click the V icon next to your address bar and choose Options, and then set your campaign code, access code, and phone number.");
} else if (message === 'noOutgoingCallerID') {
alert("You haven't set an outgoing Caller ID. Right-click the V icon next to your address bar and choose Options, and then enter the phone number you'd like to show up when you make calls.");
} else if (message === 'noMicrophonePermissions') {
alert("You haven't given permission to use your microphone. Right-click the V icon next to your address bar and choose Options, and when asked to use your microphone, click Allow.");
}
});
}

function notHomeOption() {
return document.querySelector('input[value="7"]');
}

function goToNextContact() {
hangup();
nextContact().click();
}

function hangup() {
chrome.runtime.sendMessage({ hangup: true });
}

function nextContact() {
return document.querySelector('input[value="Log call and remove from list"]');
}

function setupKeyboardShortcuts() {
document.addEventListener('keypress', (event) => {
if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
return;
}

event.preventDefault();

var keyName = event.key;

if (keyName === 'Enter') {
goToNextContact();
}

if (keyName === 'c' && phoneLink()) {
confirmCall(formattedPhone());
}

if (keyName === 'h') { hangup(); }

if (keyName === 'n') {
document.querySelector('input[value="7"]').click();
}

if (['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '#'].includes(keyName)) {
chrome.runtime.sendMessage({ sendDigit: keyName });
}
});
}

function watchForResultsSubmission() {
var observer = new MutationObserver(function(mutations) {
if (displaysFlashMessage(mutations)) {
location.reload();
}
});
observer.observe(document, { attributes: false, childList: true, characterData: false, subtree: true });
}

function displaysFlashMessage(mutations) {
return mutations[0].target.id === 'flash-container';
}

function hangupBeforeUnload() {
window.addEventListener("beforeunload", (event) => {
hangup();
});
}
4 changes: 2 additions & 2 deletions extension/controls-openvpb.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message === 'unanswered') {
if (!notHomeSelection()) { document.querySelector('.contact-toggle').click(); }
notHomeSelection().click();
chrome.runtime.sendMessage({ getDevelopment: true }, (development) => {
if (!development) {
chrome.runtime.sendMessage({ getDisableLoadNextContact: true }, (disableLoadNextContact) => {
if (!disableLoadNextContact) {
goToNextContact();
}
});
Expand Down
4 changes: 2 additions & 2 deletions extension/controls-pdi.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ function goToNextContact() {
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message === 'unanswered') {
notHomeSelection().click();
chrome.runtime.sendMessage({ getDevelopment: true }, (development) => {
if (!development) {
chrome.runtime.sendMessage({ getDisableLoadNextContact: true }, (disableLoadNextContact) => {
if (!disableLoadNextContact) {
goToNextContact();
}
});
Expand Down
4 changes: 2 additions & 2 deletions extension/controls-van.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ function setupInterface() {
if (reached) { switchButton.click(); }
var element = document.querySelectorAll('input[name="resultCodeId"][value="1"]')[0];
element.click();
chrome.runtime.sendMessage({ getDevelopment: true }, (development) => {
if (!development) {
chrome.runtime.sendMessage({ getDisableLoadNextContact: true }, (disableLoadNextContact) => {
if (!disableLoadNextContact) {
goToNextContact();
}
});
Expand Down
65 changes: 65 additions & 0 deletions extension/create-account.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Virtual Phone Bank Preview Dialer</title>
<link rel="stylesheet" href="vendor/milligram.min.css">
<style>
.container {
padding-bottom: 7.5rem;
padding-top: 3rem;
}
.intro {
text-align: center;
}
.label-inline {
font-weight: 300;
}
input {
font-size: inherit;
}
li {
margin-bottom: 0;
}
label {
font-weight: 500;
}
.single {
max-width: 700px;
}
</style>
</head>
<body>
<div class="container">
<div class="intro">
<h1>Create Account</h1>
</div>
<div class="row">
<div class="column" style="max-width: 700px; margin: auto;">
<form id="create-campaign">
<p>The dialer uses a service called Twilio to make phone calls. <a href="https://www.twilio.com/try-twilio" target="_blank">Click here to set up an account with Twilio.</a> You may need to verify your email and a phone number and answer a couple questions. When you get to your Dashboard, copy your Account SID and Auth Token below.</p>
<p><img src="twilio-dashboard.png" alt="A screenshot of the Twilio Dashboard."></p>
<label for="twilio-account-sid">Twilio Account SID</label>
<input type="text" id="twilio-account-sid">
<label for="twilio-auth-token">Twilio Auth Token</label>
<input type="text" id="twilio-auth-token">

<p>Choose a Campaign Code and Access Code for your account. Write them down so you don't forget them! You'll give these to your team members so they can use the dialer. Anybody who has them can make phone calls on your account, so only give them to people you trust.</p>
<label for="campaign-code">Campaign code</label>
<input type="text" id="campaign-code">
<label for="access-code">Access code</label>
<input type="text" id="access-code">

<p>Please provide your email so that if you have issues with your account, we'll know who you are.</p>
<label for="email">Email</label>
<input type="text" id="email">

<input type="submit" value="Create Account">
</form>
</div>
</div>
</main>
<script src="vendor/sentry.min.js"></script>
<script src="create-account.js"></script>
</body>
</html>
38 changes: 38 additions & 0 deletions extension/create-account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
if (chrome.runtime.getManifest().update_url !== undefined) {
Sentry.init({
dsn: 'https://[email protected]/2650962',
release: '2.0.4'
});
Sentry.configureScope(function(scope) {
scope.setUser({"username": localStorage.getItem('campaignCode')});
});
}

const TWILIO_BASE_URL = "vpb-dialer-5062";

window.onload = () => {
var setupForm = document.getElementById('create-campaign');
setupForm.addEventListener('submit', (event) => {
event.preventDefault();

var campaignCode = document.getElementById('campaign-code').value.replace(" ", "");
var accessCode = document.getElementById('access-code').value.replace(" ", "");
var twilioAccountSid = document.getElementById('twilio-account-sid').value.replace(" ", "");
var twilioAccountAuthToken = document.getElementById('twilio-auth-token').value.replace(" ", "");
var email = document.getElementById('email').value.replace(" ", "");

fetch('https://' + TWILIO_BASE_URL + '.twil.io/create-account?campaignCode=' + campaignCode + '&accessCode=' + accessCode + '&accountSid=' + twilioAccountSid + '&authToken=' + twilioAccountAuthToken + '&email=' + email)
.then((response) => {
return response.json();
})
.then((json) => {
alert(json.message);
localStorage.setItem('campaignCode', campaignCode);
localStorage.setItem('accessCode', accessCode);
localStorage.removeItem('accessToken');
})
.catch((response) => {
alert('Sorry, there was an issue creating your account. Please try again.');
});
});
}
2 changes: 1 addition & 1 deletion extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "VPB Preview Dialer",
"description": "Turns Virtual Phone Bank into a preview dialer.",
"version": "2.0.4",
"version": "2.0.7",
"browser_action": {
"default_icon": {
"16": "icon.png"
Expand Down
16 changes: 15 additions & 1 deletion extension/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
label {
font-weight: 500;
}
#autoLoadOption {
display: none;
}
</style>
</head>
<body>
Expand All @@ -42,7 +45,8 @@ <h2>Setup</h2>
Please give permission to use your microphone,
so that you can make calls through the browser on Virtual Phone Bank.
</p>
<p>Enter the information below from your campaign, so we know which account to use:</p>
<p>Enter the information below from your campaign, so we know which account to use.</p>
<p><a href="/create-account.html" target="_blank">Don't have an account yet? Click here to set up billing.</a></p>
<form id="campaign-setup">
<label for="campaign-code">Campaign code</label>
<input type="text" id="campaign-code">
Expand Down Expand Up @@ -78,6 +82,16 @@ <h2>Options</h2>
<input type="checkbox" id="ringUntilVoicemail">
<label class="label-inline" for="ringUntilVoicemail">Ring until voicemail reached (max 30 seconds)</label>
</div>
<div id="disableLoadNextContactOption">
<p>
Check the box below if you'd like the dialer not to load the next contact after you finish a call.
This is only available in development mode.
</p>
<div>
<input type="checkbox" id="disableLoadNextContact">
<label class="label-inline" for="disableLoadNextContact">Disable load next contact</label>
</div>
</div>
</div>
</div>
</main>
Expand Down
Loading