Fix infinite recursion + minor cleanup

master
William Toohey 10 years ago
parent 5e8b5f6515
commit e69458ec71
  1. 7
      src/js/HuesCore.js
  2. 4
      src/js/ResourceManager.js

@ -420,13 +420,14 @@ HuesCore.prototype.fillBuildup = function() {
}; };
HuesCore.prototype.randomSong = function() { HuesCore.prototype.randomSong = function() {
var index=Math.floor((Math.random() * this.resourceManager.enabledSongs.length)); var songCount = this.resourceManager.enabledSongs.length;
if (index == this.songIndex && this.resourceManager.enabledSongs.length > 1 || this.lastSongArray.indexOf(index) != -1) { var index=Math.floor((Math.random() * songCount));
if (songCount > 1 && (index == this.songIndex || this.lastSongArray.indexOf(index) != -1)) {
this.randomSong(); this.randomSong();
} else { } else {
console.log("Randoming a song!"); console.log("Randoming a song!");
this.setSong(index); this.setSong(index);
var noRepeat = Math.min(5, Math.floor((this.resourceManager.enabledSongs.length / 2))); var noRepeat = Math.min(5, Math.floor(songCount / 2));
while (this.lastSongArray.length > noRepeat && noRepeat >= 0) { while (this.lastSongArray.length > noRepeat && noRepeat >= 0) {
this.lastSongArray.shift(); this.lastSongArray.shift();
} }

@ -88,7 +88,7 @@ Resources.prototype.addAll = function(urls, progressCallback) {
var respackPromises = [] var respackPromises = []
for(var i = 0; i < urls.length; i++) { for(var i = 0; i < urls.length; i++) {
r = new Respack(); r = new Respack();
(function(r) { ((r) => {
respackPromises.push(r.loadFromURL(urls[i], function(index, progress, pack) { respackPromises.push(r.loadFromURL(urls[i], function(index, progress, pack) {
this.progressState[index] = progress; this.progressState[index] = progress;
this.updateProgress(pack); this.updateProgress(pack);
@ -804,7 +804,7 @@ Resources.prototype.remoteProgress = function(progress, respack) {
} }
}; };
Resources.prototype.remoteComplete = function(progress) { Resources.prototype.remoteComplete = function() {
var progStat = this.packsView.progressStatus; var progStat = this.packsView.progressStatus;
progStat.textContent = "Complete"; progStat.textContent = "Complete";
window.setTimeout(function() {progStat.textContent = "Idle";}, 2000); window.setTimeout(function() {progStat.textContent = "Idle";}, 2000);

Loading…
Cancel
Save