implement continious scrolling

This commit is contained in:
Jonas Heinrich 2017-08-08 19:47:45 +02:00
parent 04b1bbf49c
commit c8e86558d0
3 changed files with 26 additions and 6 deletions

View File

@ -2,6 +2,8 @@
### Added ### Added
- Display station metadata - Display station metadata
[#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra [#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra
- Changelog file
[#1523](https://github.com/owncloud/mail/pull/1523) @tahaalibra
### Changed ### Changed
- Minimum server is Nextcloud 10/ownCloud 9.1 - Minimum server is Nextcloud 10/ownCloud 9.1

View File

@ -3,7 +3,7 @@
<id>radio</id> <id>radio</id>
<name>Radio</name> <name>Radio</name>
<description>Listening to your favorite radio stations in Nextcloud</description> <description>Listening to your favorite radio stations in Nextcloud</description>
<version>0.5.0</version> <version>0.6.0</version>
<licence>agpl</licence> <licence>agpl</licence>
<author>Jonas Heinrich</author> <author>Jonas Heinrich</author>
<bugs>https://git.project-insanity.org/onny/nextcloud-app-radio/issues</bugs> <bugs>https://git.project-insanity.org/onny/nextcloud-app-radio/issues</bugs>

View File

@ -12,11 +12,25 @@ $(function(){
action_play(stationid); action_play(stationid);
}); });
/* Save station to favorites */
$('body').on('click', '.favpls', function() { $('body').on('click', '.favpls', function() {
var stationid = $(this).parent().parent().attr('data-id'); var stationid = $(this).parent().parent().attr('data-id');
action_favorite(stationid); 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 // // ACTIONS //
@ -135,21 +149,23 @@ $(function(){
method: "GET", method: "GET",
url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[stationid], url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[stationid],
dataType: 'json', dataType: 'json',
success: render_result }).success( function(data){
render_result(data);
}); });
}; };
}; };
function radio_query(type, query){ function radio_query(type, query){
var offset = $('tbody > tr').length;
switch (type) { switch (type) {
case 0: case 0:
var url = "https://www.radio-browser.info/webservice/json/stations/search"; var url = "https://www.radio-browser.info/webservice/json/stations/search";
break; break;
case 1: 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; break;
case 2: 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; break;
}; };
$.ajax({ $.ajax({
@ -157,10 +173,12 @@ $(function(){
url: url, url: url,
data: { data: {
name: query, name: query,
limit: 20 limit: 20,
offset: offset
}, },
dataType: 'json', dataType: 'json',
success: render_result }).success( function(data){
render_result(data);
}); });
}; };