Add parseQueryString and packsURL to settings (#36)

* Allow disabling query string parsing

* Allow configuring packsURL in settings
master
Anna-Maria Meriniemi 7 years ago committed by Will
parent a225a103b1
commit 9faf6e5b8c
  1. 7
      src/js/HuesSettings.js
  2. 5
      src/js/ResourceManager.js

@ -32,6 +32,8 @@ const defaultSettings = {
workersPath : "lib/workers/",
// List of respacks to load
respacks : [],
// If true, the query string (?foo=bar&baz=boz) will be parsed for settings
parseQueryString : true,
// ONLY USED FOR QUERY STRINGS this will be prepended to any respacks
// passed in as a ?packs=query
respackPath : "respacks/",
@ -47,6 +49,9 @@ const defaultSettings = {
firstImage: null,
// set to false to never change images
fullAuto: true,
// The remote respack listing JSON endpoint
// NOTE: Any packs referenced need CORS enabled or loads fail
packsURL: "https://cdn.0x40.ga/getRespacks.php",
// If set, will disable the remote resources menu. For custom pages.
disableRemoteResources: false,
// You will rarely want to change this. Enables/disables the Hues Window.
@ -248,6 +253,7 @@ class HuesSettings {
}
}
if (this.parseQueryString) {
let querySettings = this.getQuerySettings();
for(let attr in defaultSettings) {
@ -259,6 +265,7 @@ class HuesSettings {
this.respacks = this.respacks.concat(querySettings.respacks);
}
}
getQuerySettings() {
let results = {};

@ -31,9 +31,6 @@ let getAndIncrementUnique = function() {
return unique++;
};
// NOTE: Any packs referenced need CORS enabled or loads fail
let packsURL = "https://cdn.0x40.ga/getRespacks.php";
class Resources {
constructor(core, huesWin) {
this.core = core;
@ -719,7 +716,7 @@ class Resources {
let item = this.appendSimpleListItem("Loading...", remoteList);
let req = new XMLHttpRequest();
req.open('GET', packsURL, true);
req.open('GET', this.core.settings.packsURL, true);
req.responseType = 'json';
req.onload = () => {
if(!req.response) {

Loading…
Cancel
Save