Added search continuous scrolling
This commit is contained in:
		
							parent
							
								
									ea7755675c
								
							
						
					
					
						commit
						d58fca7266
					
				@ -106,7 +106,7 @@
 | 
				
			|||||||
									<div v-for="release in results.data" class="release">
 | 
														<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'">
 | 
															<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="title">{{ release.ALB_TITLE }}</p>
 | 
				
			||||||
										<p class="subtitle">{{ release.ART_NAME+' - '+release.NUMBER_TRACK+' tracks' }}</p>
 | 
															<p class="subtitle">{{ 'by '+release.ART_NAME }}</p>
 | 
				
			||||||
									</div>
 | 
														</div>
 | 
				
			||||||
								</div>
 | 
													</div>
 | 
				
			||||||
							</div>
 | 
												</div>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,7 @@
 | 
				
			|||||||
// Initialization
 | 
					// Initialization
 | 
				
			||||||
doAjax("/init", "POST");
 | 
					doAjax("/init", "POST");
 | 
				
			||||||
 | 
					search_selected = ""
 | 
				
			||||||
 | 
					main_selected=""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Functions to connect to the Flask server
 | 
					// Functions to connect to the Flask server
 | 
				
			||||||
function getHttpRequestObject(){
 | 
					function getHttpRequestObject(){
 | 
				
			||||||
@ -64,7 +66,49 @@ function changeTab(evt, section, tabName) {
 | 
				
			|||||||
    tablinks[i].className = tablinks[i].className.replace(" active", "");
 | 
					    tablinks[i].className = tablinks[i].className.replace(" active", "");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  document.getElementById(tabName).style.display = "block";
 | 
					  document.getElementById(tabName).style.display = "block";
 | 
				
			||||||
 | 
						window[section+"_selected"] = tabName
 | 
				
			||||||
  evt.currentTarget.className += " active";
 | 
					  evt.currentTarget.className += " active";
 | 
				
			||||||
 | 
						if (document.getElementById("content").offsetHeight >= document.getElementById("content").scrollHeight && main_selected == "search_tab" && ["track_search", "album_search", "artist_search", "playlist_search"].indexOf(search_selected) != -1){
 | 
				
			||||||
 | 
							scrolledSearch(window[search_selected.split("_")[0]+"Search"])
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$('#content').on('scroll', function() {
 | 
				
			||||||
 | 
					  if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) {
 | 
				
			||||||
 | 
					    if (main_selected == "search_tab" && ["track_search", "album_search", "artist_search", "playlist_search"].indexOf(search_selected) != -1){
 | 
				
			||||||
 | 
								scrolledSearch(window[search_selected.split("_")[0]+"Search"])
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function scrolledSearch(vueTab){
 | 
				
			||||||
 | 
						query = vueTab.query
 | 
				
			||||||
 | 
						if (vueTab.results.next < vueTab.results.total){
 | 
				
			||||||
 | 
							doAjax("/search", "POST", searchUpadate, {term: vueTab.query, type: vueTab.type, start: vueTab.results.next, nb: vueTab.nb});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function searchUpadate(result){
 | 
				
			||||||
 | 
						console.log(result)
 | 
				
			||||||
 | 
						vueTab = null;
 | 
				
			||||||
 | 
						switch (result.type) {
 | 
				
			||||||
 | 
							case "TRACK":
 | 
				
			||||||
 | 
								vueTab = trackSearch;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
							case "ALBUM":
 | 
				
			||||||
 | 
								vueTab = albumSearch;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
							case "ARTIST":
 | 
				
			||||||
 | 
								vueTab = artistSearch;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
							case "PLAYLIST":
 | 
				
			||||||
 | 
								vueTab = playlistSearch;
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if (vueTab && vueTab.results.next != result.next){
 | 
				
			||||||
 | 
							vueTab.results.next = result.next
 | 
				
			||||||
 | 
							vueTab.results.data = vueTab.results.data.concat(result.data)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function clickElement(button){
 | 
					function clickElement(button){
 | 
				
			||||||
@ -82,6 +126,7 @@ var mainSearch = new Vue({
 | 
				
			|||||||
			"PLAYLIST": "Playlists"
 | 
								"PLAYLIST": "Playlists"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
    results: {
 | 
					    results: {
 | 
				
			||||||
 | 
								QUERY: "",
 | 
				
			||||||
			ORDER: [],
 | 
								ORDER: [],
 | 
				
			||||||
			ALBUM: {},
 | 
								ALBUM: {},
 | 
				
			||||||
			ARTIST: {},
 | 
								ARTIST: {},
 | 
				
			||||||
@ -101,8 +146,13 @@ var mainSearch = new Vue({
 | 
				
			|||||||
var trackSearch = new Vue({
 | 
					var trackSearch = new Vue({
 | 
				
			||||||
  el: '#track_search',
 | 
					  el: '#track_search',
 | 
				
			||||||
  data: {
 | 
					  data: {
 | 
				
			||||||
 | 
							type: "TRACK",
 | 
				
			||||||
 | 
							nb: 40,
 | 
				
			||||||
 | 
							query: "",
 | 
				
			||||||
    results: {
 | 
					    results: {
 | 
				
			||||||
			data: []
 | 
								data: [],
 | 
				
			||||||
 | 
								next: 0,
 | 
				
			||||||
 | 
								total: 0
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -110,8 +160,13 @@ var trackSearch = new Vue({
 | 
				
			|||||||
var albumSearch = new Vue({
 | 
					var albumSearch = new Vue({
 | 
				
			||||||
  el: '#album_search',
 | 
					  el: '#album_search',
 | 
				
			||||||
  data: {
 | 
					  data: {
 | 
				
			||||||
 | 
							type: "ALBUM",
 | 
				
			||||||
 | 
							nb: 20,
 | 
				
			||||||
 | 
							query: "",
 | 
				
			||||||
    results: {
 | 
					    results: {
 | 
				
			||||||
			data: []
 | 
								data: [],
 | 
				
			||||||
 | 
								next: 0,
 | 
				
			||||||
 | 
								total: 0
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -119,8 +174,13 @@ var albumSearch = new Vue({
 | 
				
			|||||||
var artistSearch = new Vue({
 | 
					var artistSearch = new Vue({
 | 
				
			||||||
  el: '#artist_search',
 | 
					  el: '#artist_search',
 | 
				
			||||||
  data: {
 | 
					  data: {
 | 
				
			||||||
 | 
							type: "ARTIST",
 | 
				
			||||||
 | 
							nb: 20,
 | 
				
			||||||
 | 
							query: "",
 | 
				
			||||||
    results: {
 | 
					    results: {
 | 
				
			||||||
			data: []
 | 
								data: [],
 | 
				
			||||||
 | 
								next: 0,
 | 
				
			||||||
 | 
								total: 0
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -128,8 +188,13 @@ var artistSearch = new Vue({
 | 
				
			|||||||
var playlistSearch = new Vue({
 | 
					var playlistSearch = new Vue({
 | 
				
			||||||
  el: '#playlist_search',
 | 
					  el: '#playlist_search',
 | 
				
			||||||
  data: {
 | 
					  data: {
 | 
				
			||||||
 | 
							type: "PLAYLIST",
 | 
				
			||||||
 | 
							nb: 20,
 | 
				
			||||||
 | 
							query: "",
 | 
				
			||||||
    results: {
 | 
					    results: {
 | 
				
			||||||
			data: []
 | 
								data: [],
 | 
				
			||||||
 | 
								next: 0,
 | 
				
			||||||
 | 
								total: 0
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -143,7 +208,7 @@ $("#searchbar").keyup(function(e){
 | 
				
			|||||||
			doAjax("/download", "POST", null, {url: term});
 | 
								doAjax("/download", "POST", null, {url: term});
 | 
				
			||||||
		else{
 | 
							else{
 | 
				
			||||||
			document.getElementById("search_tab_content").style.display = "none";
 | 
								document.getElementById("search_tab_content").style.display = "none";
 | 
				
			||||||
			doAjax("/search", "POST", searchHandler, {term: term});
 | 
								doAjax("/mainsearch", "POST", searchHandler, {term: term});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
@ -155,6 +220,10 @@ function searchHandler(result){
 | 
				
			|||||||
	albumSearch.results = result.ALBUM
 | 
						albumSearch.results = result.ALBUM
 | 
				
			||||||
	artistSearch.results = result.ARTIST
 | 
						artistSearch.results = result.ARTIST
 | 
				
			||||||
	playlistSearch.results = result.PLAYLIST
 | 
						playlistSearch.results = result.PLAYLIST
 | 
				
			||||||
 | 
						trackSearch.query = result.QUERY
 | 
				
			||||||
 | 
						albumSearch.query = result.QUERY
 | 
				
			||||||
 | 
						artistSearch.query = result.QUERY
 | 
				
			||||||
 | 
						playlistSearch.query = result.QUERY
 | 
				
			||||||
	document.getElementById("search_defaultopen").click();
 | 
						document.getElementById("search_defaultopen").click();
 | 
				
			||||||
	document.getElementById("search_tab_content").style.display = "block";
 | 
						document.getElementById("search_tab_content").style.display = "block";
 | 
				
			||||||
	document.getElementById("show_searchtab").click();
 | 
						document.getElementById("show_searchtab").click();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user