-
Notifications
You must be signed in to change notification settings - Fork 7
/
renderer-pireg.js
48 lines (43 loc) · 1.38 KB
/
renderer-pireg.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
const ipc = require('electron').ipcRenderer;
const $ = jQuery = require('jquery');
const remote = require('electron').remote;
const app = remote.app;
const fs = require('fs');
const path = require('path');
let lang = {};
$('#cancel').click(function () {
let window = remote.getCurrentWindow();
window.close();
});
$('#save').click(function () {
let window = remote.getCurrentWindow();
ipc.send('piregchange', {
PIRegulatorIsEnabled: $('#PIRegulatorIsEnabled').is(':checked'),
PIRegulatorRange: $('#PIRegulatorRange').val(),
PIRegulatorPValue: $('#PIRegulatorPValue').val(),
PIRegulatorIValue: $('#PIRegulatorIValue').val()
});
window.close();
});
ipc.on('data', (event, data) => {
$('#PIRegulatorIsEnabled').prop('checked', data.PIRegulatorIsEnabled);
$('#PIRegulatorRange').val(data.PIRegulatorRange);
$('#PIRegulatorPValue').val(data.PIRegulatorPValue);
$('#PIRegulatorIValue').val(data.PIRegulatorIValue);
});
function uiTranslate() {
try {
const fp = path.join(__dirname, 'i18n', app.getLocale() + '.json');
lang = JSON.parse(fs.readFileSync(fp).toString());
} catch (err) {
return;
}
$('[data-lang]').each(function () {
const key = $(this).data('lang');
const phrase = lang[key];
if (phrase) {
$(this).html(phrase);
}
});
}
uiTranslate();