<commit_before>Dagaz.Sounds = [];

Dagaz.Sounds.move  = 0;
Dagaz.Sounds.drop  = 1;
Dagaz.Sounds.win   = 2;
Dagaz.Sounds.lose  = 3;
Dagaz.Sounds.draw  = 4;
Dagaz.Sounds.page  = 5;

(function() {

var sounds  = [];
var current = null;

function Sound(src) {
    this.sound = document.createElement("audio");
    this.sound.src = src;
    this.sound.setAttribute("preload", "auto");
    this.sound.setAttribute("controls", "none");
    this.sound.style.display = "none";
    document.body.appendChild(this.sound);
    this.play = function(){
        this.sound.play();
    }
    this.stop = function(){
        this.sound.pause();
    }
}

Dagaz.Controller.addSound = function(ix, src) {
    sounds[ix] = src;
}

Dagaz.Controller.play = function(ix) {
    Dagaz.Controller.stop();
    if ((current === null) && !_.isUndefined(sounds[ix])) {
         current = new Sound(sounds[ix]);
         current.play();
    }
}

Dagaz.Controller.stop = function() {
    if (current !== null) {
        current.stop();
        current = null;
    }
}

})();

Dagaz.Controller.addSound(Dagaz.Sounds.move, "../sounds/clack.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.drop, "../sounds/on.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.win,  "../sounds/win.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.page, "../sounds/page.wav");<commit_msg>sound-manager (sounds)<commit_after>Dagaz.Sounds = [];

Dagaz.Sounds.move  = 0;
Dagaz.Sounds.drop  = 1;
Dagaz.Sounds.win   = 2;
Dagaz.Sounds.lose  = 3;
Dagaz.Sounds.draw  = 4;
Dagaz.Sounds.page  = 5;

(function() {

var sounds  = [];
var current = null;

function Sound(src) {
    this.sound = document.createElement("audio");
    this.sound.src = src;
    this.sound.setAttribute("preload", "auto");
    this.sound.setAttribute("controls", "none");
    this.sound.style.display = "none";
    document.body.appendChild(this.sound);
    this.play = function(){
        this.sound.play();
    }
    this.stop = function(){
        this.sound.pause();
    }
}

Dagaz.Controller.addSound = function(ix, src) {
    sounds[ix] = src;
}

Dagaz.Controller.play = function(ix) {
    Dagaz.Controller.stop();
    if ((current === null) && !_.isUndefined(sounds[ix])) {
         current = new Sound(sounds[ix]);
         current.play();
    }
}

Dagaz.Controller.stop = function() {
    if (current !== null) {
        current.stop();
        current = null;
    }
}

})();

Dagaz.Controller.addSound(Dagaz.Sounds.move, "../sounds/clack.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.drop, "../sounds/on.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.win,  "../sounds/tadam.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.lose, "../sounds/loss.wav");
Dagaz.Controller.addSound(Dagaz.Sounds.draw, "../sounds/draw.ogg");
Dagaz.Controller.addSound(Dagaz.Sounds.page, "../sounds/page.wav");
{'fraction_non_alphanumeric': 0.18998211091234346, 'fraction_numerical': 0.004293381037567084, 'mean_word_length': 3.179372197309417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4128125', 'n_tokens_mistral': 1063, 'n_tokens_neox': 1032, 'n_words': 144}