Jump to content

User:Anakin101/addPortlet.js

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by Anakin101 (talk | contribs) at 20:37, 31 October 2009 (Created page with 'function addPortlet(id, title, before) { var copy = document.getElementById('p-tb'); var div = document.createElement('div'); div.setAttribute('id', id); div.se...'). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
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.
function addPortlet(id, title, before) {
	var copy = document.getElementById('p-tb');
	var div = document.createElement('div');
	div.setAttribute('id', id);
	div.setAttribute('class', copy.getAttribute('class'));
	div.innerHTML = '<h5>' + title + '</h5>';
	var pBody = document.createElement('div');
	pBody.setAttribute('class', copy.getElementsByTagName('div')[0].getAttribute('class'));
	pBody.appendChild(document.createElement('ul'));
	div.appendChild(pBody);
	if (before && (before = document.getElementById(before))) {
		copy.parentNode.insertBefore(div, before);
	} else {
		copy.parentNode.appendChild(div);
	}
	return pBody;
}