@omarelbastawesy
Posted
Great job :)
@catherineisonline
Posted
@omarelbastawesy Thanks!
Looking to hire developers?
Hello, Frontend Mentor community! This is my solution to the URL shortening API landing page.
I appreciate all the feedback you left that helped me to improve this project. I fixed the issues I had previously and added new features per your recommendation.
I have done this project a while ago however if you are here and have any feedback, tips, or ideas to share, I will be more than glad to hear them out!
Thanks
@omarelbastawesy
Posted
Great job :)
@catherineisonline
Posted
@omarelbastawesy Thanks!
@Luis15Herr
Posted
Amazing Work :)
@catherineisonline
Posted
@Luis15Herr Thank you!
@TSune-web
Posted
Well done!
@catherineisonline
Posted
@TSune-web Thank you!
@shrki416
Posted
@catherineisonline great job! This looks awesome :)
@catherineisonline
Posted
@shrki416 Thank you!
@NicolasGula
Posted
Awesome!
@catherineisonline
Posted
@NicolasGula Thanks!
@jgengo-alt
Posted
looks very good, your logo (the brushes) are a bit disappearing compared to what is expected, but that's just a detailed. It's because you used the img to also do the background-color and the border-radius: 50% instead of inserting the image in a div with those ;)
you did very great work here! thanks for sharing
@catherineisonline
Posted
@jgengo-alt I will check it out, thank you for the feedback
@msuryaditriputraR
Posted
Awesome Work..
@catherineisonline
Posted
@msuryaditriputraR Thank you!
@AditNovadianto
Posted
@catherineisonline you did this project so nice and not have any issues there!!!
@catherineisonline
Posted
@AditNovadianto Thanks!
@BikeInMan
Posted
If @nakoyawilson 's solution works for you, then please ignore. Unlike her, I didn't get time to clone and test it.
But I get a feeling, mainClone.classList = "search-result";
is wrong.
May be it should be written as
mainClone.className = "search-result";
or
mainClone.classList.add('search-result');
Just a thought.
BTW, you always say, it is not about design and just practicing js, but most of your work seems to be spot on. Great work as always.
@nakoyawilson
Posted
@BikeInMan Good point about the mainClone.classList = "search-result";
. I just checked and writing it like this isn't affecting it being rendered in the browser but using mainClone.classList.add('MyClass');
is probably better practice as it wouldn't completely overwrite other classes if the element had other classes.
@BikeInMan
Posted
@nakoyawilson Thank you for testing and clarifying.
@catherineisonline
Posted
@BikeInMan Thank you I will check it out now
@catherineisonline
Posted
@BikeInMan so what happens here is that mainClone.classList = "search-result"; doesn't just add the class but replaces it. Because the original div is hidden and its class is called "hidden-result" when the div receives some data - like links and code, it becomes visible but its class name is replaced. I know usually you can do toggle class, so it's shown or hidden however in this case, it didn't work for me because I don't toggle it. I hope it makes sense. :D
@nakoyawilson
Posted
Hey Catherine! I downloaded your code, changed all occurrences of sessionStorage
to localStorage
and deleted originalHtml = localStorage.getItem("cloneCache");
and parentNode.innerHTML = originalHtml;
from the function and the data displayed for me.
window.onload = function () {
let mainClone = shortlyResult.cloneNode(true);
let cloneLinkField = mainClone.querySelector(".inserted-link");
mainClone.classList = "search-result";
parentNode.appendChild(mainClone);
//Retrieving
let cloneLink = localStorage.getItem("cloneLink");
console.log(cloneLink);
//Injecting
console.log(cloneLinkField);
cloneLinkField.innerHTML = cloneLink;
};
@catherineisonline
Posted
@nakoyawilson Thank you so much! I will take a look now
@catherineisonline
Posted
@nakoyawilson I tried it but it still doesn't do what I needed. originalHtml = localStorage.getItem("cloneCache"); is supposed to save the whole target dom I want to keep. I need dom elements to stay there so they can accept past search results. "cloneLink" is just the link I requested to shorten. If I don't save the DOM elements in storage, upon reloading the only thing I receive is the last created element(including the latest link). Basically, there will not be enough DOM for several results, if that makes sense.
I added some changes and it started working finally but not fully.
My main goal was to keep all the past requests and the reason I was choosing sessionStorage is to let the visitor of my project, clean the requests if they closed the website and opened it some other time. Instead of setting additional code to clear the local cache. I could make it leave only the latest one but I think that won't make sense. I will try to do something else now and fix that last empty div.
@nakoyawilson
Posted
@catherineisonline Oh ok. After your question I decided to try the challenge myself and I used localStorage and stored the links as an array of objects and just pushed each new search to the array. Maybe you can try saving the links as an array of objects and see if you get the functionality you want?
@catherineisonline
Posted
@nakoyawilson I tried to check again however seems like I have an issue not retrieving the data but displaying it. For some reason, it's ignoring my first request. Let's say if I request two results and reload, it will display only one div with values inside it. If I request only one url shortening, it will display an empty div after reloading. Decided to leave it like that for now, at least it looks better now than before. Thank for the suggestions!
@nakoyawilson
Posted
@catherineisonline When you come back to it and figure out the issue, let me know. I'd love to know what the problem was.
@Ken9Kodehode
Posted
Great work!
@catherineisonline
Posted
@Ken9Kodehode Thanks!
@kerminek
Posted
Hi, one image makes your page wider than we want it to be. Solve it using "overflow: hidden" on main container of the page. Also, if you want to keep data after refresh try to make it using cookies or simply "localstorage" :)
@catherineisonline
Posted
@kerminek Thank you for the feedback. Yes, that is exactly what I am trying to do which doesn't work
@GitHub-dev12345
Posted
How to make this project and where are you learn APIs. Can you share how to learn APIs.
@catherineisonline
Posted
@GitHub-dev12345 I didn't really spend much time learning API, I am learning JavaScript and that's why I tried this project to practice API on the way. Just reading some quick guides if I don't know how to request specific data or anything else related. Practice is the best way to learn. I also didn't realize I can do it :D
@GitHub-dev12345
Posted
@catherineisonline which resources are used to learn JavaScript can you share with me ๐
@catherineisonline
Posted
@GitHub-dev12345 freeCodeCamp, Udemy courses by Jonas Schedtmann and Colt Steele, Codecademy and google :))
@GitHub-dev12345
Posted
Hey Catherine nice work๐๐
@catherineisonline
Posted
@GitHub-dev12345 Thanks!
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord