2023-04-06 09:49:59 -04:00
|
|
|
shell = require('electron').shell
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () ->
|
|
|
|
links = document.querySelectorAll('a[href^="http"]')
|
|
|
|
i = 0
|
|
|
|
while i < links.length
|
|
|
|
links[i].addEventListener('click', (event) ->
|
|
|
|
event.preventDefault()
|
|
|
|
shell.openExternal(this.href)
|
|
|
|
)
|
|
|
|
i++
|
|
|
|
)
|
|
|
|
|
2022-10-28 01:06:09 -04:00
|
|
|
@openTab = (tab) ->
|
2022-10-29 01:14:08 -04:00
|
|
|
# show the component info that's selected
|
|
|
|
tabs = document.querySelectorAll('.tab-button')
|
2022-10-28 01:06:09 -04:00
|
|
|
displays = document.querySelectorAll('.component-display')
|
|
|
|
i = 0
|
|
|
|
while i < displays.length
|
|
|
|
if displays[i].getAttribute('data-component') == tab
|
|
|
|
displays[i].classList.add('active')
|
2022-10-29 01:14:08 -04:00
|
|
|
tabs[i].classList.add('active')
|
2022-10-28 01:06:09 -04:00
|
|
|
else
|
|
|
|
displays[i].classList.remove('active')
|
2022-10-29 01:14:08 -04:00
|
|
|
tabs[i].classList.remove('active')
|
2022-10-28 01:06:09 -04:00
|
|
|
i++
|
2022-05-26 22:28:59 -04:00
|
|
|
|
|
|
|
@formatBytes = (bytes, decimals = 2) ->
|
|
|
|
if bytes == 0
|
|
|
|
return '0 Bytes'
|
|
|
|
k = 1024
|
|
|
|
dm = if decimals < 0 then 0 else decimals
|
|
|
|
sizes = [
|
|
|
|
'Bytes'
|
|
|
|
'KB'
|
|
|
|
'MB'
|
|
|
|
'GB'
|
|
|
|
'TB'
|
|
|
|
'PB'
|
|
|
|
'EB'
|
|
|
|
'ZB'
|
|
|
|
'YB'
|
|
|
|
]
|
|
|
|
i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
|
|
parseFloat((bytes / k ** i).toFixed(dm)) + ' ' + sizes[i]
|