From 5a2f1a26857f654aeabc34c1be28b428d97dc046 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 27 Aug 2023 11:32:43 +0900 Subject: [PATCH] Support string song id --- public/src/js/search.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/src/js/search.js b/public/src/js/search.js index c3a8fc0..939b9e9 100644 --- a/public/src/js/search.js +++ b/public/src/js/search.js @@ -498,6 +498,10 @@ class Search{ } proceed(songId){ + if (/^-?\d+$/.test(songId)) { + songId = parseInt(songId) + } + var song = this.songSelect.songs.find(song => song.id === songId) this.remove() this.songSelect.playBgm(false) @@ -603,7 +607,7 @@ class Search{ }else if(e.which === 1){ var songEl = e.target.closest(".song-search-result") if(songEl){ - var songId = parseInt(songEl.dataset.songId) + var songId = songEl.dataset.songId this.proceed(songId) } } @@ -642,7 +646,7 @@ class Search{ } }else if(name === "confirm"){ if(Number.isInteger(this.active)){ - this.proceed(parseInt(this.results[this.active].dataset.songId)) + this.proceed(this.results[this.active].dataset.songId) }else{ this.onInput() if(event.keyCode === 13 && this.songSelect.touchEnabled){