Better autocomplete for channelsearch + descriptions on frontpage

This commit is contained in:
Kasper Rynning-Tønnesen
2017-02-09 14:17:59 +01:00
parent f2ca6da200
commit 53b4bb81cb
7 changed files with 124 additions and 39 deletions

View File

@@ -44,7 +44,6 @@ var Frontpage = {
populate_channels: function(lists)
{
var output = "";
var num = 0;
var pinned;
if(lists[0].pinned == 1){
@@ -72,10 +71,12 @@ var Frontpage = {
{
var id = lists[x].id;
var viewers = lists[x].viewers;
var description = lists[x].description;
var img = "background-image:url('https://img.youtube.com/vi/"+id+"/hqdefault.jpg');";
if(lists[x].thumbnail){
img = "background-image:url('" + lists[x].thumbnail + "');";
}
var song_count = lists[x].count;
//$("#channels").append(channel_list);
@@ -98,6 +99,14 @@ var Frontpage = {
card.find(".chan-bg").attr("style", img);
card.find(".chan-link").attr("href", chan);
if(description != ""){
card.find(".card-title").html(chan);
card.find(".description_text").html(description);
} else {
card.find(".card-reveal").remove();
card.find(".card").removeClass("sticky-action")
}
$("#channels").append(card.html());
//$("#channels").append(card);
@@ -108,17 +117,25 @@ var Frontpage = {
var options_list = lists.slice();
options_list = options_list.sort(Frontpage.sortFunction_active);
var data = {};
//num = 0;
for(var x in options_list){
if(options_list[x].count > 5 && Math.floor((new Date).getTime()/1000) - options_list[x].accessed < 604800){
var chan = options_list[x].channel;
output+="<option value='"+chan+"'> ";
}
//if(options_list[x].count > 5 && Math.floor((new Date).getTime()/1000) - options_list[x].accessed < 604800){
/*var chan = options_list[x].channel;
output+="<option value='"+chan+"'> ";*/
data[options_list[x].channel] = null;
//}
}
var to_autocomplete = "input.desktop-search";
if(Helper.mobilecheck()) to_autocomplete = "input.mobile-search";
$(to_autocomplete).autocomplete({
data: data,
limit: 5, // The max amount of results that can be shown at once. Default: Infinity.
});
document.getElementById("preloader").style.display = "none";
document.getElementById("searches").innerHTML = output;
document.getElementById("searches_mobile").innerHTML = output;
//Materialize.fadeInImage('#channels');
$("#channels").fadeIn(800);
$("#searchFrontpage").focus();

View File

@@ -634,9 +634,9 @@ window.disable_debug = disable_debug;
$(document).keyup(function(e) {
if(event.keyCode == 27){
$("#results").html("");
if(!Helper.contains($("#search-wrapper").attr("class").split(" "), "hide"))
if($("#search-wrapper").length != 0 && !Helper.contains($("#search-wrapper").attr("class").split(" "), "hide"))
$("#search-wrapper").toggleClass("hide");
if(Helper.contains($("#song-title").attr("class").split(" "), "hide"))
if($("#song-title").length != 0 && Helper.contains($("#song-title").attr("class").split(" "), "hide"))
$("#song-title").toggleClass("hide");
if($("#search-btn i").html() == "close")
@@ -644,12 +644,28 @@ $(document).keyup(function(e) {
//$("#search-btn i").html("mdi-navigation-close");
$("#search-btn i").html("search");
}
if(!Helper.contains($(".search-container").attr("class").split(" "), "hide")){
if($(".search-container").length != 0 && !Helper.contains($(".search-container").attr("class").split(" "), "hide")){
$("#results").toggleClass("hide");
}
}
});
$(document).on("mouseenter", ".card.sticky-action", function(e){
var that = this;
$(that).find(".card-reveal").attr("style", "display: block;");
setTimeout(function(){
$(that).find(".card-reveal").attr("style", "display: block;transform: translateY(-100%);");
}, 50);
});
$(document).on("mouseleave", ".card.sticky-action", function(e){
var that = this;
$(that).find(".card-reveal").attr("style", "display: block;transform: translateY(0%);");
setTimeout(function(){
$(that).find(".card-reveal").attr("style", "display: none;");
}, 100);
});
$(document).on("click", "#offline-mode", function(e){
e.preventDefault();
if(!Crypt.get_offline()){

View File

@@ -16,7 +16,7 @@ $(document).ready(function (){
$("#about").modal();
$("#contact").modal();
if(window.location.hostname == "remote.zoff.no") add = "https://zoff.no";
else add = "localhost";
socket = io.connect(add + ':8080', connection_options);
@@ -101,7 +101,6 @@ var Remotecontroller = {
},*/
stop:function(event, ui) {
socket.emit("id", {id: id, type: "volume", value: ui.value});
//console.log(ui.value);
}
});
}else