Jump to content

User:Bassem JARKAS/microblog.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Ladsgroup (talk | contribs) at 18:18, 6 March 2021 (Maintenance: Replacing legacy global variable (phab:T72470)). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
// Adds option to share link to the current page in social networks and email


addOnloadHook(function() {
    if(wgIsArticle) {
        var shortcut = wgArticleId.toString(36),
        url = 'http://defn.me/r/' + wgContentLanguage + '/' + shortcut,
	$(document).ready(function(){
	  var socialShares= [
	 {
                     'title':'Email',
                     'url':'mailto:?subject='+encodeURIComponent(mw.config.get('wgPageName'))+'&body='+wgServer+'/wiki/'+encodeURIComponent(mw.config.get('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(mw.config.get('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;
  }
});

    }
});