window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){arguments.callee=arguments.callee.caller;var a=[].slice.call(arguments);(typeof console.log==="object"?log.apply.call(console.log,console,a):console.log.apply(console,a))}};
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
{console.log();return window.console;}catch(err){return window.console={};}})());


/***************
twitter
****************/
(function( $ ){
		  
	// =methods
	var methods = {
		init : function(){
		
			$.ajax({
				type: 'GET',
				dataType: 'jsonp',
				url: 'http://api.twitter.com/1/statuses/user_timeline.json',
				data: { screen_name: 'timong', include_rts:1, count: 3},
				success: function (data, textStatus, XMLHttpRequest) {
					//log(data);
					var tmp = false;
					var tweets = $('ul.#tweets');	
					for (var i in data) {
						
						var url = '<a href="http://twitter.com/timong/statuses/' + data[i].id_str + '">'+ data[i].text + '</a>';
						
						var d = new Date(data[i].created_at);
						var cd = '';
						
						// ie7
						if ( !isNaN(d) ) {
							cd = '<br /><span class="date">' + kld.months[d.getMonth()] + ' ' + d.getUTCDate() + ', ' + d.getFullYear() + '</span>';
						}
							
						tmp = $('<li>' + url +  cd +'</li>');
						tweets.append(tmp);
					}
				},
				error: function (req, status, error) {
					console.log('error: '+status);	
				}
			   
			});
		
		
		}

	};
	
	// =definition
	$.fn.twitterfeed = function( method ) {
		if ( methods[method] ) {
			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
			return methods.init.apply( this, arguments );
		} else {
			$.error( 'Method "' + method + '" does not exist on jQuery.twitterfeed' );
		}
	};
		 	  
		  
})( jQuery );


/***************
pinboard
****************/
(function( $ ){
		  
	// =methods
	var methods = {
		init : function(){
	
			$.ajax({
				url: 'http://feeds.pinboard.in/json/v1/u:timong/',
				data: { count: 5, cb: 'pinboardcb' },
				jsonp: 'cb',
				dataType: 'jsonp'
			   
			});
		},
		makelinks: function(data) {
			//log(data);
			var tmp;
			var pblinks = $('ul#pinboard');
			
			for (var i in data) {
						
				var url = '<a href="' + data[i].u + '">'+ data[i].d + '</a>';
				
				tmp = $('<li>' + url + '</li>');
				pblinks.append(tmp);
			}
		}

	};
	
	// =definition
	$.fn.pinboardlinks = function( method ) {
		if ( methods[method] ) {
			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
			return methods.init.apply( this, arguments );
		} else {
			$.error( 'Method "' + method + '" does not exist on jQuery.pinboardlinks' );
		}
	};
		 	  
		  
})( jQuery );
// lame
function pinboardcb(data) {
	$().pinboardlinks('makelinks',data);
}



