Skip to content

Commit

Permalink
detect key from longer URL (publiclab#1175)
Browse files Browse the repository at this point in the history
* detect key from longer URL

* detect key from longer URL

Co-authored-by: 7malikk <7malikk@gmail.com>

* fixes

* made a more flexible function to handle url

* updates

* made a more flexible function to handle url

* made new function extractKey

* replace 'http:' to https:

* updated http functionality

Co-authored-by: 7malikk <7malikk@gmail.com>
Co-authored-by: Jeffrey Warren <jeff@unterbahn.com>
  • Loading branch information
3 people committed Nov 5, 2022
1 parent ae390d1 commit 84062f7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dist/leaflet.distortableimage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 28 additions & 2 deletions examples/archive.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,33 @@ <h3 id="offcanvasRightLabel">Images</h3>

form.addEventListener('submit', (event) => {
event.preventDefault();
const url = input.value.replace('details', 'metadata');
extractKey();
});

welcomeModal.addEventListener('hidden.bs.modal', (event) => {
new bootstrap.Offcanvas(sidebar).show();
});

function extractKey() {
let getUrl;
if(!input.value.includes('archive.org/details/') && !input.value.includes('https://'))
{
getUrl = `https://archive.org/details/${input.value}/`;
showImages(getUrl);
}
else if(!input.value.includes('https://')) {
getUrl = `https://${input.value}`;
showImages(getUrl);
}
else
{
getUrl = input.value;
showImages(getUrl)
}
}

function showImages(getUrl) {
const url = getUrl.replace('details', 'metadata');
let fetchedFrom
axios.get(url)
.then((response) => {
Expand Down Expand Up @@ -139,7 +165,7 @@ <h3 id="offcanvasRightLabel">Images</h3>
.finally(() => {
bootstrap.Modal.getInstance(welcomeModal).hide();
});
});
}

welcomeModal.addEventListener('hidden.bs.modal', (event) => {
new bootstrap.Offcanvas(sidebar).show();
Expand Down

0 comments on commit 84062f7

Please sign in to comment.