diff --git a/src/js/HuesCore.js b/src/js/HuesCore.js index fb706e0..c4546b6 100644 --- a/src/js/HuesCore.js +++ b/src/js/HuesCore.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(); } diff --git a/src/js/ResourceManager.js b/src/js/ResourceManager.js index d32f319..bcec5bb 100644 --- a/src/js/ResourceManager.js +++ b/src/js/ResourceManager.js @@ -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);