Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up archive.html and archive.js #1290

Merged
merged 10 commits into from
Dec 10, 2022
Merged

Clean up archive.html and archive.js #1290

merged 10 commits into from
Dec 10, 2022

Conversation

7malikk
Copy link
Collaborator

@7malikk 7malikk commented Dec 10, 2022

Code cleanup in terms of indentation, link, script, and meta spacing and ensuring no code break and maintained functionality.

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • PR is descriptively titled 📑 and links the original issue above 🔗
  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with grunt test
  • code is in a uniquely-named feature branch and has no merge conflicts 📁
  • screenshots/GIFs are attached 📎 in case of UI updates
  • @mention the original creator of the issue in a comment below for help or for a review

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

@segun-codes
Copy link
Collaborator

Great effort @7malikk.

@7malikk
Copy link
Collaborator Author

7malikk commented Dec 10, 2022

Great effort @7malikk.

Thanks @segun-codes

let imageRow = document.createElement('div');
let image = new Image(150, 150);
let placeButton = document.createElement('a');
response.data.files.forEach((file) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. I'm going to merge it -- maybe a next step could be to break out lines 70-96 in a separate function called, what do you think... renderImages? or would it be better to have separate ones like renderPng() and renderJpeg()? Yeah, maybe that sounds better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that sounds a lot better @jywarren
I'd add that next. Thanks for the review

Copy link
Collaborator Author

@7malikk 7malikk Dec 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just going through this again, I think renderImages would be better as there is no distinction when we render a .png or .jpeg file as noticed here:

response.data.files.forEach((file) => {
if (file.format === 'PNG' || file.format === 'JPEG') {
const imageRow = document.createElement('div');
const image = new Image(150, 150);
const placeButton = document.createElement('a');
fetchedFrom = document.createElement('p');
fetchedFromUrl = document.createElement('a');
fetchedFromUrl.setAttribute('href', input.value);
fetchedFromUrl.setAttribute('target', '_blank');
fetchedFromUrl.innerHTML = 'this Internet Archive Collection';
fetchedFrom.appendChild(fetchedFromUrl);
placeButton.classList.add('btn', 'btn-sm', 'btn-outline-secondary', 'place-button');
placeButton.innerHTML = 'Place on map';
image.src = `${url.replace('metadata', 'download')}/${file.name}`;
imageRow.classList.add('d-flex', 'justify-content-between', 'align-items-center', 'mb-4', 'pe-5');
imageRow.append(image, placeButton);
imageContainer.appendChild(imageRow);
imageCount++;
}
});

There is no different render method depending on file format.

What do you think @jywarren?

@jywarren jywarren merged commit 6f925da into publiclab:main Dec 10, 2022
@7malikk 7malikk deleted the patch-1 branch December 10, 2022 19:34
@7malikk 7malikk restored the patch-1 branch December 10, 2022 19:35
@jywarren
Copy link
Member

jywarren commented Dec 10, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants