User:Mainphramephreak/monobook.js

/* see /examples for basic usage */

/** * makeLink * makes a link with the specified text and href * * param text: label text to give the link * param href: url for the link **/ function makeLink(text, href) { var link = document.createElement('A'); link.appendChild(document.createTextNode(text)); link.href = href; return link; }

/** * makeNewToolsItem * makes a new item in the personal tools portlet with the specified id * * param id: id to give the new item * returns: a new item (li) on the personal tools list with specified id **/ function makeNewToolsItem(id) { var node = document.createElement('LI'); node.id = id; // add to list var preflist = document.getElementById('pt-userpage').parentNode; preflist.appendChild(node); return node; }

/** * insertAfter * adds newElement to the DOM tree after the reference node * * param reference: the node to insert after * param newElement: the element to insert **/ function insertAfter(reference, newElement) { reference.parentNode.insertBefore(newElement,reference.nextSibling); }

/** * makeNew Portlet * make a new sidebar portlet * * param id: id to give the containing div of the portlet * param label: visible label for the portlet, like "toolbox" * returns: an empty list (UL) to be filled with items (li's) **/ function makeNewPortlet(id, label) { var node = document.createElement('DIV'); node.id = id; node.className= 'portlet'; var title = document.createElement('H5'); title.appendChild(label); node.appendChild(title); var contentnode = document.createElement('DIV'); contentnode.className = 'pBody'; node.appendChild(contentnode); var listnode = document.createElement('UL'); contentnode.appendChild(listnode);

/* by default inserts under the 'toolbox'; use a different id     in place of 'p-tb' to move where the portlet gets put */ insertAfter(document.getElementById('p-tb'), node);

return listnode; }

/** * addPortletItem * add an item to a portlet * * param portlet: a list (UL, usually) * param item: a node, most often a link (A), to add to the list */ function addPortletItem(portlet, item) { var listitem = document.createElement('LI'); listitem.appendChild(item); portlet.appendChild(listitem); }

/* generates a bunch of cookbook-related interface bits */ function ccg { // make a cookbook item in the personal tools portlet cooknode = makeNewToolsItem('pt-ccg'); // wrap "My Box >" in a span so we can alter the style independently var cooklabel = document.createElement('SPAN'); cooklabel.id = 'pt-ccg-label'; // add the links cooklabel.appendChild(makeLink(, )); cooklabel.appendChild(makeLink(, )); cooklabel.appendChild(document.createTextNode(''));

// append everything to the cookbook item cooknode.appendChild(cooklabel); cooknode.appendChild(makeLink(, )); cooknode.appendChild(document.createTextNode('')); cooknode.appendChild(makeLink(, ));

// make cookbook portlet var cooktools = makeNewPortlet('p-ccg', document.createTextNode('CCG')); // add a bunch of links to it addPortletItem(cooktools, makeLink('1E:PE', '/wiki/CCG:_Premiere_Edition')); addPortletItem(cooktools, makeLink('1E:WP', '/wiki/CCG:_Warp_Pack')); addPortletItem(cooktools, makeLink('1E:AU', '/wiki/CCG:_Alternate_Universe')); addPortletItem(cooktools, makeLink('1E:QC', '/wiki/CCG:_Q-Continuum')); addPortletItem(cooktools, makeLink('1E:ITPG', '/wiki/CCG:_Introductory_Two-Player_Game')); addPortletItem(cooktools, makeLink('1E:1A', '/wiki/CCG:_The_First_Anthology')); addPortletItem(cooktools, makeLink('1E:FC', '/wiki/CCG:_First_Contact')); addPortletItem(cooktools, makeLink('1E:ATP', '/wiki/CCG:_Away_Team_Pack')); addPortletItem(cooktools, makeLink('1E:OTSD', '/wiki/CCG:_Official_Tournament_Sealed_Deck')); addPortletItem(cooktools, makeLink('1E:DS9', '/wiki/CCG:_Deep_Space_Nine')); addPortletItem(cooktools, makeLink('1E:SD2', '/wiki/CCG:_Starter_Deck_II')); addPortletItem(cooktools, makeLink('1E:EFC', '/wiki/CCG:_Enhanced_First_Contact')); addPortletItem(cooktools, makeLink('1E:DOM', '/wiki/CCG:_The_Dominion')); addPortletItem(cooktools, makeLink('1E:BoG', '/wiki/CCG:_Blaze_of_Glory')); addPortletItem(cooktools, makeLink('1E:BoGF', '/wiki/CCG:_Blaze_of_Glory_Foils')); addPortletItem(cooktools, makeLink('1E:RoA', '/wiki/CCG:_The_Rules_of_Acquisition')); addPortletItem(cooktools, makeLink('1E:2A', '/wiki/CCG:_The_Second_Anthology')); addPortletItem(cooktools, makeLink('1E:ARM', '/wiki/CCG:_Armada')); addPortletItem(cooktools, makeLink('1E:TWT', '/wiki/CCG:_The_Trouble_with_Tribbles')); addPortletItem(cooktools, makeLink('1E:EP', '/wiki/CCG:_Enhanced_Premiere')); addPortletItem(cooktools, makeLink('1E:Ref', '/wiki/CCG:_Reflections')); addPortletItem(cooktools, makeLink('1E:MM', '/wiki/CCG:_Mirror%2C_Mirror')); addPortletItem(cooktools, makeLink('1E:Voy', '/wiki/CCG:_Voyager')); addPortletItem(cooktools, makeLink('1E:Borg', '/wiki/CCG:_The_Borg')); addPortletItem(cooktools, makeLink('1E:HA', '/wiki/CCG:_Holodeck_Adventures')); addPortletItem(cooktools, makeLink('1E:TMP', '/wiki/CCG:_The_Motion_Pictures')); addPortletItem(cooktools, makeLink('1E:AGT', '/wiki/CCG:_All_Good_Things')); addPortletItem(cooktools, makeLink('1E:TEC', '/wiki/CCG:_The_Enterprise_Collection')); addPortletItem(cooktools, makeLink('2E:SE', '/wiki/CCG:_Second_Edition')); addPortletItem(cooktools, makeLink('2E:Eng', '/wiki/CCG:_Engergize')); addPortletItem(cooktools, makeLink('2E:NE', '/wiki/CCG:_Necessary_Evil')); addPortletItem(cooktools, makeLink('2E:TAC', '/wiki/CCG:_Tenth_Anniversary_Collection')); addPortletItem(cooktools, makeLink('2E:FT', '/wiki/CCG:_Fractured_Time')); addPortletItem(cooktools, makeLink('2E:Ref', '/wiki/CCG:_Reflections_2.0')); addPortletItem(cooktools, makeLink('2E:SNW', '/wiki/CCG:_Strange_New_Worlds')); addPortletItem(cooktools, makeLink('2E:AA', '/wiki/CCG:_Adversaries_Anthology')); addPortletItem(cooktools, makeLink('2E:TBG', '/wiki/CCG:_To_Boldly_Go')); addPortletItem(cooktools, makeLink('2E:DM', '/wiki/CCG:_Dangerous_Missions')); addPortletItem(cooktools, makeLink('2E:CL', '/wiki/CCG:_Captain%27s_Log')); addPortletItem(cooktools, makeLink('2E:Gen', '/wiki/CCG:_Genesis')); addPortletItem(cooktools, makeLink('2E:TATV', '/wiki/CCG:_These_are_the_Voyages')); addPortletItem(cooktools, makeLink('2E:IAMD', '/wiki/CCG:_In_a_Mirror%2C_Darkly')); addPortletItem(cooktools, makeLink('2E:WYLB', '/wiki/CCG:_What_You_Leave_Behind')); addPortletItem(cooktools, makeLink('2E:AC', '/wiki/CCG:_Archive_Cards')); addPortletItem(cooktools, makeLink('2E:PC', '/wiki/CCG:_Promotional_Cards'));

}

/* run ccg when a page is loaded */ if (window.addEventListener) window.addEventListener("load",ccg,false); else if (window.attachEvent) window.attachEvent("onload",ccg);

/* generates a bunch of cookbook-related interface bits */ function mybox { // make a cookbook item in the personal tools portlet cooknode = makeNewToolsItem('pt-mybox'); // wrap "My Box >" in a span so we can alter the style independently var cooklabel = document.createElement('SPAN'); cooklabel.id = 'pt-mybox-label'; // add the links cooklabel.appendChild(makeLink(, )); cooklabel.appendChild(makeLink(, )); cooklabel.appendChild(document.createTextNode(''));

// append everything to the cookbook item cooknode.appendChild(cooklabel); cooknode.appendChild(makeLink(, )); cooknode.appendChild(document.createTextNode('')); cooknode.appendChild(makeLink(, ));

// make cookbook portlet var cooktools = makeNewPortlet('p-mybox', document.createTextNode('My Box')); // add a bunch of links to it addPortletItem(cooktools, makeLink('CCG Roster', '/wiki/User:Mainphramephreak/CCG Roster')); addPortletItem(cooktools, makeLink('Stuff', '/wiki/User:Mainphramephreak/Stuff')); addPortletItem(cooktools, makeLink('Decipher', 'http://startrekccg.fanhq.com/')); addPortletItem(cooktools, makeLink('Wixiban', 'http://www.wixiban.co.uk/ccg/ccg.htm')); addPortletItem(cooktools, makeLink('TrekCore', 'http://www.trekcore.com/')); addPortletItem(cooktools, makeLink('Transcripts', 'http://www.chakoteya.net/')); addPortletItem(cooktools, makeLink('LCARS', 'http://www.cygnus-x1.net/links/lcars/eps-main2.php')); addPortletItem(cooktools, makeLink('My monobook skin', '/wiki/User:Mainphramephreak/monobook.css')); addPortletItem(cooktools, makeLink('My monobook sidebar', '/wiki/User:Mainphramephreak/monobook.js')); addPortletItem(cooktools, makeLink('My monaco skin', '/wiki/User:Mainphramephreak/monaco.css')); addPortletItem(cooktools, makeLink('My monaco sikdebar', '/wiki/User:Mainphramephreak/Monaco-sidebar')); }

/* run mybox when a page is loaded */ if (window.addEventListener) window.addEventListener("load",mybox,false); else if (window.attachEvent) window.attachEvent("onload",mybox);