Assorted cleaning

master
William Toohey 10 years ago
parent e7eb724f73
commit 235a4f2a86
  1. 26
      js/HuesCore.js
  2. 11
      js/HuesUI.js

@ -80,8 +80,7 @@ function HuesCore(defaults) {
*
* Called on every new beat.
* beatString is a 256 char long array of current and upcoming beat chars
* beatIndex is a "safe to display" beat index. 0 during buildups,
* index % beatmap length otherwise.
* beatIndex is the beat index. Negative during buildups
*/
beat : [],
/* callback invert(isInverted)
@ -172,13 +171,16 @@ function HuesCore(defaults) {
document.onkeydown = function(e){
e = e || window.event;
if(e.defaultPrevented) {
return true;
}
// Ignore modifiers so we don't steal other events
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
return true;
}
// If we've focused a text input, let the input go through!
if(document.activeElement.tagName.toLowerCase() == "input" &&
document.activeElement.type == "text") {
if((e.target.tagName.toLowerCase() == "input" && e.target.type == "text")
|| e.target.contentEditable === "true") {
return true;
}
var key = e.keyCode || e.which;
@ -281,14 +283,22 @@ HuesCore.prototype.animationLoop = function() {
this.callEventListeners("frame");
};
HuesCore.prototype.getSafeBeatIndex = function() {
HuesCore.prototype.getBeatIndex = function() {
if(!this.soundManager.playing) {
return 0;
} else if(this.beatIndex < 0) {
return this.beatIndex;
} else {
return this.beatIndex % this.currentSong.rhythm.length;
}
if(this.beatIndex < 0) {
}
HuesCore.prototype.getSafeBeatIndex = function() {
var index = this.getBeatIndex();
if(index < 0) {
return 0;
} else {
return this.beatIndex % this.currentSong.rhythm.length;
return index;
}
};
@ -549,7 +559,7 @@ HuesCore.prototype.getBeat = function(index) {
};
HuesCore.prototype.beater = function(beat) {
this.callEventListeners("beat", this.getBeatString(), this.getSafeBeatIndex());
this.callEventListeners("beat", this.getBeatString(), this.getBeatIndex());
switch(beat) {
case 'X':
case 'x':

@ -419,6 +419,9 @@ RetroUI.prototype.newColour = function(colour) {
RetroUI.prototype.beat = function(beats, index) {
var rest = beats.slice(1);
this.beatBar.textContent = ">>" + rest;
if(index < 0) {
index = 0;
}
this.beatCount.textContent = "B=" + this.intToHex4(index);
};
@ -480,7 +483,10 @@ WeedUI.prototype.beat = function(beats, index) {
this.beatLeft.textContent = rest;
this.beatRight.textContent = rest;
if(index < 0) {
index = 0;
}
this.beatCount.textContent = "B=" + this.intToHex4(index);
if(["x", "o", "X", "O"].indexOf(beats[0]) != -1) {
@ -744,6 +750,9 @@ ModernUI.prototype.beat = function(beats, index) {
span.textContent = this.currentBeat;
this.beatCenter.appendChild(span);
}
if(index < 0) {
index = 0;
}
this.beatCount.textContent = "B=" + this.intToHex4(index);
};

Loading…
Cancel
Save