X Tutup
// Cache will time out after 1 hour var userCardCacheTimeMillis = 60 * 60 * 1000; $(document).ready(function () { $('div[data-card-user]').each(function (i, element) { var $cardDiv = $(element); getApiValue('https://api.github.com/users/' + $cardDiv.data('card-user'), userCardCacheTimeMillis, function (userData, error) { if (error || !userData) { console.error("User card data not available! Using static text card instead."); return; } $cardDiv.empty(); $cardDiv = $('').appendTo($cardDiv); var $avatarDiv = $('
').appendTo($cardDiv); var $textDiv = $('
').appendTo($cardDiv); $textDiv.append('
' + (userData.name || userData.login) + '
'); $textDiv.append('
@' + userData.login + '
'); // Give the text a margin to make sure it does not overlap the avatar $avatarDiv.resize(function () { $textDiv.css({ width: 'auto', "margin-left": $avatarDiv.height() }); }); $avatarDiv.resize(); }); }); });
X Tutup