User:Lyrithya/dropdown.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
// <nowiki>

function addCactionsDropdown(node, links) {
	if (document.getElementById(node)) addDropdown($('#' + node), links, 0);
}
 
function addDropdown(node, links, type) {
	// Type 0 = down, type 1 = right side

	// Add arrow
	var imgb = document.createElement('img');
	if(type == 0) {
		imgb.setAttribute('src', 'http://images4.wikia.nocookie.net/__cb20110614134245/uncyclopedia/images/0/04/Doinky_v.png');
		imgb.setAttribute('height', '5px');
		imgb.setAttribute('width', '11px');
		imgb.setAttribute('style', 'margin-left:5px;');
		node.children('a:last').append(imgb);
	} else {
		imgb.setAttribute('src', 'http://images3.wikia.nocookie.net/__cb20110614143245/uncyclopedia/images/6/6c/Doinky_.png');
		imgb.setAttribute('height', '11px');
		imgb.setAttribute('width', '11px');
		var imgbc = document.createElement('div');
		imgbc.setAttribute('style', 'margin-left:5px; margin-right: -6px; width:11px; float:right;')
		imgbc.appendChild(imgb);
		node.children('a:last').append(imgbc);
	} 
 	
	if (type == 0) {
		node.addClass('ca-dropdown');
		node.append('<div class="dropdown"></div>');
		var ddown = node.children('.dropdown:first');
	} else {
		node.addClass('d-dropdown');
		node.append('<div class="dropdownn"></div>');
		var ddown = node.children('.dropdownn:first');
	}

	for (var qua = 0, an = links.length; qua < an; qua++) {
		if (links[qua][0].constructor.toString().indexOf("Array") == -1) {
			var tia = '', ia = '';
			if (links[qua][3]) tia = ' title="' + links[qua][3] + '"';
			if (links[qua][2]) ia = ' id="' + links[qua][2] + '"';
			ddown.append('<span' + ia + '><a href="' + links[qua][0] + '"' + tia + '>' + links[qua][1] + '</a></span>');
		} else { 
			var tia = '', ia = '', hia = ' href=""';
			if (links[qua][4]) tia = ' title="' + links[qua][4] + '"';
			if (links[qua][3]) ia = ' id="' + links[qua][3] + '"';
			if (links[qua][1]) hia = ' href="' + links[qua][1] + '"';
			ddown.append('<span class="d-dropdown"' + ia + '><a' + hia + tia + '>' + links[qua][2] + '</a></span>');
			addDropdown(ddown.children('.d-dropdown:last'), links[qua][0], 1);
		}
	}
 	node.append(ddown);
	return;
}

// </nowiki>