User:Zyephyrus/acai.js

/** * Catégories à Gauche * * Met les catégories dans un panneau de navigation * * Auteur : Jmfayard * Dernière révision : 3 novembre 2006 * */ function CategoriesAGauche { var catlinks = document.getElementById("catlinks"); if (!catlinks) { return; } var categories = catlinks.getElementsByTagName("a") ; var h5_cats = document.createElement( "h5" ); var text = document.createTextNode( " " ) ; h5_cats.appendChild( text ) ; var div_cats = document.createElement( "div" ); div_cats.setAttribute( "class", "pBody" ); var ul = document.createElement( "ul" ); var a_debut = 1 ; // evitons le lien Categories: for (var i = a_debut ; i < categories.length ; i++ ) { var a = categories[i] ; var li = document.createElement( "li" ) ; li.appendChild( a.cloneNode(1) ) ; ul.appendChild( li ); }       div_cats.appendChild( ul ) ; var portlet = document.createElement( "div" ) ; portlet.setAttribute( "class", "portlet" ); portlet.setAttribute( "id", "p-cat" ) ; portlet.appendChild( h5_cats ) ; portlet.appendChild( div_cats ) ; //document.getElementById("column-one").insertBefore( document.getElementById("p-search"), portlet ) ; //document.getElementById("column-one").appendChild( portlet ) ; div_ptb = document.getElementById( "p-Lire" ); document.getElementById("column-one").insertBefore( portlet, div_ptb) } addOnloadHook( CategoriesAGauche ) ;

/** * Menu de Gauche * * Rajoute des liens * * Auteur : FredB. */

function nouvelleBoite { var l = document.getElementById('column-one'); if (!l) return; l.innerHTML = l.innerHTML + ' '    + ' '     + '   ' + '    Bac 10' + '    ThomasBot’ + '    Bots' + '    Gallica</li>' + '    <li><a href="http://books.google.com">Google Books</a></li>' + '    <li><a href="http://www.archive.org/details/texts">Internet Archive</a></li>' + '    <li><a href="http://vs.aka-online.de/cgi-bin/wppagehiststat.pl">Page stats</a></li>' + '    <li><a href="http://classiques.uqac.ca/classiques/">Classiques</a></li>' + '  </ul>' + ' '    + ' ';  }  addOnloadHook(nouvelleBoite);

// helper functions // works in FF and Opera, definitely not in IE, other not tested // browser has to support XPath var $ = function(id) { return document.getElementById(id); }; var $$ = function(css) { return $x('//*[contains(@class,"'+css+'")]'); }; var $x = function(exp, node) { node = node || document; var r = document.evaluate(exp, node, null, 0, null); switch (r.resultType) { case 1: return r.numberValue; case 2: return r.stringValue; case 3: return r.booleanValue; case 4: { var a = []; while(i = r.iterateNext) a.push(i); return a;		} } }; // use other format for Special:IndexPages, only hard nurmbers // only start, have to check something if (wgCanonicalSpecialPageName == 'IndexPages') { addOnloadHook(function {		// where to get the data and the array itself		var where = $x('//ol[@class="special"]')[0];		var data = new Array;		// data is stored in the td-tags, first 3 are shit, extract data to data array		var tds = $x('//td', where);		for (var i = 0; ((i+1)*9)+3 <= tds.length; i++) {			var n = (i*9)+3;			data[i] = new Array(8);			data[i].href = tds[n].firstChild.href;			data[i].name = tds[n].firstChild.innerHTML;			data[i].pages = parseInt(/(\d+)/.exec(tds[n+1].innerHTML));			data[i].q4 = (tds[n+4].width ? parseInt(tds[n+4].width) : 0);			data[i].q3 = (tds[n+5].width ? parseInt(tds[n+5].width) : 0);			data[i].q2 = (tds[n+6].width ? parseInt(tds[n+6].width) : 0);			data[i].q1 = (tds[n+7].width ? parseInt(tds[n+7].width) : 0);			data[i].q0 = (tds[n+8].width ? parseInt(tds[n+8].width) : 0);		};		// delete list and create own		where.innerHTML = '';		var table = document.createElement('table');		table.setAttribute('style','background-color:transparent; width:100%;');		var tr = new Array;		var th = new Array(9);		var text = ['Livre','Pages','NA','-','Pb','1','2','3','Total']		tr[0] = document.createElement('tr');		for (i in text) {			th[i] = document.createElement('th');			th[i].innerHTML = text[i];			tr[0].appendChild(th[i]);		}		tr[0].setAttribute('style','text-align:left;');		for (var i = 0; i < data.length; i++) {			tr[i+1] = document.createElement('tr');			var td = new Array(9);			for (var j = 0; j < 9; j++) { td[j] = document.createElement('td'); }			var a = document.createElement('a');			a.innerHTML = data[i].name;			a.href = data[i].href;			td[0].appendChild(a);			td[0].setAttribute('style','font-weight:bold;');			td[1].innerHTML = data[i].pages; td[2].innerHTML = data[i].pages - data[i].q0 - data[i].q1 - data[i].q2 - data[i].q3 - data[i].q4; td[3].innerHTML = data[i].q0; td[3].setAttribute('class','quality0'); td[4].innerHTML = data[i].q2; td[4].setAttribute('class','quality2'); td[5].innerHTML = data[i].q1; td[5].setAttribute('class','quality1'); td[6].innerHTML = data[i].q3; td[6].setAttribute('class','quality3'); td[7].innerHTML = data[i].q4; td[7].setAttribute('class','quality4'); td[8].innerHTML = Math.round((data[i].q1 + (data[i].q3 * 2) + (data[i].q4 * 3)) * 100 / (data[i].pages * 3)) +'%'; td[8].setAttribute('style','font-weight:bold;'); for (var j = 0; j < 9; j++) { tr[i+1].appendChild(td[j]); } }		for (var i = 0; i < tr.length; i++) { table.appendChild(tr[i]); } where.appendChild(table); }); };