hexo-theme-stellar/source/js/services/fcircle.js

36 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-02-12 23:07:56 +08:00
utils.jq(() => {
$(function () {
2024-02-18 12:33:28 +08:00
const els = document.getElementsByClassName('ds-fcircle');
2024-02-12 23:07:56 +08:00
for (var i = 0; i < els.length; i++) {
const el = els[i];
const api = el.getAttribute('api');
if (api == null) {
continue;
}
const default_avatar = def.avatar;
// layout
utils.request(el, api, function(data) {
const arr = data.article_data || [];
const limit = el.getAttribute('limit');
arr.forEach((item, i) => {
if (limit && i >= limit) {
return;
}
var cell = '<div class="timenode" index="' + i + '">';
cell += '<div class="header">';
cell += '<div class="user-info">';
cell += '<img src="' + (item.avatar || default_avatar) + '" onerror="javascript:this.src=\'' + default_avatar + '\';">';
cell += '<span>' + item.author + '</span>';
cell += '</div>';
cell += '<span>' + item.created + '</span>';
cell += '</div>';
cell += '<a class="body" href="' + item.link + '" target="_blank" rel="external nofollow noopener noreferrer">';
cell += item.title;
cell += '</a>';
cell += '</div>';
$(el).append(cell);
});
});
}
});
});