si = require('systeminformation') window.onload = () -> # Set the option selector to trigger an info grab on element change document.getElementById('diskSelector').addEventListener('change', () -> updateDiskInfo(@value) ) # Load GPUs into the selector loadDisks() # Run the updateGpuInfo function with the default value of 0 updateDiskInfo() loadDisks = () -> si.diskLayout() .then((data) -> console.log(data) i = 0 while i < data.length optionElem = document.createElement('option') diskName = data[i].name + '(' + data[i].device + ')' optionElem.innerText = diskName optionElem.setAttribute('value', i) document.getElementById('diskSelector').appendChild(optionElem) i++ ).catch((error) -> console.error(error) ) updateDiskInfo = (diskId = 0) -> si.diskLayout() .then((data) -> document.getElementById('diskInfo').innerText = data[diskId].name document.getElementById('diskPath').innerText = data[diskId].device document.getElementById('diskType').innerText = data[diskId].type document.getElementById('diskSize').innerText = formatBytes(data[diskId].size) document.getElementById('diskVendor').innerText = data[diskId].vendor ).catch((error) -> console.error(error) )