const ipDiv = document.getElementById('ipDiv');
const logParent = document.getElementById('logParent');
const logDiv = document.getElementById('logDiv');
const dirSelect = document.getElementById('dirSelect')

api.getIps((e,ipList) => {
  if(e) { return }
  ipDiv.innerHTML = ``;
  ipList.map((ip) => {ipDiv.innerHTML+=`${ip}<br/>\n`});
});

lg = (msg) => {
    logDiv.innerHTML+= `${msg}<br/>`;
}

api.handleLg((event, value) => {
    console.log(`Index-app received handleLg event from api: `,value);
    lg(value);
});

dirSelect.onclick = e => {
  api.invokeIpc(`chooseFtpDirectory`).then((result) => {
    if(!result) {console.log(`Nothing selected`); return;}
    logParent.classList.remove('is-hidden');
    dirSelect.classList.add('is-hidden');
    //lg(`Katalog zostal wybrany: ${result}`);
  })
}
