Untitled diff
4 removals
429 lines
5 additions
429 lines
/*********************************************************************
/*********************************************************************
* #### Twitter Post Fetcher v17.0.3 ####
* #### Twitter Post Fetcher v17.0.3 ####
* Coded by Jason Mayes 2015. A present to all the developers out there.
* Coded by Jason Mayes 2015. A present to all the developers out there.
* www.jasonmayes.com
* www.jasonmayes.com
* Please keep this disclaimer with my code if you use it. Thanks. :-)
* Please keep this disclaimer with my code if you use it. Thanks. :-)
* Got feedback or questions, ask here:
* Got feedback or questions, ask here:
* http://www.jasonmayes.com/projects/twitterApi/
* http://www.jasonmayes.com/projects/twitterApi/
* Github: https://github.com/jasonmayes/Twitter-Post-Fetcher
* Github: https://github.com/jasonmayes/Twitter-Post-Fetcher
* Updates will be posted to this site.
* Updates will be posted to this site.
*********************************************************************/
*********************************************************************/
(function(root, factory) {
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
// AMD. Register as an anonymous module.
define([], factory);
define([], factory);
} else if (typeof exports === 'object') {
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// only CommonJS-like environments that support module.exports,
// like Node.
// like Node.
module.exports = factory();
module.exports = factory();
} else {
} else {
// Browser globals.
// Browser globals.
factory();
factory();
}
}
}(this, function() {
}(this, function() {
var domNode = '';
var domNode = '';
var maxTweets = 20;
var maxTweets = 20;
var parseLinks = true;
var parseLinks = true;
var queue = [];
var queue = [];
var inProgress = false;
var inProgress = false;
var printTime = true;
var printTime = true;
var printUser = true;
var printUser = true;
var formatterFunction = null;
var formatterFunction = null;
var supportsClassName = true;
var supportsClassName = true;
var showRts = true;
var showRts = true;
var customCallbackFunction = null;
var customCallbackFunction = null;
var showInteractionLinks = true;
var showInteractionLinks = true;
var showImages = false;
var showImages = false;
var useEmoji = false;
var useEmoji = false;
var targetBlank = true;
var targetBlank = true;
var lang = 'en';
var lang = 'en';
var permalinks = true;
var permalinks = true;
var dataOnly = false;
var dataOnly = false;
var script = null;
var script = null;
var scriptAdded = false;
var scriptAdded = false;
function handleTweets(tweets){
function handleTweets(tweets){
if (customCallbackFunction === null) {
if (customCallbackFunction === null) {
var x = tweets.length;
var x = tweets.length;
var n = 0;
var n = 0;
var element = document.getElementById(domNode);
var element = document.getElementById(domNode);
var html = '<ul>';
var html = '<ul>';
while(n < x) {
while(n < x) {
html += '<li>' + tweets[n] + '</li>';
html += '<li>' + tweets[n] + '</li>';
n++;
n++;
}
}
html += '</ul>';
html += '</ul>';
element.innerHTML = html;
element.innerHTML = html;
} else {
} else {
customCallbackFunction(tweets);
customCallbackFunction(tweets);
}
}
}
}
function strip(data) {
function strip(data) {
return data.replace(/<b[^>]*>(.*?)<\/b>/gi, function(a,s){return s;})
return data.replace(/<b[^>]*>(.*?)<\/b>/gi, function(a,s){return s;})
.replace(/class="(?!(tco-hidden|tco-display|tco-ellipsis))+.*?"|data-query-source=".*?"|dir=".*?"|rel=".*?"/gi,
.replace(/class="(?!(tco-hidden|tco-display|tco-ellipsis))+.*?"|data-query-source=".*?"|dir=".*?"|rel=".*?"/gi,
'');
'');
}
}
function targetLinksToNewWindow(el) {
function targetLinksToNewWindow(el) {
var links = el.getElementsByTagName('a');
var links = el.getElementsByTagName('a');
for (var i = links.length - 1; i >= 0; i--) {
for (var i = links.length - 1; i >= 0; i--) {
links[i].setAttribute('target', '_blank');
links[i].setAttribute('target', '_blank');
}
}
}
}
function getElementsByClassName (node, classname) {
function getElementsByClassName (node, classname) {
var a = [];
var a = [];
var regex = new RegExp('(^| )' + classname + '( |$)');
var regex = new RegExp('(^| )' + classname + '( |$)');
var elems = node.getElementsByTagName('*');
var elems = node.getElementsByTagName('*');
for (var i = 0, j = elems.length; i < j; i++) {
for (var i = 0, j = elems.length; i < j; i++) {
if(regex.test(elems[i].className)){
if(regex.test(elems[i].className)){
a.push(elems[i]);
a.push(elems[i]);
}
}
}
}
return a;
return a;
}
}
function extractImageUrl(image_data) {
function extractImageUrl(image_data) {
if (image_data !== undefined && image_data.innerHTML.indexOf('data-image') >= 0) {
if (image_data !== undefined && image_data.innerHTML.indexOf('data-image') >= 0) {
var data_src = image_data.innerHTML.match(/data-image=\"([A-z0-9]+:\/\/[A-z0-9]+\.[A-z0-9]+\.[A-z0-9]+\/[A-z0-9]+\/[A-z0-9\-]+)/i)[1];
var data_src = image_data.innerHTML.match(/data-image=\"([A-z0-9]+:\/\/[A-z0-9]+\.[A-z0-9]+\.[A-z0-9]+\/[A-z0-9]+\/[A-z0-9\-]+)/i)[1];
return decodeURIComponent(data_src) + '.jpg';
return decodeURIComponent(data_src) + '.jpg';
}
}
}
}
var twitterFetcher = {
var twitterFetcher = {
fetch: function(config) {
fetch: function(config) {
if (config.maxTweets === undefined) {
if (config.maxTweets === undefined) {
config.maxTweets = 20;
config.maxTweets = 20;
}
}
if (config.enableLinks === undefined) {
if (config.enableLinks === undefined) {
config.enableLinks = true;
config.enableLinks = true;
}
}
if (config.showUser === undefined) {
if (config.showUser === undefined) {
config.showUser = true;
config.showUser = true;
}
}
if (config.showTime === undefined) {
if (config.showTime === undefined) {
config.showTime = true;
config.showTime = true;
}
}
if (config.dateFunction === undefined) {
if (config.dateFunction === undefined) {
config.dateFunction = 'default';
config.dateFunction = 'default';
}
}
if (config.showRetweet === undefined) {
if (config.showRetweet === undefined) {
config.showRetweet = true;
config.showRetweet = true;
}
}
if (config.customCallback === undefined) {
if (config.customCallback === undefined) {
config.customCallback = null;
config.customCallback = null;
}
}
if (config.showInteraction === undefined) {
if (config.showInteraction === undefined) {
config.showInteraction = true;
config.showInteraction = true;
}
}
if (config.showImages === undefined) {
if (config.showImages === undefined) {
config.showImages = false;
config.showImages = false;
}
}
if (config.useEmoji === undefined) {
if (config.useEmoji === undefined) {
config.useEmoji = false;
config.useEmoji = false;
}
}
if (config.linksInNewWindow === undefined) {
if (config.linksInNewWindow === undefined) {
config.linksInNewWindow = true;
config.linksInNewWindow = true;
}
}
if (config.showPermalinks === undefined) {
if (config.showPermalinks === undefined) {
config.showPermalinks = true;
config.showPermalinks = true;
}
}
if (config.dataOnly === undefined) {
if (config.dataOnly === undefined) {
config.dataOnly = false;
config.dataOnly = false;
}
}
if (inProgress) {
if (inProgress) {
queue.push(config);
queue.push(config);
} else {
} else {
inProgress = true;
inProgress = true;
domNode = config.domId;
domNode = config.domId;
maxTweets = config.maxTweets;
maxTweets = config.maxTweets;
parseLinks = config.enableLinks;
parseLinks = config.enableLinks;
printUser = config.showUser;
printUser = config.showUser;
printTime = config.showTime;
printTime = config.showTime;
showRts = config.showRetweet;
showRts = config.showRetweet;
formatterFunction = config.dateFunction;
formatterFunction = config.dateFunction;
customCallbackFunction = config.customCallback;
customCallbackFunction = config.customCallback;
showInteractionLinks = config.showInteraction;
showInteractionLinks = config.showInteraction;
showImages = config.showImages;
showImages = config.showImages;
useEmoji = config.useEmoji;
useEmoji = config.useEmoji;
targetBlank = config.linksInNewWindow;
targetBlank = config.linksInNewWindow;
permalinks = config.showPermalinks;
permalinks = config.showPermalinks;
dataOnly = config.dataOnly;
dataOnly = config.dataOnly;
var head = document.getElementsByTagName('head')[0];
var head = document.getElementsByTagName('head')[0];
if (script !== null) {
if (script !== null) {
head.removeChild(script);
head.removeChild(script);
}
}
script = document.createElement('script');
script = document.createElement('script');
script.type = 'text/javascript';
script.type = 'text/javascript';
if (config.list !== undefined) {
if (config.list !== undefined) {
script.src = 'https://syndication.twitter.com/timeline/list?' +
script.src = 'https://syndication.twitter.com/timeline/list?' +
'callback=__twttrf.callback&dnt=false&list_slug=' +
'callback=__twttrf.callback&dnt=false&list_slug=' +
config.list.listSlug + '&screen_name=' + config.list.screenName +
config.list.listSlug + '&screen_name=' + config.list.screenName +
'&suppress_response_codes=true&lang=' + (config.lang || lang) +
'&suppress_response_codes=true&lang=' + (config.lang || lang) +
'&rnd=' + Math.random();
'&rnd=' + Math.random();
} else if (config.profile !== undefined) {
} else if (config.profile !== undefined) {
script.src = 'https://syndication.twitter.com/timeline/profile?' +
script.src = 'https://syndication.twitter.com/timeline/profile?' +
'callback=__twttrf.callback&dnt=false' +
'callback=__twttrf.callback&dnt=false' +
'&screen_name=' + config.profile.screenName +
'&screen_name=' + config.profile.screenName +
'&suppress_response_codes=true&lang=' + (config.lang || lang) +
'&suppress_response_codes=true&lang=' + (config.lang || lang) +
'&rnd=' + Math.random();
'&rnd=' + Math.random();
} else if (config.likes !== undefined) {
} else if (config.likes !== undefined) {
script.src = 'https://syndication.twitter.com/timeline/likes?' +
script.src = 'https://syndication.twitter.com/timeline/likes?' +
'callback=__twttrf.callback&dnt=false' +
'callback=__twttrf.callback&dnt=false' +
'&screen_name=' + config.likes.screenName +
'&screen_name=' + config.likes.screenName +
'&suppress_response_codes=true&lang=' + (config.lang || lang) +
'&suppress_response_codes=true&lang=' + (config.lang || lang) +
'&rnd=' + Math.random();
'&rnd=' + Math.random();
} else {
} else {
script.src = 'https://cdn.syndication.twimg.com/widgets/timelines/' +
script.src = 'https://cdn.syndication.twimg.com/widgets/timelines/' +
config.id + '?&lang=' + (config.lang || lang) +
config.id + '?&lang=' + (config.lang || lang) +
'&callback=__twttrf.callback&' +
'&callback=__twttrf.callback&' +
'suppress_response_codes=true&rnd=' + Math.random();
'suppress_response_codes=true&rnd=' + Math.random();
}
}
head.appendChild(script);
head.appendChild(script);
}
}
},
},
callback: function(data) {
callback: function(data) {
if (data === undefined || data.body === undefined) {
if (data === undefined || data.body === undefined) {
inProgress = false;
inProgress = false;
if (queue.length > 0) {
if (queue.length > 0) {
twitterFetcher.fetch(queue[0]);
twitterFetcher.fetch(queue[0]);
queue.splice(0,1);
queue.splice(0,1);
}
}
return;
return;
}
}
// Remove emoji and summary card images.
// Remove emoji and summary card images.
if(!useEmoji){
if(!useEmoji){
data.body = data.body.replace(/(<img[^c]*class="Emoji[^>]*>)|(<img[^c]*class="u-block[^>]*>)/g, '');
data.body = data.body.replace(/(<img[^c]*class="Emoji[^>]*>)|(<img[^c]*class="u-block[^>]*>)/g, '');
}
}
// Remove display images.
// Remove display images.
if (!showImages) {
if (!showImages) {
data.body = data.body.replace(/(<img[^c]*class="NaturalImage-image[^>]*>|(<img[^c]*class="CroppedImage-image[^>]*>))/g, '');
data.body = data.body.replace(/(<img[^c]*class="NaturalImage-image[^>]*>|(<img[^c]*class="CroppedImage-image[^>]*>))/g, '');
}
}
// Remove avatar images.
// Remove avatar images.
if (!printUser) {
if (!printUser) {
data.body = data.body.replace(/(<img[^c]*class="Avatar"[^>]*>)/g, '');
data.body = data.body.replace(/(<img[^c]*class="Avatar"[^>]*>)/g, '');
}
}
var div = document.createElement('div');
var div = document.createElement('div');
div.innerHTML = data.body;
div.innerHTML = data.body;
if (typeof(div.getElementsByClassName) === 'undefined') {
if (typeof(div.getElementsByClassName) === 'undefined') {
supportsClassName = false;
supportsClassName = false;
}
}
function swapDataSrc(element) {
function swapDataSrc(element) {
var avatarImg = element.getElementsByTagName('img')[0];
var avatarImg = element.getElementsByTagName('img')[0];
avatarImg.src = avatarImg.getAttribute('data-src-2x');
avatarImg.src = avatarImg.getAttribute('data-src-2x');
return element;
return element;
}
}
var tweets = [];
var tweets = [];
var authors = [];
var authors = [];
var times = [];
var times = [];
var images = [];
var images = [];
var rts = [];
var rts = [];
var tids = [];
var tids = [];
var permalinksURL = [];
var permalinksURL = [];
var x = 0;
var x = 0;
if (supportsClassName) {
if (supportsClassName) {
var tmp = div.getElementsByClassName('timeline-Tweet');
var tmp = div.getElementsByClassName('timeline-Tweet');
while (x < tmp.length) {
while (x < tmp.length) {
if (tmp[x].getElementsByClassName('timeline-Tweet-retweetCredit').length > 0) {
if (tmp[x].getElementsByClassName('timeline-Tweet-retweetCredit').length > 0) {
rts.push(true);
rts.push(true);
} else {
} else {
rts.push(false);
rts.push(false);
}
}
if (!rts[x] || rts[x] && showRts) {
if (!rts[x] || rts[x] && showRts) {
tweets.push(tmp[x].getElementsByClassName('timeline-Tweet-text')[0]);
tweets.push(tmp[x].getElementsByClassName('timeline-Tweet-text')[0]);
tids.push(tmp[x].getAttribute('data-tweet-id'));
tids.push(tmp[x].getAttribute('data-tweet-id'));
if (printUser) {
if (printUser) {
authors.push(swapDataSrc(tmp[x].getElementsByClassName('timeline-Tweet-author')[0]));
authors.push(swapDataSrc(tmp[x].getElementsByClassName('timeline-Tweet-author')[0]));
}
}
times.push(tmp[x].getElementsByClassName('dt-updated')[0]);
times.push(tmp[x].getElementsByClassName('dt-updated')[0]);
permalinksURL.push(tmp[x].getElementsByClassName('timeline-Tweet-timestamp')[0]);
permalinksURL.push(tmp[x].getElementsByClassName('timeline-Tweet-timestamp')[0]);
if (tmp[x].getElementsByClassName('timeline-Tweet-media')[0] !==
if (tmp[x].getElementsByClassName('timeline-Tweet-media')[0] !==
undefined) {
undefined) {
images.push(tmp[x].getElementsByClassName('timeline-Tweet-media')[0]);
images.push(tmp[x].getElementsByClassName('timeline-Tweet-media')[0]);
} else {
} else {
images.push(undefined);
images.push(undefined);
}
}
}
}
x++;
x++;
}
}
} else {
} else {
var tmp = getElementsByClassName(div, 'timeline-Tweet');
var tmp = getElementsByClassName(div, 'timeline-Tweet');
while (x < tmp.length) {
while (x < tmp.length) {
if (getElementsByClassName(tmp[x], 'timeline-Tweet-retweetCredit').length > 0) {
if (getElementsByClassName(tmp[x], 'timeline-Tweet-retweetCredit').length > 0) {
rts.push(true);
rts.push(true);
} else {
} else {
rts.push(false);
rts.push(false);
}
}
if (!rts[x] || rts[x] && showRts) {
if (!rts[x] || rts[x] && showRts) {
tweets.push(getElementsByClassName(tmp[x], 'timeline-Tweet-text')[0]);
tweets.push(getElementsByClassName(tmp[x], 'timeline-Tweet-text')[0]);
tids.push(tmp[x].getAttribute('data-tweet-id'));
tids.push(tmp[x].getAttribute('data-tweet-id'));
if (printUser) {
if (printUser) {
authors.push(swapDataSrc(getElementsByClassName(tmp[x],'timeline-Tweet-author')[0]));
authors.push(swapDataSrc(getElementsByClassName(tmp[x],'timeline-Tweet-author')[0]));
}
}
times.push(getElementsByClassName(tmp[x], 'dt-updated')[0]);
times.push(getElementsByClassName(tmp[x], 'dt-updated')[0]);
permalinksURL.push(getElementsByClassName(tmp[x], 'timeline-Tweet-timestamp')[0]);
permalinksURL.push(getElementsByClassName(tmp[x], 'timeline-Tweet-timestamp')[0]);
if (getElementsByClassName(tmp[x], 'timeline-Tweet-media')[0] !== undefined) {
if (getElementsByClassName(tmp[x], 'timeline-Tweet-media')[0] !== undefined) {
images.push(getElementsByClassName(tmp[x], 'timeline-Tweet-media')[0]);
images.push(getElementsByClassName(tmp[x], 'timeline-Tweet-media')[0]);
} else {
} else {
images.push(undefined);
images.push(undefined);
}
}
}
}
x++;
x++;
}
}
}
}
if (tweets.length > maxTweets) {
if (tweets.length > maxTweets) {
tweets.splice(maxTweets, (tweets.length - maxTweets));
tweets.splice(maxTweets, (tweets.length - maxTweets));
authors.splice(maxTweets, (authors.length - maxTweets));
authors.splice(maxTweets, (authors.length - maxTweets));
times.splice(maxTweets, (times.length - maxTweets));
times.splice(maxTweets, (times.length - maxTweets));
rts.splice(maxTweets, (rts.length - maxTweets));
rts.splice(maxTweets, (rts.length - maxTweets));
images.splice(maxTweets, (images.length - maxTweets));
images.splice(maxTweets, (images.length - maxTweets));
permalinksURL.splice(maxTweets, (permalinksURL.length - maxTweets));
permalinksURL.splice(maxTweets, (permalinksURL.length - maxTweets));
}
}
var arrayTweets = [];
var arrayTweets = [];
var x = tweets.length;
var x = tweets.length;
var n = 0;
var n = 0;
if (dataOnly) {
if (dataOnly) {
while (n < x) {
while (n < x) {
arrayTweets.push({
arrayTweets.push({
tweet: tweets[n].innerHTML,
tweet: tweets[n].innerHTML,
author: authors[n] ? authors[n].innerHTML : 'Unknown Author',
author: authors[n] ? authors[n].innerHTML : 'Unknown Author',
author_data: {
author_data: {
profile_url: authors[n] ? authors[n].querySelector('[data-scribe="element:user_link"]').href : null,
profile_url: authors[n] ? authors[n].querySelector('[data-scribe="element:user_link"]').href : null,
profile_image: authors[n] ? authors[n].querySelector('[data-scribe="element:avatar"]').getAttribute('data-src-1x') : null,
profile_image: authors[n] ? authors[n].querySelector('[data-scribe="element:avatar"]').getAttribute('data-src-1x') : null,
profile_image_2x: authors[n] ? authors[n].querySelector('[data-scribe="element:avatar"]').getAttribute('data-src-2x') : null,
profile_image_2x: authors[n] ? authors[n].querySelector('[data-scribe="element:avatar"]').getAttribute('data-src-2x') : null,
screen_name: authors[n] ? authors[n].querySelector('[data-scribe="element:screen_name"]').title : null,
screen_name: authors[n] ? authors[n].querySelector('[data-scribe="element:screen_name"]').title : null,
name: authors[n] ? authors[n].querySelector('[data-scribe="element:name"]').title : null
name: authors[n] ? authors[n].querySelector('[data-scribe="element:name"]').title : null
},
},
time: times[n].textContent,
time: times[n].textContent,
timestamp: times[n].getAttribute('datetime').replace('+0000', 'Z').replace(/([\+\-])(\d\d)(\d\d)/, '$1$2:$3'),
timestamp: times[n].getAttribute('datetime').replace('+0000', 'Z').replace(/([\+\-])(\d\d)(\d\d)/, '$1$2:$3'),
image: extractImageUrl(images[n]),
image: extractImageUrl(images[n]),
rt: rts[n],
rt: rts[n],
tid: tids[n],
tid: tids[n],
permalinkURL: (permalinksURL[n] === undefined) ?
permalinkURL: (permalinksURL[n] === undefined) ?
'' : permalinksURL[n].href
'' : permalinksURL[n].href
});
});
n++;
n++;
}
}
} else {
} else {
while (n < x) {
while (n < x) {
if (typeof(formatterFunction) !== 'string') {
if (typeof(formatterFunction) !== 'string') {
var datetimeText = times[n].getAttribute('datetime');
var datetimeText = times[n].getAttribute('datetime');
var newDate = new Date(times[n].getAttribute('datetime')
var newDate = new Date(times[n].getAttribute('datetime')
.replace(/-/g,'/').replace('T', ' ').split('+')[0]);
.replace(/-/g,'/').replace('T', ' ').split('+')[0]);
var dateString = formatterFunction(newDate, datetimeText);
var dateString = formatterFunction(newDate, datetimeText);
times[n].setAttribute('aria-label', dateString);
times[n].setAttribute('aria-label', dateString);
if (tweets[n].textContent) {
if (tweets[n].textContent) {
// IE hack.
// IE hack.
if (supportsClassName) {
if (supportsClassName) {
times[n].textContent = dateString;
times[n].textContent = dateString;
} else {
} else {
var h = document.createElement('p');
var h = document.createElement('p');
var t = document.createTextNode(dateString);
var t = document.createTextNode(dateString);
h.appendChild(t);
h.appendChild(t);
h.setAttribute('aria-label', dateString);
h.setAttribute('aria-label', dateString);
times[n] = h;
times[n] = h;
}
}
} else {
} else {
times[n].textContent = dateString;
times[n].textContent = dateString;
}
}
}
}
var op = '';
var op = '';
if (parseLinks) {
if (parseLinks) {
if (targetBlank) {
if (targetBlank) {
targetLinksToNewWindow(tweets[n]);
targetLinksToNewWindow(tweets[n]);
if (printUser) {
if (printUser) {
targetLinksToNewWindow(authors[n]);
targetLinksToNewWindow(authors[n]);
}
}
}
}
if (printUser) {
if (printUser) {
op += '<div class="user">' + strip(authors[n].innerHTML) +
op += '<div class="user">' + strip(authors[n].innerHTML) +
'</div>';
'</div>';
}
}
op += '<p class="tweet">' + strip(tweets[n].innerHTML) + '</p>';
op += '<p class="tweet" id="tweet--' + n + '">' + strip(tweets[n].innerHTML) + '</p>';
if (printTime) {
if (printTime) {
if (permalinks) {
if (permalinks) {
op += '<p class="timePosted"><a href="' + permalinksURL[n] +
op += '<p class="timePosted"><a href="' + permalinksURL[n] +
'">' + times[n].getAttribute('aria-label') + '</a></p>';
'" aria-labelledby="tweet--' + n + '">' + times[n].getAttribute('aria-label') + '</a></p>';
} else {
} else {
op += '<p class="timePosted">' +
op += '<p class="timePosted">' +
times[n].getAttribute('aria-label') + '</p>';
times[n].getAttribute('aria-label') + '</p>';
}
}
}
}
} else {
} else {
if (tweets[n].textContent) {
if (tweets[n].textContent) {
if (printUser) {
if (printUser) {
op += '<p class="user">' + authors[n].textContent + '</p>';
op += '<p class="user">' + authors[n].textContent + '</p>';
}
}
op += '<p class="tweet">' + tweets[n].textContent + '</p>';
op += '<p class="tweet" id="tweet--' + n + '">' + tweets[n].textContent + '</p>';
if (printTime) {
if (printTime) {
op += '<p class="timePosted">' + times[n].textContent + '</p>';
op += '<p class="timePosted">' + times[n].textContent + '</p>';
}
}
} else {
} else {
if (printUser) {
if (printUser) {
op += '<p class="user">' + authors[n].textContent + '</p>';
op += '<p class="user">' + authors[n].textContent + '</p>';
}
}
op += '<p class="tweet">' + tweets[n].textContent + '</p>';
op += '<p class="tweet" id="tweet--' + n + '">' + tweets[n].textContent + '</p>';
if (printTime) {
if (printTime) {
op += '<p class="timePosted">' + times[n].textContent + '</p>';
op += '<p class="timePosted">' + times[n].textContent + '</p>';
}
}
}
}
}
}
if (showInteractionLinks) {
if (showInteractionLinks) {
op += '<p class="interact"><a href="https://twitter.com/intent/' +
op += '<p class="interact"><a href="https://twitter.com/intent/' +
'tweet?in_reply_to=' + tids[n] +
'tweet?in_reply_to=' + tids[n] +
'" class="twitter_reply_icon"' +
'" class="twitter_reply_icon"' +
(targetBlank ? ' target="_blank">' : '>') +
(targetBlank ? ' target="_blank">' : '>') +
'Reply</a><a href="https://twitter.com/intent/retweet?' +
'Reply</a><a href="https://twitter.com/intent/retweet?' +
'tweet_id=' + tids[n] + '" class="twitter_retweet_icon"' +
'tweet_id=' + tids[n] + '" class="twitter_retweet_icon"' +
(targetBlank ? ' target="_blank">' : '>') + 'Retweet</a>' +
(targetBlank ? ' target="_blank">' : '>') + 'Retweet</a>' +
'<a href="https://twitter.com/intent/favorite?tweet_id=' +
'<a href="https://twitter.com/intent/favorite?tweet_id=' +
tids[n] + '" class="twitter_fav_icon"' +
tids[n] + '" class="twitter_fav_icon"' +
(targetBlank ? ' target="_blank">' : '>') + 'Favorite</a></p>';
(targetBlank ? ' target="_blank">' : '>') + 'Favorite</a></p>';
}
}
if (showImages && images[n] !== undefined && extractImageUrl(images[n]) !== undefined) {
if (showImages && images[n] !== undefined && extractImageUrl(images[n]) !== undefined) {
op += '<div class="media">' +
op += '<div class="media">' +
'<img src="' + extractImageUrl(images[n]) +
'<img src="' + extractImageUrl(images[n]) +
'" alt="Image from tweet" />' + '</div>';
'" alt="Image from tweet" />' + '</div>';
}
}
if (showImages) {
if (showImages) {
arrayTweets.push(op);
arrayTweets.push(op);
} else if (!showImages && tweets[n].textContent.length) {
} else if (!showImages && tweets[n].textContent.length) {
arrayTweets.push(op);
arrayTweets.push(op);
}
}
n++;
n++;
}
}
}
}
handleTweets(arrayTweets);
handleTweets(arrayTweets);
inProgress = false;
inProgress = false;
if (queue.length > 0) {
if (queue.length > 0) {
twitterFetcher.fetch(queue[0]);
twitterFetcher.fetch(queue[0]);
queue.splice(0,1);
queue.splice(0,1);
}
}
}
}
};
};
// It must be a global variable because it will be called by JSONP.
// It must be a global variable because it will be called by JSONP.
window.__twttrf = twitterFetcher;
window.__twttrf = twitterFetcher;
window.twitterFetcher = twitterFetcher;
window.twitterFetcher = twitterFetcher;
return twitterFetcher;
return twitterFetcher;
}));
}));