Skip to content

Commit

Permalink
refactor: ♻️ update settings methods to identify private funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Aug 3, 2024
1 parent fcf0d9d commit 3fe6110
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
50 changes: 34 additions & 16 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1142,21 +1142,21 @@ export class SettingsManager {
init(settingsOverride?: any) {
this.pTime = [];

this.checkIfIframe();
this.checkIfIframe_();
this.setInstallDirectory_();
this.setMobileSettings();
this.setEmbedOverrides();
this.setColorSettings();
this.setMobileSettings_();
this.setEmbedOverrides_();
this.setColorSettings_();
/**
* Load Order:
* URL Params > Local Storage > Default
*/
this.loadOverrides(settingsOverride);
this.loadOverrides_(settingsOverride);
this.loadPersistedSettings();

const params = this.loadOverridesFromUrl();
const params = this.loadOverridesFromUrl_();

this.initParseFromGETVariables(params);
this.initParseFromGETVariables_(params);

// If No UI Reduce Overhead
if (this.disableUI) {
Expand All @@ -1174,7 +1174,7 @@ export class SettingsManager {
this.maxFieldOfViewMarkers = 1;
}

this.loadLastMapTexture();
this.loadLastMapTexture_();

/*
* Export settingsManager to everyone else
Expand All @@ -1186,7 +1186,7 @@ export class SettingsManager {
}
}

private checkIfIframe() {
private checkIfIframe_() {
if (window.self !== window.top) {
this.isInIframe = true;
this.isShowLogo = true;
Expand All @@ -1199,7 +1199,7 @@ export class SettingsManager {
*
* @private
*/
private setColorSettings() {
private setColorSettings_() {
this.selectedColorFallback = this.selectedColor;

this.colors = {} as ColorSchemeColorMap;
Expand Down Expand Up @@ -1315,7 +1315,7 @@ export class SettingsManager {
* Loads overrides from the URL query string and applies them to the plugin settings.
* @returns An array of query string parameters.
*/
private loadOverridesFromUrl() {
private loadOverridesFromUrl_() {
const queryStr = window.location.search.substring(1);

// URI Encode all %22 to ensure url is not broken
Expand Down Expand Up @@ -1365,7 +1365,7 @@ export class SettingsManager {
* This is an initial parse of the GET variables to determine
* critical settings. Other variables are checked later during catalogManagerInstance.init
*/
private initParseFromGETVariables(params: string[]) {
private initParseFromGETVariables_(params: string[]) {
if (!this.disableUI) {
for (const param of params) {
const key = param.split('=')[0];
Expand Down Expand Up @@ -1529,7 +1529,7 @@ export class SettingsManager {
/**
* Load the previously saved map texture.
*/
private loadLastMapTexture() {
private loadLastMapTexture_() {
if (this.disableUI) {
this.isLoadLastMap = false;
}
Expand Down Expand Up @@ -1591,7 +1591,7 @@ export class SettingsManager {
*
* FOR TESTING ONLY
*/
private setEmbedOverrides() {
private setEmbedOverrides_() {
let pageName = location.href.split('/').slice(-1);

pageName = pageName[0].split('?').slice(0);
Expand All @@ -1615,7 +1615,7 @@ export class SettingsManager {
* If the window width is less than or equal to the desktop minimum width,
* mobile mode is enabled and certain settings are adjusted accordingly.
*/
private setMobileSettings() {
private setMobileSettings_() {
if (window.innerWidth <= this.desktopMinimumWidth) {
this.disableWindowTouchMove = false;
/*
Expand All @@ -1626,7 +1626,25 @@ export class SettingsManager {
}
}

private loadOverrides(settingsOverride: any) {
exportSettingsToJSON() {
const settings = {};

for (const key of Object.keys(this)) {
settings[key] = this[key];
}

// Save the settings to a file
const settingsBlob = new Blob([JSON.stringify(settings)], { type: 'application/json' });
const url = URL.createObjectURL(settingsBlob);
const a = document.createElement('a');

a.href = url;
a.download = 'settings.json';

a.click();
}

private loadOverrides_(settingsOverride: any) {
// combine settingsOverride with window.settingsOverride
const overrides = { ...settingsOverride, ...window.settingsOverride };
// override values in this with overrides
Expand Down
2 changes: 1 addition & 1 deletion src/settings/versionDate.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
export const VERSION_DATE = 'July 19, 2024';
export const VERSION_DATE = 'July 22, 2024';

0 comments on commit 3fe6110

Please sign in to comment.