aboutsummaryrefslogtreecommitdiff
path: root/extension/junction.js
diff options
context:
space:
mode:
authorRuben Knol <c.minor6@gmail.com>2020-09-27 16:57:24 +0000
committerRuben Knol <c.minor6@gmail.com>2020-09-27 16:57:24 +0000
commitcdeb0efb1e64bd059c0bf8af0cf89c24200d9468 (patch)
treea9644889942942f899a69016f3c2e0046350ef3d /extension/junction.js
parentad7fccbee23e7ab0348bee23a12401fbc650acd2 (diff)
parente3dca99b9461e2b0fc8f918e6ec2b5212060a8ac (diff)
Merge branch 'babel-setup' into 'main'
Build system See merge request rbdr/junction!3
Diffstat (limited to 'extension/junction.js')
-rw-r--r--extension/junction.js91
1 files changed, 0 insertions, 91 deletions
diff --git a/extension/junction.js b/extension/junction.js
deleted file mode 100644
index e78a02b..0000000
--- a/extension/junction.js
+++ /dev/null
@@ -1,91 +0,0 @@
-const internals = {
-
- promisesSupported: !!(window.browser),
- isInCallState: false,
-
- icons: {
- call: {
- 16: 'icons/action-16.png',
- 32: 'icons/action-32.png'
- },
-
- hangUp: {
- 16: 'icons/hang_up-16.png',
- 32: 'icons/hang_up-32.png'
- }
- },
-
- onClick() {
- if (internals.isInCall()) {
- return internals.hangUp();
- }
-
- return internals.joinAudioCall();
- },
-
- async joinAudioCall() {
-
- internals.isInCallState = true;
- internals.setIcon('hangUp');
- const activeTabs = await internals.getActiveTabs();
-
- console.log(activeTabs[0].url); // placeholder while we connect backend.
- internals.createAudioElement(internals.getRoot().runtime.getURL('sounds/tada.wav'));
- },
-
- hangUp() {
-
- document.querySelectorAll('audio').forEach((audioElement) => audioElement.remove());
- internals.setIcon('call');
- internals.isInCallState = false;
- },
-
- createAudioElement(source, type = 'audio/wav') {
-
- const audioElement = document.createElement('audio');
- audioElement.src = source;
- audioElement.autoplay = 'autoplay';
- audioElement.type = type;
- document.querySelector('body').appendChild(audioElement);
- },
-
- isInCall() {
- return internals.isInCallState; // this should be replaced with actually checking the built stuff
- },
-
- setIcon(iconSet) {
-
- internals.getRoot().browserAction.setIcon({
- path: internals.icons[iconSet]
- });
- },
-
- getRoot() {
-
- return window.browser || window.chrome;
- },
-
- // Chrome doesn't yet implement the promise based tabs.query :'(
-
- getActiveTabs() {
-
- const query = {
- currentWindow: true,
- active: true
- };
-
- if (internals.promisesSupported) {
- return internals.getRoot().tabs.query(query);
- }
-
- return new Promise((resolve, reject) => {
-
- internals.getRoot().tabs.query(query, (tabs) => {
-
- return resolve(tabs);
- });
- });
- },
-};
-
-internals.getRoot().browserAction.onClicked.addListener(internals.onClick);