-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.js
40 lines (35 loc) · 1.07 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
const list = document.getElementById('list');
//loop trough the rpcs folder
fs.readdir('./rpcs', (err, files) => {
files.forEach(file => {
//read the file
fs.readFile('./rpcs/'+file, 'utf8', (err, data) => {
if(err) {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: err
})
}
//parse the file
try{
data = JSON.parse(data);
const li = document.createElement('li');
const button = document.createElement('button');
button.innerHTML = data.name;
button.ondblclick = () => {
select(file);
}
li.id = file;
li.appendChild(button);
list.appendChild(li);
} catch (err) {
Swal.fire({
icon: 'error',
title: 'Oops...',
text: file + " : " + err
})
}
});
})
});