mirror of
https://github.com/2ec0b4/kaamelott-soundboard.git
synced 2025-12-09 16:05:35 +00:00
Filtrage lors de l'aléatoire
This commit is contained in:
@@ -29,6 +29,7 @@ define("views/sounds", function(require) {
|
||||
this.channel.request("getSounds").then(this.initCollection.bind(this));
|
||||
this.channel.on("sounds:filter", this.filterCollection.bind(this));
|
||||
this.channel.on("sounds:random", this.randomSound.bind(this));
|
||||
this.channel.on("sounds:reset", this.resetCollection.bind(this));
|
||||
},
|
||||
onBeforeRender: function() {
|
||||
var sound;
|
||||
@@ -53,17 +54,29 @@ define("views/sounds", function(require) {
|
||||
|
||||
this.render();
|
||||
},
|
||||
filterCollectionByCid: function(cid) {
|
||||
this.collection = this.data.collection.filterByCid(cid);
|
||||
|
||||
this.render();
|
||||
},
|
||||
manageSounds: function(args) {
|
||||
this.stopPlayingSound();
|
||||
|
||||
Radio.channel("Sounds").trigger("sound:play", args.model.getSlug());
|
||||
},
|
||||
randomSound: function() {
|
||||
this.filterCollection("");
|
||||
var index = Math.floor(Math.random() * Math.floor(this.collection.length));
|
||||
var sound = this.collection.models[index];
|
||||
this.filterCollectionByCid(sound.cid);
|
||||
|
||||
Radio.channel("Sounds").trigger("sound:play", sound.getSlug());
|
||||
// sound.play();
|
||||
sound.play();
|
||||
},
|
||||
resetCollection: function() {
|
||||
this.filterCollection("");
|
||||
|
||||
Radio.channel("Sounds").trigger("sound:stop");
|
||||
},
|
||||
stopPlayingSound: function() {
|
||||
var playingSound = this.collection.findWhere({playing: true});
|
||||
|
||||
Reference in New Issue
Block a user