Add noUI and showInfo options.

master
William Toohey 10 years ago
parent eb20e9534e
commit 1c5b02d370
  1. 25
      js/HuesSettings.js
  2. 4
      js/HuesUI.js
  3. 46
      js/ResourceManager.js

@ -33,6 +33,10 @@ HuesSettings.prototype.defaultSettings = {
firstImage: null, firstImage: null,
// If set, will disable the remote resources menu. For custom pages. // If set, will disable the remote resources menu. For custom pages.
disableRemoteResources: false, 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 // Preloader customisation
preloadPrefix: "0x", preloadPrefix: "0x",
preloadBase: 16, preloadBase: 16,
@ -62,7 +66,9 @@ HuesSettings.prototype.ephemeralSettings = [
"disableRemoteResources", "disableRemoteResources",
"preloadPrefix", "preloadPrefix",
"preloadBase", "preloadBase",
"preloadMax" "preloadMax",
"noUI",
"showInfo"
]; ];
// To dynamically build the UI like the cool guy I am // To dynamically build the UI like the cool guy I am
@ -126,9 +132,9 @@ HuesSettings.prototype.settingsOptions = {
function HuesSettings(defaults) { function HuesSettings(defaults) {
this.core = null; this.core = null;
this.hasUI = false;
this.root = document.getElementById("huesSettings"); this.root = document.getElementById("huesSettings");
this.window = document.getElementById("settingsHelper"); this.window = document.getElementById("settingsHelper");
this.hide();
for(var attr in this.defaultSettings) { for(var attr in this.defaultSettings) {
if(this.defaultSettings.hasOwnProperty(attr)) { if(this.defaultSettings.hasOwnProperty(attr)) {
@ -150,8 +156,19 @@ function HuesSettings(defaults) {
} }
this.defaults = 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) { HuesSettings.prototype.connectCore = function(core) {
@ -198,7 +215,6 @@ HuesSettings.prototype.initUI = function() {
var doc = this.root.ownerDocument; var doc = this.root.ownerDocument;
var that = this; var that = this;
document.getElementById("closeButton").onclick = function() {that.hide();};
// To order things nicely // To order things nicely
for(var cat in this.settingsCategories) { for(var cat in this.settingsCategories) {
@ -243,6 +259,7 @@ HuesSettings.prototype.initUI = function() {
this.root.appendChild(catContainer); this.root.appendChild(catContainer);
} }
} }
this.hasUI = true;
}; };
// Set a named index to its named value, returns false if name doesn't exist // Set a named index to its named value, returns false if name doesn't exist

@ -151,7 +151,9 @@ HuesUI.prototype.initUI = function() {
HuesUI.prototype.connectCore = function(core) { HuesUI.prototype.connectCore = function(core) {
this.core = core; this.core = core;
this.root.style.display = "block"; 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); this.visualiserContainer.appendChild(this.core.visualiser);
window.addEventListener('resize', this.resizeHandler); window.addEventListener('resize', this.resizeHandler);

@ -24,6 +24,7 @@ var packsURL = "http://cdn.0x40hu.es/getRespacks.php";
function Resources(core) { function Resources(core) {
this.core = core; this.core = core;
this.hasUI = false;
this.resourcePacks = []; this.resourcePacks = [];
@ -71,7 +72,9 @@ function Resources(core) {
this.fileInput = null; this.fileInput = null;
this.fileParseQueue = []; this.fileParseQueue = [];
this.currentlyParsing = false; 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 // Array of URLs to load, and a callback for when we're done
@ -179,22 +182,23 @@ Resources.prototype.rebuildEnabled = function() {
} }
} }
} }
if(this.hasUI) {
var songList = this.enabledSongList; var songList = this.enabledSongList;
while(songList.firstElementChild) { while(songList.firstElementChild) {
songList.removeChild(songList.firstElementChild); songList.removeChild(songList.firstElementChild);
} }
var imageList = this.enabledImageList; var imageList = this.enabledImageList;
while(imageList.firstElementChild) { while(imageList.firstElementChild) {
imageList.removeChild(imageList.firstElementChild); imageList.removeChild(imageList.firstElementChild);
} }
for(var i = 0; i < this.enabledSongs.length; i++) { for(var i = 0; i < this.enabledSongs.length; i++) {
var song = this.enabledSongs[i]; var song = this.enabledSongs[i];
this.appendSimpleListItem(song.title, songList, this.playSongCallback(i)); this.appendSimpleListItem(song.title, songList, this.playSongCallback(i));
} }
for(var i = 0; i < this.enabledImages.length; i++) { for(var i = 0; i < this.enabledImages.length; i++) {
var image = this.enabledImages[i]; var image = this.enabledImages[i];
this.appendSimpleListItem(image.name, imageList, this.selectImageCallback(i)); this.appendSimpleListItem(image.name, imageList, this.selectImageCallback(i));
}
} }
this.updateTotals(); this.updateTotals();
}; };
@ -268,6 +272,7 @@ Resources.prototype.parseLocalQueue = function(recursing) {
}; };
Resources.prototype.localProgress = function(progress, respack) { Resources.prototype.localProgress = function(progress, respack) {
if(!this.hasUI) {return;}
this.packsView.progressStatus.textContent = "Processing..."; this.packsView.progressStatus.textContent = "Processing...";
this.packsView.progressBar.style.width = (progress * 100) + "%"; this.packsView.progressBar.style.width = (progress * 100) + "%";
@ -510,14 +515,18 @@ Resources.prototype.initUI = function() {
this.listView.appendChild(this.enabledSongList); this.listView.appendChild(this.enabledSongList);
this.listView.appendChild(this.enabledImageList); this.listView.appendChild(this.enabledImageList);
this.hasUI = true;
}; };
Resources.prototype.hideLists = function() { Resources.prototype.hideLists = function() {
if(!this.hasUI) {return;}
this.enabledSongList.className = "hidden"; this.enabledSongList.className = "hidden";
this.enabledImageList.className = "hidden"; this.enabledImageList.className = "hidden";
}; };
Resources.prototype.toggleSongList = function() { Resources.prototype.toggleSongList = function() {
if(!this.hasUI) {return;}
if(this.enabledSongList.className == "hidden") { if(this.enabledSongList.className == "hidden") {
this.enabledSongList.className = "res-list"; this.enabledSongList.className = "res-list";
} else { } else {
@ -527,6 +536,7 @@ Resources.prototype.toggleSongList = function() {
}; };
Resources.prototype.toggleImageList = function() { Resources.prototype.toggleImageList = function() {
if(!this.hasUI) {return;}
if(this.enabledImageList.className == "hidden") { if(this.enabledImageList.className == "hidden") {
this.enabledImageList.className = "res-list"; this.enabledImageList.className = "res-list";
} else { } else {
@ -536,6 +546,7 @@ Resources.prototype.toggleImageList = function() {
}; };
Resources.prototype.updateTotals = function() { Resources.prototype.updateTotals = function() {
if(!this.hasUI) {return;}
this.packView.totalSongs.textContent = this.packView.totalSongs.textContent =
this.enabledSongs.length + "/" + this.allSongs.length; this.enabledSongs.length + "/" + this.allSongs.length;
this.packView.totalImages.textContent = this.packView.totalImages.textContent =
@ -671,6 +682,7 @@ Resources.prototype.invert = function() {
}; };
Resources.prototype.appendListItem = function(name, value, id, root, oncheck, onclick, checked) { Resources.prototype.appendListItem = function(name, value, id, root, oncheck, onclick, checked) {
if(!this.hasUI) {return;}
if(checked === undefined) { if(checked === undefined) {
checked = true; checked = true;
} }

Loading…
Cancel
Save