From d79e0d36e22b67476994068086fd26e079080be0 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Thu, 1 Oct 2015 12:48:44 +1000 Subject: [PATCH] Add option to disable remote respacks list - for integrated deployments --- css/hues-res.css | 4 ++++ js/HuesSettings.js | 24 +++++++++++++++++++----- js/ResourceManager.js | 28 +++++++++++++++++----------- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/css/hues-res.css b/css/hues-res.css index 2c8c186..99237b0 100644 --- a/css/hues-res.css +++ b/css/hues-res.css @@ -34,6 +34,10 @@ height: 120px; } +#res-packlist.noremotes { + height: 305px; +} + #res-remotelist { height: 155px; } diff --git a/js/HuesSettings.js b/js/HuesSettings.js index 318796a..b6771d0 100644 --- a/js/HuesSettings.js +++ b/js/HuesSettings.js @@ -29,6 +29,8 @@ HuesSettings.prototype.defaultSettings = { overwriteLocal : false, // If set, will attempt to play the named song first firstSong: null, + // If set, will disable the remote resources menu. For custom pages. + disableRemoteResources: false, // UI accessible config // Autosong stuff is a todo, becuase why even implement that @@ -43,6 +45,16 @@ HuesSettings.prototype.defaultSettings = { volume : 0.7 } +// Don't get saved to localStorage +HuesSettings.prototype.ephemeralSettings = [ + "load", + "autoplay", + "overwriteLocal", + "respacks", + "firstSong", + "disableRemoteResources" +]; + // To dynamically build the UI like the cool guy I am HuesSettings.prototype.settingsCategories = { "Image Settings" : [ @@ -104,12 +116,14 @@ function HuesSettings(defaults) { this.hide(); for(var attr in this.defaultSettings) { - if(attr == "respacks") { - continue; - } if(defaults[attr] == undefined) { defaults[attr] = this.defaultSettings[attr]; - } else if(defaults.overwriteLocal) { + } + // don't write to local if it's a temp settings + if(this.ephemeralSettings.indexOf(attr) != -1) { + continue; + } + if(defaults.overwriteLocal) { localStorage[attr] = defaults[attr]; } // populate defaults, ignoring current @@ -234,7 +248,7 @@ HuesSettings.prototype.set = function(setting, value) { // the defaults given in the initialiser HuesSettings.prototype.setDefaults = function() { for(var attr in this.defaults) { - if(attr == "respacks") { + if(this.ephemeralSettings.indexOf(attr) != -1) { continue; } localStorage[attr] = this.defaults[attr]; diff --git a/js/ResourceManager.js b/js/ResourceManager.js index 6f420cf..2f8e7a9 100644 --- a/js/ResourceManager.js +++ b/js/ResourceManager.js @@ -302,15 +302,19 @@ Resources.prototype.initUI = function() { packList.className = "res-list"; packList.id = "res-packlist"; this.packsView.respackList = packList; - var remoteHeader = document.createElement("div"); - remoteHeader.textContent = "Remote respacks"; - remoteHeader.className = "res-header"; - var remoteList = document.createElement("div"); - remoteList.className = "res-list"; - remoteList.id = "res-remotelist"; - this.appendSimpleListItem("Click to load the list", remoteList, - function() {that.loadRemotes();}); - this.packsView.remoteList = remoteList; + if(!this.core.settings.defaults.disableRemoteResources) { + var remoteHeader = document.createElement("div"); + remoteHeader.textContent = "Remote respacks"; + remoteHeader.className = "res-header"; + var remoteList = document.createElement("div"); + remoteList.className = "res-list"; + remoteList.id = "res-remotelist"; + this.appendSimpleListItem("Click to load the list", remoteList, + function() {that.loadRemotes();}); + this.packsView.remoteList = remoteList; + } else { + packList.className += " noremotes"; + } var buttons = document.createElement("div"); buttons.className = "res-buttons"; @@ -368,8 +372,10 @@ Resources.prototype.initUI = function() { packsContainer.appendChild(packHeader); packsContainer.appendChild(packList); - packsContainer.appendChild(remoteHeader); - packsContainer.appendChild(remoteList); + if(!this.core.settings.defaults.disableRemoteResources) { + packsContainer.appendChild(remoteHeader); + packsContainer.appendChild(remoteList); + } packsContainer.appendChild(buttons); packsContainer.appendChild(progressContainer);