fix for search.js split

This commit is contained in:
Bui 2022-03-22 00:44:28 +00:00
parent 7d3cff5cbe
commit f4f0081e3d
2 changed files with 17 additions and 4 deletions

View File

@ -33,6 +33,18 @@ class Search{
loader.screen.appendChild(this.style)
}
normalizeString(string){
string = string
.replace('', '\'').replace('“', '"').replace('”', '"')
.replace('。', '.').replace('', ',').replace('、', ',')
kanaPairs.forEach(pair => {
string = string.replace(pair[1], pair[0])
})
return string.normalize("NFKD").replace(/[\u0300-\u036f]/g, "")
}
perform(query){
var results = []
var filters = {}
@ -79,7 +91,7 @@ class Search{
}
})
query = editedSplit.join(" ").trim().normalize("NFD").replace(/[\u0300-\u036f]/g, "")
query = this.normalizeString(editedSplit.join(" ").trim())
var totalFilters = Object.keys(filters).length
var random = false

View File

@ -94,12 +94,14 @@ class SongSelect{
this.font = strings.font
this.search = new Search(this)
this.songs = []
for(let song of assets.songs){
var title = this.getLocalTitle(song.title, song.title_lang)
song.titlePrepared = title ? fuzzysort.prepare(this.normalizeSearch(title)) : null
song.titlePrepared = title ? fuzzysort.prepare(this.search.normalizeString(title)) : null
var subtitle = this.getLocalTitle(title === song.title ? song.subtitle : "", song.subtitle_lang)
song.subtitlePrepared = subtitle ? fuzzysort.prepare(this.normalizeSearch(subtitle)) : null
song.subtitlePrepared = subtitle ? fuzzysort.prepare(this.search.normalizeString(subtitle)) : null
this.songs.push(this.addSong(song))
}
this.songs.sort((a, b) => {
@ -228,7 +230,6 @@ class SongSelect{
this.currentSongCache = new CanvasCache(noSmoothing)
this.nameplateCache = new CanvasCache(noSmoothing)
this.search = new Search(this)
this.difficulty = [strings.easy, strings.normal, strings.hard, strings.oni]
this.difficultyId = ["easy", "normal", "hard", "oni", "ura"]