/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ var sfx = {}; function initSFX() { if (localStorage.getItem("alertsound") == null) { localStorage.setItem("alertsound", "sonar"); } var alertNoiseName = localStorage.getItem("alertsound"); sfx = { "alert": new Audio("assets/audio/alert." + alertNoiseName + ".mp3"), "ok": new Audio("assets/audio/ok.mp3"), "error": new Audio("assets/audio/error.mp3") }; } function playSound(sound) { sfx[sound].play(); } initSFX();