-
{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].ART_NAME : results.TOP_RESULT[0].__TYPE__ == 'album' ? results.TOP_RESULT[0].ALB_TITLE : '' }}
-
{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].NB_FAN + ' fans' : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'by '+results.TOP_RESULT[0].ART_NAME+' - '+results.TOP_RESULT[0].NUMBER_TRACK+' tracks' : '' }}
-
{{ results.TOP_RESULT[0].__TYPE__.charAt(0).toUpperCase() + results.TOP_RESULT[0].__TYPE__.substring(1)}}
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ names[section] }}
+
+
+
+
+
{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].ART_NAME : results.TOP_RESULT[0].__TYPE__ == 'album' ? results.TOP_RESULT[0].ALB_TITLE : '' }}
+
{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? numberWithDots(results.TOP_RESULT[0].NB_FAN) + ' fans' : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'by '+results.TOP_RESULT[0].ART_NAME+' - '+results.TOP_RESULT[0].NUMBER_TRACK+' tracks' : '' }}
+
{{ results.TOP_RESULT[0].__TYPE__.charAt(0).toUpperCase() + results.TOP_RESULT[0].__TYPE__.substring(1)}}
+
+
+
+
+
+ |
+ {{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}} |
+ {{artist.ART_NAME}} |
+ {{track.ALB_TITLE}} |
+ {{convertDuration(track.DURATION)}} |
+ get_app |
+
+
+
+
+
+
+
{{ section == 'ARTIST' ? release.ART_NAME : section == 'ALBUM' ? release.ALB_TITLE : section == 'PLAYLIST' ? release.TITLE : '' }}
+
{{ section == 'ARTIST' ? numberWithDots(release.NB_FAN) + ' fans' : section == 'ALBUM' ? release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' : section == 'PLAYLIST' ? release.NB_SONG+' tracks' : '' }}
+
-
-
-
- |
- {{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}} |
- {{artist.ART_NAME}} |
- {{track.ALB_TITLE}} |
- {{track.DURATION}} |
- get_app |
-
-
-
-
-
-
-
{{ section == 'ARTIST' ? release.ART_NAME : section == 'ALBUM' ? release.ALB_TITLE : section == 'PLAYLIST' ? release.TITLE : '' }}
-
{{ section == 'ARTIST' ? release.NB_FAN + ' fans' : section == 'ALBUM' ? release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' : section == 'PLAYLIST' ? release.NB_SONG+' tracks' : '' }}
-
+
+
+
No results
+
+
+
+
+
+
No Tracks found
+
+
+
+ |
+ Title |
+ Artists |
+ Album |
+ timer |
+ |
+
+
+ |
+ {{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}} |
+ {{artist.ART_NAME}} |
+ {{track.ALB_TITLE}} |
+ {{convertDuration(track.DURATION)}} |
+ get_app |
+
+
+
+
+
+
+
No Albums found
+
+
+
+
+
{{ release.ALB_TITLE }}
+
{{ release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' }}
-
+
+
+
+
+
No Artists found
+
+
+
+
+
{{ release.ART_NAME }}
+
{{ numberWithDots(release.NB_FAN) + ' fans' }}
+
+
+
+
+
+
+
No Playlists found
+
+
+
+
+
{{ release.TITLE }}
+
{{ release.NB_SONG+' tracks' }}
+
+
+
diff --git a/public/js/frontend.js b/public/js/frontend.js
index 2c7c084..a7177ef 100644
--- a/public/js/frontend.js
+++ b/public/js/frontend.js
@@ -53,6 +53,22 @@ document.querySelector("#hide_download_tab").onclick = (ev)=>{
document.querySelector("#download_tab").style.display = "none";
}
+// searchTab
+
+function searchTab(evt, tabName) {
+ var i, tabcontent, tablinks;
+ tabcontent = document.getElementsByClassName("search_tabcontent");
+ for (i = 0; i < tabcontent.length; i++) {
+ tabcontent[i].style.display = "none";
+ }
+ tablinks = document.getElementsByClassName("search_tablinks");
+ for (i = 0; i < tablinks.length; i++) {
+ tablinks[i].className = tablinks[i].className.replace(" active", "");
+ }
+ document.getElementById(tabName).style.display = "block";
+ evt.currentTarget.className += " active";
+}
+
var mainSearch = new Vue({
el: '#main_search',
data: {
@@ -74,6 +90,42 @@ var mainSearch = new Vue({
}
})
+var trackSearch = new Vue({
+ el: '#track_search',
+ data: {
+ results: {
+ data: []
+ }
+ }
+})
+
+var albumSearch = new Vue({
+ el: '#album_search',
+ data: {
+ results: {
+ data: []
+ }
+ }
+})
+
+var artistSearch = new Vue({
+ el: '#artist_search',
+ data: {
+ results: {
+ data: []
+ }
+ }
+})
+
+var playlistSearch = new Vue({
+ el: '#playlist_search',
+ data: {
+ results: {
+ data: []
+ }
+ }
+})
+
// Search section
$("#searchbar").keyup(function(e){
if(e.keyCode == 13){
@@ -81,12 +133,20 @@ $("#searchbar").keyup(function(e){
console.log(term)
if (isValidURL(term))
doAjax("/download", "POST", null, {url: term});
- else
+ else{
+ document.getElementById("search_tab").style.display = "none";
doAjax("/search", "POST", searchHandler, {term: term});
+ }
}
})
function searchHandler(result){
console.log(result)
mainSearch.results = result
+ trackSearch.results = result.TRACK
+ albumSearch.results = result.ALBUM
+ artistSearch.results = result.ARTIST
+ playlistSearch.results = result.PLAYLIST
+ document.getElementById("search_defaultopen").click();
+ document.getElementById("search_tab").style.display = "block";
}
diff --git a/public/js/utils.js b/public/js/utils.js
index 821a458..69075f5 100644
--- a/public/js/utils.js
+++ b/public/js/utils.js
@@ -6,3 +6,27 @@ function isValidURL(text){
return true
return false
}
+function convertDuration(duration) {
+ //convert from seconds only to mm:ss format
+ var mm, ss
+ mm = Math.floor(duration / 60)
+ ss = duration - (mm * 60)
+ //add leading zero if ss < 0
+ if (ss < 10) {
+ ss = "0" + ss
+ }
+ return mm + ":" + ss
+}
+
+function convertDurationSeparated(duration){
+ var hh, mm, ss
+ mm = Math.floor(duration / 60)
+ hh = Math.floor(mm / 60)
+ ss = duration - (mm * 60)
+ mm -= hh*60
+ return [hh, mm, ss]
+}
+
+function numberWithDots(x) {
+ return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
+}