2018-01-31 15:42:11 +00:00
|
|
|
|
2016-06-19 00:15:41 +00:00
|
|
|
var devices = {};
|
|
|
|
|
|
|
|
devices.init = function () {
|
|
|
|
'use strict';
|
|
|
|
devices.listen();
|
|
|
|
gui.overlay(true);
|
|
|
|
gui.spinner(true);
|
|
|
|
};
|
|
|
|
devices.listen = function () {
|
|
|
|
'use strict';
|
2018-01-09 18:01:19 +00:00
|
|
|
|
|
|
|
ipcRenderer.on('ready', devices.ready);
|
2018-01-31 15:42:11 +00:00
|
|
|
ipcRenderer.on('intval', devices.intvalCb);
|
2016-06-19 00:15:41 +00:00
|
|
|
};
|
2018-01-09 18:01:19 +00:00
|
|
|
devices.ready = function (event, arg) {
|
2016-06-19 00:15:41 +00:00
|
|
|
'use strict';
|
2018-01-09 18:01:19 +00:00
|
|
|
let opt;
|
2018-01-31 15:42:11 +00:00
|
|
|
let devs = [];
|
2016-06-19 00:15:41 +00:00
|
|
|
gui.spinner(false);
|
|
|
|
gui.overlay(false);
|
2018-01-09 18:01:19 +00:00
|
|
|
for (let i in arg) {
|
2018-01-31 15:42:11 +00:00
|
|
|
if (arg[i] !== '/dev/fake') {
|
|
|
|
devs.push(arg[i]);
|
|
|
|
}
|
2018-01-09 18:01:19 +00:00
|
|
|
opt = $('<option>');
|
|
|
|
opt.val(arg[i]);
|
|
|
|
opt.text(arg[i]);
|
|
|
|
$(`#${i}_device`).empty();
|
|
|
|
$(`#${i}_device`).append(opt);
|
|
|
|
}
|
2018-01-31 15:42:11 +00:00
|
|
|
if (devs.length > 0) {
|
|
|
|
$('#devices').empty();
|
|
|
|
for (let i of devs) {
|
|
|
|
opt = $('<option>');
|
|
|
|
opt.val(i);
|
|
|
|
opt.text(i);
|
|
|
|
$('#devices').append(opt);
|
|
|
|
}
|
|
|
|
}
|
2018-01-09 18:01:19 +00:00
|
|
|
return event.returnValue = true;
|
2016-06-19 00:15:41 +00:00
|
|
|
};
|
|
|
|
|
2018-01-31 15:42:11 +00:00
|
|
|
devices.intval = function () {
|
|
|
|
'use strict';
|
|
|
|
const url = $('#intval').val()
|
|
|
|
let proceed = false
|
|
|
|
let obj = {
|
|
|
|
connect: true,
|
|
|
|
url : url
|
|
|
|
}
|
|
|
|
if ( url !== '' && typeof url !== 'undefined') {
|
|
|
|
proceed = confirm(`Are you sure you want to connect to INTVAL3 ${url}?`)
|
|
|
|
} else {
|
|
|
|
alert('Cannot connect to INTVAL3 url as entered.')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (proceed) {
|
|
|
|
gui.overlay(true);
|
|
|
|
gui.spinner(true);
|
|
|
|
ipcRenderer.send('intval', obj)
|
|
|
|
} else {
|
|
|
|
$('input[name=camera_type][value=arduino]').prop('checked', 'checked');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
devices.intvalCb = function (a, b) {
|
|
|
|
'use strict';
|
|
|
|
console.dir(a);
|
|
|
|
console.dir(b);
|
|
|
|
};
|
|
|
|
|
2016-06-19 00:15:41 +00:00
|
|
|
module.exports = devices;
|