1
我建立一個自定義RSS儀表板和我遍歷飼料的陣列,並將它們投擲到谷歌的服務。無常面板的設置引導
,但是當我看着自己的面板他們不是爲了始終如一。
代碼:問題
JQuery的
var rssArray = [
'https://blog.malwarebytes.org/feed/',
'http://krebsonsecurity.com/feed/',
'http://motherboard.vice.com/rss?trk_source=motherboard',
'https://www.trustwave.com/rss.aspx?type=twblog',
'http://threatpost.com/feed/',
'https://news.ycombinator.com/rss',
'http://feeds.trendmicro.com/TrendMicroSimplySecurity?format=xml',
'https://securityintelligence.com/topics/vulnerabilities-threats/feed/',
'https://securityintelligence.com/topics/x-force/feed/'
]
for (var i=0; i < rssArray.length; i++){
$.ajax({
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=5&callback=?&q=' + encodeURIComponent(rssArray[i]),
dataType: 'json',
success: function(data) {
// console.log(data)
var feedBody = $('<div>', {class: 'panel-body'})
var feedHead = $('<div>', {class: 'panel-heading', html: '<h3 class="panel-title text-center">'+capitaliseFirstLetter(data.responseData.feed.title)+'</h3>'})
var contentHolder = $('<ul>', {class: 'list-group'})
var feed = $('<div>', {class: 'col-xs-6 col-md-4 panel panel-warning'}).append(feedHead).append(feedBody).append(contentHolder)
$.each(data.responseData.feed.entries, function(key, value){
if (value.contentSnippet === "Comments"){
var thehtml = '<a href="'+value.link+'" target="_blank" class="list-group-item"><h5 class="list-group-item-heading">'+value.title+'</h5></a>';
} else {
var thehtml = '<a href="'+value.link+'" target="_blank" class="list-group-item"><h5 class="list-group-item-heading">'+value.title+'</h5><p class="list-group-item-text">'+value.contentSnippet+'</p></a>';
}
feedBody.append(thehtml)
});
$("#content").append(feed)
}
})
}
HTML
<div class="row">
<div id="content">
</div>
</div>
例子:
ahh謝謝你。 – user3271518