User:Milnivri/monaco.js

From Wikifang, a definitive guide to Telefang, Dino Device and Bugsite
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
function addPortletLink(portlet, href, text, id, tooltip, accesskey, nextnode) {
 var root = document.getElementById(portlet);
 if ( !root ) return null;
 var node = root.getElementsByTagName( "ul" )[0];
 if ( !node ) return null;

 // unhide portlet if it was hidden before
 root.className = root.className.replace( /(^| )emptyPortlet( |$)/, "$2" );

 var span = document.createElement( "span" );
 span.appendChild( document.createTextNode( text ) );

 var link = document.createElement( "a" );
 link.appendChild( span );
 link.href = href;

 var item = document.createElement( "li" );
 item.appendChild( link );
 if ( id ) item.id = id;

 if ( accesskey ) {
 link.setAttribute( "accesskey", accesskey );
 tooltip += " ["+accesskey+"]";
 }
 if ( tooltip ) {
 link.setAttribute( "title", tooltip );
 }
 if ( accesskey && tooltip ) {
 updateTooltipAccessKeys( new Array( link ) );
 }

 if ( nextnode && nextnode.parentNode == node )
 node.insertBefore( item, nextnode );
 else
 node.appendChild( item ); // IE compatibility (?)

 return item;
}

//add ExtEdit link 
addOnloadHook(function(){
  var editTab = document.getElementById('ca-edit');
  if (!editTab) return;
  addPortletLink('p-cactions', editTab.firstChild.href + '&externaledit=true', '→', 'ca-exted', 'Edit with External Editor ',, editTab.nextSibling);
})