User:Kellen/monobook.js/examples

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Here are some minimal usage examples for the javascript in my monobook:

Adding a tool item[edit | edit source]

 toolitem = makeNewToolsItem('pt-cookbook');	// creates a LI in the personal tools portlet with the id 'pt-cookbook'
 toolitem.appendChild(makeLink('Cookbook', '/wiki/Cookbook'));		// creates a link to '/wiki/Cookbook' with the text 'Cookbook' and appends the link to the LI

Adding a sidebar portlet[edit | edit source]

 // makes a new portlet after "toolbox" with the id 'p-cookbook' and a label with text 'Cookbook'
 var cooktools = makeNewPortlet('p-cookbook', document.createTextNode('Cookbook'));  
 // adds a link to the portlet to '/wiki/Cookbook' with the label 'Main page'
 // repeat as necessary
 addPortletItem(cooktools, makeLink('Main page', '/wiki/Cookbook'));