From c8e86558d0a1ceeea21f801f6e2391ab70046a4e Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Tue, 8 Aug 2017 19:47:45 +0200 Subject: [PATCH] implement continious scrolling --- CHANGELOG.md | 2 ++ appinfo/info.xml | 2 +- js/main.js | 28 +++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2995108..f421275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Added - Display station metadata [#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra +- Changelog file + [#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra ### Changed - Minimum server is Nextcloud 10/ownCloud 9.1 diff --git a/appinfo/info.xml b/appinfo/info.xml index 9b208e9..bbfe697 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -3,7 +3,7 @@ radio Radio Listening to your favorite radio stations in Nextcloud - 0.5.0 + 0.6.0 agpl Jonas Heinrich https://git.project-insanity.org/onny/nextcloud-app-radio/issues diff --git a/js/main.js b/js/main.js index 103d86e..f466f4d 100644 --- a/js/main.js +++ b/js/main.js @@ -12,11 +12,25 @@ $(function(){ action_play(stationid); }); +/* Save station to favorites */ $('body').on('click', '.favpls', function() { var stationid = $(this).parent().parent().attr('data-id'); 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); + radio_query(1, ""); + var ref = $(this); + setTimeout(function(){ + ref.data("didfire", false); + }, 500); + }; + }; + }); /* ============== // ACTIONS // @@ -135,21 +149,23 @@ $(function(){ method: "GET", url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[stationid], dataType: 'json', - success: render_result + }).success( function(data){ + render_result(data); }); }; }; function radio_query(type, query){ + var offset = $('tbody > tr').length; switch (type) { case 0: var url = "https://www.radio-browser.info/webservice/json/stations/search"; break; case 1: - var url = "https://www.radio-browser.info/webservice/json/stations/topclick/20"; + var url = "https://www.radio-browser.info/webservice/json/stations/topclick"; break; case 2: - var url = "https://www.radio-browser.info/webservice/json/stations/lastchange/20"; + var url = "https://www.radio-browser.info/webservice/json/stations/lastchange"; break; }; $.ajax({ @@ -157,10 +173,12 @@ $(function(){ url: url, data: { name: query, - limit: 20 + limit: 20, + offset: offset }, dataType: 'json', - success: render_result + }).success( function(data){ + render_result(data); }); };