From ba2f7c589ec78f77fe338855c6fb005754a60b91 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Wed, 6 Jan 2016 23:00:49 +1000 Subject: [PATCH] Show "... and x more things" when loading remotes with many resources --- js/ResourceManager.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/js/ResourceManager.js b/js/ResourceManager.js index 08c7202..11969c8 100644 --- a/js/ResourceManager.js +++ b/js/ResourceManager.js @@ -758,11 +758,29 @@ Resources.prototype.selectRemotePack = function(id) { var song = pack.songs[i]; this.appendSimpleListItem(song, songList); } + var moreSongs = pack.songcount - pack.songs.length; + if(moreSongs > 0) { + var text = "... and " + moreSongs + " more song"; + if(moreSongs > 1) { + text += "s" + } + this.appendSimpleListItem(text + ".", songList); + this.appendSimpleListItem("Load the respack to show the rest!", songList); + } for(var i = 0; i < pack.images.length; i++) { var image = pack.images[i]; this.appendSimpleListItem(image, imageList); } + var moreImages = pack.imagecount - pack.images.length; + if(moreImages > 0) { + var text = "... and " + moreImages + " more image"; + if(moreImages > 1) { + text += "s" + } + this.appendSimpleListItem(text + ".", imageList); + this.appendSimpleListItem("Load the respack to show the rest!", imageList); + } }; Resources.prototype.loadCurrentRemote = function() { @@ -818,7 +836,8 @@ Resources.prototype.appendSimpleListItem = function(value, root, onclick) { var div = document.createElement("div"); div.className = "res-listitem"; var label = document.createElement("span"); - label.textContent = value; + // Because we're using textContent, we replace with literal & + label.textContent = value.replace(/&/g, '&'); label.onclick = onclick; div.appendChild(label); root.appendChild(div);