Wikipedia:User scripts/Guide: Difference between revisions
Content deleted Content added
Johnduhart (talk | contribs) →portlets: Updating portlet code |
|||
Line 266:
</div>
There is a special function in [
<tt>mw.util.'''addPortletLink''' (portlet, href, text, id, tooltip, accesskey, nextnode)</tt>
<source lang="javascript">
// Several examples of portlet links
addPortletLink ('p-tb', wgArticlePath.replace('$1', 'Special:MyPage/vector.js'), 'My vector.js', 'pt-myvector', 'Visit your vector.js file');▼
</source>▼
// Adds a link to your Vector.js file to the toolbox
mw.util.addPortletLink ( 'p-tb', mw.util.wikiGetlink( 'Special:MyPage/vector.js' ),
▲
// Add a link to the edit page for your Notes in your personal links
// Note: We assume that short/pretty URLs are in use with ?action, ideally you
// would check for that.
mw.util.addPortletLink ( 'p-personal', mw.util.wikiGetlink( 'Special:MyPage/Notes' ) + '?action=edit',
'My notes', 'pt-mynotes', 'Edit your personal notes' );
// Adds a link to prefix index for the current page to the toolbox
mw.util.addPortletLink ( 'p-tb',
mw.util.wikiGetlink( 'Special:Prefixindex/' + mw.config.get( 'wgPageName' ) ),
'Prefixindex', 'tb-prefixindex');
// Adds a link to
mw.util.addPortletLink ( 'p-personal',
mw.util.wikiGetlink( 'Special:Log/' + mw.config.get( 'wgUserName' ) ),
'My logs', 'pt-mylogs');
▲</source>
=== Adding elements ===
|