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

Kokonais vapaapudotusaika ja #nro Poistetaan...

parent 00821240
No related branches found
No related tags found
No related merge requests found
......@@ -130,7 +130,9 @@ function createDeleteButton(jump) {
function cancelDelete(id) {
let jumpItem = document.getElementById(id)
jumpItem.innerHTML = 'Poistetaan...'
let jumpIndex = jumpsJSON.findIndex(jump => jump._id === id)
let jumpNumber = jumpsJSON[jumpIndex].number
jumpItem.innerHTML = `#${jumpNumber} Poistetaan...`
let cancelButtonSpan = document.createElement('span')
let cancelButtonSpanClass = document.createAttribute('class')
cancelButtonSpanClass.value = 'cancelDeleteButton'
......@@ -160,12 +162,12 @@ function showJumps(jumps) {
if (jumps.length === 0) {
infoText.innerHTML = 'Ei hyppyjä'
} else {
if (jumpOrder == 'asc') {
if (jumpOrder == 'desc') {
jumps.sort((a, b) => a.number - b.number)
} else {
jumps.sort((a, b) => b.number - a.number)
}
jumps.forEach(jump => {
jumps.reverse().forEach(jump => {
let li = createJumpListItem(jump)
jumpsList.appendChild(li)
})
......@@ -178,11 +180,11 @@ function changeJumpOrder() {
let button = document.getElementById('sortJumpsButton')
if (button.innerHTML == 'Järjestys ▼') {
button.innerHTML = 'Järjestys ▲'
jumpOrder = 'asc'
jumpOrder = 'desc'
showJumps(jumpsJSON)
} else {
button.innerHTML = 'Järjestys ▼'
jumpOrder = 'desc'
jumpOrder = 'asc'
showJumps(jumpsJSON)
}
}
......@@ -270,7 +272,7 @@ async function removeJump(id) {
}
function removeLocally(id) {
var index = jumpsJSON.findIndex(jump => jump._id === id);
var index = jumpsJSON.findIndex(jump => jump._id === id)
if (index > -1) {
jumpsJSON.splice(index, 1)
}
......
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