﻿
//replaces things that look like links with actual links
String.prototype.linkify = function() {
	return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
		return m.link(m);
	});
};

//populates a ul#tweets with the latest wiltshirefarm feed
jQuery(function() {
	if (jQuery('#tweets').length > 0) {
		jQuery.getJSON('https://twitter.com/status/user_timeline/wiltshirefarm.json?count=4&callback=?',
		function(data) {
			jQuery.each(data, function(i, item) {
				jQuery('#tweets').append('<li>' + item.text.linkify() + '</li>');
			});
		});
	}
});
