1
0
mirror of https://github.com/2ec0b4/kaamelott-soundboard.git synced 2025-12-08 23:53:24 +00:00

Filtrage lors de l'aléatoire

This commit is contained in:
Thomas Graviou
2019-10-25 14:25:51 +02:00
parent 0261f2b86b
commit aa163e62e1
5 changed files with 39 additions and 6 deletions

View File

@@ -14,6 +14,15 @@ define("collections/sounds", function(require) {
return str1.localeCompare(str2);
},
filterByCid: function(cid) {
if(cid == "") {
return this;
}
return new Sounds(this.filter(function(data) {
return data.cid == cid;
}));
},
filterByTitle: function(search){
var that = this,
pattern;
@@ -25,7 +34,7 @@ define("collections/sounds", function(require) {
pattern = new RegExp(this.removeDiacritics(search), "gi");
return new Sounds(this.filter(function(data) {
pattern.lastIndex = 0;
return pattern.test(that.removeDiacritics(data.get("title")))
|| pattern.test(that.removeDiacritics(data.get("character")))
|| pattern.test(that.removeDiacritics(data.get("episode")));