From 24c43d96ebdd583a22003144cff558628345107a Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Mon, 6 Aug 2018 17:07:52 +0200 Subject: [PATCH] fix continious scrolling --- js/main.js | 69 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/js/main.js b/js/main.js index 7c4de13..a2fc5c8 100644 --- a/js/main.js +++ b/js/main.js @@ -2,6 +2,7 @@ $(function(){ $(document).ready(function () { + // Player icon pause/stop var vid = document.getElementById("player"); vid.onwaiting = function () { $('#playbutton').attr("class", "buffering"); @@ -9,6 +10,34 @@ $(function(){ vid.onplaying = function () { $('#playbutton').attr("class", "pause"); }; + vid.onpause = function () { + $('#playbutton').attr("class", "play"); + }; + + // Scroll event handler + $(window).scroll(function(){ + var station_list = $("#app-content-files"); + if ( ( $(window).scrollTop() + $(window).height() ) == $(document).height() ) { + if(!station_list.data("didfire")) { + console.log("fire"); + station_list.data("didfire", true); + if ($('li.nav-files').hasClass('active')){ + radio_query(1, ""); + } else if ($('li.nav-recent').hasClass('active')) { + radio_query(2, ""); + } else if ($('li.nav-favorites').hasClass('active')) { + console.log("todo"); + } else { + var query = $('#searchbox').val(); + radio_query(0, query); + }; + var ref = station_list; + setTimeout(function(){ + ref.data("didfire", false); + }, 500); + }; + }; + }); }); @@ -62,38 +91,12 @@ $(function(){ action_favorite(stationid); }); - /* Scroll event handler for continious scrolling */ - $('#app-content').data("didfire", false).scroll(function() { - if ($(this).height() == ($(this).get(0).scrollHeight - $(this).scrollTop())) { - if(!$(this).data("didfire")) { - $(this).data("didfire", true); - if ($('li.nav-files').hasClass('active')){ - radio_query(1, ""); - } else if ($('li.nav-recent').hasClass('active')) { - radio_query(2, ""); - } else if ($('li.nav-favorites').hasClass('active')) { - console.log("todo"); - } else { - var query = $('#searchbox').val(); - radio_query(0, query); - }; - var ref = $(this); - setTimeout(function(){ - ref.data("didfire", false); - }, 500); - }; - }; - }); - /* Playbutton click */ $('#playbutton').click(function() { var music = document.getElementById('player'); if (music.paused && $("#player").attr("src") != "") { music.play(); - } else { - $('#playbutton').removeClass("pause"); - $('#playbutton').addClass("play"); music.pause(); } }); @@ -345,9 +348,17 @@ $(function(){ search.setFilter('radio', mySearch); } });*/ - OC.Plugins.attach('OCA.Search.Core', function(search) { - search.setFilter('radio', mySearch); - }); + + + SearchProxy = { + attach: function(search) { + search.setFilter('radio', function(query) { + alert("test"); + }); + } + }; + + OC.Plugins.register('OCA.Search.Core', SearchProxy); $('#volumeslider').slider({ orientation: "horizontal",