Bruger:Wegge/monobook.js

Fra Wikipedia, den frie encyklopædi
/*
* Category intersection.
*/

/* addOnloadHook ( add_category_intersection ) ; */

ci_list = Array() ;

function add_category_intersection () {
  if ( wgNamespaceNumber != 0 ) return ;
  catlinks = document.getElementById('catlinks') ;
  links = catlinks.getElementsByTagName('a');
  catname = "Kategori:" ;
  for ( i = 0 ; i < links.length ; i++ ) {
    t = links[i].title ;
    if ( t.substr ( 0 , catname.length ) != catname ) continue ;
    ci_list.push ( t.substr ( catname.length ) ) ;
  }
  if ( ci_list.length < 2 ) return ;
  
  a = document.createElement ( 'a' ) ;
  a.href = '#' ;
  a.onclick = category_intersection_show ;
  a.appendChild ( document.createTextNode ( 'Other articles in these categories' ) ) ;
  catlinks.appendChild ( a ) ;
}

function category_intersection_show () {
  d = document.getElementById('category_intersection_div') ;
  if ( d ) return false ;

  d = document.createElement ( 'div' ) ;
  d.id = 'category_intersection_div' ;
  d.style.border = '2px solid black' ;
  d.style.background = 'white' ;
  d.style.margin = '5px' ;
  d.style.padding = '5px' ;
  d.style.position = 'relative' ;
  d.style.zindex = 99 ;
  d.style.left = '200px' ;

  n = ci_list.length * 9 + 20 ;
  d.style.top = '-' + n + 'px' ;

  h = document.createElement ( 'h2' ) ;
  h.appendChild ( document.createTextNode ( 'Category intersection' ) ) ;
  d.appendChild ( h ) ;

  t = "" ;
  for ( i = 0 ; i < ci_list.length ; i++ ) {
    cb = document.createElement ( 'input' ) ;
    cb.type = 'checkbox' ;
    cb.name = ci_list[i] ;
    cb.value = 1 ;
    cb.checked = 1 ;
    d.appendChild ( cb ) ;
    d.appendChild ( document.createTextNode ( ci_list[i] ) ) ;
    d.appendChild ( document.createElement ( 'br' ) ) ;
  }

  x = document.createElement ( 'input' ) ;
  x.type = 'button' ;
  x.value = 'Show articles in the above category intersection' ;
  x.onclick = category_intersection_action ;
  x.style.margin_right = '50px' ;
  x.style.marginright = '50px' ;
  d.appendChild ( x ) ;

  x = document.createElement ( 'input' ) ;
  x.type = 'button' ;
  x.value = 'Cancel' ;
  x.onclick = category_intersection_cancel ;
  d.appendChild ( x ) ;

  catlinks = document.getElementById('catlinks') ;
  catlinks.appendChild ( d ) ;
  return false ;
}

function category_intersection_action () {
  d = document.getElementById('category_intersection_div') ;
  cbs = d.getElementsByTagName('input') ;
  call = Array() ;
  for ( i = 0 ; i < cbs.length ; i++ ) {
    if ( cbs[i].type != 'checkbox' ) continue ;
    if ( !cbs[i].checked ) continue ;
    call.push ( cbs[i].name.split(' ').join('_') ) ;
  }
  call = call.join("|") ;
  url = 'http://toolserver.org/~magnus/category_intersection.php?language=da&project=wikipedia&doit=1&namespace=0&categories=' + call ;
  window.location = url ;
}

function category_intersection_cancel () {
  d = document.getElementById('category_intersection_div') ;
  d.parentNode.removeChild ( d ) ;
}


/*
== User-popups ==
*/

// [[User:Lupin/popups.js]] - please include this line 
 
document.write('<script type="text/javascript" src="' 
             + 'ht' + 'tp://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
popupDelay=2.0;
//simplePopups=true;
popupAdminLinks=true;


// install [[User:Cacycle/wikEd]] in-browser text editor

document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/*
==Navigation tabs i bunden af siden.==
*/
 
function morelinks() {
   var tabs = document.getElementById('p-cactions').cloneNode(true);
   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);
}
if (window.addEventListener) window.addEventListener("load",morelinks,false);
else if (window.attachEvent) window.attachEvent("onload",morelinks);


// Velkomstskabeloner Bruger:Morten_LJ (inkluder venligst denne linie)
document.write('<script type="text/javascript" src="' 
    + 'http://da.wikipedia.org/w/index.php?title=User:Morten_LJ/velkomst.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');