Skip to content

Commit

Permalink
Working on allowing configs to be URLs Ref: #506
Browse files Browse the repository at this point in the history
  • Loading branch information
danpastori committed May 5, 2022
1 parent 6a108f7 commit 4c58fdd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
6 changes: 0 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ import Core from "./core/core.js";
*/
import Shuffler from "./utilities/shuffler.js";

/**
* Imports the config state module.
* @module ConfigState
*/
import ConfigState from "./utilities/configState.js";

/**
* Imports the audio navigation
* @module utilities/AudioNavigation
Expand Down
30 changes: 17 additions & 13 deletions src/init/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,28 @@ let Initializer = (function() {
*/
function initialize(userConfig) {
if( typeof userConfig == 'string' ){
fetch(userConfig).then( function( response ){
if( response.status != 200 ){
throw response.status;
}else{
return response.json();
}
}.bind(this))
.then( function( data ){
setUserConfig(data);
}.bind(this))
.catch( function( error ){
Debug.writeMessage(error);
}.bind(this));
loadUserConfig(userConfig);
}else{
setUserConfig( userConfig );
}
}

function loadUserConfig(userConfig){
fetch(userConfig).then( function( response ){
if( response.status != 200 ){
throw response.status;
}else{
return response.json();
}
}.bind(this))
.then( function( data ){
setUserConfig(data);
}.bind(this))
.catch( function( error ){
Debug.writeMessage(error);
}.bind(this));
}

function setUserConfig( userConfig ) {
let ready = false;

Expand Down

0 comments on commit 4c58fdd

Please sign in to comment.