Jump to content

User:DavidHOzAu/citefix

From Wikipedia, the free encyclopedia

This page is unmaintained and may be buggy. If you want to get rid of all[citation needed] on a page, add the citations already.

This code solves two issues:

  1. Line-spacing problem for {{Citation needed}}, whereby superscripts add extra space. This works by simply setting the verticalAlign attribute to 'top'. This simple hack works on IE and Mozilla.
  2. Replace the contents of {{Citation needed}} with contents of your own. Two examples are provided:
    First example: an image, . This requires that you are also changing verticalAlign for it to work.
    Second example: a shorter version that resembles [cite].

You will have choose which one you want by uncommenting/commenting one of them. I prefer the shorter text, which is what I'm using right now.

If you want to fix spacing for all <sup> and <ref> tags instead of customizing how {{citeneeded}} looks, consider adding the subpage /code.css to your customized CSS file.

Copy and paste the following text into your monobook.js.

/*

 */
function MyCitation() 
{
   // iterate over all <sup>-elements
   for(var i=0; a = document.getElementsByTagName("sup")[i]; i++) {
      // if found a citation thag
      if(a.getAttribute("title")=="Needs citation" || a.getAttribute("class")=="uncited") {
         // 1) fix style -- a wider-scope fix can be found at the corresponding CSS page.
         //a.style.verticalAlign = 'top'; // absolutely required for the image.
         a.style.textDecoration = 'blink'; // another alternative

         // 2) replace it with whatever I want.  ** Note: Uncomment one of the following, or roll your own. **
         // 2.1) Image
         //a.innerHTML = '<span style="padding: 0; margin: 0;"><a href="/wiki/Wikipedia:Cite_sources" title="Citation needed"><img src="http://upload.wikimedia.org/wikipedia/en/4/4a/Citation_needed.gif" alt="Citation needed" width="38" height="11" border="0"/></a></span>';
         // 2.2) Shorter text
         a.innerHTML = '[<a href="/wiki/Wikipedia:Cite_sources" title="Citation needed">CITE</a>]';
      }
   }
}
addOnloadHook(MyCitation);
/* 

*/