Commit 35a03bd1 authored by Liang Ding's avatar Liang Ding

🎨 调整后台首页推荐贴

parent 4a9f5721
...@@ -32,71 +32,54 @@ ...@@ -32,71 +32,54 @@
<script type="text/javascript"> <script type="text/javascript">
plugins.symphonyInterest = { plugins.symphonyInterest = {
init: function () { init: function () {
$("#loadMsg").text("${loadingLabel}"); $('#loadMsg').text("${loadingLabel}")
$("#symphonyInterest").css("background", $('#symphonyInterest').css('background',
"url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent"); "url(${staticServePath}/images/loader.gif) no-repeat scroll center center transparent")
$.ajax({ $.ajax({
url: "${servePath}/blog/interest-tags", url: 'https://hacpai.com/apis/articles?',
type: "GET", type: 'GET',
dataType: "json", dataType: 'jsonp',
jsonp: 'callback',
error: function () { error: function () {
$("#symphonyInterest").html("Loading Interest failed :-(").css("background", "none"); $('#symphonyInterest').html('Loading Interest failed :-(').css('background', 'none')
}, },
success: function (result, textStatus) { success: function (data, textStatus) {
var tags = result.data; var articles = data.articles
if (0 === tags.length) { if (0 === articles.length) {
return; return
} }
$.ajax({
url: "https://hacpai.com/apis/articles?p=1&size=7&tags=" + tags.join(),
type: "GET",
dataType: "jsonp",
jsonp: "callback",
error: function () {
$("#symphonyInterest").html("Loading Interest failed :-(").css("background", "none");
},
success: function (data, textStatus) {
var articles = data.articles;
if (0 === articles.length) {
return;
}
var listHTML = "<ul>";
for (var i = 0; i < articles.length; i++) {
var article = articles[i];
var articleLiHtml = "<li>"
+ "<a target='_blank' href='" + article.articlePermalink + "'>"
+ article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateTime, 1);
+"</span></li>"
listHTML += articleLiHtml
}
listHTML += "</ul>";
$("#symphonyInterest").html(listHTML).css("background", "none"); var listHTML = '<ul>'
} for (var i = 0; i < articles.length; i++) {
}); var article = articles[i]
}
});
var articleLiHtml = '<li>'
+ '<a target=\'_blank\' href=\'' + article.articlePermalink + '\'>'
+ article.articleTitle + '</a>&nbsp; <span class=\'date\'>' + $.bowknot.getDate(article.articleCreateTime, 1);
+'</span></li>'
listHTML += articleLiHtml
}
listHTML += '</ul>'
$('#symphonyInterest').html(listHTML).css('background', 'none')
}
})
$("#loadMsg").text(""); $('#loadMsg').text('')
} }
}; }
/* /*
* 添加插件 * 添加插件
*/ */
admin.plugin.add({ admin.plugin.add({
"id": "symphonyInterest", 'id': 'symphonyInterest',
"path": "/main/panel1", 'path': '/main/panel1',
"content": $("#symphonyInterestPanel").html() 'content': $('#symphonyInterestPanel').html()
}); })
// 移除现有内容 // 移除现有内容
$("#symphonyInterestPanel").remove(); $('#symphonyInterestPanel').remove()
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment