-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #263 from NymexData/development
Development
- Loading branch information
Showing
15 changed files
with
160 additions
and
82 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Theaterflix Extension", | ||
"version": "1.0", | ||
"version": "1.1.0", | ||
"description": "Extension to display personalized recommendations for movies and series.", | ||
"action": { | ||
"default_popup": "popup/index.html" | ||
"default_popup": "popup/index.html" | ||
}, | ||
"icons": { | ||
"48": "assets/icon.png" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["<all_urls>"], | ||
"js": ["scripts/content.js"] | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
// popup.js | ||
// popup/popup.js | ||
|
||
$(document).ready(function() { | ||
// Add accordion behavior using jQuery | ||
$('.accordion-header').click(function() { | ||
$('.accordion-content').slideToggle(); | ||
// Add a click event listener to toggle the configuration section | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const configButton = document.querySelector('.accordion-header'); | ||
const configSection = document.getElementById('config-section'); | ||
|
||
configButton.addEventListener('click', () => { | ||
configSection.classList.toggle('active'); | ||
}); | ||
|
||
// Add a click event listener to save the API key | ||
$('#save-button').click(function() { | ||
const apiKey = $('#api-key').val(); | ||
const saveButton = document.getElementById('save-button'); | ||
const apiKeyInput = document.getElementById('api-key'); | ||
const statusMessage = document.getElementById('status-message'); | ||
|
||
saveButton.addEventListener('click', () => { | ||
const apiKey = apiKeyInput.value; | ||
if (apiKey) { | ||
// Save the API key to local storage or wherever you need to store it | ||
// For simplicity, let's store it in local storage | ||
// Save the API key to local storage | ||
localStorage.setItem('tmdb_api_key', apiKey); | ||
// Optionally, you can display a success message to the user | ||
alert('API Key saved successfully!'); | ||
// Display a success message to the user | ||
statusMessage.textContent = 'API Key saved successfully!'; | ||
} else { | ||
alert('Please enter a valid API Key.'); | ||
statusMessage.textContent = 'Please enter a valid API Key.'; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,53 @@ | ||
// scripts/api.js | ||
const recommendationsContainer = document.getElementById('recommendations'); | ||
// api.js | ||
|
||
// Function to fetch recommendations from the TMDB API using the user's API key | ||
async function fetchRecommendations(apiKey) { | ||
// Function to fetch movie recommendations using the provided API key | ||
async function fetchMovieRecommendations(apiKey) { | ||
try { | ||
// Fetch recommendations data from the TMDB API using the user's API key | ||
const response = await axios.get('https://api.themoviedb.org/3/discover/movie', { | ||
params: { | ||
api_key: apiKey, | ||
language: 'en-US', | ||
sort_by: 'popularity.desc', | ||
include_adult: false, | ||
include_video: false, | ||
page: 1, | ||
}, | ||
}); | ||
|
||
const recommendationsData = response.data.results; | ||
// Process the data and display recommendations in the popup | ||
displayRecommendations(recommendationsData); | ||
const response = await axios.get(`https://api.themoviedb.org/3/movie/popular?api_key=${apiKey}`); | ||
return response.data.results; | ||
} catch (error) { | ||
console.error('Error fetching recommendations:', error); | ||
console.error('Error fetching movie recommendations:', error); | ||
return []; | ||
} | ||
} | ||
|
||
// Function to display the recommendations in the popup | ||
function displayRecommendations(recommendationsData) { | ||
recommendationsContainer.innerHTML = ''; | ||
|
||
recommendationsData.forEach((recommendation) => { | ||
const { title, poster_path, vote_average } = recommendation; | ||
const poster = `https://image.tmdb.org/t/p/w200${poster_path}`; | ||
const rating = vote_average.toFixed(1); | ||
|
||
const recommendationElement = document.createElement('div'); | ||
recommendationElement.classList.add('recommendation'); | ||
recommendationElement.innerHTML = ` | ||
<img src="${poster}" alt="${title}"> | ||
<h3>${title}</h3> | ||
<p>Rating: ${rating}/10</p> | ||
<hr> | ||
`; | ||
|
||
recommendationsContainer.appendChild(recommendationElement); | ||
// Function to render movie recommendations in the popup | ||
function renderMovieRecommendations(recommendations) { | ||
const recommendationsList = document.getElementById('recommendations-list'); | ||
|
||
recommendationsList.innerHTML = ''; // Clear previous recommendations | ||
|
||
recommendations.forEach((movie) => { | ||
const movieBox = document.createElement('div'); | ||
movieBox.className = 'movie-box'; | ||
|
||
const moviePoster = document.createElement('img'); | ||
moviePoster.className = 'movie-poster'; | ||
moviePoster.src = `https://image.tmdb.org/t/p/w185${movie.poster_path}`; | ||
movieBox.appendChild(moviePoster); | ||
|
||
const movieInfo = document.createElement('div'); | ||
movieInfo.className = 'movie-info'; | ||
|
||
const movieTitle = document.createElement('h2'); | ||
movieTitle.textContent = movie.title; | ||
movieInfo.appendChild(movieTitle); | ||
|
||
const movieOverview = document.createElement('p'); | ||
movieOverview.textContent = movie.overview; | ||
movieInfo.appendChild(movieOverview); | ||
|
||
movieBox.appendChild(movieInfo); | ||
recommendationsList.appendChild(movieBox); | ||
}); | ||
} | ||
|
||
// Fetch the user's API key from local storage | ||
chrome.storage.local.get(['apiKey'], (result) => { | ||
const apiKey = result.apiKey; | ||
if (apiKey) { | ||
fetchRecommendations(apiKey); | ||
} else { | ||
// Display a message to prompt the user to enter their API key | ||
console.log('Please enter your API key.'); | ||
} | ||
}); | ||
// Check if the API key is already saved in local storage | ||
const apiKey = localStorage.getItem('tmdb_api_key'); | ||
|
||
// If the API key is already saved, fetch and render movie recommendations | ||
if (apiKey) { | ||
fetchMovieRecommendations(apiKey) | ||
.then((recommendations) => renderMovieRecommendations(recommendations)) | ||
.catch((error) => console.error('Error fetching movie recommendations:', error)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* styles/popup.css */ | ||
/* popup.css */ | ||
body { | ||
width: 600px; /* Set the width of the popup */ | ||
margin: 20px auto; /* Center the popup horizontally */ | ||
padding: 20px; | ||
} | ||
|
||
#recommendations-list { | ||
list-style: none; | ||
padding: 0; | ||
} | ||
|
||
.movie-box { | ||
border: 1px solid #ccc; | ||
padding: 10px; | ||
margin-bottom: 10px; | ||
display: flex; | ||
} | ||
|
||
.movie-poster { | ||
width: 100px; | ||
height: 150px; | ||
object-fit: cover; | ||
margin-right: 10px; | ||
} | ||
|
||
.movie-info { | ||
flex: 1; | ||
} | ||
|
||
|
||
/* CSS styles for the configuration section */ | ||
#config-section { | ||
display: none; | ||
border: 1px solid #ccc; | ||
padding: 10px; | ||
margin-bottom: 10px; | ||
} | ||
#config-section.active { | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters