Implemented simple tab system

This commit is contained in:
RemixDev 2020-04-09 12:50:05 +02:00
parent bba5e6522c
commit 11164375be
3 changed files with 139 additions and 112 deletions

View File

@ -13,6 +13,9 @@ aside#sidebar > .side_icon{
font-size: 24px; font-size: 24px;
margin: 12px; margin: 12px;
} }
.side_icon.active{
color: #0A84FF;
}
/* Rest of the app */ /* Rest of the app */
main#main_content{ main#main_content{
@ -85,13 +88,10 @@ div#middle_section {
} }
} }
/* Search Tab */ /* Tabs */
.search_tabcontent { .search_tabcontent, .main_tabcontent {
display: none; display: none;
} }
#search_tab{
display: none;
}
/* Main Search Tab */ /* Main Search Tab */

View File

@ -11,131 +11,139 @@
<body> <body>
<aside id="sidebar"> <aside id="sidebar">
<i class="material-icons side_icon">menu</i> <i class="material-icons side_icon">menu</i>
<i class="material-icons side_icon">home</i> <i onclick="changeTab(event, 'main', 'search_tab')" id="show_searchtab" class="main_tablinks"></i>
<i class="material-icons side_icon">bubble_chart</i> <i onclick="changeTab(event, 'main', 'home_tab')" id="main_defaultopen" class="material-icons side_icon main_tablinks">home</i>
<i class="material-icons side_icon">album</i> <i onclick="changeTab(event, 'main', 'charts_tab')" class="material-icons side_icon main_tablinks">bubble_chart</i>
<i class="material-icons side_icon">link</i> <i onclick="changeTab(event, 'main', 'favorites_tab')" class="material-icons side_icon main_tablinks">album</i>
<i class="material-icons side_icon">settings</i> <i onclick="changeTab(event, 'main', 'analyzer_tab')" class="material-icons side_icon main_tablinks">link</i>
<i class="material-icons side_icon">info</i> <i onclick="changeTab(event, 'main', 'settings_tab')" class="material-icons side_icon main_tablinks">settings</i>
<i onclick="changeTab(event, 'main', 'about_tab')" class="material-icons side_icon main_tablinks">info</i>
</aside> </aside>
<main id="main_content"> <main id="main_content">
<div id="middle_section"> <div id="middle_section">
<header id="search"><input id="searchbar" type="text" name="searchbar" value="" placeholder="Search..."></header> <header id="search"><input id="searchbar" type="text" name="searchbar" value="" placeholder="Search..."></header>
<section id="content"><div id="container"> <section id="content"><div id="container">
<div id="search_tab"> <div id="search_tab" class="main_tabcontent">
<div class="tab"> <div class="tab">
<button class="search_tablinks" id="search_defaultopen" onclick="searchTab(event, 'main_search')">All</button> <button class="search_tablinks" id="search_defaultopen" onclick="changeTab(event, 'search', 'main_search')">All</button>
<button class="search_tablinks" onclick="searchTab(event, 'track_search')">Tracks</button> <button class="search_tablinks" onclick="changeTab(event, 'search', 'track_search')">Tracks</button>
<button class="search_tablinks" onclick="searchTab(event, 'album_search')">Album</button> <button class="search_tablinks" onclick="changeTab(event, 'search', 'album_search')">Album</button>
<button class="search_tablinks" onclick="searchTab(event, 'artist_search')">Artist</button> <button class="search_tablinks" onclick="changeTab(event, 'search', 'artist_search')">Artist</button>
<button class="search_tablinks" onclick="searchTab(event, 'playlist_search')">Playlist</button> <button class="search_tablinks" onclick="changeTab(event, 'search', 'playlist_search')">Playlist</button>
</div> </div>
<!-- ### Main Search Tab ### --> <div id="search_tab_content">
<div id="main_search" class="search_tabcontent"> <!-- ### Main Search Tab ### -->
<template v-for="section in results.ORDER"> <div id="main_search" class="search_tabcontent">
<div v-if="(section != 'TOP_RESULT' && results[section].data.length > 0) || (results[section].length > 0)" class="search_section"> <template v-for="section in results.ORDER">
<h1>{{ names[section] }}</h1> <div v-if="(section != 'TOP_RESULT' && results[section].data.length > 0) || (results[section].length > 0)" class="search_section">
<!-- Top result --> <h1>{{ names[section] }}</h1>
<div v-if="section == 'TOP_RESULT'" class="top_result"> <!-- Top result -->
<img v-bind:src="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'https://e-cdns-images.dzcdn.net/images/artist/' + results.TOP_RESULT[0].ART_PICTURE : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'https://e-cdns-images.dzcdn.net/images/cover/' + results.TOP_RESULT[0].ALB_PICTURE : 'https://e-cdns-images.dzcdn.net/images/cover/') + '/156x156-000000-80-0-0.jpg'" <div v-if="section == 'TOP_RESULT'" class="top_result">
v-bind:class="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'circle' : 'rounded') + ' coverart'"></img> <img v-bind:src="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'https://e-cdns-images.dzcdn.net/images/artist/' + results.TOP_RESULT[0].ART_PICTURE : results.TOP_RESULT[0].__TYPE__ == 'album' ? 'https://e-cdns-images.dzcdn.net/images/cover/' + results.TOP_RESULT[0].ALB_PICTURE : 'https://e-cdns-images.dzcdn.net/images/cover/') + '/156x156-000000-80-0-0.jpg'"
<div class="info_box"> v-bind:class="(results.TOP_RESULT[0].__TYPE__ == 'artist' ? 'circle' : 'rounded') + ' coverart'"></img>
<p class="title">{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].ART_NAME : results.TOP_RESULT[0].__TYPE__ == 'album' ? results.TOP_RESULT[0].ALB_TITLE : '' }}</p> <div class="info_box">
<p class="subtitle">{{ 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' : '' }}</p> <p class="title">{{ results.TOP_RESULT[0].__TYPE__ == 'artist' ? results.TOP_RESULT[0].ART_NAME : results.TOP_RESULT[0].__TYPE__ == 'album' ? results.TOP_RESULT[0].ALB_TITLE : '' }}</p>
<span class="tag">{{ results.TOP_RESULT[0].__TYPE__.charAt(0).toUpperCase() + results.TOP_RESULT[0].__TYPE__.substring(1)}}</span> <p class="subtitle">{{ 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' : '' }}</p>
<span class="tag">{{ results.TOP_RESULT[0].__TYPE__.charAt(0).toUpperCase() + results.TOP_RESULT[0].__TYPE__.substring(1)}}</span>
</div>
</div>
<div v-if="section == 'TRACK'">
<table class="tracks_table">
<tr v-for="track in results.TRACK.data.slice(0, 6)" class="track_row">
<td style="width: 48px;"><img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/'+track.ALB_PICTURE+'/32x32-000000-80-0-0.jpg'"></td>
<td>{{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}}</td>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</td>
<td style="width: 56px;"><i class="material-icons">get_app</i></td>
</tr>
</table>
</div>
<div v-if="section != 'TRACK' && section != 'TOP_RESULT'" class="release_grid">
<div v-for="release in results[section].data.slice(0, 6)" class="release">
<img v-bind:class="(section == 'ARTIST' ? 'circle' : 'rounded') + ' coverart'" v-bind:src="(section == 'ARTIST' ? 'https://e-cdns-images.dzcdn.net/images/artist/' + release.ART_PICTURE : section == 'ALBUM' ? 'https://e-cdns-images.dzcdn.net/images/cover/' + release.ALB_PICTURE : section == 'PLAYLIST' ? 'https://e-cdns-images.dzcdn.net/images/'+ release.PICTURE_TYPE +'/' + release.PLAYLIST_PICTURE : 'https://e-cdns-images.dzcdn.net/images/cover/' ) + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ section == 'ARTIST' ? release.ART_NAME : section == 'ALBUM' ? release.ALB_TITLE : section == 'PLAYLIST' ? release.TITLE : '' }}</p>
<p class="subtitle">{{ section == 'ARTIST' ? numberWithDots(release.NB_FAN) + ' fans' : section == 'ALBUM' ? release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' : section == 'PLAYLIST' ? release.NB_SONG+' tracks' : '' }}</p>
</div>
</div> </div>
</div> </div>
<div v-if="section == 'TRACK'"> </template>
<table class="tracks_table"> <div v-if="results.ORDER.every(section => section == 'TOP_RESULT' ? results[section].length == 0 : results[section].data.length == 0)">
<tr v-for="track in results.TRACK.data.slice(0, 6)" class="track_row"> <h1>No results</h1>
<td style="width: 48px;"><img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/'+track.ALB_PICTURE+'/32x32-000000-80-0-0.jpg'"></td> </div>
<td>{{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}}</td> </div>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td> <!-- ### Track Search Tab ### -->
<td>{{track.ALB_TITLE}}</td> <div id="track_search" class="search_tabcontent">
<td>{{convertDuration(track.DURATION)}}</td> <div v-if="results.data.length == 0">
<td style="width: 56px;"><i class="material-icons">get_app</i></td> <h1>No Tracks found</h1>
</tr> </div>
</table> <table class="tracks_table" v-if="results.data.length > 0">
</div> <tr>
<div v-if="section != 'TRACK' && section != 'TOP_RESULT'" class="release_grid"> <th style="width: 48px;"></th>
<div v-for="release in results[section].data.slice(0, 6)" class="release"> <th>Title</th>
<img v-bind:class="(section == 'ARTIST' ? 'circle' : 'rounded') + ' coverart'" v-bind:src="(section == 'ARTIST' ? 'https://e-cdns-images.dzcdn.net/images/artist/' + release.ART_PICTURE : section == 'ALBUM' ? 'https://e-cdns-images.dzcdn.net/images/cover/' + release.ALB_PICTURE : section == 'PLAYLIST' ? 'https://e-cdns-images.dzcdn.net/images/'+ release.PICTURE_TYPE +'/' + release.PLAYLIST_PICTURE : 'https://e-cdns-images.dzcdn.net/images/cover/' ) + '/156x156-000000-80-0-0.jpg'"> <th>Artists</th>
<p class="title">{{ section == 'ARTIST' ? release.ART_NAME : section == 'ALBUM' ? release.ALB_TITLE : section == 'PLAYLIST' ? release.TITLE : '' }}</p> <th>Album</th>
<p class="subtitle">{{ section == 'ARTIST' ? numberWithDots(release.NB_FAN) + ' fans' : section == 'ALBUM' ? release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' : section == 'PLAYLIST' ? release.NB_SONG+' tracks' : '' }}</p> <th><i class="material-icons">timer</i></th>
</div> <th style="width: 56px;"></th>
</tr>
<tr v-for="track in results.data" class="track_row">
<td><img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/'+track.ALB_PICTURE+'/32x32-000000-80-0-0.jpg'"></td>
<td>{{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}}</td>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</td>
<td><i class="material-icons">get_app</i></td>
</tr>
</table>
</div>
<!-- ### Album Search Tab ### -->
<div id="album_search" class="search_tabcontent">
<div v-if="results.data.length == 0">
<h1>No Albums found</h1>
</div>
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/' + release.ALB_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.ALB_TITLE }}</p>
<p class="subtitle">{{ release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' }}</p>
</div> </div>
</div> </div>
</template>
<div v-if="results.ORDER.every(section => section == 'TOP_RESULT' ? results[section].length == 0 : results[section].data.length == 0)">
<h1>No results</h1>
</div> </div>
</div> <!-- ### Artist Search Tab ### -->
<!-- ### Track Search Tab ### --> <div id="artist_search" class="search_tabcontent">
<div id="track_search" class="search_tabcontent"> <div v-if="results.data.length == 0">
<div v-if="results.data.length == 0"> <h1>No Artists found</h1>
<h1>No Tracks found</h1> </div>
</div> <div class="release_grid" v-if="results.data.length > 0">
<table class="tracks_table" v-if="results.data.length > 0"> <div v-for="release in results.data" class="release">
<tr> <img class="circle coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/artist/' + release.ART_PICTURE + '/156x156-000000-80-0-0.jpg'">
<th style="width: 48px;"></th> <p class="title">{{ release.ART_NAME }}</p>
<th>Title</th> <p class="subtitle">{{ numberWithDots(release.NB_FAN) + ' fans' }}</p>
<th>Artists</th> </div>
<th>Album</th>
<th><i class="material-icons">timer</i></th>
<th style="width: 56px;"></th>
</tr>
<tr v-for="track in results.data" class="track_row">
<td><img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/'+track.ALB_PICTURE+'/32x32-000000-80-0-0.jpg'"></td>
<td>{{track.SNG_TITLE + (track.VERSION ? ' '+track.VERSION : '')}}</td>
<td><span v-for="artist in track.ARTISTS">{{artist.ART_NAME}} </span></td>
<td>{{track.ALB_TITLE}}</td>
<td>{{convertDuration(track.DURATION)}}</td>
<td><i class="material-icons">get_app</i></td>
</tr>
</table>
</div>
<!-- ### Album Search Tab ### -->
<div id="album_search" class="search_tabcontent">
<div v-if="results.data.length == 0">
<h1>No Albums found</h1>
</div>
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/cover/' + release.ALB_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.ALB_TITLE }}</p>
<p class="subtitle">{{ release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' }}</p>
</div> </div>
</div> </div>
</div> <!-- ### Playlist Search Tab ### -->
<!-- ### Artist Search Tab ### --> <div id="playlist_search" class="search_tabcontent">
<div id="artist_search" class="search_tabcontent"> <div v-if="results.data.length == 0">
<div v-if="results.data.length == 0"> <h1>No Playlists found</h1>
<h1>No Artists found</h1>
</div>
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="circle coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/artist/' + release.ART_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.ART_NAME }}</p>
<p class="subtitle">{{ numberWithDots(release.NB_FAN) + ' fans' }}</p>
</div> </div>
</div> <div class="release_grid" v-if="results.data.length > 0">
</div> <div v-for="release in results.data" class="release">
<!-- ### Playlist Search Tab ### --> <img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/'+ release.PICTURE_TYPE +'/' + release.PLAYLIST_PICTURE + '/156x156-000000-80-0-0.jpg'">
<div id="playlist_search" class="search_tabcontent"> <p class="title">{{ release.TITLE }}</p>
<div v-if="results.data.length == 0"> <p class="subtitle">{{ release.NB_SONG+' tracks' }}</p>
<h1>No Playlists found</h1> </div>
</div>
<div class="release_grid" v-if="results.data.length > 0">
<div v-for="release in results.data" class="release">
<img class="rounded coverart" v-bind:src="'https://e-cdns-images.dzcdn.net/images/'+ release.PICTURE_TYPE +'/' + release.PLAYLIST_PICTURE + '/156x156-000000-80-0-0.jpg'">
<p class="title">{{ release.TITLE }}</p>
<p class="subtitle">{{ release.NB_SONG+' tracks' }}</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="home_tab" class="main_tabcontent"><h1>Home</h1></div>
<div id="charts_tab" class="main_tabcontent"><h1>Charts</h1></div>
<div id="favorites_tab" class="main_tabcontent"><h1>Favorites</h1></div>
<div id="analyzer_tab" class="main_tabcontent"><h1>Link Analyzer</h1></div>
<div id="settings_tab" class="main_tabcontent"><h1>Settings</h1></div>
<div id="about_tab" class="main_tabcontent"><h1>About</h1></div>
</div></section> </div></section>
</div> </div>
<div id="download_tab_container"> <div id="download_tab_container">

View File

@ -53,6 +53,20 @@ document.querySelector("#hide_download_tab").onclick = (ev)=>{
document.querySelector("#download_tab").style.display = "none"; document.querySelector("#download_tab").style.display = "none";
} }
function changeTab(evt, section, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName(section+"_tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName(section+"_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";
}
// searchTab // searchTab
function searchTab(evt, tabName) { function searchTab(evt, tabName) {
@ -134,7 +148,7 @@ $("#searchbar").keyup(function(e){
if (isValidURL(term)) if (isValidURL(term))
doAjax("/download", "POST", null, {url: term}); doAjax("/download", "POST", null, {url: term});
else{ else{
document.getElementById("search_tab").style.display = "none"; document.getElementById("search_tab_content").style.display = "none";
doAjax("/search", "POST", searchHandler, {term: term}); doAjax("/search", "POST", searchHandler, {term: term});
} }
} }
@ -148,5 +162,10 @@ function searchHandler(result){
artistSearch.results = result.ARTIST artistSearch.results = result.ARTIST
playlistSearch.results = result.PLAYLIST playlistSearch.results = result.PLAYLIST
document.getElementById("search_defaultopen").click(); document.getElementById("search_defaultopen").click();
document.getElementById("search_tab").style.display = "block"; document.getElementById("search_tab_content").style.display = "block";
document.getElementById("show_searchtab").click();
} }
$(function(){
document.getElementById("main_defaultopen").click();
})