Files
grocy/public/viewjs/components/habitcard.js

21 lines
645 B
JavaScript
Raw Normal View History

2018-04-14 11:10:38 +02:00
Grocy.Components.HabitCard = { };
Grocy.Components.HabitCard.Refresh = function(habitId)
2018-04-14 11:10:38 +02:00
{
Grocy.Api.Get('habits/get-habit-details/' + habitId,
2018-04-14 11:10:38 +02:00
function(habitDetails)
{
$('#habitcard-habit-name').text(habitDetails.habit.name);
$('#habitcard-habit-last-tracked').text((habitDetails.last_tracked || 'never'));
$('#habitcard-habit-last-tracked-timeago').text($.timeago(habitDetails.last_tracked || ''));
$('#habitcard-habit-tracked-count').text((habitDetails.tracked_count || '0'));
2018-04-16 19:11:32 +02:00
EmptyElementWhenMatches('#habitcard-habit-last-tracked-timeago', L('timeago_nan'));
2018-04-14 11:10:38 +02:00
},
function(xhr)
{
console.error(xhr);
}
);
};