-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3111d1c
commit 505f15b
Showing
4 changed files
with
59 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
namespace OSFramework.Maps.ProviderVersion { | ||
/** | ||
* Function that allows to get the version of a specific the provider | ||
* Function that allows to set the version of a specific the provider. | ||
* If the forceRefresh is set to true and the version has changed, the page will be reloaded. | ||
* Otherwise, the version will be updated in the local storage. | ||
* | ||
* @export | ||
* @param {OSFramework.Maps.Enum.ProviderType} provider | ||
* @return {*} {string} | ||
* @param {string} version | ||
* @param {boolean} [forceRefresh=false] | ||
*/ | ||
export function Get(provider: OSFramework.Maps.Enum.ProviderType): string { | ||
let version = ''; | ||
export function Change(provider: OSFramework.Maps.Enum.ProviderType, version: string, forceRefresh = false): void { | ||
let versionChanged = false; | ||
switch (provider) { | ||
case OSFramework.Maps.Enum.ProviderType.Google: | ||
version = Provider.Maps.Google.Version.Get(); | ||
versionChanged = Provider.Maps.Google.Version.Change(version); | ||
break; | ||
case OSFramework.Maps.Enum.ProviderType.Leaflet: | ||
version = Provider.Maps.Leaflet.Version.Get(); | ||
versionChanged = Provider.Maps.Leaflet.Version.Change(version); | ||
break; | ||
default: | ||
throw new Error(`There provider '${provider}' is not supported.`); | ||
} | ||
return version; | ||
|
||
if (forceRefresh && versionChanged) { | ||
// Force refresh the library | ||
window.location.reload(); | ||
} | ||
} | ||
|
||
/** | ||
* Function that allows to set the version of a specific the provider. | ||
* If the forceRefresh is set to true and the version has changed, the page will be reloaded. | ||
* Otherwise, the version will be updated in the local storage. | ||
* Function that allows to get the version of a specific the provider | ||
* | ||
* @export | ||
* @param {OSFramework.Maps.Enum.ProviderType} provider | ||
* @param {string} version | ||
* @param {boolean} [forceRefresh=false] | ||
* @return {*} {string} | ||
*/ | ||
export function Set(provider: OSFramework.Maps.Enum.ProviderType, version: string, forceRefresh = false): void { | ||
let versionChanged = false; | ||
export function Get(provider: OSFramework.Maps.Enum.ProviderType): string { | ||
let version = ''; | ||
switch (provider) { | ||
case OSFramework.Maps.Enum.ProviderType.Google: | ||
versionChanged = Provider.Maps.Google.Version.Set(version); | ||
version = Provider.Maps.Google.Version.Get(); | ||
break; | ||
case OSFramework.Maps.Enum.ProviderType.Leaflet: | ||
versionChanged = Provider.Maps.Leaflet.Version.Set(version); | ||
version = Provider.Maps.Leaflet.Version.Get(); | ||
break; | ||
default: | ||
throw new Error(`There provider '${provider}' is not supported.`); | ||
} | ||
|
||
if (forceRefresh && versionChanged) { | ||
// Force refresh the library | ||
window.location.reload(); | ||
} | ||
return version; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters