2018-06-20 18:08:49 +01:00
|
|
|
document.addEventListener 'DOMContentLoaded', (event) ->
|
2018-01-06 19:11:47 +00:00
|
|
|
|
2018-01-06 20:33:54 +00:00
|
|
|
window.mdc.autoInit()
|
|
|
|
window.tabBar = new mdc.tabs.MDCTabBar document.querySelector '#tab-bar'
|
2018-01-06 19:11:47 +00:00
|
|
|
|
2018-01-06 20:33:54 +00:00
|
|
|
# Hide all panels but the selected one
|
|
|
|
activatePanel = (panelId) ->
|
|
|
|
allPanels = document.querySelectorAll '.panel'
|
|
|
|
for panel, i in allPanels
|
|
|
|
if panel.id is panelId
|
|
|
|
tabBar.activeTabIndex = i
|
|
|
|
panel.style.display = if panel.id is panelId then 'block' else 'none'
|
2018-01-06 19:11:47 +00:00
|
|
|
|
2018-01-06 20:33:54 +00:00
|
|
|
# React to clicking the tabs
|
|
|
|
window.tabBar.listen 'MDCTabBar:change', (t) ->
|
|
|
|
nthChildIndex = t.detail.activeTabIndex
|
|
|
|
tabId = t.srcElement.id
|
|
|
|
tab = document.querySelector "##{tabId} .mdc-tab:nth-child(#{nthChildIndex + 1})"
|
|
|
|
panelId = tab.dataset.panel
|
|
|
|
activatePanel panelId
|
|
|
|
|
|
|
|
# If specific tab/panel given in URL, e.g. #motion, switch to that
|
|
|
|
hash = location.hash
|
|
|
|
if hash.length > 1
|
|
|
|
activatePanel 'family-' + hash.substring 1
|
|
|
|
else
|
|
|
|
activatePanel 'family-keyone'
|
2018-01-06 23:55:45 +00:00
|
|
|
|
|
|
|
window.showTooltip = (event) ->
|
2018-02-18 22:31:14 +00:00
|
|
|
tt = document.querySelector '#tooltip'
|
|
|
|
tt_title = document.querySelector '#tooltip-title'
|
|
|
|
tt_text = document.querySelector '#tooltip-text'
|
2018-01-06 23:55:45 +00:00
|
|
|
|
|
|
|
ref = event.target.parentNode.dataset.ref
|
2018-10-26 12:26:08 +01:00
|
|
|
ver = event.target.innerText.trim()
|
2018-01-06 23:55:45 +00:00
|
|
|
|
2018-01-07 20:22:09 +00:00
|
|
|
meta = window.metadata[ref]
|
2018-10-26 12:26:08 +01:00
|
|
|
#console.log("Meta: %o (Ver: %o)", meta, ver)
|
2018-01-07 20:22:09 +00:00
|
|
|
vermeta = meta['versions'][ver]
|
|
|
|
|
2018-01-07 21:32:20 +00:00
|
|
|
updateText = ''
|
2018-01-07 20:22:09 +00:00
|
|
|
if vermeta['FULL'].length > 0
|
|
|
|
fullmeta = vermeta['FULL'][0]
|
|
|
|
fullInfo = "✔️ (first released: #{fullmeta['published_first']})"
|
2018-01-07 21:32:20 +00:00
|
|
|
if fullmeta['note']['en']
|
|
|
|
updateText = fullmeta['note']['en']
|
|
|
|
updateText = updateText.replace /\n/g, '<br/>'
|
|
|
|
#updateText += '<br/><br/>'
|
2018-01-07 20:22:09 +00:00
|
|
|
else
|
|
|
|
fullInfo = "❌"
|
|
|
|
|
|
|
|
if vermeta['OTA'].length > 0
|
|
|
|
fromList = (v['fv'] for v in vermeta['OTA'])
|
2018-02-16 22:50:42 +00:00
|
|
|
fromList = fromList.sort().reverse()
|
|
|
|
fromListText = fromList.join ', '
|
|
|
|
if fromList.length > 3
|
|
|
|
fromMore = fromList.length - 3
|
|
|
|
fromList = fromList[0..2]
|
|
|
|
fromListText = (fromList.join ', ') + " + #{fromMore} more"
|
|
|
|
otaInfo = "✔️ (from #{fromListText})"
|
2018-08-09 17:14:08 +01:00
|
|
|
for v in vermeta['OTA']
|
|
|
|
if v['note']['en'] and updateText is ''
|
|
|
|
updateText = '(' + v['fv'] + ' to ' + v['tv'] + ') '
|
|
|
|
updateText += v['note']['en'].replace /\n/g, '<br/>'
|
2018-01-07 20:22:09 +00:00
|
|
|
else
|
|
|
|
otaInfo = "❌"
|
|
|
|
|
|
|
|
if vermeta['OTA_FROM'].length > 0
|
|
|
|
toList = (v['tv'] for v in vermeta['OTA_FROM'])
|
2018-02-16 22:50:42 +00:00
|
|
|
toList = toList.sort().reverse()
|
|
|
|
toListText = toList.join ', '
|
|
|
|
if toList.length > 3
|
|
|
|
toMore = toList.length - 3
|
|
|
|
toList = toList[0..2]
|
|
|
|
toListText = (toList.join ', ') + " + #{toMore} more"
|
|
|
|
updateInfo = "<strong>OTA possible to #{toListText}</strong>"
|
2018-01-07 20:22:09 +00:00
|
|
|
else
|
2018-01-07 21:32:20 +00:00
|
|
|
updateInfo = "No OTA to future version."
|
2018-01-07 20:22:09 +00:00
|
|
|
|
2018-01-06 23:55:45 +00:00
|
|
|
tt_title.innerHTML = ver
|
2018-01-07 20:22:09 +00:00
|
|
|
tt_text.innerHTML = """
|
2018-01-07 21:32:20 +00:00
|
|
|
for #{ref}<br/>
|
|
|
|
#{meta['variant']}<br/>
|
2018-01-07 20:22:09 +00:00
|
|
|
<br/>
|
|
|
|
FULL: #{fullInfo}<br/>
|
|
|
|
OTA: #{otaInfo}<br/>
|
2018-01-07 21:32:20 +00:00
|
|
|
#{updateInfo}<br/>
|
2018-01-07 20:22:09 +00:00
|
|
|
<br/>
|
2018-01-07 21:32:20 +00:00
|
|
|
#{updateText}
|
2018-01-07 20:22:09 +00:00
|
|
|
"""
|
2018-01-06 23:55:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Show tooltip
|
|
|
|
tt.style.visibility = 'hidden'
|
|
|
|
tt.style.display = 'block'
|
|
|
|
positionTooltip event.clientX + window.scrollX, event.clientY + window.scrollY
|
|
|
|
tt.style.visibility = 'visible'
|
|
|
|
|
|
|
|
window.positionTooltip = (mouseX, mouseY) ->
|
|
|
|
tooltip = document.querySelector '#tooltip'
|
|
|
|
|
|
|
|
#pageHeight = document.documentElement.getBoundingClientRect().height
|
|
|
|
viewportBottom = document.documentElement.clientHeight + document.documentElement.scrollTop
|
|
|
|
viewportRight = document.documentElement.clientWidth + document.documentElement.scrollLeft
|
|
|
|
cursorOffset = 20
|
|
|
|
tooltipHeight = tooltip.clientHeight
|
|
|
|
tooltipWidth = tooltip.clientWidth
|
|
|
|
|
|
|
|
#console.log('Cursor: %o, Planned bottom: %o, Viewport bottom: %o', mouseY, mouseY+cursorOffset+tooltipHeight, viewportBottom)
|
|
|
|
|
|
|
|
# Check if tooltip is outside bottom of document
|
|
|
|
if mouseY + cursorOffset + tooltipHeight >= viewportBottom
|
|
|
|
# show tooltip ABOVE cursor
|
|
|
|
tooltip.style.top = (mouseY - cursorOffset - tooltipHeight) + 'px'
|
|
|
|
else
|
|
|
|
# show tooltip below cursor
|
|
|
|
tooltip.style.top = (mouseY + cursorOffset) + 'px'
|
|
|
|
|
|
|
|
if mouseX + cursorOffset + tooltipWidth >= viewportRight
|
|
|
|
# show tooltip LEFT of cursor
|
2018-06-20 18:08:49 +01:00
|
|
|
leftPos = mouseX - cursorOffset - tooltipWidth
|
|
|
|
if leftPos < 0
|
|
|
|
leftPos = 0
|
|
|
|
tooltip.style.left = leftPos + 'px'
|
2018-01-06 23:55:45 +00:00
|
|
|
else
|
|
|
|
# show tooltip right of cursor
|
|
|
|
tooltip.style.left = (mouseX + cursorOffset) + 'px'
|
|
|
|
|
2018-01-07 20:22:09 +00:00
|
|
|
# Load metadata
|
|
|
|
metadata = {}
|
|
|
|
xhr = new XMLHttpRequest()
|
|
|
|
xhr.open('GET', 'json_updatedetails.php', true);
|
|
|
|
xhr.onreadystatechange = ->
|
|
|
|
if xhr.readyState is 4 and xhr.status is 200
|
|
|
|
window.metadata = JSON.parse xhr.responseText
|
|
|
|
|
|
|
|
# Add event listeners to all versions so tooltips start to work AFTER data was loaded
|
|
|
|
versionitems = document.querySelectorAll '.version'
|
|
|
|
for vi in versionitems
|
|
|
|
vi.addEventListener 'mousemove', (event) ->
|
|
|
|
positionTooltip event.clientX + window.scrollX, event.clientY + window.scrollY
|
|
|
|
vi.addEventListener 'mouseover', (event) ->
|
|
|
|
showTooltip event
|
|
|
|
vi.addEventListener 'mouseout', (event) ->
|
|
|
|
document.querySelector('#tooltip').style.display = 'none'
|
|
|
|
|
|
|
|
snackbar = new mdc.snackbar.MDCSnackbar document.querySelector '.mdc-snackbar'
|
|
|
|
snackbar.show
|
|
|
|
message: 'Update details loaded. Hover a version number to see details.'
|
|
|
|
timeout: 5000
|
|
|
|
|
|
|
|
xhr.send()
|