More functioning 'autocomplete'

This commit is contained in:
Kasper Rynning-Tønnesen
2017-02-14 21:35:59 +01:00
parent 35a428b801
commit 9d4bb0b68b
7 changed files with 42 additions and 23 deletions

View File

@@ -2130,6 +2130,7 @@ nav ul li:hover, nav ul li.active {
text-shadow: 0px 0px 0px rgba(0, 0, 0, 0.42); text-shadow: 0px 0px 0px rgba(0, 0, 0, 0.42);
width: calc(100vw - 170px); width: calc(100vw - 170px);
max-width: 100%; max-width: 100%;
font-size:2rem;
} }
.control-list li a{ min-width: 0px; width: 37px; padding: 0 0 0 0px;} .control-list li a{ min-width: 0px; width: 37px; padding: 0 0 0 0px;}
@@ -2143,8 +2144,8 @@ nav ul li:hover, nav ul li.active {
} }
#search_loader{ #search_loader{
margin-left: -75px; margin-left: -50px;
margin-top: 5px; margin-top: 0px;
} }
.title-container{ .title-container{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -136,6 +136,8 @@ var Frontpage = {
limit: 5, // The max amount of results that can be shown at once. Default: Infinity. limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
}); });
$(".autocomplete").off('keydown.autocomplete');
document.getElementById("preloader").style.display = "none"; document.getElementById("preloader").style.display = "none";
//Materialize.fadeInImage('#channels'); //Materialize.fadeInImage('#channels');
$("#channels").fadeIn(800); $("#channels").fadeIn(800);

View File

@@ -102,6 +102,9 @@ var List = {
List.can_fit = Math.round(($(window).height() - $(".tabs").height() - $("header").height() -66) / 71)+1; List.can_fit = Math.round(($(window).height() - $(".tabs").height() - $("header").height() -66) / 71)+1;
List.element_height = (($(window).height() - $(".tabs").height() - $("header").height() -66) / List.can_fit)-6; List.element_height = (($(window).height() - $(".tabs").height() - $("header").height() -66) / List.can_fit)-6;
} }
if(List.element_height < 55.2){
List.element_height = 55.2;
}
if(list_html === undefined) list_html = $("#list-song-html").html(); if(list_html === undefined) list_html = $("#list-song-html").html();
full_playlist = msg; full_playlist = msg;
if(offline && !no_reset){ if(offline && !no_reset){
@@ -118,9 +121,9 @@ var List = {
Helper.log("---------------------------"); Helper.log("---------------------------");
if(full_playlist.length > 1){ if(full_playlist.length > 1){
$.each(full_playlist, function(j, current_song){ $.each(full_playlist, function(j, _current_song){
if(!current_song.now_playing){ //check that the song isnt playing if(!_current_song.now_playing){ //check that the song isnt playing
$("#wrapper").append(List.generateSong(current_song, false, lazy_load, true, false, "", true)); $("#wrapper").append(List.generateSong(_current_song, false, lazy_load, true, false, "", true));
} }
}); });
if($("#wrapper").children().length > List.can_fit && !$("#pageButtons").length){ if($("#wrapper").children().length > List.can_fit && !$("#pageButtons").length){
@@ -810,12 +813,12 @@ var List = {
} }
}, },
generateSong: function(song_info, transition, lazy, list, user, display, initial) generateSong: function(_song_info, transition, lazy, list, user, display, initial)
{ {
if(list_html === undefined) list_html = $("#list-song-html").html(); if(list_html === undefined) list_html = $("#list-song-html").html();
var video_id = song_info.id; var video_id = _song_info.id;
var video_title = song_info.title; var video_title = _song_info.title;
var video_votes = song_info.votes; var video_votes = _song_info.votes;
var video_thumb = "background-image:url('//img.youtube.com/vi/"+video_id+"/mqdefault.jpg');"; var video_thumb = "background-image:url('//img.youtube.com/vi/"+video_id+"/mqdefault.jpg');";
var song = $("<div>"+list_html+"</div>"); var song = $("<div>"+list_html+"</div>");
var image_attr = "style"; var image_attr = "style";
@@ -831,7 +834,6 @@ var List = {
video_thumb = "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg"; video_thumb = "//img.youtube.com/vi/"+video_id+"/mqdefault.jpg";
image_attr = "data-original"; image_attr = "data-original";
} }
if(list){ if(list){
song.find(".list-votes").text(video_votes); song.find(".list-votes").text(video_votes);
song.find("#list-song").attr("id", video_id); song.find("#list-song").attr("id", video_id);
@@ -842,7 +844,7 @@ var List = {
attr = ".vote-container"; attr = ".vote-container";
del_attr = "del"; del_attr = "del";
}else if(!list){ }else if(!list){
song.find(".vote-text").text(song_info.duration); song.find(".vote-text").text(_song_info.duration);
attr = ".add-suggested"; attr = ".add-suggested";
if(user) if(user)
@@ -854,7 +856,7 @@ var List = {
song.find(".add-suggested").attr("title", video_title); song.find(".add-suggested").attr("title", video_title);
song.find("#del").attr("id", del_attr); song.find("#del").attr("id", del_attr);
song.find(attr).attr("data-video-title", video_title); song.find(attr).attr("data-video-title", video_title);
song.find(attr).attr("data-video-length", song_info.length); song.find(attr).attr("data-video-length", _song_info.length);
song.find("#list-song").attr("id", "suggested-" + video_id); song.find("#list-song").attr("id", "suggested-" + video_id);
song.find(".list-image").attr("class", song.find(".list-image").attr("class").replace("list-image", "list-suggested-image")); song.find(".list-image").attr("class", song.find(".list-image").attr("class").replace("list-image", "list-suggested-image"));

View File

@@ -851,13 +851,30 @@ $(document).on("click", ".listen-button", function(e){
$(document).on("submit", ".channel-finder", function(e){ $(document).on("submit", ".channel-finder", function(e){
e.preventDefault(); e.preventDefault();
//console.log($(".room-namer").val());
Frontpage.to_channel($(".room-namer").val()); Frontpage.to_channel($(".room-namer").val());
return false; return false;
}); });
$(document).off("keyup", "keyup.autocomplete", function(e){
if(e.keyCode == 13){
e.preventDefault();
console.log(e.keyCode);
console.log($(this).val());
}
});
$(document).off("keydown", "keydown.autocomplete", function(e){
if(e.keyCode == 13){
e.preventDefault();
console.log(e.keyCode);
console.log($(this).val());
}
});
$(document).on("submit", ".channel-finder-mobile", function(e){ $(document).on("submit", ".channel-finder-mobile", function(e){
e.preventDefault(); e.preventDefault();
Frontpage.to_channel($("#search-mobile").val()); Frontpage.to_channel($("#searchFrontpage").val());
return false; return false;
}); });
@@ -1173,15 +1190,12 @@ $(window).resize(function(){
List.dynamicContentPage(-10); List.dynamicContentPage(-10);
} }
if(List.can_fit < temp_fit){ if(List.can_fit < temp_fit){
console.log("1");
$($("#wrapper").children()[List.page + temp_fit - 1]).css("display", "block"); $($("#wrapper").children()[List.page + temp_fit - 1]).css("display", "block");
} else if(List.can_fit > temp_fit){ } else if(List.can_fit > temp_fit){
console.log("2");
$($("#wrapper").children()[List.page + temp_fit]).css("display", "none"); $($("#wrapper").children()[List.page + temp_fit]).css("display", "none");
} }
List.can_fit = temp_fit; List.can_fit = temp_fit;
List.element_height = (($("#wrapper").height()) / List.can_fit)-5.3; List.element_height = (($("#wrapper").height()) / List.can_fit)-5.3;
console.log(List.page);
$(".list-song").css("height", List.element_height + "px"); $(".list-song").css("height", List.element_height + "px");
$("#player_overlay").width($("#player").width()+1); $("#player_overlay").width($("#player").width()+1);
set_title_width(); set_title_width();

View File

@@ -68,7 +68,7 @@ var Player = {
seekTo = 1; seekTo = 1;
try{ try{
if(full_playlist[0].id == video_id){ if(full_playlist[0].id == video_id && !mobile_beginning){
List.song_change(full_playlist[0].added); List.song_change(full_playlist[0].added);
} }
Suggestions.fetchYoutubeSuggests(video_id); Suggestions.fetchYoutubeSuggests(video_id);