User:Lyrithya/share.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
function shareLinks() {
	var a = document.getElementById( 'ca-edit' );
	if( !a ) a = document.getElementById( 'ca-viewsource' ); 
	if( !a ) return;

	// create tab
	var root = document.getElementById('p-cactions');
	var node=root.getElementsByTagName('ul')[0];
	root.className=root.className.replace(/(^| )emptyPortlet( |$)/,"$2");

	var imga=document.createElement('img');
	var link=document.createElement('a');
	link.href='';

	if (skin == 'monobook') {
		imga.setAttribute('src', 'http://images.uncyclomedia.co/uncyclopedia/en/5/56/Share-icon-12x12.png');
		imga.setAttribute('height', '12px');
		imga.setAttribute('width', '12px');
		imga.style.padding = '0 6px 0 0';
		var an=document.createTextNode('Share');
		//link.appendChild(imga);
		link.appendChild(an);
	}
	else {
		imga.setAttribute('src', 'http://images.uncyclomedia.co/uncyclopedia/en/b/b5/Share-icon_vector.png');
		imga.setAttribute('height', '16px');
		imga.setAttribute('width', '16px');
		imga.style.margin = '-4px 0 -2px 0';
		link.appendChild(imga);
	}
	var item=document.createElement('li');
	item.appendChild(link);
	item.id = 'ca-share';
	link.setAttribute('title', 'Share this page');

	node.appendChild(item);
	
	var shares = new Array(7);
	var pathn = wgServer + wgArticlePath.replace('$1', wgPageName);
	var titlen = escape(wgCanonicalNamespace + ':' + wgTitle);
	var titlenu = escape(wgCanonicalNamespace + ':' + wgTitle + '- on Uncyclopedia');

	shares[0] = ['http://www.facebook.com/share.php?u=' + pathn + '?facebook&t=' + titlenu, 'Facebook', 'd-facebook'];
	shares[1] = ['http://twitter.com/intent/tweet?original_referer=' + pathn + '&related=uncyclopedia&text=' + titlen + '&url=' + pathn, 'Twitter', 'd-twitter'];
	shares[2] = ['http://www.stumbleupon.com/submit?url=' + pathn + '&title=' + titlen, 'Stumbleupon', 'd-stumbleupon'];
	shares[3] = ['http://reddit.com/submit?url=' + pathn + '&title=' + titlenu, 'Reddit', 'd-reddit'];
	shares[4] = ['http://digg.com/submit?phase=2&url=' + pathn, 'Digg', 'd-digg'];
	shares[5] = ['http://spaces.live.com/BlogIt.aspx?Title=' + titlenu + '&SourceURL=' + pathn, 'BlogIt', 'd-blogit'];
	shares[6] = ['http://www.tumblr.com/share?v=3&u=' + pathn + '&t=' + titlenu, 'Tumblr', 'd-tumblr'];

	//shares[3] = ['https://m.google.com/app/plus/x/?v=compose&content=' + titlenu + ' - ' + pathn, 'Google+', 'd-googleplus'];
	//shares[n] = ['http://www.myspace.com/Modules/PostTo/Pages/?l=3&u=' + pathn + '&t=' + titlenu, 'MySpace', 'd-myspace'];
	//shares[n] = ['http://www.delicious.com/save?v=5&noui&jump=close&url=' + pathn + '&title=' + titlen, 'Delicious', 'd-delicious'];
	//shares[n] = ['http://www.buzzfeed.com/...', 'BuzzFeed', 'd-buzzfeed'];

	importStylesheetURI( 'http://en.uncyclopedia.co/w/index.php?title=User:Lyrithya/share.css&action=raw&ctype=text/css' );
	addCactionsDropdown('ca-share', shares);
}

YAHOO.util.Event.onContentReady('p-cactions', shareLinks);