Skip to content

Commit

Permalink
component folder change
Browse files Browse the repository at this point in the history
  • Loading branch information
RishiWebDeveloper1 authored Jun 30, 2024
1 parent 5c53a62 commit b857d87
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 67 deletions.
1 change: 1 addition & 0 deletions components/apps/camera/camera.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Camera</title>
<link rel="stylesheet" href="camera.css">

</head>

<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<!-- https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1&mute=1 -->
<div class="tool-bar-box">
<div class="logo-box">
<img src="../../images/youtube_icon.png" alt="YouTube" class="logo-icon">
<a href="/youtube.html">
<img src="../../images/youtube_icon.png" alt="YouTube" class="logo-icon">
</a>
</div>
<div class="search-box">
<input type="text" id="searchInput" placeholder="Search...">
Expand Down
18 changes: 18 additions & 0 deletions components/apps/youtube/key_functionality.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
document.addEventListener("keydown", handelKeydown);

function handelKeydown(event) {
// event.preventDefault();
if (event.key == "ArrowDown" || event.key == "ArrowUp") {
console.log("event");
searchResults.focus();
}
else if (event.ctrlKey && event.key === "Enter") {
searchInput.focus()
}
}

searchInput.addEventListener('keypress', function(event) {
if (event.key === 'Enter') {
serachQuery();
}
});
48 changes: 11 additions & 37 deletions components/apps/youtube/youtube.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
<div class="container">
<div class="tool-bar-box">
<div class="logo-box">
<img src="images\youtube_icon.png" alt="YouTube" class="logo-icon">
<a href="">
<img src="images\youtube_icon.png" alt="YouTube" class="logo-icon">
</a>
</div>
<div class="search-box">
<input type="text" id="searchInput" placeholder="Search...">
Expand All @@ -29,6 +31,11 @@
<div id="searchResultsBox">







<!-- <div class="search-result">
<div class="video-detail-box"
onclick="storeDataToLocal('LIVE: PM Modi pays floral tribute at the statue of Babasaheb Ambedkar in Mumbai', 'VbQsDdIx-Qk', 'Prime Minister Narendra Modi pays floral tribute at the statue of Babasaheb Ambedkar in Mumbai. #narendramodi ...', 'UC1NF71EwP41VdjAU1iXdLkw')">
Expand All @@ -46,15 +53,6 @@ <h3 class="title">LIVE: PM Modi pays floral tribute at the statue of Babasaheb A
<h3 class="title">Ujung Tanduk - Bakwan: Fight Back Episode 15 [ Minecraft Roleplay ]</h3>
</div>
</div>
<div class="search-result">
<div class="video-detail-box"
onclick="storeDataToLocal('Martin O'Neill DEFENDS Arsenal &amp; Insists They DO NOT Deserve To Be Labelled As BOTTLERS! 👀🔥', 'TvofF_i-xTw', 'Simon Jordan, Jim White &amp; Martin O'Neill debate if Arsenal can proud of their season, even if they fail to win the Premier League ...', 'UCWw6scNyopJ0yjMu1SyOEyw')">
<img class="thumbnail-image" src="https://i.ytimg.com/vi/TvofF_i-xTw/hqdefault.jpg"
alt="Martin O'Neill DEFENDS Arsenal &amp; Insists They DO NOT Deserve To Be Labelled As BOTTLERS! 👀🔥">
<h3 class="title">Martin O'Neill DEFENDS Arsenal &amp; Insists They DO NOT Deserve To Be
Labelled As BOTTLERS! 👀🔥</h3>
</div>
</div>
<div class="search-result">
<div class="video-detail-box"
onclick="storeDataToLocal('BREAKING: Scottie Scheffler arrested by police before start of PGA championship', '98JBgfYeG64', 'World No. 1 golfer Scottie Scheffler was detained by police and charged with assaulting an officer and other counts Friday outside ...', 'UCaXkIU1QidjPwiAYu6GcHjg')">
Expand Down Expand Up @@ -91,34 +89,9 @@ <h3 class="title">"Most intense week of my life" | Jurgen Klopp speaks ahead of
Liverpool match</h3>
</div>
</div>
<div class="search-result">
<div class="video-detail-box"
onclick="storeDataToLocal('가사 도우미 일하러 갔다가 &quot;주인이 준 커피 마셨는데&quot; …/ KNN', 'GiyKUfM1C3Q', 'knn뉴스 ▷ 전화 부산 051-850-9000 경남 055-283-0505 ▷ 이메일 [email protected] ▷ knn 홈페이지/앱 접속, 제보 누르기 ▷ 카카오 ...', 'UC1ifSsWUG241rRfK0ezYCgA')">
<img class="thumbnail-image" src="https://i.ytimg.com/vi/GiyKUfM1C3Q/hqdefault.jpg"
alt="가사 도우미 일하러 갔다가 &quot;주인이 준 커피 마셨는데&quot; …/ KNN">
<h3 class="title">가사 도우미 일하러 갔다가 "주인이 준 커피 마셨는데" …/ KNN</h3>
</div>
</div>
<div class="search-result">
<div class="video-detail-box"
onclick="storeDataToLocal('International Court : युद्ध अपराध' पर इसराइल क्या बोला? । 17 May । दिनभर (BBC Hindi)', 'bfmrF3KG9vY', 'बीबीसी हिंदी का पॉडकास्ट दिनभर-पूरा दिन, पूरी ख़बर, विनीत खरे और ...', 'UCN7B-QD0Qgn2boVH5Q0pOWg')">
<img class="thumbnail-image" src="https://i.ytimg.com/vi/bfmrF3KG9vY/hqdefault_live.jpg"
alt="International Court : युद्ध अपराध' पर इसराइल क्या बोला? । 17 May । दिनभर (BBC Hindi)">
<h3 class="title">International Court : युद्ध अपराध' पर इसराइल क्या बोला? । 17 May । दिनभर
(BBC Hindi)</h3>
</div>
</div>
<div class="search-result">
<div class="video-detail-box"
onclick="storeDataToLocal('Sabse Bada Sawal: 4 जून को अबकी बार...'मुफ्त' वाली सरकार ? | Garima Singh | INDIA | NDA | PM Modi', 'MDsjTnqryOQ', 'loksabhaelection2024 #indiavsnda #pmmodi #rahulgandhi #arvindkejriwal #news24 Sabse Bada Sawal: 4 जून को अबकी ...', 'UCuzS3rPQAYqHcLWqOFuY0pw')">
<img class="thumbnail-image" src="https://i.ytimg.com/vi/MDsjTnqryOQ/hqdefault.jpg"
alt="Sabse Bada Sawal: 4 जून को अबकी बार...'मुफ्त' वाली सरकार ? | Garima Singh | INDIA | NDA | PM Modi">
<h3 class="title">Sabse Bada Sawal: 4 जून को अबकी बार...'मुफ्त' वाली सरकार ? | Garima Singh
| INDIA | NDA | PM Modi</h3>
</div>
</div>
</div> -->



</div>
Expand All @@ -131,6 +104,7 @@ <h3 class="title">Sabse Bada Sawal: 4 जून को अबकी बार...
</div>

<script src="youtube.js"></script>
<script src="key_functionality.js"></script>
</body>

</html>
67 changes: 39 additions & 28 deletions components/apps/youtube/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ function displaySearchResults(results) {

function storeDataToLocal(title, videoId, discription, channelId) {

let getTitle = localStorage.setItem('title-youtube', title);
let getUrl = localStorage.setItem('url-youtube', videoId);
let getDiscription = localStorage.setItem('discription-youtube', discription);
let getchannelId = localStorage.setItem('channelId-youtube', channelId);
localStorage.setItem('title-youtube', title);
localStorage.setItem('url-youtube', videoId);
localStorage.setItem('discription-youtube', discription);
localStorage.setItem('channelId-youtube', channelId);

window.location.href = "components/video_player/video_player.html";
}
Expand All @@ -89,11 +89,12 @@ function storeQuery(query) {
// const apiKey = 'AIzaSyCkzOqQxFUSEBsN7pO_W797gQCZJ9_haM4'; // my own key
// const apiKey = 'AIzaSyB61dCiMiNQ0njfW4uUCORhE2P96oQrMs0';
// const apiKey = 'AIzaSyDQvEF9PuhdW3JJM28VQZXQGOo84iYvd-Q';
const apiKey = 'AIzaSyAwM_RLjqj8dbbMAP5ls4qg1olDsaxSq5s';
// const apiKey = 'AIzaSyAzfFLwjVLNVIHbBf8EWOSH3nCE0zLgF44';
// const apiKey = 'AIzaSyAn8h71VOzmap8ve9kxoCHqKoE_T79ADD8';
const apiKey = 'AIzaSyAn8h71VOzmap8ve9kxoCHqKoE_T79ADD8'; //h
// const apiKey = 'AIzaSyD3WKXZwbplcvQ2BlmIj4n3FlyFpvY_47M';

// const apiKey = 'AIzaSyAwM_RLjqj8dbbMAP5ls4qg1olDsaxSq5s';

const maxResults = 10;

function formatDuration(isoDuration) {
Expand Down Expand Up @@ -121,11 +122,11 @@ const channels = [
'UCttspZesZIDEwwpVIgoZtWQ' // India TV
];

const movieQueries = ['Latest Bhojpuri Movies', 'New Bhojpuri Movies'];
const movieQueries = ['Latest Hindi Movies', 'New hollywood Movies', 'cartoon in hind', 'new comedy video'];

const newsQueries = ['Latest News hindi', 'Breaking News hindi', 'Recent News hindi', 'hindi news', 'yesterday news hindi'];

function getRandomElement(arr) {
console.log(arr[Math.floor(Math.random() * arr.length)]);
return arr[Math.floor(Math.random() * arr.length)];
}

Expand Down Expand Up @@ -159,9 +160,10 @@ function fetchVideos(previousClear) {
if (previousClear == 'previousClear') {
searchResults.innerHTML = '';
}

url = `https://www.googleapis.com/youtube/v3/search?q=${searchTerm}&key=${apiKey}&maxResults=${maxResults}&part=snippet&type=video`;
} else {
}
else {
randomQuery = getRandomQuery();
url = `https://www.googleapis.com/youtube/v3/search?key=${apiKey}&part=snippet&${randomQuery}&type=video&maxResults=${maxResults}`;
}
Expand All @@ -188,28 +190,41 @@ function fetchVideoDetails(videoIds) {
function displayVideos(videos) {

videos.forEach(video => {
// console.log(video)
const title = discriptionRepair(video.snippet.title);
const videoId = video.id;
const thumbnailUrl = video.snippet.thumbnails.high.url;
let discription = discriptionRepair(video.snippet.description);
const channelId = video.snippet.channelId;
let duration = formatDuration(video.contentDetails.duration);

const resultItem = document.createElement('div');
resultItem.classList.add('search-result');
resultItem.innerHTML = `
<div class="video-detail-box" onclick="storeDataToLocal(${`\`${title}\``}, '${videoId}', ${`\`${discription}\``}, '${channelId}')">
<img class="thumbnail-image" src="${thumbnailUrl}" alt="${title}">
<div class="duration">${duration}</div>
<h3 class="title">${title}</h3>
</div>
`;

searchResults.appendChild(resultItem);
let durationCheck = durationChecker(duration);

if (durationCheck == true) {
const resultItem = document.createElement('div');
resultItem.classList.add('search-result');
resultItem.innerHTML = `
<div class="video-detail-box" onclick="storeDataToLocal(${`\`${title}\``}, '${videoId}', ${`\`${discription}\``}, '${channelId}')">
<img class="thumbnail-image" src="${thumbnailUrl}" alt="${title}">
<div class="duration">${duration}</div>
<h3 class="title">${title}</h3>
</div>
`;

searchResults.appendChild(resultItem);
}
});
}

function durationChecker(durationString) {
let duration = durationString.split('');
let test = duration[duration.length - 5] + duration[duration.length - 4];
if (test == "00") {
return false;
}
else {
return true;
}
}

function discriptionRepair(text) {

text = text.replace(/&/g, "&amp;");
Expand All @@ -224,16 +239,12 @@ function discriptionRepair(text) {

document.addEventListener('DOMContentLoaded', () => {
searchResults.innerHTML = '';
console.log("outside the if");
fetchVideos();
let showMore = document.querySelector('.show_more');
showMore.addEventListener('click', fetchVideos);

setTimeout(() => {
console.log(searchResults.innerHTML == '');
// console.log(searchResults.innerHTML);
if (searchResults.innerHTML == '') {
console.log("inside the if");
fetchVideos();
}
}, 1000);
Expand Down
2 changes: 1 addition & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ function removeContextMenuBox() {
}
}

function handleKeyPress(event) {
function handleKeyPressX(event) {
event.preventDefault();
// console.log(event)
if (event.key === "Meta" || event.key === "Windows") {
Expand Down

0 comments on commit b857d87

Please sign in to comment.