Skip to content

Commit

Permalink
firstSong name now uses fuzzy instead of exact match
Browse files Browse the repository at this point in the history
  • Loading branch information
mon committed Oct 19, 2016
1 parent bdeacc3 commit 3265fb9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/js/HuesCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,16 @@ class HuesCore {

setSongByName(name) {
let songs = this.resourceManager.enabledSongs;
let bestSong = 0;
let bestScore = 0;
for(let i = 0; i < songs.length; i++) {
if(songs[i].title == name) {
return this.setSong(i);
let score = songs[i].title.score(name);
if(score > bestScore) {
bestScore = score;
bestSong = i;
}
}
return this.setSong(0); // fallback
return this.setSong(bestSong);
}

/* To set songs via reference instead of index - used in HuesEditor */
Expand Down
3 changes: 3 additions & 0 deletions src/js/string_score.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3265fb9

Please sign in to comment.