Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsonukushwaha authored Jan 30, 2022
1 parent d41870f commit aafda65
Show file tree
Hide file tree
Showing 7 changed files with 1,041 additions and 1,214 deletions.
5 changes: 5 additions & 0 deletions details.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const id = new URLSearchParams(window.location.search).get('id');


const renderDetails = async () => {
const res = await fetch(`https://tarana-music-player.herokuapp.com/songs/` + id);
if (!res.ok) {
window.location.replace("./index.html");
}

const song = await res.json();

track.src = song.path;
title.innerHTML = song.name;
track_image.src = song.img;
Expand All @@ -23,4 +25,7 @@ const renderDetails = async () => {

}




window.addEventListener('DOMContentLoaded', renderDetails);
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
}
</script>

<!-- <script src="./main.js"></script> -->
<script src="./main.js"></script>
<script src="./up.js"></script>

<script async src="https://api.countapi.xyz/hit/sonu.live/tarana?callback=cb"></script>
Expand Down
61 changes: 19 additions & 42 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,25 @@
// const searchForm = document.querySelector('#srh');
const searchForm = document.querySelector('#srh');

// const getSongs = async (term) => {
// let uri = `https://tarana-music-player.herokuapp.com/songs/?_sort=name&_order=asc`;
const searchSong = async (term) => {
let uri = `https://tarana-music-player.herokuapp.com/songs/?_sort=name&_order=asc`;

// if (term) {
// uri += `&q=${term}`;
// list.innerHTML = "";
// }
if (term) {
uri += `&q=${term}`;
list.innerHTML = "";
}

// const res = await fetch(uri);
// const data = await res.json();
const res = await fetch(uri);
const data = await res.json();

// data.forEach(element => {
// link = document.createElement('a');
// link.innerHTML = `${element.id}. ${element.name} &rarr;${element.singer}`;
data.forEach(element => {
genLink(element);

// // console.log(element);
});
}

// link.addEventListener('click', function () {
// track.src = element.path;
// title.innerHTML = element.name;
// track_image.src = element.img;
// artist.innerHTML = element.singer;
// present.innerHTML = element.id;

// total.innerHTML = All_song.length;


// nochange();
// reset_slider();

// playsong();

// });

// list.append(link);
// });

// }

// searchForm.addEventListener('input', (e) => {
// e.preventDefault();
// getSongs(searchForm.value.trim());

// });

// // window.addEventListener('DOMContentLoaded', () => getSongs());
searchForm.addEventListener('input', (e) => {
e.preventDefault();
if(searchForm.value.trim() != ''){
searchSong(searchForm.value.trim());
}
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"start": "nodemon server.js",
"serve": "json-server --watch songs.json"
},
"keywords": [],
"keywords": [
"tarana",
"music-player"
],
"author": "Sonu Kumar Kushwaha <[email protected]>",
"license": "MIT",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion play.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

<script src="./details.js"></script>
<script src="./up.js"></script>

<script src="./main.js"></script>

<script async src="https://api.countapi.xyz/hit/sonu.live/tarana?callback=cb"></script>
</body>
Expand Down
Loading

0 comments on commit aafda65

Please sign in to comment.