Jump to content

User:Bassem JARKAS/microblog.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Bassem JARKAS (talk | contribs) at 03:16, 22 May 2012. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
<source lang="javascript">
// Adds option to share link to the current page in social networks and email

$(document).ready(function(){
  var socialShares= [
 {
                     'title':'Email',
                     'url':'mailto:?subject='+encodeURIComponent(wgPageName)+'&body='+wgServer+'/wiki/'+encodeURIComponent(wgPageName),
                     'img':'/media/wikipedia/commons/4/42/Icon_External_Link_E-Mail.png'
                     },
{
                     'title':'Facebook',
                     'url':'http://www.facebook.com/sharer.php?u='+wgServer+'/wiki/'+encodeURIComponent(wgPageName),
                     'img':'/media/wikinews/en/5/55/Facebook.png'
                     },
{
                     'title':'Twitter',
                     'url':'http://twitter.com/?status='+encodeURIComponent('See page: \n'+wgPageName+'\non Wikipedia'),
                     'img':'/media/wikinews/en/f/f7/Twitter.png'
                     }
];

  try {

    var whatLinksItem= $( "#t-whatlinkshere" );
    if ( !whatLinksItem.length) return;
    
        var shareText=$( "<span>Share: </span>" );

$(socialShares).each(function(){
         var socialSpan= $( "<span></span>" );
         var socialA= $( '<a></a>',{href:this.url,title:this.title} );
if(this.title!='Email') socialA.click(function(){
 window.open(this.href,'Share','toolbar=0,status=0,resizable=1,width=550,height=400');
return false;
});

         var socialImg= $( '<img />', {'src': this.img});
         socialA.append(socialImg);
         socialSpan.append(socialA);
         shareText.append(socialSpan);
});

        var item = $( "<li></li>",{id:'t-socialShare'} );
        item.append( shareText);
        whatLinksItem.before ( item);
    
  }
  catch(e)
  {
    return;
  }
});
</source>