Jump to content

User:Dragon695/addlilink.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.
<!--
 // -->[[User:Dragon695/addlilink.js]] - The addlilink and tab/toolbox helper functions based on [[WP:WPUS/Scripts/Add_LI_link]].

<!--
 // -->Taken from [[User:Quarl/addlilink.js]].

<!--
 // --><table class="wikitable">
<!--
 // --><caption><b><u>Version History</u></b></caption>
<!--
 // --><tr><th>Rev.</th><th>Editor</th><th>Date</th><th>Comments</th></tr>
<!--
 // --><tr><td>1.1</td><td>[[User:Quarl|quarl]]</td><td>2005-12-29</td><td>Initial version</td></tr>
<!--
 // --><tr><td>1.2</td><td>[[User:Quarl|quarl]]</td><td>2006-01-03</td><td>Moved [[User:Quarl/add li link.js]] to [[User:Quarl/addlilink.js]]</td></tr>
<!--
 // --><tr><td>1.3</td><td>[[User:Quarl|quarl]]</td><td>2006-01-03</td><td>None</td></tr>
<!--
 // --><tr><td>1.4</td><td>[[User:Quarl|quarl]]</td><td>2006-01-03</td><td>None</td></tr>
<!--
 // --><tr><td>1.5</td><td>[[User:Quarl|quarl]]</td><td>2006-01-03</td><td>None</td></tr>
<!--
 // --><tr><td>1.6</td><td>[[User:Quarl|quarl]]</td><td>2006-01-04</td><td>None</td></tr>
<!--
 // --><tr><td>1.7</td><td>[[User:Quarl|quarl]]</td><td>2006-01-04</td><td>None</td></tr>
<!--
 // --><tr><td>1.8</td><td>[[User:Quarl|quarl]]</td><td>2006-01-04</td><td>None</td></tr>
<!--
 // --><tr><td>1.9</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>Commenting</td></tr>
<!--
 // --><tr><td>1.10</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>getNavigationBox, addNavigationLink</td></tr>
<!--
 // --><tr><td>1.11</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>addlilinkX</td></tr>
<!--
 // --><tr><td>1.12</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>addNavigationEditLink</td></tr>
<!--
 // --><tr><td>1.13</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>addNavigationEditLink: use pagename</td></tr>
<!--
 // --><tr><td>1.14</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>fix paren</td></tr>
<!--
 // --><tr><td>1.15</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>+"style='display:inline'"</td></tr>
<!--
 // --><tr><td>1.16</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>bf quote</td></tr>
<!--
 // --><tr><td>1.17</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>+"style='display:inline'"</td></tr>
<!--
 // --><tr><td>1.18</td><td>[[User:Quarl|quarl]]</td><td>2006-01-30</td><td>mv addNavigationEditLink to nav_custom.js</td></tr>
<!--
 // --><tr><td>1.18</td><td>[[User:Quarl|quarl]]</td><td>2006-02-06</td><td>window.ta</td></tr>
<!--
 // --></table>

// <pre><nowiki>


function getTabActions() {
	return (document.getElementById('p-cactions').getElementsByTagName('ul')[0]);
}

function getToolbox() {
	return (document.getElementById('p-tb').getElementsByTagName('ul')[0]);
}

function getNavigationBox() {
	return (document.getElementById('p-navigation').getElementsByTagName('ul')[0]);
}

function addTab(url, name, id, title, key) {
	addlilink(getTabActions(), url, name, id, title, key);
}

function addToolboxLink(url, name, id, title, key) {
	addlilink(getToolbox(), url, name, id, title, key);
}

function addNavigationLink(url, name, id, title, key) {
	addlilink(getNavigationBox(), url, name, id, title, key);
}

function addlilinkX(tabs, entry, id, title, key){
	var li = document.createElement('li');
	if (id) {
		li.id = id;
	}
	if (typeof(entry) == 'string') {
		li.innerHTML = entry;
	} else {
		li.appendChild(entry);
	}
	tabs.appendChild(li);
	if (id && (key || title) && window.ta) {
		ta[id] = [(key || ''), (title || '')];
	}
	//
	// Re-render the title and accesskeys from existing code in wikibits.js.
	//
	akeytt();

	return (li);
}

function addlilink(tabs, url, name, id, title, key) {
	var na = document.createElement('a');
	na.href = url;
	na.appendChild(document.createTextNode(name));

	return (addlilinkX(tabs, na, id, title, key));
}


// </nowiki></pre>