Skip to content
Snippets Groups Projects
Commit 00821240 authored by AA2875's avatar AA2875
Browse files

Hyperlinkki toimii + yht. vapaan alotus kokeilu

parent 25311022
No related branches found
No related tags found
No related merge requests found
...@@ -64,14 +64,15 @@ function createJumpListItem(jump) { ...@@ -64,14 +64,15 @@ function createJumpListItem(jump) {
} }
return li return li
} }
var totalFalltime = 0
function jumpItemFullInfo(jump) { function jumpItemFullInfo(jump) {
totalFalltime += parseInt(jump.falltime)
const specs = [ const specs = [
'Paikka: ' + jump.place, 'Paikka: ' + jump.place,
'Lentokone: ' + jump.plane, 'Lentokone: ' + jump.plane,
'Päävarjo: ' + jump.canopy, 'Päävarjo: ' + jump.canopy,
'Korkeus: ' + jump.height + ' m', 'Korkeus: ' + jump.height + ' m',
'Vapaapudotusaika: ' + jump.falltime + ' s', 'Vapaapudotusaika: ' + jump.falltime + ' s ' + `(yht. ${totalFalltime} s)`,
jump.comments, jump.comments,
jump.link jump.link
] ]
...@@ -81,20 +82,40 @@ function jumpItemFullInfo(jump) { ...@@ -81,20 +82,40 @@ function jumpItemFullInfo(jump) {
ul.setAttributeNode(ulClass) ul.setAttributeNode(ulClass)
let ulStyle = document.createAttribute('style') let ulStyle = document.createAttribute('style')
ulStyle.value = 'display: none;' ulStyle.value = 'display: none;'
ul.setAttributeNode(ulStyle) ul.setAttributeNode(ulStyle)
specs.forEach(spec => { specs.forEach((spec, index, specs) => {
if (spec != '') { let li = document.createElement('li')
let li = document.createElement('li') let jumpSpec = document.createTextNode(spec)
let jumpSpec = document.createTextNode(spec) if (index === specs.length - 1 && spec != '' && spec != undefined) {
li.appendChild(createHyperlink(spec))
ul.appendChild(li)
}
else if (spec != '') {
li.appendChild(jumpSpec) li.appendChild(jumpSpec)
ul.appendChild(li) ul.appendChild(li)
} }
}); })
ul.appendChild(createDeleteButton(jump)) ul.appendChild(createDeleteButton(jump))
return ul return ul
} }
function createHyperlink(link) {
if (link.slice(0,4) != 'http') {
link = `https://${link}`
}
let a = document.createElement('a')
let href = document.createAttribute('href')
href.value = link
a.setAttributeNode(href)
let target = document.createAttribute('target')
target.value = '_blank'
a.setAttributeNode(target)
let linkText = document.createTextNode(link)
a.appendChild(linkText)
return a
}
function createDeleteButton(jump) { function createDeleteButton(jump) {
let deleteDiv = document.createElement('div') let deleteDiv = document.createElement('div')
let delDivClass = document.createAttribute('class') let delDivClass = document.createAttribute('class')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment