mirror of
https://github.com/smogon/pokemon-showdown-client.git
synced 2026-09-30 23:01:05 -05:00
Use JSON API for addNews() (#1537)
This commit is contained in:
@@ -124,14 +124,34 @@
|
||||
// news
|
||||
|
||||
addNews: function () {
|
||||
var newsId = '1990';
|
||||
if (newsId === '' + Dex.prefs('readnews')) return;
|
||||
this.addPseudoPM({
|
||||
title: 'Latest News',
|
||||
html: '<iframe src="/news-embed.php?news' + (window.nodewebkit || document.location.protocol === 'https:' ? '&https' : '') + '" width="270" height="400" border="0" style="border:0;width:100%;height:100%;display:block"></iframe>',
|
||||
attributes: 'data-newsid="' + newsId + '"',
|
||||
cssClass: 'news-embed',
|
||||
height: 400
|
||||
var self = this;
|
||||
$.ajax({
|
||||
url: "https://pokemonshowdown.com/news.json",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
var html = '';
|
||||
for (var i in [0, 1]) {
|
||||
var post = data[i];
|
||||
var hasRead = data[i].id && Dex.prefs('readnews') === '' + data[i].id;
|
||||
|
||||
html += '<div class="newsentry' + (hasRead ? '' : ' unread') + '">';
|
||||
if (post.title) html += '<h4>' + post.title + '</h4>';
|
||||
if (post.summaryHTML) html += '<p>' + post.summaryHTML + '</p>';
|
||||
html += '<p>';
|
||||
if (post.author) html += '—<strong>' + post.author + '</strong>';
|
||||
if (post.date) {
|
||||
html += '<small class="date"> on ' + new Date(post.date * 1000).toDateString() + '</small>';
|
||||
}
|
||||
html += '</p></div>';
|
||||
}
|
||||
self.addPseudoPM({
|
||||
title: 'Latest News',
|
||||
html: html,
|
||||
attributes: 'data-newsid="' + (data[0].id ? data[0].id : '1990') + '"',
|
||||
cssClass: 'news-embed',
|
||||
maxHeight: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user