Add page permalink
This commit is contained in:
parent
7b3edd753b
commit
c358169ec6
@ -1,4 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import url from '$lib/url.js';
|
||||||
|
import CopyButton from '$lib/CopyButton.svelte';
|
||||||
import { getWasm, rustEnumToArray } from '$lib/common.js';
|
import { getWasm, rustEnumToArray } from '$lib/common.js';
|
||||||
import { WasmStatus } from '$lib/common.js';
|
import { WasmStatus } from '$lib/common.js';
|
||||||
import { tick, onMount, onDestroy } from 'svelte';
|
import { tick, onMount, onDestroy } from 'svelte';
|
||||||
@ -143,6 +145,8 @@
|
|||||||
coordinateInputValue = addr.allCoordinates[selectedCoordinateType];
|
coordinateInputValue = addr.allCoordinates[selectedCoordinateType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
history.replaceState(undefined, undefined, `#${addr.address.replaceAll(' ', '-')}`);
|
||||||
|
|
||||||
map.panTo(latlng, 20);
|
map.panTo(latlng, 20);
|
||||||
leaflet.popup().setLatLng(latlng).setContent(`${addr.address}`).openOn(map);
|
leaflet.popup().setLatLng(latlng).setContent(`${addr.address}`).openOn(map);
|
||||||
if (fromTextInput) {
|
if (fromTextInput) {
|
||||||
@ -169,6 +173,22 @@
|
|||||||
$: {
|
$: {
|
||||||
mapIsVisible = initSuccess && tabInfo.selected == 0;
|
mapIsVisible = initSuccess && tabInfo.selected == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let lastHash;
|
||||||
|
$: {
|
||||||
|
if ($url && $url.hash) {
|
||||||
|
let hash = decodeURI($url.hash.substr(1))
|
||||||
|
.replaceAll(/-|\+|\s+/g, ' ')
|
||||||
|
.trim();
|
||||||
|
|
||||||
|
if (hash !== lastHash) {
|
||||||
|
addrInputValue = hash;
|
||||||
|
addressInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
lastHash = hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
@ -187,6 +207,11 @@
|
|||||||
{:then}
|
{:then}
|
||||||
<AddressInput bind:value={addrInputValue} on:change={addressInput} />
|
<AddressInput bind:value={addrInputValue} on:change={addressInput} />
|
||||||
|
|
||||||
|
{#if $url && $url.hash}
|
||||||
|
<a class="text-indigo-600" href={$url}>Permalink</a>
|
||||||
|
<CopyButton data={$url} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
<CoordinateInput
|
<CoordinateInput
|
||||||
bind:value={coordinateInputValue}
|
bind:value={coordinateInputValue}
|
||||||
on:type-change={selectedCoordinateTypeChange}
|
on:type-change={selectedCoordinateTypeChange}
|
||||||
|
Loading…
Reference in New Issue
Block a user