Jump to content

User:RCSDevs/spider web.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by RCSDevs (talk | contribs) at 03:37, 20 July 2016. 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.
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 = localStorage.getItem('SHOW_SPIDERWEB') ? localStorage.getItem('SHOW_SPIDERWEB') : false;
	
	tag.html('Related Pages | <a id="toggle_spiderweb" href="#">Toggle SpiderWeb</a>');
	section.append('<div id="web_container"></div>');
	
	var web_container = $('#web_container'),
		setup = function()
		{
			if(showSpiderWeb)
			{
				var width = tag.width();
				list.hide();
				web_container.show();
				web_container.width(width).height(width / 3);
				web_container.slideToggle("slow");
			}
			else
			{
				web_container.slideToggle("slow");
				list.fadeIn();
			}
		};

	$('#toggle_spiderweb').click(function(event)
	{
		event.preventDefault();
		showSpiderWeb = !showSpiderWeb;
		localStorage.setItem('SHOW_SPIDERWEB', showSpiderWeb);
		
		setup();
	});
	
	$(window).resize(setup);
});