-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (33 loc) · 1.11 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let ipc = require('electron').ipcRenderer;
let urlencode = require('urlencode');
document.addEventListener('DOMContentLoaded',function() {
const twHandler = document.getElementById('twitterId');
const intrst = document.getElementById('interests');
toggleAdvertising(true);
getAdvertiseButton().addEventListener('click', function() {
const button = getAdvertiseButton();
if (button.dataset.advertise !== 'true') {
ipc.send('stop-advertise');
toggleAdvertising(true);
return;
}
const value = twHandler.value.trim();
var interests = intrst.value.trim();
if (value) {
interests = urlencode(interests);
const cardUrl = `https://tengam.org/sociallighthouse?twitterId=${value}&interests=${interests}`;
ipc.send('advertise', cardUrl);
toggleAdvertising(false);
}
});
function toggleAdvertising(enable) {
const button = getAdvertiseButton();
button.dataset.advertise = enable;
twHandler.disabled = !enable;
intrst.disabled = !enable;
button.textContent = enable ? 'Broadcast' : 'Stop broadcast';
}
function getAdvertiseButton() {
return document.getElementById('advertise');
}
});