Skip to content

Commit

Permalink
feat(event-display): function to get url options from url options man…
Browse files Browse the repository at this point in the history
…ager
  • Loading branch information
9inpachi committed Sep 24, 2021
1 parent 18c3bd6 commit 0ba5097
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
14 changes: 12 additions & 2 deletions packages/phoenix-event-display/src/event-display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export class EventDisplay {
private loadingManager: LoadingManager;
/** State manager for managing event display state. */
private stateManager: StateManager;
/** URL manager for managing options given through URL. */
private urlOptionsManager: URLOptionsManager;

/**
* Create the Phoenix event display and intitialize all the elements.
Expand Down Expand Up @@ -77,9 +79,9 @@ export class EventDisplay {
this.graphicsLibrary.setAnimationLoop(uiLoop);

// Process and apply URL options
this.urlOptionsManager = new URLOptionsManager(this, configuration);
if (configuration.allowUrlOptions !== false) {
const urlOptionsManager = new URLOptionsManager(this, configuration);
urlOptionsManager.applyOptions();
this.urlOptionsManager.applyOptions();
}

// Allow adding elements through console
Expand Down Expand Up @@ -201,6 +203,14 @@ export class EventDisplay {
return this.stateManager;
}

/**
* Get the URL options manager that manages options given through URL.
* @returns The URL options manager.
*/
public getURLOptionsManager() {
return this.urlOptionsManager;
}

// **********************
// * LOADING GEOMETRIES *
// **********************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ export class URLOptionsManager {
private eventDisplay: EventDisplay,
private configuration: Configuration
) {
const locationHref = window.location.href;
this.urlOptions = new URLSearchParams(
locationHref.substr(locationHref.lastIndexOf('?'))
window.location.href.substr(window.location.href.lastIndexOf('?'))
);
}

Expand Down Expand Up @@ -181,4 +180,12 @@ export class URLOptionsManager {
}
});
}

/**
* Get options from URL set through query parameters.
* @returns URL options.
*/
public getURLOptions() {
return this.urlOptions;
}
}

0 comments on commit 0ba5097

Please sign in to comment.