User:Lupo/monobook.js

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari/Konqueror: hold down Shift while clicking Reload (or press Ctrl-Shift-R), IE: press Ctrl-F5, Opera: press F5.

var months = new Array ("January", "February", "March", "April", "May", "June",
                        "July", "August", "September", "October", "November", "December");
var today  = new Date ();

/*------------------------------------------------------------------------------------------
  General functions: creating links
  ------------------------------------------------------------------------------------------*/

function makerawlink(name, url)
{
  /* Creates a link pointing to "url", displaying "name" */
  var link = document.createElement('a');
  link.setAttribute('href', url);  
  link.appendChild(document.createTextNode(name));
  return link;
}

function makewikilink (name, url)
{
  return makerawlink (name, '/wiki/' + url);
}

function makeactivelink (name, script)
{
  var link = makerawlink (name, '#');
  link.setAttribute('onclick', 'javascript:' + script);
  return link;
}

/*------------------------------------------------------------------------------------------
  Edit lead section link
  ------------------------------------------------------------------------------------------*/

function getElementsByClassName (class_name)
{
  /* Returns an array of all elements having the class "class_name". This simplified version
     works only for single classes. If the length of the returned array is zero, no such
     elements were found. */
  var all_obj;
  var result=new Array();
  var j = 0;

  if (document.all)   /* For IE */
     all_obj=document.all;
  else if (document.getElementsByTagName && !document.all) /* For Mozilla/Firefox */
    all_obj=document.getElementsByTagName ("*");
  for (i = 0; i < all_obj.length; i++)
  {
    if (all_obj[i].className == class_name)
    {
      result[j] = all_obj[i]; j++;
    }
  }
  return result;
} 

function addLeadSectionTab () {
  /* Only add new tab if the page is editable and has section editing links. */
  if (getElementsByClassName('editsection').length > 0) {
    var edit_tab = document.getElementById ('ca-edit');
    if (edit_tab != null) {
      var href_for_lead = edit_tab.firstChild.getAttribute ('href') + "&section=0";
      var first_title   = getElementsByClassName ('firstHeading');
      if (first_title.length > 0) {
        /* We have a "firstHeading": put "[edit]" to its right */
        var edit_div = document.createElement ('div');
        edit_div.setAttribute ('class', 'editsection');
        edit_div.setAttribute ('style', 'float:right;margin-left:5px;');
        edit_div.appendChild (document.createTextNode ('['));
        edit_div.appendChild (makerawlink ("edit", href_for_lead));
        edit_div.appendChild (document.createTextNode (']'));
        first_title[0].parentNode.insertBefore (edit_div, first_title[0]);
      } else {
        /* No first title found: create a tab */                                   
        var new_tab = document.createElement ('li');
        new_tab.id = 'ca-editlead';
        var link = makerawlink ("Edit lead", href_for_lead);
        new_tab.appendChild (link);
      
        edit_tab.parentNode.appendChild (new_tab);
      }
    }
  }
}

function setLeadSectionEditSummary ()
{
  /* The edit summary is set to "Lead section" if we're editing only the lead section of
     an article. This is the case iff the URL of the document ends in "&section=0". */

  if ((document.location.href.indexOf ("&section=0") + 10 == document.location.href.length) &&
      (document.editform != null) &&
      (document.editform.wpSummary != null))
  {
     document.editform.wpSummary.value = "/* Lead section */ ";
  }
}

/*------------------------------------------------------------------------------------------
  Add block tabs. Useful only for admins. Inspired by [[User:Korath/blockip.js]].
  ------------------------------------------------------------------------------------------*/

function get_escaped_username ()
{
  var edit_tab = document.getElementById ('ca-edit');

  if (edit_tab == null) return "";
  var edit_lk = edit_tab.firstChild.getAttribute ('href');
  /* Extract the part between "title=" up to "&action=edit" */
  edit_lk = edit_lk.substring (edit_lk.indexOf ("title=") + 6);
  var idx = edit_lk.indexOf ("&")
  if (idx >= 0) edit_lk = edit_lk.substring (0, idx);
  /* Discard "User:" or "User talk:" */
  idx = edit_lk.indexOf (":");
  if (idx >= 0) edit_lk = edit_lk.substring (idx+1);
  /* If we're on a subpage, take only the part before the first slash. */
  idx = edit_lk.indexOf ("/");
  if (idx >= 0) edit_lk = edit_lk.substring (0, idx);
  return edit_lk;
}

function get_escaped_username_special ()
{
  /* Two possibilities: "Special:Contributions/X" or "Special:Contributions&target=X" */
  var edit_lk = document.location.href;
  /* Extract the part after "Special:Contributions" */
  edit_lk = edit_lk.substring (edit_lk.indexOf ("Special:Contributions") + 21);
  var idx = edit_lk.indexOf ("&target=");
  if (idx >= 0) {
    /* Second form */
    edit_lk = edit_lk.substring (idx + 8);
  } else {
    idx = edit_lk.indexOf ("/");
    if (idx >= 0) edit_lk = edit_lk.substring (idx + 1);
  }
  /* Discard anything that might follow. */
  var idx = edit_lk.indexOf ("&")
  if (idx >= 0) edit_lk = edit_lk.substring (0, idx);
  return edit_lk;
}

function do_block_tab (a_tab, escaped_username)
{
  if (a_tab == null) return;
  var href = "/w/index.php?title=Special%3ABlockip&ip=" + escaped_username;

  var new_tab = document.createElement ('li');
  new_tab.id = 'ca-block';
  new_tab.appendChild (makerawlink ("Block", href));

  a_tab.parentNode.appendChild (new_tab);
}

function do_blocklog_tab (a_tab, escaped_username)
{
  if (a_tab == null) return;
  var href = "/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A" + escaped_username;

  var new_tab = document.createElement ('li');
  new_tab.id = 'ca-blocklog';
  new_tab.appendChild (makerawlink ("Block log", href));

  a_tab.parentNode.appendChild (new_tab);
}

function add_inline_log (escaped_username)
{
  /* Hmmm... doesn't work. For some reason, the href is not loaded into the iframe, but on top
     of the whole page. Also, sizing the iframe doesn't seem to work. Call is commented out
     below. */
  var href = "/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A" + escaped_username;
  var iframe = document.createElement ('iframe');

  iframe.setAttribute ('src', href);
  iframe.setAttribute ('frameborder', "0");
  iframe.style.width  = 100+"%";
  iframe.style.height = 400+"px";
  var form = document.getElementById ('blockip');
  if (form == null || form.nextSibling == null) return;
  
  form.parentNode.insertBefore (iframe, form.nextSibling);
}

function addBlockTabs ()
{
  if (document.getElementById ('ca-nstab-user') != null) {
    /* If there is a "user page" tab, we are on a user page, user talk page, subpage thereof, or
       editing one of these pages. */
    var escaped_username = get_escaped_username ();
    var a_tab = document.getElementById ('ca-edit');
    do_block_tab (a_tab, escaped_username);
    do_blocklog_tab (a_tab, escaped_username);
  } else if (document.title.indexOf ("User contributions") == 0) {
    var escaped_username = get_escaped_username_special ();
    var a_tab = document.getElementById ('ca-article');
    do_block_tab (a_tab, escaped_username);
    do_blocklog_tab (a_tab, escaped_username);
  } else if (document.title.indexOf ("Block user") == 0) {
    var form = document.getElementsByName('wpBlockAddress');
    if (form != null && form[0] != null) {
      /* If the form is null, we're on the result page after a user has been blocked! */
      do_blocklog_tab (document.getElementById ('ca-article'),
                       escape (form[0].value));
      /* add_inline_log (escape (form[0].value)); */
    }
  }
}

/*------------------------------------------------------------------------------------------
  Personal toolbox
  ------------------------------------------------------------------------------------------*/

function myPortlet() {
  /* Put together a new portlet and insert it at the top of the left column. */
  /* Note: \xa0 is &nbsp; and \xa9 is &copy; */
  var newportlet = document.createElement('div');
  var content    = document.createElement('div');
  
  newportlet.setAttribute('class', 'portlet');
  newportlet.setAttribute('id', 'p-lupo-links');
  content.setAttribute('class', 'pBody');
  
  content.appendChild
    (makerawlink('Mailing list (en)',
                 'http://mail.wikipedia.org/pipermail/wikien-l/' +
                 (1900 + today.getYear ()) + '-' + months[today.getMonth()] + '/thread.html#end'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('msgs', 'Special:Allmessages'));
  content.appendChild (document.createElement('br'));

  content.appendChild (document.createTextNode('Logs: '));
  content.appendChild (makewikilink ('P', 'Special:Log/protect'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('B', 'Special:Log/block'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('D', 'Special:Log/delete'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('U', 'Special:Log/upload'));
  content.appendChild (document.createElement('br'));

  content.appendChild
    (makewikilink
       ('VfD', 
        "Wikipedia:Votes_for_deletion/Log/" + 
        (1900 + today.getYear ()) + '_' +
        months[today.getMonth ()] + '_' +
        today.getDate ()));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('IFD', 'WP:IFD'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('AN', 'WP:AN'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('CPM', 'Wikipedia:How_to_fix_cut_and_paste_moves'));
  content.appendChild (document.createElement('br'));

  content.appendChild (makewikilink ('news', 'WP:GO'));
  content.appendChild (document.createTextNode('\xa0'));
  content.appendChild (makewikilink ('paper', 'Wikipedia:Wikipedia_Signpost'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('FA', 'WP:FAC'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('HD', 'WP:HD'));
  content.appendChild (document.createTextNode('\xa0'));
  content.appendChild (makewikilink ('RD', 'WP:RD'));
  content.appendChild (document.createElement('br'));

  content.appendChild (makewikilink ('\xa9vios', 'WP:CP'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('\xa9tags', 'Wikipedia:Image_copyright_tags'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild (makewikilink ('Kudos', 'Wikipedia:Great_editing_in_progress'));
  content.appendChild (document.createElement('hr'));
  
  content.appendChild
    (makeactivelink ('\xa9vio',
"document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\\n\\n\{\{subst:User:Lupo/Do_not_copyvio\}\} \~\~\~\~\'; document.editform.wpSummary.value = \'Do not copyvio, please\'; document.editform.wpTextbox1.focus();"));
  content.appendChild (document.createTextNode('\xa0'));
  content.appendChild
    (makeactivelink ('src',
"document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\\n\\n\{\{User:Lupo/Img Src|img=[[:]]\}\} \~\~\~\~'; document.editform.wpSummary.value = document.editform.wpSummary.value + 'Info on image, please'; document.editform.wpTextbox1.focus();"))
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild
    (makeactivelink ('t',
"document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\\n\\n\{\{subst:test\}\} \~\~\~\~'; document.editform.wpSummary.value = 'your test'; document.editform.submit ();"));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild
    (makeactivelink ('n',
"document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\\n\\n\{\{subst:test2\}\} \~\~\~\~'; document.editform.wpSummary.value = 'do not post nonsense, please'; document.editform.submit ();"));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild
    (makeactivelink ('v',
"document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\\n\\nDo not [[Wikipedia:Vandalism|vandalize]] or you will be prevented from editing. \~\~\~\~'; document.editform.wpSummary.value = 'stop vandalizing'; document.editform.submit ();"));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild
    (makeactivelink ('red',
"document.editform.wpTextbox1.value = '#REDIRECT [[]]'; document.editform.wpSummary.value = 'redir'; document.editform.wpMinoredit.checked=1; document.editform.wpTextbox1.focus();"));
  content.appendChild (document.createTextNode('\xa0'));
  content.appendChild
    (makeactivelink ('hi',
"document.editform.wpTextbox1.value = document.editform.wpTextbox1.value + '\\n\\n\{\{subst:User:Lupo/Welcome\}\} \~\~\~\~'; document.editform.wpSummary.value = 'Welcome '; document.editform.wpTextbox1.focus();"));
  content.appendChild (document.createElement('hr'));

  content.appendChild (makewikilink ('rechts', 'User:Lupo/rechts'));
  content.appendChild (document.createTextNode('\xa0'));
  content.appendChild
    (makerawlink ('(edit)', '/w/wiki.phtml?title=User:Lupo/rechts&action=edit'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild
    (makerawlink ('css', '/w/wiki.phtml?title=User:Lupo/monobook.css&action=edit'));
  content.appendChild (document.createTextNode('\xa0|\xa0'));
  content.appendChild
    (makerawlink ('js', '/w/wiki.phtml?title=User:Lupo/monobook.js&action=edit'));
  
  var title=document.createElement('h5');
  title.setAttribute ('style', 'text-transform: none;');
  title.appendChild
   (document.createTextNode
     (months[today.getMonth ()] + ' ' +
      today.getDate () + ', ' +
      (1900 + today.getYear ())));
  newportlet.appendChild(title);
  newportlet.appendChild(content);
  
  /* Insert the newly created portlet in the left column. */
  var leftcolumn = document.getElementById ('column-one');
  
  leftcolumn.insertBefore (newportlet, leftcolumn.firstChild);
}

/*------------------------------------------------------------------------------------------
  Other customizations: interwikis to top, bottom tabs
  ------------------------------------------------------------------------------------------*/

function languageAtTop () {
  /* Take the #p-lang (if there is one) out of the .portlet sidebar and put it
     physically into the main column. */
  var contents  = document.getElementById('column-content');
  var langlinks = document.getElementById('p-lang');

  if (langlinks != null) {
    langlinks.parentNode.removeChild (langlinks);
    contents.insertBefore(langlinks, contents.firstChild);
  }
}

function bottomTabs() {
  /* Duplicate the top "tabs" at the end of the content area. */
  var tabs = document.getElementById('p-cactions').cloneNode(true);
  /* Give all the named items new ids to avoid id clashes with the existing top "tabs". */
  tabs.id = 'mytabs';
  var listitems = tabs.getElementsByTagName('LI');
  for (i=0;i<listitems.length;i++) {
    if(listitems[i].id) listitems[i].id = 'mytabs-' + listitems[i].id;
  }
  document.getElementById('column-content').appendChild(tabs);
}

function topTabsToRightPlace() {
  /* Remove the top "tabs" from the .portlet side column (why were they ever put there?) and
     put them at the top of the content area, where they belong! (This allows me to use simple
     relative positioning to get a proper layout. I don't have to mess around with absolute
     positioning. This is necessary for my language links at the top to work properly, but it
     is cleaner anyway. */
  var contents  = document.getElementById('column-content');
  var tabs      = document.getElementById('p-cactions');

  tabs.parentNode.removeChild (tabs);
  contents.insertBefore(tabs, contents.firstChild);
}

function rmLogo() {
  /* Physically remove the logo. My CSS doesn't display it anyway, but I don't know whether
     that is sufficient to prevent the browser loading it. */
  var logo = document.getElementById('p-logo');

  logo.parentNode.removeChild (logo);
}

function reformatMyPage() {
  rmLogo();
  addLeadSectionTab();
  setLeadSectionEditSummary();
  addBlockTabs();
  myPortlet();
  bottomTabs();
  topTabsToRightPlace();  /* First the top "tabs"... */
  languageAtTop();        /* ... and then the language links */
  /* The order is important here: first move the tabs, then the language links, otherwise they
     will end up in the wrong order (tabs above language links). */
}

if (window.addEventListener) window.addEventListener("load",reformatMyPage,false);
else if (window.attachEvent) window.attachEvent("onload",reformatMyPage);
Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools