Remove popup in js and create url from js or .htaccess

In the following script index.html:

    <!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>جستجوگر فیلم و سریال | IMDB And OMDB</title>
  <link rel='stylesheet' href=''>
</head>
<body>
<!-- partial:index.partial.html -->
<div id='app'></div>

<!-- Courtesy to OMDB API -->
<!-- partial -->
  <script src=''></script>
<script src=''></script></script>
</body>
</html>

In the following script style.css:

@import url("https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400;700&display=swap");
* {
  box-sizing: border-box;
  font-family: "Roboto Condensed", sans-serif;
}

body {
  background: linear-gradient(to right, #42275a, #734b6d);
  margin: 0;
  padding: 0;
}
body::-webkit-scrollbar-track {
  background-color: #734b6d;
}
body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background-color: transparent;
}
body::-webkit-scrollbar-thumb {
  background-color: #42275a;
}

img {
  max-width: 100%;
}

.head {
  text-align: center;
  font-size: 1.5rem;
  color: #a8e063;
  text-shadow: 0 13.36px 14.896px #42275a;
  margin: 20px;
}

.search {
  height: 100px;
  display: grid;
  place-content: center;
}
.search-box {
  display: flex;
  transition: all 0.2s ease;
}
.search-box:focus-within {
  box-shadow: 0 3px 5px -2px rgba(0, 0, 0, 0.3);
}
.search-box input {
  appearance: none;
  border: 0;
  outline: 0;
  height: 40px;
  background-color: white;
  padding: 0 10px;
  min-width: 350px;
}
.search-box button {
  appearance: none;
  border: 0;
  outline: 0;
  height: 40px;
  background-color: white;
  padding: 0 10px;
  cursor: pointer;
}

.cards {
  animation: poof 0.5s;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: minmax(min-content, max-content);
  padding: 10px;
  gap: 10px;
  min-height: 68vh;
  align-items: start;
}

.cards > div:nth-child(1) {
  animation-delay: 0.1s;
}

.cards > div:nth-child(2) {
  animation-delay: 0.2s;
}

.cards > div:nth-child(3) {
  animation-delay: 0.3s;
}

.cards > div:nth-child(4) {
  animation-delay: 0.4s;
}

.cards > div:nth-child(5) {
  animation-delay: 0.5s;
}

.cards > div:nth-child(6) {
  animation-delay: 0.6s;
}

.cards > div:nth-child(7) {
  animation-delay: 0.7s;
}

.cards > div:nth-child(8) {
  animation-delay: 0.8s;
}

.cards > div:nth-child(9) {
  animation-delay: 0.9s;
}

.cards > div:nth-child(10) {
  animation-delay: 1s;
}

.card {
  opacity: 0;
  animation: poof 0.5s forwards;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 3px 5px -2px rgba(0, 0, 0, 0.3);
}
.card:hover img {
  transform: scale(1.04);
}
.card img {
  cursor: pointer;
  display: block;
  width: 100%;
  transition: all 0.3s ease;
}
.show-expand {
  z-index: 100000;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(5px);
}
.show-expand::-webkit-scrollbar-track {
  background-color: transparent;
}
.show-expand::-webkit-scrollbar {
  width: 6px;
  height: 6px;
  background-color: transparent;
}
.show-expand::-webkit-scrollbar-thumb {
  background-color: #42275a;
}

.show-content {
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 400px;
  animation: poof 0.5s;
  overflow: hidden;
  margin: 12px auto;
  width: 100%;
  max-width: 800px;
  color: #fff;
  background: linear-gradient(to left, #3ca55c, #56ab2f);
  border-radius: 0.8em;
  box-shadow: rgba(0, 0, 0, 0.2) 0 30px 18px -24px;
}
@media (max-width: 600px) {
  .show-content {
    flex-direction: column;
  }
}

.show-poster {
  position: relative;
  display: flex;
}
.show-poster-bg {
  position: absolute;
  overflow: hidden;
  top: -20%;
  bottom: -20%;
  left: -20%;
  width: 100%;
  height: 150%;
  transform: rotate(5deg);
}
@media (max-width: 600px) {
  .show-poster-bg {
    left: auto;
    top: -80%;
    width: 150%;
  }
}
.show-poster-bg img {
  filter: blur(6px);
  object-fit: cover;
  width: 100%;
  height: 100%;
  transform: scale(1.4);
}
.show-poster-main {
  position: relative;
  left: 56px;
  align-self: center;
  overflow: hidden;
  width: 140px;
  background-color: gainsboro;
  border-radius: 2px;
  box-shadow: rgba(0, 0, 0, 0.6) 0 6px 12px -6px;
  z-index: 1;
}
@media (max-width: 600px) {
  .show-poster-main {
    left: auto;
    margin-top: 84px;
    margin-left: 24px;
  }
}
.show-poster-main img {
  width: 140px;
  vertical-align: middle;
}

.show-detail {
  flex: 1;
  padding: 72px;
}
@media (max-width: 600px) {
  .show-detail {
    padding: 24px;
  }
}
.show-detail h2 {
  font-size: 2em;
  margin: 0;
  margin-bottom: 12px;
}
.show-detail .show-tags {
  margin: 0;
  padding: 0;
  font-size: 0.75em;
  color: #d7f1b8;
  list-style: none;
  margin-bottom: 12px;
}
.show-detail .show-tags li {
  display: inline-block;
  margin-right: 12px;
  font-size: 0.9em;
  line-height: 1.5;
}
.show-detail .show-plot {
  font-size: 0.9em;
  line-height: 1.5;
  margin-bottom: 12px;
}
.show-detail .show-credits p {
  margin: 0;
  font-size: 0.9em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.show-close {
  z-index: 1;
  font-size: 24px;
  position: absolute;
  top: 14px;
  right: 14px;
  margin: auto;
  padding: 15px 20px;
  cursor: pointer;
}
@media (max-width: 600px) {
  .show-close {
    color: #fff;
  }
}
.show-close:hover {
  color: red;
}

.loader, .error {
  grid-column: 1/-1;
  text-align: center;
  font-size: 24px;
  animation: poof 0.5s;
  color: #a8e063;
}

.pagination {
  margin: 15px auto;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  outline: none;
}

.pagination > .active > a {
  background-color: #fff;
  border-color: #fff;
  color: #56ab2f;
}

.pagination > li > a {
  border: 1px solid #fff;
  padding: 5px 10px;
  outline: none;
  cursor: pointer;
}

.pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus {
  background-color: #fff;
  border-color: #fff;
  outline: none;
}

.pagination > li > a, .pagination > li > span {
  color: #fff;
}

.pagination > li:first-child > a, .pagination > li:first-child > span, .pagination > li:last-child > a, .pagination > li:last-child > span {
  border-radius: unset;
}

/* Keyframes  */
@keyframes poof {
  0% {
    opacity: 0;
    transform: translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: translateY(0px);
  }
}

In the following script script.js:

function _extends() {_extends = Object.assign || function (target) {for (var i = 1; i < arguments.length; i++) {var source = arguments[i];for (var key in source) {if (Object.prototype.hasOwnProperty.call(source, key)) {target[key] = source[key];}}}return target;};return _extends.apply(this, arguments);}import axios, * as others from "https://cdn.skypack.dev/axios@0.21.1";
import ReactPaginate from "https://cdn.skypack.dev/react-paginate@7.1.0";

// https://www.omdbapi.com/?apikey=756abb2f&i=tt4154664&plot=full

const { useState, useEffect } = React;

// Main component -------------------------------
const Main = props => {

  const getMovies = (term = 'war', page = 1) => {
    setLoading(true);
    axios.get(`https://www.omdbapi.com/?apikey=756abb2f&s=${encodeURIComponent(term)}&plot=full&page=${page}`).
    then(response => {
      // console.log(response.data);
      setMovies(response.data.Search);
      setTotal(Math.ceil(response.data.totalResults / 10));
      setPages(page);
      setLoading(false);
    }).catch(error => {
      // console.log(error);
      setMovies([]);
      setLoading(false);
    });
  };

  const getMovie = movieId => {
    axios.get(`https://www.omdbapi.com/?apikey=756abb2f&i=${movieId}&plot=full`).
    then(response => {
      // console.log(response.data);
      setMovie(response.data);
      setShowPop(true);
    });
  };

  const [loading, setLoading] = useState(true);
  const [showPop, setShowPop] = useState(false);
  const [movies, setMovies] = useState([]);
  const [movie, setMovie] = useState({});
  const [keyword, setKeyword] = useState('frozen');
  const [pages, setPages] = useState(1);
  const [total, setTotal] = useState();
  useEffect(() => {
    getMovies();
  }, []);

  const handlePageClick = e => {
    console.log(e.selected);
    getMovies(keyword, e.selected + 1);
  };

  const handleCardClicked = movieId => {
    // console.log(movieId);
    getMovie(movieId);

  };

  const genCards = () => {
    let allCards = [];
    if (movies) {
      movies.map(movie => {
        allCards.push( /*#__PURE__*/React.createElement(Card, _extends({}, movie, { cardClicked: handleCardClicked })));
      });
    }
    return allCards;
  };

  let allCards = genCards();

  return /*#__PURE__*/(
    React.createElement("div", { className: "main" }, /*#__PURE__*/
    React.createElement("h1", { className: "head" }, "جستجوگر فیلم و سریال"), /*#__PURE__*/
    React.createElement(Search, {
      getInputValue: val => setKeyword(val),
      sendEnter: () => getMovies(keyword),
      getSubmit: () => getMovies(keyword) }),

    showPop ? /*#__PURE__*/React.createElement(Showexpand, _extends({}, movie, { closePop: () => setShowPop(false) })) : null, /*#__PURE__*/

    React.createElement("div", { className: "cards" },
    loading ? /*#__PURE__*/React.createElement(Loader, null) :
    allCards.length === 0 ? /*#__PURE__*/
    React.createElement("div", { className: "error" }, "No movie found...", /*#__PURE__*/

    React.createElement("i", { class: "far fa-grin-beam-sweat" })) :
    allCards), /*#__PURE__*/


    React.createElement("div", { className: "paginate" }, /*#__PURE__*/
    React.createElement(ReactPaginate, {
      previousLabel: "Back",
      nextLabel: "Next",
      breakLabel: "...",
      breakClassName: "break-me",
      pageCount: total,
      marginPagesDisplayed: 1,
      pageRangeDisplayed: 4,
      onPageChange: handlePageClick,
      containerClassName: "pagination",
      subContainerClassName: "pages pagination",
      activeClassName: "active" }))));






};



// Loader component -------------------------------
const Loader = props => {

  return /*#__PURE__*/(
    React.createElement("div", { className: "loader" }, "Loading...", /*#__PURE__*/

    React.createElement("i", { class: "fas fa-sync-alt fa-spin" })));


};


// Search component -------------------------
const Search = props => {

  let sendValue = e => {
    props.getInputValue(e.target.value);
  };

  const handleSubmit = () => {
    props.getSubmit();
  };

  const handleKeyDown = e => {
    if (e.key === 'Enter') {
      props.sendEnter();
      // console.log('Enter');
    }
  };

  return /*#__PURE__*/(
    React.createElement("div", { className: "search" }, /*#__PURE__*/
    React.createElement("div", { className: "search-box" }, /*#__PURE__*/
    React.createElement("input", { type: "text",
      onChange: sendValue,
      onKeyDown: handleKeyDown,
      placeholder: "Find movie..." }), /*#__PURE__*/
    React.createElement("button", { onClick: handleSubmit }, /*#__PURE__*/React.createElement("i", { class: "fas fa-search" })))));



};


// Card component ------------------------------------------------
const Card = props => {

  // console.log(props);
  const handleClick = e => {
    // console.log(e.target.dataset.id);
    props.cardClicked(e.target.dataset.id);
  };
  return /*#__PURE__*/(
    React.createElement("div", { className: "card", title: props.Title, "data-id": props.imdbID, onClick: handleClick }, /*#__PURE__*/
    React.createElement("img", { src: props.Poster !== 'N/A' ? props.Poster : 'https://via.placeholder.com/163x240/111217/FFFFFF/?text=No%20Image', alt: props.Title, "data-id": props.imdbID })));


};



// Show expand component ---------------------------------------
const Showexpand = props => {

  console.log(props);

  return /*#__PURE__*/(
    React.createElement("div", { className: "show-expand" }, /*#__PURE__*/

    React.createElement("div", { className: "show-content" }, /*#__PURE__*/
    React.createElement("i", { class: "show-close fas fa-times", onClick: props.closePop }), /*#__PURE__*/

    React.createElement("div", { className: "show-poster" }, /*#__PURE__*/
    React.createElement("span", { className: "show-poster-bg" }, /*#__PURE__*/
    React.createElement("img", { src: props.Poster !== 'N/A' ? props.Poster : 'https://via.placeholder.com/163x240/111217/FFFFFF/?text=No%20Image', alt: props.Title })), /*#__PURE__*/

    React.createElement("span", { className: "show-poster-main" }, /*#__PURE__*/
    React.createElement("img", { src: props.Poster !== 'N/A' ? props.Poster : 'https://via.placeholder.com/163x240/111217/FFFFFF/?text=No%20Image', alt: props.Title }))), /*#__PURE__*/



    React.createElement("div", { className: "show-detail" }, /*#__PURE__*/
    React.createElement("h2", null, props.Title), /*#__PURE__*/
    React.createElement("ul", { className: "show-tags" }, /*#__PURE__*/
    React.createElement("li", { className: "show-rated" }, props.Country), /*#__PURE__*/
    React.createElement("li", { className: "show-rated" }, props.Year), /*#__PURE__*/
    React.createElement("li", { className: "show-year" }, props.Rated), /*#__PURE__*/
    React.createElement("li", { className: "show-year" }, props.Genre)), /*#__PURE__*/

    React.createElement("div", { class: "show-plot" }, /*#__PURE__*/
    React.createElement("p", null, props.Plot)), /*#__PURE__*/


    React.createElement("div", { class: "show-credits" }, /*#__PURE__*/
    React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "Production:"), " ", props.Production), /*#__PURE__*/
    React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "Runtime:"), " ", props.Runtime || 'N/A '), /*#__PURE__*/
    React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "Rating:"), " ", props.imdbRating), /*#__PURE__*/
    React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "Director:"), " ", props.Director), /*#__PURE__*/
    React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "Actors:"), " ", props.Actors), /*#__PURE__*/
    React.createElement("p", null, /*#__PURE__*/React.createElement("strong", null, "BoxOffice:"), " ", props.BoxOffice || 'N/A '))))));






};

ReactDOM.render( /*#__PURE__*/React.createElement(Main, null), document.getElementById('app'));

I ran into a problem with this script that I can’t figure out
After clicking on all the videos, they will be opened as a pop-up and their information will be displayed.
But I want the pages to open after clicking like this:

site/index.php?id=tt12345

Or

site/tt12345

But I don’t have enough knowledge to do this, the script with all the details and codes is at your disposal above.

I don’t really understand the question, what exactly is it you are trying to do?

Also, you have posted Babel transpiled code instead of the actual source code.

Hello, what I mean is that if you run these codes, the output of these codes will be an omdb api system, which will display its information by clicking on each video, now I want this information on a separate page. be displayed

Do you want to route to a different “page” and show the movie information on that page instead of a modal?

You can use a router (like react-router-dom). Look up some react-router-dom tutorials if you haven’t used it before.


Did you copy this code from a deployed app, is that why you have transpiled code? Do you not have the original source code?

Regarding your first question, yes, I want them to be on a separate and independent page, and I must also declare that I am using a shared host and not using a server.

Original source code:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.