MediaWiki:Common.js/Main Page

From Wikinews, the free news source you can write!
Jump to: navigation, search

/*extern addOnloadHook wgUserGroups*/

/*

  1. This is the javascript that is executed only when viewing the [[Main Page]].
    
  2.  
    
  3. */
    
  4.  
    
  5. /* add class for autoconfirmed users, so [edit lead] only appears to those who can edit them */ 
    
  6. addOnloadHook(function() {
    
  7. if (!wgUserGroups || wgUserGroups.join('').indexOf('autoconfirmed') === -1) {
    
  8.     try {
    
  9.     document.body.className += " notAutoconfirmed";
    
  10.     } catch (e) {}
    
  11. }
    
  12. });
    
  13.  
    
  14. /*
    
  15. function dieWhitespaceDie () {
    
  16.  try {
    
  17.  //this is for us low res folks
    
  18.  //hides some of the members of the dpl list on main page, if list too long.
    
  19.  //this is not cross browser (yet). IE uses different method names for height
    
  20.  if (wgPageName !== "Main_Page" || wgAction !== "view") {return;}
    
  21.  var firstLead = document.getElementById('mf-l_table_numb4'); //switch to last after height:100% hack.
    
  22.  var excessWS = (firstLead.parentNode.clientHeight - firstLead.clientHeight);
    
  23.  var DPLList = document.getElementById('MainPage_latest_news_text').getElementsByTagName('ul')[0];
    
  24.  var DPL = DPLList.getElementsByTagName('li');
    
  25.  var DPLlength = DPL.length;
    
  26.  //10 is just emergancy cut off. should stop way before that.
    
  27.  if (DPLlength < 10) {throw new Error("Latest news should have more items...");}
    
  28.  var curItem, prev = -1;
    
  29.  for (var i = 1; i < 10;i++) { //note, start at 1.
    
  30.   curItem = DPL[DPLlength - i];
    
  31.   prev = excessWS;
    
  32.   excessWS -= curItem.clientHeight;
    
  33.   if (excessWS < 5 || prev === excessWS)  { break;}
    
  34.   DPLList.removeChild(curItem); //this should perhaps use a range, so only a single re-draw.
    
  35.   if (prev === (firstLead.parentNode.clientHeight - firstLead.clientHeight)) {break;}
    
  36.  }
    
  37.  } catch (e) {}
    
  38.  
    
  39. }
    
  40. addOnloadHook(dieWhitespaceDie);
    
  41. */
    
  42. /*
    

*/