Jump to content

User:RCSDevs/spider web.js

From Wikipedia, the free encyclopedia
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.
importStylesheet('User:RCSDevs/spider_web.css');

$(document).ready(function()
{
	var section = $('aside.ra-read-more.post-content.noprint').eq(0),
		tag = section.find('h2').eq(0),
		list = section.find('ul').eq(0),
		showSpiderWeb = false;
	
	tag.html('Related Pages | <a id="toggle_spiderweb" href="#">Toggle SpiderWeb</a>');
	list.before('<svg id="web_container"><image xlink:href="/media/wikipedia/commons/thumb/5/57/Plantains.jpg/67px-Plantains.jpg" x="822" y="240.1665" height="90" width="67"></image></svg>');
	
	var web_container = $('#web_container'),
		setup = function()
		{
			if(showSpiderWeb)
			{
				var width = tag.width();
				web_container.show();
				web_container.width(width);
				web_container.animate({'height': ((width / 3) + 'px')}, 300);
				$('html, body').animate({ 
   					scrollTop: $(document).height() - ($(window).height() - (width / 3)) 
				}, 305);
			}
			else
			{
				web_container.animate({'height': '0px'}, 300, function()
				{
					web_container.hide();
				});
			}
		};

	$('#toggle_spiderweb').click(function(event)
	{
		event.preventDefault();
		showSpiderWeb = !showSpiderWeb;

		setup();
	});
	
	$(window).resize(setup);
});