-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrenderer.js
66 lines (52 loc) · 2.42 KB
/
renderer.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
const { ipcRenderer } = require('electron')
const { clipboard } = require('electron')
ipcRenderer.on("addrUpdate", function (event, data) {
const addrText = document.getElementById("addr");
addrText.innerText = data;
});
ipcRenderer.on("status", function (event, data) {
const addrText = document.getElementById("status");
addrText.innerText = data;
//alert("received data")
});
ipcRenderer.invoke('getAddr').then((result) => {
const addrText = document.getElementById("addr");
addrText.innerText = result;
})
document.querySelector('#addrBtn').addEventListener('click', () => {
const address = document.getElementById("addr").innerText;
clipboard.writeText(address)
alert("Copied Address to Clipboard",)
})
document.querySelector('#bind').addEventListener('click', () => {
document.getElementById("bindCls").className = "is-active"
document.getElementById("pbCls").className = " "
document.getElementById("pbDiv").className = "notification is-light tabcontent"
document.getElementById("bindDiv").className = "notification is-light current"
})
document.querySelector('#pb').addEventListener('click', () => {
document.getElementById("bindCls").className = ""
document.getElementById("pbCls").className = "is-active"
document.getElementById("pbDiv").className = "notification is-light current"
document.getElementById("bindDiv").className = "notification is-dark tabcontent"
})
document.querySelector('#publishDiode').addEventListener('click', () => {
const ports = document.getElementById("portP").value.split(" ");
const mode = document.getElementById("methodP").value.toLowerCase();
const remoteAddress = document.getElementById("privAddrP").value;
ipcRenderer.invoke('publish',ports,mode,remoteAddress)
})
document.querySelector('#bindDiode').addEventListener('click', () => {
const ports = document.getElementById("portB").value.split(" ");
const remoteAddress = document.getElementById("privAddrB").value;
ipcRenderer.invoke('bind',ports,remoteAddress)
})
document.querySelector('#disconnect').addEventListener('click', () => {
ipcRenderer.invoke('kill')
})