Skip to content

Commit

Permalink
Fix duplication in the ports select list when you hit refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
noisymime committed Jan 3, 2019
1 parent 03ec201 commit 11f1aa7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {ipcRenderer} = require("electron")
function refreshSerialPorts()
{
serialport.list((err, ports) => {
console.log('ports', ports);
console.log('Serial ports found: ', ports);
if (err) {
document.getElementById('serialDetectError').textContent = err.message
return
Expand All @@ -19,9 +19,9 @@ function refreshSerialPorts()
select = document.getElementById('portsSelect');

//Clear the current options
for (i = 0; i < select.length; i++)
for (i = 0; i <= select.options.length; i++)
{
select.options[i] = null;
select.remove(0); //Always 0 index (As each time an item is removed, everything shuffles up 1 place)
}

//Load the current serial values
Expand All @@ -30,7 +30,7 @@ function refreshSerialPorts()
var newOption = document.createElement('option');
newOption.value = ports[i].comName;
newOption.innerHTML = ports[i].comName;
select.appendChild(newOption);
select.add(newOption);
}
var button = document.getElementById("btnInstall")
if(ports.length > 0)
Expand Down

0 comments on commit 11f1aa7

Please sign in to comment.