-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer2.js
71 lines (60 loc) · 2.31 KB
/
renderer2.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
66
67
68
69
70
71
const { getGlobal } = require('electron').remote;
const { remote } = require('electron');
const { writeFile } = require('fs');
const {join} = require('path')
let reload_button;
window.onload = function() {
let to_hide = getGlobal('sharedObj').noKey & getGlobal('sharedObj').noPath
reload_button = document.getElementById('retour')
reload_button.disabled = to_hide
reload_button.addEventListener('click', () => {
remote.getCurrentWindow().loadURL(join('file://', __dirname, 'index.html'));
})
save_button = document.getElementById('save')
key_area = document.getElementById('inputKey')
key_area.value = getGlobal('sharedObj')['key']
save_button.addEventListener('click', () => {
if(key_area.value != ""){
getGlobal('sharedObj').noKey = false;
getGlobal('sharedObj').key = key_area.value;
save_dict(getGlobal('sharedObj'));
make_green(key_area);
if(getGlobal('sharedObj').noPath == false){
remote.getCurrentWindow().loadURL(join('file://', __dirname, 'index.html'));
}
}
else{
make_red(key_area);
}
})
pathzone = document.getElementById('path')
curpath = document.getElementById('curpath')
curpath.innerText = "Chemin courant : " + getGlobal('sharedObj')['path']
pathzone.onchange = function() {
getGlobal('sharedObj').noPath = false;
getGlobal('sharedObj').path = pathzone.files[0].path;
curpath.innerText = "Chemin courant : " + getGlobal('sharedObj')['path']
save_dict(getGlobal('sharedObj'));
console.dir(pathzone)
if(getGlobal('sharedObj').noKey === false){
remote.getCurrentWindow().loadURL(join('file://', __dirname, 'index.html'));
}
};
}
var save_dict = (dictstring)=>{
var dictstring = JSON.stringify(dictstring);
writeFile("config.json", dictstring, function(err, result) {
if(err) console.log('error', err);
});
writeFile("config.json", dictstring, function(err, result) {
if(err) console.log('error', err);
});
}
var make_red = (area) => {
area.classList.add("is-invalid");
area.classList.remove("is-valid");
}
var make_green = (area) => {
area.classList.add("is-valid");
area.classList.remove("is-invalid");
}