si = require('systeminformation') window.addEventListener('load', () -> # 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() # Start running our function to update the drive's temperature setDiskTemp() , false) loadDisks = () -> si.diskLayout() .then((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) ) setDiskTemp = (diskId = -1) -> selector = document.getElementById('diskSelector') if selector.length < 1 return if (diskId = -1) diskId = selector.value si.diskLayout() .then((data) -> if (data[diskId].temperature) document.getElementById('diskTemp').innerText = data[diskId].temperature ).catch((error) -> console.error(error) ) setTimeout(setDiskTemp, 2000)