From 1eee181e219dfd993d396ac3169e7aad3dd285eb Mon Sep 17 00:00:00 2001 From: Factiven Date: Sun, 16 Jul 2023 22:35:39 +0700 Subject: Update v3.6.4 - Added Manga page with a working tracker for AniList user - Added schedule component to home page - Added disqus comment section so you can fight on each other (not recommended) - Added /id and /en route for english and indonesian subs (id route still work in progress) --- components/hero/content.js | 244 --------------------------------------------- 1 file changed, 244 deletions(-) delete mode 100644 components/hero/content.js (limited to 'components/hero/content.js') diff --git a/components/hero/content.js b/components/hero/content.js deleted file mode 100644 index 24ee942..0000000 --- a/components/hero/content.js +++ /dev/null @@ -1,244 +0,0 @@ -import Link from "next/link"; -import React, { useState, useRef, useEffect } from "react"; -import Image from "next/image"; -import { MdChevronRight } from "react-icons/md"; -import { - ChevronRightIcon, - ArrowRightCircleIcon, -} from "@heroicons/react/24/outline"; - -import { ChevronLeftIcon } from "@heroicons/react/20/solid"; -import { ExclamationCircleIcon } from "@heroicons/react/24/solid"; - -export default function Content({ ids, section, data, og }) { - const [startX, setStartX] = useState(null); - const [scrollLefts, setScrollLefts] = useState(null); - const containerRef = useRef(null); - - const [isDragging, setIsDragging] = useState(false); - const [clicked, setClicked] = useState(false); - - useEffect(() => { - const click = localStorage.getItem("clicked"); - if (click) { - setClicked(JSON.parse(click)); - } - }, []); - - const handleMouseDown = (e) => { - setIsDragging(true); - setStartX(e.pageX - containerRef.current.offsetLeft); - setScrollLefts(containerRef.current.scrollLeft); - }; - - const handleMouseUp = () => { - setIsDragging(false); - }; - - const handleMouseMove = (e) => { - if (!isDragging) return; - e.preventDefault(); - const x = e.pageX - containerRef.current.offsetLeft; - const walk = (x - startX) * 3; - containerRef.current.scrollLeft = scrollLeft - walk; - }; - - const handleClick = (e) => { - if (isDragging) { - e.preventDefault(); - } - }; - - const [scrollLeft, setScrollLeft] = useState(false); - const [scrollRight, setScrollRight] = useState(true); - - const slideLeft = () => { - var slider = document.getElementById(ids); - slider.scrollLeft = slider.scrollLeft - 500; - }; - const slideRight = () => { - var slider = document.getElementById(ids); - slider.scrollLeft = slider.scrollLeft + 500; - }; - - const handleScroll = (e) => { - const scrollLeft = e.target.scrollLeft > 31; - const scrollRight = - e.target.scrollLeft < e.target.scrollWidth - e.target.clientWidth; - setScrollLeft(scrollLeft); - setScrollRight(scrollRight); - }; - - function handleAlert(e) { - if (localStorage.getItem("clicked")) { - const existingDataString = localStorage.getItem("clicked"); - const existingData = JSON.parse(existingDataString); - - existingData[e] = true; - - const updatedDataString = JSON.stringify(existingData); - - localStorage.setItem("clicked", updatedDataString); - } else { - const newData = { - [e]: true, - }; - - const newDataString = JSON.stringify(newData); - - localStorage.setItem("clicked", newDataString); - } - } - - const array = data; - let filteredData = array?.filter((item) => item !== null); - const slicedData = - filteredData?.length > 15 ? filteredData?.slice(0, 15) : filteredData; - - return ( -
-
-

{section}

- -
-
-
- -
-
- {slicedData?.map((anime) => { - const progress = og?.find((i) => i.mediaId === anime.id); - return ( -
- - {ids === "onGoing" && ( -
-
-

- {anime.title.romaji || anime.title.english} -

- {checkProgress(progress) && - !clicked?.hasOwnProperty(anime.id) && ( - - )} - {checkProgress(progress) && ( -
handleAlert(anime.id)} - className="group-hover:visible invisible absolute top-0 bg-black bg-opacity-20 w-full h-full z-20 text-center" - > -

- {checkProgress(progress)} -

-
- )} -
-

Episode {anime.nextAiringEpisode.episode} in

-

- {convertSecondsToTime( - anime?.nextAiringEpisode?.timeUntilAiring - )} -

-
-
-
- )} - {anime.title.romaji - -
- ); - })} - {filteredData.length >= 10 && section !== "Recommendations" && ( -
-
-

- More on {section} -

- -
-
- )} -
- -
-
- ); -} - -function convertSecondsToTime(sec) { - let days = Math.floor(sec / (3600 * 24)); - let hours = Math.floor((sec % (3600 * 24)) / 3600); - let minutes = Math.floor((sec % 3600) / 60); - - let time = ""; - - if (days > 0) { - time += `${days}d `; - time += `${hours}h`; - } else { - time += `${hours}h `; - time += `${minutes}m`; - } - - return time.trim(); -} - -function checkProgress(entry) { - const { progress, media } = entry; - const { episodes, nextAiringEpisode } = media; - - if (nextAiringEpisode !== null) { - const { episode } = nextAiringEpisode; - - if (episode - progress > 1) { - const missedEpisodes = episode - progress - 1; - return `${missedEpisodes} episode${missedEpisodes > 1 ? "s" : ""} behind`; - } - } - - return; -} -- cgit v1.2.3