in src/StrippetsVisual.ts [700:771]
private onLoadArticle(articleId: string): any {
const t = this;
const data = _.find(<any>t.data.items, (d: any) => d.id === articleId);
if (data) {
if (StrippetBrowser16424341054522.isUrl(data.content)) {
if (t.settings.content.readerContentType === 'readability') {
return new Promise((resolve: any, reject: any) => {
$.ajax({
dataType: 'jsonp',
method: 'GET',
url: data.content,
}).done((responseBody) => {
const highlightedContent = t.highlight(StrippetBrowser16424341054522.sanitizeHTML(responseBody.content || responseBody, StrippetBrowser16424341054522.HTML_WHITELIST_CONTENT), data.entities);
resolve({
title: StrippetBrowser16424341054522.asUtf8(data.title ? StrippetBrowser16424341054522.cleanString(String(data.title)) : ''),
content: highlightedContent || '',
author: StrippetBrowser16424341054522.cleanString(data.author),
source: StrippetBrowser16424341054522.cleanString(data.source),
sourceUrl: StrippetBrowser16424341054522.cleanString(data.sourceUrl),
figureImgUrl: StrippetBrowser16424341054522.cleanImageUrl(data.imageUrl),
figureCaption: '',
lastupdatedon: data.articleDate ? moment.utc(data.articleDate).format('MMM. D, YYYY') : '',
});
}).fail((err) => {
reject(err);
});
});
}
else if (t.settings.content.readerContentType === 'web') {
const readerData = {
title: '',
content: '<iframe src="' + data.content + '" style="width:100%;height:100%;border:none;"></iframe>',
author: '',
source: '',
sourceUrl: StrippetBrowser16424341054522.cleanString(data.sourceUrl),
figureImgUrl: '',
figureCaption: '',
lastupdatedon: '',
};
return new Promise((resolve: any) => resolve(readerData));
}
else {
const readerData = {
title: StrippetBrowser16424341054522.asUtf8(data.title ? StrippetBrowser16424341054522.cleanString(String(data.title)) : ''),
content: '<a href="#" onclick="javascript:window.open(\'' + data.content + '\')">' + data.content + '</a>',
author: StrippetBrowser16424341054522.cleanString(data.author),
source: StrippetBrowser16424341054522.cleanString(data.source),
sourceUrl: StrippetBrowser16424341054522.cleanString(data.sourceUrl),
figureImgUrl: StrippetBrowser16424341054522.cleanImageUrl(data.imageUrl),
figureCaption: '',
lastupdatedon: data.articleDate ? moment.utc(data.articleDate).format('MMM. D, YYYY') : '',
};
return new Promise((resolve: any) => resolve(readerData));
}
} else {
const readerData = {
title: StrippetBrowser16424341054522.asUtf8(data.title ? StrippetBrowser16424341054522.cleanString(String(data.title)) : ''),
content: t.highlight(StrippetBrowser16424341054522.sanitizeHTML(data.content, StrippetBrowser16424341054522.HTML_WHITELIST_CONTENT), data.entities) || '',
author: StrippetBrowser16424341054522.cleanString(data.author),
source: StrippetBrowser16424341054522.cleanString(data.source),
sourceUrl: StrippetBrowser16424341054522.cleanString(data.sourceUrl),
figureImgUrl: StrippetBrowser16424341054522.cleanImageUrl(data.imageUrl),
figureCaption: '',
lastupdatedon: data.articleDate ? moment.utc(data.articleDate).format('MMM. D, YYYY') : '',
};
return new Promise((resolve: any) => resolve(readerData));
}
} else {
// throwing an error here will cause the component to be unresponsive.
// throw new Error('Unable to load Document');
}
}