// Based on cool-ass code at http://gpiot.com/blog/elegant-twitter-share-button-and-dialog-with-jquery/

// Cool Regex code:
// http://stackoverflow.com/questions/4058923/get-all-characters-after-character
// http://stackoverflow.com/questions/3780696/javascript-string-replace-with-regex-to-strip-off-illegal-characters

(function(){

  var linkElement = document.getElementById( "tweet-this-post" ),
      getPostTitle = document.getElementById( "blog-post-title" ).innerHTML,
      getPostLink = window.location.href,
      cleanLink = getPostLink.replace( /[^/]*$/g, "" );

  linkElement.setAttribute( "href", cleanLink );

  // Bind jQuery.click() to the Tweet link
  $( linkElement ).on( "click", function( e ){

    // Don't follow the link...ignore its href
    e.preventDefault();

    var tweetedLink = this.getAttribute( "href" );

    window.open( "http://twitter.com/intent/tweet?url=" + tweetedLink + "&text=" + getPostTitle + "&via=kaidez&", "twitterwindow", "height=450, width=550, toolbar=0, location=0, menubar=0, directories=0, scrollbars=0" );

  });

})();
@@ -319,24 +319,9 @@
 rs%0A%0A
-(function()%7B%0A%0A  
+%0A
 var 
@@ -378,23 +378,146 @@
 -post%22 )
-,%0A     
+;%0A%0A$( linkElement ).on( %22click%22, function( event )%7B%0A%0A  // Bind jQuery.click() to the Tweet link%0A  event.preventDefault();%0A  %0A  var
  getPost
@@ -676,16 +676,35 @@
 /g, %22%22 )
+,%0A      tweetedLink
 ;%0A%0A  lin
@@ -754,177 +754,8 @@
 %0A%0A  
-// Bind jQuery.click() to the Tweet link%0A  $( linkElement ).on( %22click%22, function( e )%7B%0A%0A    // Don't follow the link...ignore its href%0A    e.preventDefault();%0A%0A    var 
 twee
@@ -794,18 +794,16 @@
 ef%22 );%0A%0A
-  
   window
@@ -1018,16 +1018,7 @@
 );%0A%0A
-  
 %7D);
-%0A%0A%7D)();

refactor tweetButton.js