Skip to content

Commit

Permalink
Add parseQueryString and packsURL to settings (#36)
Browse files Browse the repository at this point in the history
* Allow disabling query string parsing

* Allow configuring packsURL in settings
  • Loading branch information
TheAMM authored and mon committed Aug 2, 2018
1 parent a225a10 commit 9faf6e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
21 changes: 14 additions & 7 deletions src/js/HuesSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand All @@ -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.
Expand Down Expand Up @@ -248,16 +253,18 @@ class HuesSettings {
}
}

let querySettings = this.getQuerySettings();
if (this.parseQueryString) {
let querySettings = this.getQuerySettings();

for(let attr in defaultSettings) {
// query string overrides, finally
if(querySettings[attr] !== undefined && attr != 'respacks') {
this.ephemerals[attr] = querySettings[attr];
for(let attr in defaultSettings) {
// query string overrides, finally
if(querySettings[attr] !== undefined && attr != 'respacks') {
this.ephemerals[attr] = querySettings[attr];
}
}
}

this.respacks = this.respacks.concat(querySettings.respacks);
this.respacks = this.respacks.concat(querySettings.respacks);
}
}

getQuerySettings() {
Expand Down
5 changes: 1 addition & 4 deletions src/js/ResourceManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 9faf6e5

Please sign in to comment.