diff --git a/js/HuesSettings.js b/js/HuesSettings.js index e630562..a17013f 100644 --- a/js/HuesSettings.js +++ b/js/HuesSettings.js @@ -33,6 +33,10 @@ HuesSettings.prototype.defaultSettings = { firstImage: null, // If set, will disable the remote resources menu. For custom pages. disableRemoteResources: false, + // You will rarely want this. Disables the generated UI elements in the tab box + noUI: false, + // Whether to show the info window on page load + showInfo: false, // Preloader customisation preloadPrefix: "0x", preloadBase: 16, @@ -62,7 +66,9 @@ HuesSettings.prototype.ephemeralSettings = [ "disableRemoteResources", "preloadPrefix", "preloadBase", - "preloadMax" + "preloadMax", + "noUI", + "showInfo" ]; // To dynamically build the UI like the cool guy I am @@ -126,9 +132,9 @@ HuesSettings.prototype.settingsOptions = { function HuesSettings(defaults) { this.core = null; + this.hasUI = false; this.root = document.getElementById("huesSettings"); this.window = document.getElementById("settingsHelper"); - this.hide(); for(var attr in this.defaultSettings) { if(this.defaultSettings.hasOwnProperty(attr)) { @@ -150,8 +156,19 @@ function HuesSettings(defaults) { } this.defaults = defaults; + + if(this.defaults.showInfo) { + this.show(); + } else { + this.hide(); + } - this.initUI(); + // because we still care about the main window + var that = this; + document.getElementById("closeButton").onclick = function() {that.hide();}; + if(!this.defaults.noUI) { + this.initUI(); + } } HuesSettings.prototype.connectCore = function(core) { @@ -198,7 +215,6 @@ HuesSettings.prototype.initUI = function() { var doc = this.root.ownerDocument; var that = this; - document.getElementById("closeButton").onclick = function() {that.hide();}; // To order things nicely for(var cat in this.settingsCategories) { @@ -243,6 +259,7 @@ HuesSettings.prototype.initUI = function() { this.root.appendChild(catContainer); } } + this.hasUI = true; }; // Set a named index to its named value, returns false if name doesn't exist diff --git a/js/HuesUI.js b/js/HuesUI.js index 1c66b2a..e463f24 100644 --- a/js/HuesUI.js +++ b/js/HuesUI.js @@ -151,7 +151,9 @@ HuesUI.prototype.initUI = function() { HuesUI.prototype.connectCore = function(core) { this.core = core; this.root.style.display = "block"; - this.listContainer.appendChild(core.resourceManager.listView); + if(core.resourceManager.hasUI) { + this.listContainer.appendChild(core.resourceManager.listView); + } this.visualiserContainer.appendChild(this.core.visualiser); window.addEventListener('resize', this.resizeHandler); diff --git a/js/ResourceManager.js b/js/ResourceManager.js index b4f60f9..dab454a 100644 --- a/js/ResourceManager.js +++ b/js/ResourceManager.js @@ -24,6 +24,7 @@ var packsURL = "http://cdn.0x40hu.es/getRespacks.php"; function Resources(core) { this.core = core; + this.hasUI = false; this.resourcePacks = []; @@ -71,7 +72,9 @@ function Resources(core) { this.fileInput = null; this.fileParseQueue = []; this.currentlyParsing = false; - this.initUI(); + if(!core.settings.defaults.noUI) { + this.initUI(); + } } // Array of URLs to load, and a callback for when we're done @@ -179,22 +182,23 @@ Resources.prototype.rebuildEnabled = function() { } } } - - var songList = this.enabledSongList; - while(songList.firstElementChild) { - songList.removeChild(songList.firstElementChild); - } - var imageList = this.enabledImageList; - while(imageList.firstElementChild) { - imageList.removeChild(imageList.firstElementChild); - } - for(var i = 0; i < this.enabledSongs.length; i++) { - var song = this.enabledSongs[i]; - this.appendSimpleListItem(song.title, songList, this.playSongCallback(i)); - } - for(var i = 0; i < this.enabledImages.length; i++) { - var image = this.enabledImages[i]; - this.appendSimpleListItem(image.name, imageList, this.selectImageCallback(i)); + if(this.hasUI) { + var songList = this.enabledSongList; + while(songList.firstElementChild) { + songList.removeChild(songList.firstElementChild); + } + var imageList = this.enabledImageList; + while(imageList.firstElementChild) { + imageList.removeChild(imageList.firstElementChild); + } + for(var i = 0; i < this.enabledSongs.length; i++) { + var song = this.enabledSongs[i]; + this.appendSimpleListItem(song.title, songList, this.playSongCallback(i)); + } + for(var i = 0; i < this.enabledImages.length; i++) { + var image = this.enabledImages[i]; + this.appendSimpleListItem(image.name, imageList, this.selectImageCallback(i)); + } } this.updateTotals(); }; @@ -268,6 +272,7 @@ Resources.prototype.parseLocalQueue = function(recursing) { }; Resources.prototype.localProgress = function(progress, respack) { + if(!this.hasUI) {return;} this.packsView.progressStatus.textContent = "Processing..."; this.packsView.progressBar.style.width = (progress * 100) + "%"; @@ -510,14 +515,18 @@ Resources.prototype.initUI = function() { this.listView.appendChild(this.enabledSongList); this.listView.appendChild(this.enabledImageList); + + this.hasUI = true; }; Resources.prototype.hideLists = function() { + if(!this.hasUI) {return;} this.enabledSongList.className = "hidden"; this.enabledImageList.className = "hidden"; }; Resources.prototype.toggleSongList = function() { + if(!this.hasUI) {return;} if(this.enabledSongList.className == "hidden") { this.enabledSongList.className = "res-list"; } else { @@ -527,6 +536,7 @@ Resources.prototype.toggleSongList = function() { }; Resources.prototype.toggleImageList = function() { + if(!this.hasUI) {return;} if(this.enabledImageList.className == "hidden") { this.enabledImageList.className = "res-list"; } else { @@ -536,6 +546,7 @@ Resources.prototype.toggleImageList = function() { }; Resources.prototype.updateTotals = function() { + if(!this.hasUI) {return;} this.packView.totalSongs.textContent = this.enabledSongs.length + "/" + this.allSongs.length; this.packView.totalImages.textContent = @@ -671,6 +682,7 @@ Resources.prototype.invert = function() { }; Resources.prototype.appendListItem = function(name, value, id, root, oncheck, onclick, checked) { + if(!this.hasUI) {return;} if(checked === undefined) { checked = true; }