« Utilisateur:Dr Bot/wikimini.js » : différence entre les versions
Jump to navigation
Jump to search
(Page créée avec « //__NORICHEDITOR__ // Pas de WYGSYG sur ma page Javascript function WhosOnlineNewPage(){ //var ListePresents = document.getElementById('WhosOnlineList'); v… ») |
Aucun résumé des modifications |
||
| Ligne 1 : | Ligne 1 : | ||
//__NORICHEDITOR__ // Pas de WYGSYG sur ma page Javascript |
//__NORICHEDITOR__ // Pas de WYGSYG sur ma page Javascript |
||
/////////////////////////////////////////////////////////////////////// Fonctions utiles |
|||
/////////////////////////////////////////////////////////////////// |
|||
function insertAfter(parent, node, referenceNode) { |
|||
parent.insertBefore(node, referenceNode.nextSibling); |
|||
} |
|||
function hasClass(node, className) { |
|||
if (node.className == className) { |
|||
return true; |
|||
} |
|||
var reg = new RegExp('(^| )'+ className +'($| )') |
|||
if (reg.test(node.className)) { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
function addClass(node, className) { |
|||
if (hasClass(node, className)) { |
|||
return false; |
|||
} |
|||
node.className += ' '+ className; |
|||
return true; |
|||
} |
|||
function removeClass(node, className) { |
|||
if (!hasClass(node, className)) { |
|||
return false; |
|||
} |
|||
node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className); |
|||
return true; |
|||
} |
|||
function eregReplace(search, replace, subject) { |
|||
return subject.replace(new RegExp(search,'g'), replace); |
|||
} |
|||
function get_nextsibling(n){ |
|||
x=n.nextSibling; |
|||
if(x==null) return false; |
|||
while (x.nodeType!=1) { |
|||
x=x.nextSibling; |
|||
if(x==null) return false; |
|||
} |
|||
return x; |
|||
} |
|||
function get_previoussibling(n){ |
|||
x=n.previousSibling; |
|||
if(x==null) return false; |
|||
while (x.nodeType!=1) { |
|||
x=x.previousSibling; |
|||
if(x==null) return false; |
|||
} |
|||
return x; |
|||
} |
|||
function getTextContent(oNode) { |
|||
if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;} |
|||
switch (oNode.nodeType) { |
|||
case 3: // TEXT_NODE |
|||
case 4: // CDATA_SECTION_NODE |
|||
return oNode.nodeValue; |
|||
break; |
|||
case 7: // PROCESSING_INSTRUCTION_NODE |
|||
case 8: // COMMENT_NODE |
|||
if (getTextContent.caller!=getTextContent) { |
|||
return oNode.nodeValue; |
|||
} |
|||
break; |
|||
case 9: // DOCUMENT_NODE |
|||
case 10: // DOCUMENT_TYPE_NODE |
|||
case 12: // NOTATION_NODE |
|||
return null; |
|||
break; |
|||
} |
|||
var _textContent = ""; |
|||
oNode = oNode.firstChild; |
|||
while (oNode) { |
|||
_textContent += getTextContent(oNode); |
|||
oNode = oNode.nextSibling; |
|||
} |
|||
return _textContent; |
|||
} |
|||
function setCookie (cookieName, cookieValue, expires, path) { |
|||
document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; EXPIRES=' + expires.toGMTString() : '') + "; PATH=/" ; |
|||
} |
|||
function getCookie(cookieName) { |
|||
var cookieValue = null; |
|||
var posName = document.cookie.indexOf(escape(cookieName) + '=' ); |
|||
if (posName != -1) { |
|||
var posValue = posName + (escape(cookieName) + '=' ).length; |
|||
var endPos = document.cookie.indexOf(';', posValue) ; |
|||
if (endPos != -1) { |
|||
cookieValue = unescape(document.cookie.substring(posValue, endPos)); |
|||
} else { |
|||
cookieValue = unescape(document.cookie.substring(posValue)); |
|||
} |
|||
} |
|||
return decodeURIComponent(cookieValue); |
|||
} |
|||
/////////////////////////////////////////////////////////////////////// Modification de l'apparence du skin wikimini (inutile avec la redirection monobook) |
|||
/////////////////////////////////////////////////////////////////////// |
|||
addOnloadHook (function(){ |
|||
// ################## GÉNÉRAL ################## |
|||
// --------- Largeur = 100% au lieu de 800px ------------------- |
|||
var mainDiv = document.getElementById('main'); |
|||
mainDiv.style.width = '100%'; |
|||
// --------- Suppression de l'objet flash (trop gros, trop moche...) ------------------- |
|||
var flashDiv = document.getElementById('header'); |
|||
flashDiv.style.display = 'none'; |
|||
// --------- Déplacement des liens personnels en haut de page ------------------- |
|||
var AllH5 = document.getElementsByTagName('h5'); |
|||
for(a=0;a<AllH5.length;a++){ |
|||
if(AllH5[a].innerHTML.indexOf('Outils personnels')!=-1){ |
|||
var TitrePerso = AllH5[a]; |
|||
var IconePerso = get_previoussibling(TitrePerso); |
|||
var LiensPerso = get_nextsibling(TitrePerso); |
|||
LiensPerso.parentNode.removeChild ( LiensPerso ) ; |
|||
document.body.insertBefore(LiensPerso, document.body.firstChild); |
|||
LiensPerso.style.marginLeft = '3em'; |
|||
var LiensPersoDiv = LiensPerso.getElementsByTagName('div'); |
|||
for(b=0;b<LiensPersoDiv.length;b++){ |
|||
LiensPersoDiv[b].style.padding = '0'; |
|||
LiensPersoDiv[b].style.margin = '0'; |
|||
} |
|||
TitrePerso.parentNode.removeChild ( TitrePerso ) ; |
|||
LiensPerso.insertBefore(TitrePerso , LiensPerso.firstChild); |
|||
TitrePerso.style.padding = '0'; |
|||
TitrePerso.style.margin = '0'; |
|||
TitrePerso.style.marginLeft = '3em'; |
|||
IconePerso.parentNode.removeChild ( IconePerso ) ; |
|||
LiensPerso.insertBefore(IconePerso, LiensPerso.firstChild); |
|||
IconePerso.style.padding = '0'; |
|||
IconePerso.style.margin = '0'; |
|||
IconePerso.style.marginLeft = '2em'; |
|||
} |
|||
} |
|||
// ################## COLONNES ################## |
|||
var AllDiv = document.getElementsByTagName('Div'); |
|||
for(a=0;a<AllDiv.length;a++){ |
|||
if(hasClass(AllDiv[a], 'columns')){ |
|||
var Colonnes = AllDiv[a] |
|||
}else if(hasClass(AllDiv[a], 'column1')){ |
|||
var Colonne1 = AllDiv[a] |
|||
}else if(hasClass(AllDiv[a], 'column2')){ |
|||
var Colonne2 = AllDiv[a] |
|||
} |
|||
} |
|||
// --------- Largeur colonne de droite réduite ------------------- |
|||
Colonne1.style.width = '80%'; |
|||
Colonne2.style.width = '20%'; |
|||
// --------- Zone de recherche en haut de la colonne de droite ------------------- |
|||
var Recherche = document.getElementById('p-search'); |
|||
if(Recherche){ |
|||
Recherche.parentNode.removeChild ( Recherche ) ; |
|||
Colonne2.insertBefore(Recherche , Colonne2.firstChild); |
|||
} |
|||
// --------- Suppression de l'image dans la boîte à outils ------------------- |
|||
var Outils = document.getElementById('p-tb'); |
|||
if(Outils){ |
|||
var Image = Outils.getElementsByTagName('img')[1]; |
|||
Image.style.display = 'none'; |
|||
} |
|||
// ################## ÉDITION ################## |
|||
if(((wgAction=="edit")||(wgAction=="submit"))&&(wgNamespaceNumber>=0)){ |
|||
// --------- Taille zone d'édition ------------------- |
|||
var EditBox = document.getElementById('wpTextbox1'); |
|||
if(EditBox){ |
|||
Colonne1.style.width = '100%'; |
|||
Colonne2.style.display = 'none'; |
|||
EditBox.rows = 50; |
|||
// --------- Ajout toolbar si elle n'y est pas ------------------- |
|||
var toolbar = document.getElementById('toolbar'); |
|||
if(!toolbar){ |
|||
toolbar = document.createElement('div'); |
|||
toolbar.id = 'toolbar'; |
|||
EditBox.parentNode.insertBefore(toolbar, EditBox); |
|||
} |
|||
// --------- Affiche les boutons de publication cachés ------------------- |
|||
var EditOptionsElements = document.getElementById('wpSummaryLabel'); |
|||
while(get_nextsibling(EditOptionsElements)){ |
|||
EditOptionsElements.style.display = 'inline'; |
|||
EditOptionsElements = get_nextsibling(EditOptionsElements); |
|||
} |
|||
var wpSave= document.getElementById('wpSave'); |
|||
wpSave.style.marginLeft = '75px'; |
|||
var wpDiff = document.getElementById('wpDiff'); |
|||
wpDiff.style.display = 'inline'; |
|||
wpDiff.style.margin = '0.5em'; |
|||
// --------- Page modifiée automatiquement suivie ------------------- |
|||
var SuiviModif = document.getElementById('wpWatchthis'); |
|||
SuiviModif.checked = 'checked'; |
|||
} |
|||
} |
|||
}); |
|||
function WhosOnlineNewPage(){ |
function WhosOnlineNewPage(){ |
||
| Ligne 21 : | Ligne 240 : | ||
var Liens = ListePresents.getElementsByTagName('a'); |
var Liens = ListePresents.getElementsByTagName('a'); |
||
for(a=0;a<Liens.length;a++){ |
for(a=0;a<Liens.length;a++){ |
||
var LienHref = Liens[a].href; |
|||
LienHref = LienHref.split(wgServer).join('').split('/wiki/').join(''); |
|||
var A = sajax_init_object(); |
|||
A.open('GET', wgServer+'/w/api.php?action=query&format=xml&redirects&titles='+LienHref, true); |
|||
A.send(null); |
|||
A.onreadystatechange = function(e){ |
|||
if (!e) var e = window.event; |
|||
if (this.readyState == 4){ |
|||
if (this.status == 200){ |
|||
var docXML = this.responseXML; |
|||
if (docXML.getElementsByTagName('page')[0].getAttribute('missing') == ''){ |
|||
Liens[a].className="new"; |
Liens[a].className="new"; |
||
} |
} |
||
Version du 13 janvier 2010 à 00:11
//__NORICHEDITOR__ // Pas de WYGSYG sur ma page Javascript
/////////////////////////////////////////////////////////////////////// Fonctions utiles
///////////////////////////////////////////////////////////////////
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}
function hasClass(node, className) {
if (node.className == className) {
return true;
}
var reg = new RegExp('(^| )'+ className +'($| )')
if (reg.test(node.className)) {
return true;
}
return false;
}
function addClass(node, className) {
if (hasClass(node, className)) {
return false;
}
node.className += ' '+ className;
return true;
}
function removeClass(node, className) {
if (!hasClass(node, className)) {
return false;
}
node.className = eregReplace('(^|\\s+)'+ className +'($|\\s+)', ' ', node.className);
return true;
}
function eregReplace(search, replace, subject) {
return subject.replace(new RegExp(search,'g'), replace);
}
function get_nextsibling(n){
x=n.nextSibling;
if(x==null) return false;
while (x.nodeType!=1) {
x=x.nextSibling;
if(x==null) return false;
}
return x;
}
function get_previoussibling(n){
x=n.previousSibling;
if(x==null) return false;
while (x.nodeType!=1) {
x=x.previousSibling;
if(x==null) return false;
}
return x;
}
function getTextContent(oNode) {
if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
switch (oNode.nodeType) {
case 3: // TEXT_NODE
case 4: // CDATA_SECTION_NODE
return oNode.nodeValue;
break;
case 7: // PROCESSING_INSTRUCTION_NODE
case 8: // COMMENT_NODE
if (getTextContent.caller!=getTextContent) {
return oNode.nodeValue;
}
break;
case 9: // DOCUMENT_NODE
case 10: // DOCUMENT_TYPE_NODE
case 12: // NOTATION_NODE
return null;
break;
}
var _textContent = "";
oNode = oNode.firstChild;
while (oNode) {
_textContent += getTextContent(oNode);
oNode = oNode.nextSibling;
}
return _textContent;
}
function setCookie (cookieName, cookieValue, expires, path) {
document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; EXPIRES=' + expires.toGMTString() : '') + "; PATH=/" ;
}
function getCookie(cookieName) {
var cookieValue = null;
var posName = document.cookie.indexOf(escape(cookieName) + '=' );
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=' ).length;
var endPos = document.cookie.indexOf(';', posValue) ;
if (endPos != -1) {
cookieValue = unescape(document.cookie.substring(posValue, endPos));
} else {
cookieValue = unescape(document.cookie.substring(posValue));
}
}
return decodeURIComponent(cookieValue);
}
/////////////////////////////////////////////////////////////////////// Modification de l'apparence du skin wikimini (inutile avec la redirection monobook)
///////////////////////////////////////////////////////////////////////
addOnloadHook (function(){
// ################## GÉNÉRAL ##################
// --------- Largeur = 100% au lieu de 800px -------------------
var mainDiv = document.getElementById('main');
mainDiv.style.width = '100%';
// --------- Suppression de l'objet flash (trop gros, trop moche...) -------------------
var flashDiv = document.getElementById('header');
flashDiv.style.display = 'none';
// --------- Déplacement des liens personnels en haut de page -------------------
var AllH5 = document.getElementsByTagName('h5');
for(a=0;a<AllH5.length;a++){
if(AllH5[a].innerHTML.indexOf('Outils personnels')!=-1){
var TitrePerso = AllH5[a];
var IconePerso = get_previoussibling(TitrePerso);
var LiensPerso = get_nextsibling(TitrePerso);
LiensPerso.parentNode.removeChild ( LiensPerso ) ;
document.body.insertBefore(LiensPerso, document.body.firstChild);
LiensPerso.style.marginLeft = '3em';
var LiensPersoDiv = LiensPerso.getElementsByTagName('div');
for(b=0;b<LiensPersoDiv.length;b++){
LiensPersoDiv[b].style.padding = '0';
LiensPersoDiv[b].style.margin = '0';
}
TitrePerso.parentNode.removeChild ( TitrePerso ) ;
LiensPerso.insertBefore(TitrePerso , LiensPerso.firstChild);
TitrePerso.style.padding = '0';
TitrePerso.style.margin = '0';
TitrePerso.style.marginLeft = '3em';
IconePerso.parentNode.removeChild ( IconePerso ) ;
LiensPerso.insertBefore(IconePerso, LiensPerso.firstChild);
IconePerso.style.padding = '0';
IconePerso.style.margin = '0';
IconePerso.style.marginLeft = '2em';
}
}
// ################## COLONNES ##################
var AllDiv = document.getElementsByTagName('Div');
for(a=0;a<AllDiv.length;a++){
if(hasClass(AllDiv[a], 'columns')){
var Colonnes = AllDiv[a]
}else if(hasClass(AllDiv[a], 'column1')){
var Colonne1 = AllDiv[a]
}else if(hasClass(AllDiv[a], 'column2')){
var Colonne2 = AllDiv[a]
}
}
// --------- Largeur colonne de droite réduite -------------------
Colonne1.style.width = '80%';
Colonne2.style.width = '20%';
// --------- Zone de recherche en haut de la colonne de droite -------------------
var Recherche = document.getElementById('p-search');
if(Recherche){
Recherche.parentNode.removeChild ( Recherche ) ;
Colonne2.insertBefore(Recherche , Colonne2.firstChild);
}
// --------- Suppression de l'image dans la boîte à outils -------------------
var Outils = document.getElementById('p-tb');
if(Outils){
var Image = Outils.getElementsByTagName('img')[1];
Image.style.display = 'none';
}
// ################## ÉDITION ##################
if(((wgAction=="edit")||(wgAction=="submit"))&&(wgNamespaceNumber>=0)){
// --------- Taille zone d'édition -------------------
var EditBox = document.getElementById('wpTextbox1');
if(EditBox){
Colonne1.style.width = '100%';
Colonne2.style.display = 'none';
EditBox.rows = 50;
// --------- Ajout toolbar si elle n'y est pas -------------------
var toolbar = document.getElementById('toolbar');
if(!toolbar){
toolbar = document.createElement('div');
toolbar.id = 'toolbar';
EditBox.parentNode.insertBefore(toolbar, EditBox);
}
// --------- Affiche les boutons de publication cachés -------------------
var EditOptionsElements = document.getElementById('wpSummaryLabel');
while(get_nextsibling(EditOptionsElements)){
EditOptionsElements.style.display = 'inline';
EditOptionsElements = get_nextsibling(EditOptionsElements);
}
var wpSave= document.getElementById('wpSave');
wpSave.style.marginLeft = '75px';
var wpDiff = document.getElementById('wpDiff');
wpDiff.style.display = 'inline';
wpDiff.style.margin = '0.5em';
// --------- Page modifiée automatiquement suivie -------------------
var SuiviModif = document.getElementById('wpWatchthis');
SuiviModif.checked = 'checked';
}
}
});
function WhosOnlineNewPage(){
//var ListePresents = document.getElementById('WhosOnlineList');
var TitreListePresents = document.getElementsByTagName('h3');
for(a=0;a<TitreListePresents.length;a++){
var Link = TitreListePresents[a].getElementsByTagName('a')[0];
if(Link){
if(Link.title='Spécial:Qui est en ligne'){
var ListePresents = TitreListePresents.nextSibling;
}
}
}
if(!ListePresents){
alert('Pas trouvé UL');
return;
}
var Liens = ListePresents.getElementsByTagName('a');
for(a=0;a<Liens.length;a++){
var LienHref = Liens[a].href;
LienHref = LienHref.split(wgServer).join('').split('/wiki/').join('');
var A = sajax_init_object();
A.open('GET', wgServer+'/w/api.php?action=query&format=xml&redirects&titles='+LienHref, true);
A.send(null);
A.onreadystatechange = function(e){
if (!e) var e = window.event;
if (this.readyState == 4){
if (this.status == 200){
var docXML = this.responseXML;
if (docXML.getElementsByTagName('page')[0].getAttribute('missing') == ''){
Liens[a].className="new";
}
}
}
}
}
}
}
addOnloadHook(WhosOnlineNewPage)
Ce que tu peux faire
Outils

Outils personnels