diff --git a/fetchShowing.js b/fetchShowing.js index aaedc6b..1a7d9dd 100644 --- a/fetchShowing.js +++ b/fetchShowing.js @@ -1,22 +1,41 @@ - // Define the movie card HTML as a template - const movieCardTemplate = ` -
-
- -
-

Abigail

-
- -
-
-
-
- `; +// Read the movie data from the Movies.txt file +fetch('Movies.txt') + .then(response => response.text()) + .then(data => { + const movieData = []; + const lines = data.split('\n'); - // Get the container element - const container = document.getElementById('showing-movies-container'); + for (let i = 0; i < lines.length; i++) { + const line = lines[i].trim(); + if (line.startsWith('MoviesShowing\\')) { + const parts = line.split('\\'); + const name = parts[1].replace(/.jpg/g, ''); + const image = `MoviesShowing/${parts[1]}`; + movieData.push({ name, image }); + } + } - // Insert the movie card template 10 times - for (let i = 0; i < 10; i++) { - container.innerHTML += movieCardTemplate; - } \ No newline at end of file + // Define the movie card HTML as a template function + const movieCardTemplate = (movie) => ` +
+
+ +
+

${movie.name}

+
+ +
+
+
+
+ `; + + // Get the container element + const container = document.getElementById('showing-movies-container'); + + // Generate the HTML for each movie and append it to the container + movieData.forEach(movie => { + container.innerHTML += movieCardTemplate(movie); + }); + }) + .catch(error => console.error('Error:', error)); \ No newline at end of file diff --git a/fetchUpcoming.js b/fetchUpcoming.js index bae612f..6243d57 100644 --- a/fetchUpcoming.js +++ b/fetchUpcoming.js @@ -1,25 +1,44 @@ -// Define the upcoming movie card HTML as a template -const upcomingMovieCardTemplate = ` -
-
- -
-

Anh Hùng Bàn Phím

-
- +// Read the movie data from the Movies.txt file +fetch('Movies.txt') + .then(response => response.text()) + .then(data => { + const upcomingMovieData = []; + const lines = data.split('\n'); + + for (let i = 0; i < lines.length; i++) { + const line = lines[i].trim(); + if (line.startsWith('MoviesUpcoming\\')) { + const parts = line.split('\\'); + const name = parts[1].replace(/.jpg/g, ''); + const image = `MoviesUpcoming/${parts[1]}`; + upcomingMovieData.push({ name, image }); + } + } + + // Define the upcoming movie card HTML as a template function + const upcomingMovieCardTemplate = (movie) => ` +
+
+ +
+

${movie.name}

+
+ +
+
-
-
-`; + `; -// Get the container element -const upcomingContainer = document.getElementById('pills-sub'); + // Get the container element + const upcomingContainer = document.getElementById('pills-sub'); -// Get the row2 element inside the container -const row2 = upcomingContainer.querySelector('.row2'); + // Get the row2 element inside the container + const row2 = upcomingContainer.querySelector('.row2'); -// Insert the upcoming movie card template 10 times -for (let i = 0; i < 10; i++) { - row2.innerHTML += upcomingMovieCardTemplate; -} \ No newline at end of file + // Generate the HTML for each upcoming movie and append it to the row2 element + upcomingMovieData.forEach(movie => { + row2.innerHTML += upcomingMovieCardTemplate(movie); + }); + }) + .catch(error => console.error('Error:', error)); \ No newline at end of file diff --git a/fetchmovies.js b/fetchmovies.js new file mode 100644 index 0000000..1b3a577 --- /dev/null +++ b/fetchmovies.js @@ -0,0 +1,31 @@ +// Run in Node.js +const fs = require('fs'); +const path = require('path'); + +const directoryPaths = ['MoviesShowing', 'MoviesUpcoming']; +const outputFile = 'movies.txt'; + +// Function to fetch JPG file names in a directory +function fetchJPGFileNames(directory) { + return fs.readdirSync(directory) + .filter(file => path.extname(file).toLowerCase() === '.jpg'); +} + +// Function to write file names to a text file +function writeToFile(fileNames) { + fs.writeFileSync(outputFile, fileNames.join('\n')); +} + +// Main function to fetch file names from directories and write to file +function fetchAndWriteFileNames() { + let allFileNames = []; + directoryPaths.forEach(directory => { + const fileNames = fetchJPGFileNames(directory); + allFileNames = allFileNames.concat(fileNames.map(fileName => path.join(directory, fileName))); + }); + + writeToFile(allFileNames); + console.log(`File names written to ${outputFile}`); +} + +fetchAndWriteFileNames(); \ No newline at end of file diff --git a/index.html b/index.html index 5eb331d..6285b78 100644 --- a/index.html +++ b/index.html @@ -25,6 +25,7 @@ + diff --git a/minh.html b/minh.html new file mode 100644 index 0000000..2b6db96 --- /dev/null +++ b/minh.html @@ -0,0 +1,42 @@ + + + + + + YouTube Search + + +

YouTube Search Result

+
+ + + + diff --git a/movies.txt b/movies.txt new file mode 100644 index 0000000..8a9a01e --- /dev/null +++ b/movies.txt @@ -0,0 +1,27 @@ +MoviesShowing\Abigail.jpg +MoviesShowing\DUNE Phần Hai.jpg +MoviesShowing\Exhuma Quật Mộ Trùng Ma.jpg +MoviesShowing\Godzilla X Kong Đế Chế Mới.jpg +MoviesShowing\Kung Fu Panda 4.jpg +MoviesShowing\Mai.jpg +MoviesShowing\Mobile Suit Gundam SEED FREEDOM.jpg +MoviesShowing\Monkey Man.jpg +MoviesShowing\Muôn Vị Nhân Gian.jpg +MoviesShowing\Người Chết Trở Về.jpg +MoviesShowing\Quỷ Thuật.jpg +MoviesShowing\Sáng Đèn.jpg +MoviesShowing\Thanh Xuân 18x2 Lữ Trình Hướng Về Em.jpg +MoviesShowing\Điềm Báo Của Quỷ.jpg +MoviesShowing\Đền Mạng.jpg +MoviesUpcoming\Anh Hùng Bàn Phím.jpg +MoviesUpcoming\B4S – Trước Giờ “Yêu”.jpg +MoviesUpcoming\Biệt Đội Săn Ma Kỷ Nguyên Băng Giá.jpg +MoviesUpcoming\Cái Giá Của Hạnh Phúc.jpg +MoviesUpcoming\Hòa Quang Đẫm Máu.jpg +MoviesUpcoming\Mùa Hè Của Luca.jpg +MoviesUpcoming\Ngày Tàn Của Đế Quốc.jpg +MoviesUpcoming\Người Bạn Trong Tưởng Tượng.jpg +MoviesUpcoming\Quỷ Cái.jpg +MoviesUpcoming\SUGA Agust D TOUR ‘D-DAY’ THE MOVIE.jpg +MoviesUpcoming\Trò Chơi Chết Chóc.jpg +MoviesUpcoming\Đóa Hoa Mong Manh.jpg \ No newline at end of file