<commit_before>/*jslint browser: true, 
         eqeq: true, 
         plusplus: true, 
         regexp: true, 
         white: false */
/*global document, screen, window, $ */

var S	= {
	ready														: function()
	{
		S.detectBrowser();
		S.loadTweets();
		S.handleExternalLinks();
	},
	
	loadTweets													: function()
	{
		var t	= $( '#tweets' );
		
		$.getJSON( 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=ahmednuaman&count=5&callback=?', function(d)
		{
			if ( d.length )
			{
				var li	= $( 'li', t ).empty().remove();
				
				$.each( d, function()
				{
					var l	= li.clone();
					var h	= S.prepareLinks( this.text );
					
					l.html( h );
					
					t.append( l );
				});
				
				S.handleExternalLinks();
			}
			else
			{
				$( 'li', t ).text( 'Magical, the tweets didn\'t load. This is Ahmed\'s fault, damn arabs.' );
			}
		});
	},
	
	prepareLinks												: function(t)
	{
		t	= t.replace( /&/gim, '&amp;' ).replace( /</gim, '&lt;' ).replace( />/gim, '&gt;' ).replace( /"/gim, '&quot;' ).replace( /'/gim, '&#039;' ); 
		
		t	= t.replace( /((https?:\/\/|www\.)[^\s]+)/gim, function(m)
		{
			var l	= ( m.indexOf( 'http' ) === -1 ? 'http://' : '' ) + m;

			return '<a href="' + l + '" class="external">' + m + '</a>';
		});

		t	= t.replace( /\s(\@[^\s]+)\s?/gim, function(m)
		{
			m		= m.replace( /\s/gim, '' );

			var l	= 'http://twitter.com/' + m;

			return ' <a href="' + l + '" class="external">' + m + '</a> ';
		});

		t	= t.replace( /\s(\#[^\s]+)\s?/gim, function(m)
		{
			m		= m.replace( /\s/gim, '' );

			var l	= 'http://twitter.com/search?q=' + m;

			return ' <a href="' + l + '" class="external">' + m + '</a> ';
		});

		return t;
	},
	
	handleExternalLinks											: function()
	{
		$( 'a:not(.external):not(.internal)' ).each( function()
		{
			var h	= $( this ).attr( 'href' );
			
			if ( h.search( /https?\:\/\//i ) === 0 && h.indexOf( document.domain ) === -1 )
			{
				window.open( '_blank', h );
			}
		});
	},
	
	detectBrowser							: function()
	{
		if ( $.browser.msie )
		{
			$( 'html' ).addClass( 'ie' );
			
			if ( $.browser.version == '9.0' )
			{
				$( 'html' ).addClass( 'ie9' );
			}
			else if ( $.browser.version == '8.0' )
			{
				$( 'html' ).addClass( 'ie8' );
			}
			else if ( $.browser.version == '7.0' )
			{
				$( 'html' ).addClass( 'ie7' );
			} 
			else
			{
				$( 'html' ).addClass( 'ie6' );
			}
		}
		
		if ( $.browser.webkit )
		{
			$( 'html' ).addClass( 'webkit' );<commit_msg>added classes<commit_after>/*jslint browser: true, 
         eqeq: true, 
         plusplus: true, 
         regexp: true, 
         white: false */
/*global document, screen, window, $ */

var S	= {
	ready														: function()
	{
		S.detectBrowser();
		S.loadTweets();
		S.handleExternalLinks();
	},
	
	loadTweets													: function()
	{
		var t	= $( '#tweets' );
		
		$.getJSON( 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=ahmednuaman&count=5&callback=?', function(d)
		{
			if ( d.length )
			{
				var li	= $( 'li', t ).empty().remove();
				
				$.each( d, function()
				{
					var l	= li.clone();
					var h	= S.prepareLinks( this.text );
					
					l.html( h );
					
					t.append( l );
				});
				
				S.handleExternalLinks();
			}
			else
			{
				$( 'li', t ).text( 'Magical, the tweets didn\'t load. This is Ahmed\'s fault, damn arabs.' );
			}
		});
	},
	
	prepareLinks												: function(t)
	{
		t	= t.replace( /&/gim, '&amp;' ).replace( /</gim, '&lt;' ).replace( />/gim, '&gt;' ).replace( /"/gim, '&quot;' ).replace( /'/gim, '&#039;' ); 
		
		t	= t.replace( /((https?:\/\/|www\.)[^\s]+)/gim, function(m)
		{
			var l	= ( m.indexOf( 'http' ) === -1 ? 'http://' : '' ) + m;

			return '<a href="' + l + '" class="external">' + m + '</a>';
		});

		t	= t.replace( /\s(\@[^\s]+)\s?/gim, function(m)
		{
			m		= m.replace( /\s/gim, '' );

			var l	= 'http://twitter.com/' + m;

			return ' <a href="' + l + '" class="external">' + m + '</a> ';
		});

		t	= t.replace( /\s(\#[^\s]+)\s?/gim, function(m)
		{
			m		= m.replace( /\s/gim, '' );

			var l	= 'http://twitter.com/search?q=' + m;

			return ' <a href="' + l + '" class="external">' + m + '</a> ';
		});

		return t;
	},
	
	handleExternalLinks											: function()
	{
		$( 'a:not(.external):not(.internal)' ).each( function()
		{
			var h	= $( this ).attr( 'href' );
			
			if ( h.search( /https?\:\/\//i ) === 0 && h.indexOf( document.domain ) === -1 )
			{
				$( this ).addClass( 'external' ).click( function()
				{
					window.open( h );
					
					return false;
				});
			}
			else
			{
				$( this ).addClass( 'internal' );
			}
		});
	},
	
	detectBrowser							: function()
	{
		if ( $.browser.msie )
		{
			$( 'html' ).addClass( 'ie' );
			
			if ( $.browser.version == '9.0' )
			{
				$( 'html' ).addClass( 'ie9' );
			}
			else if ( $.browser.version == '8.0' )
			{
				$( 'html' ).addClass( 'ie8' );
			}
			else if ( $.browser.version == '7.0' )
			{
				$( 'html' ).addClass( 'ie7' );
			} 
			else
			{
				$( 'html' ).addClass( 'ie6' );
			}
		}
		
		if ( $.browser.webkit )
		{
			$( 'html' ).addClass( 'webkit' );
{'fraction_non_alphanumeric': 0.2501459996106677, 'fraction_numerical': 0.007007981312049835, 'mean_word_length': 1.941041785918718, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5994140', 'n_tokens_mistral': 2590, 'n_tokens_neox': 2057, 'n_words': 405}