play sound for poweron and toggle switches. TODO: refactor code to play sound for stateless switches
This commit is contained in:
parent
da820a4fe6
commit
6656bb7f66
|
@ -570,6 +570,10 @@
|
||||||
<div id="mem-dump"></div>
|
<div id="mem-dump"></div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
<audio id="sound-beepbeep" src="media/beepbeep.mp3"></audio>
|
||||||
|
<audio id="sound-switch" src="media/switch.mp3"></audio>
|
||||||
|
<audio id="sound-toggle" src="media/toggle.mp3"></audio>
|
||||||
|
|
||||||
<script src="js/l10n.js"></script>
|
<script src="js/l10n.js"></script>
|
||||||
<script src="js/8080.js"></script>
|
<script src="js/8080.js"></script>
|
||||||
<script src="js/sim8800.js"></script>
|
<script src="js/sim8800.js"></script>
|
||||||
|
|
23
js/panel.js
23
js/panel.js
|
@ -508,6 +508,24 @@ panel.debugLoadData = function() {
|
||||||
panel.sim.loadDataAsHexString(0, data);
|
panel.sim.loadDataAsHexString(0, data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
panel.playSound = function(id) {
|
||||||
|
var sound = document.getElementById(id);
|
||||||
|
sound.currentTime = 0;
|
||||||
|
sound.play();
|
||||||
|
};
|
||||||
|
|
||||||
|
panel.playBeepbeep = function() {
|
||||||
|
panel.playSound('sound-beepbeep');
|
||||||
|
};
|
||||||
|
|
||||||
|
panel.playToggle = function() {
|
||||||
|
panel.playSound('sound-toggle');
|
||||||
|
};
|
||||||
|
|
||||||
|
panel.playSwitch = function() {
|
||||||
|
panel.playSound('sound-switch');
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new LED inside the panel svg.
|
* Creates a new LED inside the panel svg.
|
||||||
* @param {string} id The LED ID. This ID will be used as the prefix
|
* @param {string} id The LED ID. This ID will be used as the prefix
|
||||||
|
@ -600,11 +618,13 @@ panel.createSwitch = function(id, type, x, y) {
|
||||||
var sourceId = id;
|
var sourceId = id;
|
||||||
upElem.addEventListener('click',
|
upElem.addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
|
panel.playToggle();
|
||||||
panel.onToggle(sourceId, 1);
|
panel.onToggle(sourceId, 1);
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
downElem.addEventListener('click',
|
downElem.addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
|
panel.playToggle();
|
||||||
panel.onToggle(sourceId, 0);
|
panel.onToggle(sourceId, 0);
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
|
@ -766,6 +786,9 @@ panel.onReset = function() {
|
||||||
*/
|
*/
|
||||||
panel.onPowerOn = function() {
|
panel.onPowerOn = function() {
|
||||||
panel.sim.powerOn();
|
panel.sim.powerOn();
|
||||||
|
window.setTimeout(function() {
|
||||||
|
panel.playBeepbeep();
|
||||||
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user