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) {
var tags = result.data;
if (0 === tags.length) {
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) { success: function (data, textStatus) {
var articles = data.articles; var articles = data.articles
if (0 === articles.length) { if (0 === articles.length) {
return; return
} }
var listHTML = "<ul>"; var listHTML = '<ul>'
for (var i = 0; i < articles.length; i++) { for (var i = 0; i < articles.length; i++) {
var article = articles[i]; var article = articles[i]
var articleLiHtml = "<li>" var articleLiHtml = '<li>'
+ "<a target='_blank' href='" + article.articlePermalink + "'>" + '<a target=\'_blank\' href=\'' + article.articlePermalink + '\'>'
+ article.articleTitle + "</a>&nbsp; <span class='date'>" + $.bowknot.getDate(article.articleCreateTime, 1); + article.articleTitle + '</a>&nbsp; <span class=\'date\'>' + $.bowknot.getDate(article.articleCreateTime, 1);
+"</span></li>" +'</span></li>'
listHTML += articleLiHtml listHTML += articleLiHtml
} }
listHTML += "</ul>"; listHTML += '</ul>'
$("#symphonyInterest").html(listHTML).css("background", "none"); $('#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