Skip to content

Commit

Permalink
made changes in js
Browse files Browse the repository at this point in the history
  • Loading branch information
Rataash99 committed Mar 5, 2024
1 parent 5c7b7b0 commit 202586f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 6 additions & 1 deletion favorite.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const retreivedData = localStorage.getItem("favMovieData");
document.addEventListener('DOMContentLoaded', function() {
// Your JavaScript code here
const retreivedData = localStorage.getItem("favMovieData");
let favoriteMovies = [];
if(retreivedData) favoriteMovies = JSON.parse(retreivedData);

Expand Down Expand Up @@ -75,3 +77,6 @@ function sendingDataToHTML(element, item){
}
})
}

});

10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const favourites = document.querySelector("#favourites");
document.addEventListener('DOMContentLoaded', function() {
// Your JavaScript code here
const favourites = document.querySelector("#favourites");

let movieData = [];
const retreivedData = localStorage.getItem("favMovieData");
Expand Down Expand Up @@ -33,7 +35,7 @@ function createMovieDiv(movieData){
const movies = document.querySelector("#movies");

// edge case - if no movies found
if(!movieData || movieData.length == 0){
if(movieData.length == 0){
const ele = document.createElement('div');
ele.innerHTML = `<div class = "text-2xl mx-auto flex flex-col justify-center items-center p-2 gap-4 text-center w-[65vw] h-[85vh] rounded-md">
<div class = "flex flex-col sm:flex-row gap-3 items-center">
Expand Down Expand Up @@ -208,4 +210,6 @@ function sendingDataToHTML(element, item){
window.location.href = `./movie.html?data=${encodeURIComponent(jsonData)}`
}
})
}
}
});

0 comments on commit 202586f

Please sign in to comment.