Sentry/assets/coffee/sentry.coffee

46 lines
1.1 KiB
CoffeeScript
Raw Normal View History

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++
)
@openTab = (tab) ->
2022-10-29 01:14:08 -04:00
# show the component info that's selected
tabs = document.querySelectorAll('.tab-button')
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')
else
displays[i].classList.remove('active')
2022-10-29 01:14:08 -04:00
tabs[i].classList.remove('active')
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]