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() {
var index=Math.floor((Math.random() * this.resourceManager.enabledSongs.length));
if (index == this.songIndex && this.resourceManager.enabledSongs.length > 1 || this.lastSongArray.indexOf(index) != -1) {
var songCount = this.resourceManager.enabledSongs.length;
var index=Math.floor((Math.random() * songCount));
if (songCount > 1 && (index == this.songIndex || this.lastSongArray.indexOf(index) != -1)) {
this.randomSong();
} else {
console.log("Randoming a song!");
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) {
this.lastSongArray.shift();
}

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

Loading…
Cancel
Save