Skip to content

Commit

Permalink
fix: removing current index item
Browse files Browse the repository at this point in the history
  • Loading branch information
pxeemo committed Dec 6, 2024
1 parent 054da49 commit bae6164
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ parseBtn.addEventListener('click', () => {

function nextItem() {
if (currentIndex < itemsList.length - 1) {
currentIndex += 1
currentIndex++
const currentTime = audio.currentTime
const item = itemsList[currentIndex]
item.children[0].children[1].innerText = formatTime(currentTime)
item.dataset.time = currentTime
item.addEventListener('click', () => {
if (item.dataset.time !== undefined) {
if (typeof item.dataset.time != "undefined") {
audio.currentTime = item.dataset.time
}
})
Expand Down Expand Up @@ -226,7 +226,7 @@ function prevItem() {
})
audio.currentTime = prevItemElement.dataset.time
}
currentIndex -= 1
currentIndex--
}
}

Expand Down Expand Up @@ -273,8 +273,8 @@ editItemRemove.addEventListener('click', () => {
const index = editItemIndex.value
itemsList[index].classList.add('hidden')
itemsList = itemsList.filter((e) => e != itemsList[index])
if (currentIndex > index) {
currentIndex -= 1
if (currentIndex >= index) {
currentIndex--
}
hideModal()
})
Expand All @@ -296,7 +296,7 @@ dlFileBtn.addEventListener('click', () => {
let text = ''
itemsList.forEach((item) => {
const time = item.dataset.time
if (time !== undefined) {
if (typeof time != "undefined") {
text += `[${formatTime(time)}]`
}
text += `${item.children[1].innerText}\n`
Expand Down

0 comments on commit bae6164

Please sign in to comment.