download only passed items
Hey everyone, i'm beginning with learning Jquery, Javascript
I have some code that needs an adjustment but i can't figure it out myself.
It is a spinner that is downloading playlists from a radiostation.
All playlist are loaded @ 00:00h so you can view the playlists of that day.
Thats what we don't want because then there is no suprise in a program that uses a chart from 30 to 1 for ex.
So what i want to do is ajust the spinner so you can only go back in time.
If it's 17.00h i don't want to see the playlist of 19.00h
Here is an URL where you can try yourself:
http://www.radiofmgold.be/playlist/
push : 'Zoeken' to download playlist
code that we're using:
Social.playlists = {
initialize: function(social, options) {
this.playlistTable = options.playlistTable;
this.playlistButton = options.playlistButton;
this.logo = options.logo;
this.social = social;
this.options = options
console.log("social =" + this.social.station);
// this.update = _updateTable();
$(this.playlistButton).click(function() {
console.log('button clicked');
var time = options.playlistTime();
console.log("start time " + time.stime + " end time " + time.etime);
this._updateTable(time.stime, time.etime);
}.bind(this));
},
_updateTable: function(stime, etime) {
var station = this.social.station;
var playlistTable = this.playlistTable;
var logo = this.logo;
console.log('station = ' + station);
console.log('playlistTable = ' + playlistTable);
$.ajax({
url: this.social.url + "/api/" + station + "/scheduled?start=" + stime + "&end=" + etime,
dataType: 'jsonp',
success: function(results) {
$(playlistTable + " tbody").remove()
$.each(results, function(index, value) {
if (value.item != null && typeof value.item.artists != 'undefined') {
var row = $("<tr />")
var itemdate = new Date();
itemdate.setTime(value.date);
$(playlistTable).append(row);
if (value.item.albumurl) {
row.append($("<td><img src='" + value.item.albumurl + "' height='50' width='50'></td>"));
}
else if (logo) {
row.append($("<td><img src='" + logo + "' height='50' width='50'></td>"));
}
else {
row.append($("<td><img src='
https://onairdesk.com/images/note.png' height='50' width='50'></td>"));
}
row.append($("<td>" + itemdate.getHours() + ":" + this.pad(itemdate.getMinutes()) + ":" + this.pad(itemdate.getSeconds()) + "</td>"));
row.append($("<td>" + value.item.title + "</td>"));
row.append($("<td>" + value.item.artists[0] + "</td>"));
}
}.bind(this));
}.bind(this)
});
},
pad: function(value) {
if (value < 10) {
return '0' + value;
}
else {
return value;
}
}
};