2024-08-14 10:16:54 +02:00
|
|
|
document.body.onload=loadWishlistedGames()
|
2024-08-14 11:03:19 +02:00
|
|
|
document.getElementById('wishlist_nav').classList.add('active')
|
2024-08-14 10:16:54 +02:00
|
|
|
|
|
|
|
|
async function loadWishlistedGames() {
|
|
|
|
|
|
|
|
|
|
var wishlist_priorities = [1,2,3,4]
|
|
|
|
|
|
|
|
|
|
jQuery.each(wishlist_priorities, function(index, item){
|
|
|
|
|
|
|
|
|
|
var boardgame_datatable = new DataTable('#wishlist_table'+item, {
|
|
|
|
|
ajax: {
|
|
|
|
|
url: api_url + '/wishlist?priority='+item,
|
|
|
|
|
dataSrc: ''
|
|
|
|
|
},
|
|
|
|
|
columns: [
|
|
|
|
|
{
|
|
|
|
|
data: 'wishlist_priority'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
data: 'thumbnail_url',
|
|
|
|
|
render: function (data,type){
|
|
|
|
|
return '<img src="' + data + '" class="img-fluid" />'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
data: 'name'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
data: 'min_players',
|
|
|
|
|
render: function(data,type,row){
|
|
|
|
|
if (row.min_players != row.max_players){
|
|
|
|
|
return row.min_players + '-' + row.max_players
|
|
|
|
|
}else{
|
|
|
|
|
return row.min_players
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
data: 'min_playing_time',
|
|
|
|
|
render: function(data,type,row){
|
|
|
|
|
if (row.min_playing_time != row.max_playing_time){
|
|
|
|
|
return row.min_playing_time + '-' + row.max_playing_time
|
|
|
|
|
}else{
|
|
|
|
|
return row.min_playing_time
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
data: 'weight'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
columnDefs: [
|
|
|
|
|
{
|
|
|
|
|
target: 0,
|
|
|
|
|
visible: false
|
|
|
|
|
},
|
|
|
|
|
{ targets: 'no-sort', orderable: false }
|
|
|
|
|
],
|
|
|
|
|
order: [[2, 'asc']]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#wishlist_table'+item).on('click', 'tbody tr', function() {
|
|
|
|
|
var boardgame_id = boardgame_datatable.row(this).data().id;
|
|
|
|
|
window.location.href = "/boardgame?id=" + boardgame_id
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|