function daysInMonth( month, year ) {
return 32 - new Date( year, month - 1, 32 ).getDate();
}
function daysInMonth30fevrier( month ) {
if ( month == 1 ) return 31;
if ( month == 2 ) return 30;
if ( month == 3 ) return 31;
if ( month == 4 ) return 30;
if ( month == 5 ) return 31;
if ( month == 6 ) return 30;
if ( month == 7 ) return 31;
if ( month == 8 ) return 31;
if ( month == 9 ) return 30;
if ( month == 10 ) return 31;
if ( month == 11 ) return 30;
if ( month == 12 ) return 31;
return 0;
}
function addWeeksSubpages( basepagename, yearisprefix, yearaffix, semaineMinMaj, unwatch ) {
if ( semaineMinMaj ) semaineMinMaj = 'Semaine';
else semaineMinMaj = 'semaine';
if ( unwatch ) unwatch = "&unwatch";
else unwatch = '';
var api = sajax_init_object();
if ( !yearaffix ) yearaffix = new Date().getFullYear() + 1900;
document.getElementById( "WL-results-maindiv" ).style.height = "300px";
for ( var i = 1 ; i < 54 ; i++ ) {
var fullpagename = basepagename.replace( /( \/ )?$/ ,'' ) + '/';
if ( yearisprefix ) fullpagename += yearaffix + "/";
fullpagename += semaineMinMaj + ' ' + i;
if ( !yearisprefix ) fullpagename += " " + yearaffix;
api.open( 'POST', wgServer + '/w/api.php?action=watch&title=' + fullpagename + unwatch, false );
api.send( null );
document.getElementById( "WLaddsubpages-results" ).innerHTML += fullpagename;
if ( unwatch == '' ) document.getElementById( "WLaddsubpages-results" ).innerHTML = document.getElementById( "WLaddsubpages-results" ).innerHTML + '
';
else document.getElementById( "WLaddsubpages-results" ).innerHTML += '
';
document.getElementById( "WLaddsubpages-results-count" ).innerHTML = parseInt( document.getElementById( "WLaddsubpages-results-count" ).innerHTML ) + 1;
document.location.hash = "WLaddsubpages-results-bottom";
}
return true;
}
function addBistroSubpages( year, months, unwatch ) {
if ( unwatch ) unwatch = "&unwatch";
else unwatch = '';
if ( months === false ) { months = new Array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ); }
var api = sajax_init_object();
var monthsListLocalized = {"1": "janvier", "2": "février", "3": "mars", "4": "avril", "5": "mai", "6": "juin", "7": "juillet", "8": "août", "9": "septembre", "10": "octobre", "11": "novembre", "12": "décembre"};
if ( months.length > 3 ) {
var monthsListConfirm = new Array();
for ( i = 0 ; i < months.length ; i++ ) {
monthsListConfirm.push( monthsListLocalized[ months[i] ] );
}
if ( !confirm( "Voulez-vous vraiment ajouter les mois de " + monthsListConfirm.join( ", " ) + " ? Cela risque de prendre du temps !" ) ) return false;
}
document.getElementById( "WL-results-maindiv" ).style.height = "300px";
for ( var i = 0 ; i < months.length ; i++ ) {
for ( var j = 1 ; j <= daysInMonth( months[i], year ) ; j++ ) {
var fullpagename = 'Wikipédia:Le Bistro/' + j + ' ' + monthsListLocalized[ months[i] ] + ' ' + year;
api.open( 'POST', wgServer + '/w/api.php?action=watch&title=' + fullpagename + unwatch, false );
api.send( null );
document.getElementById( "WLaddsubpages-results" ).innerHTML += fullpagename;
if ( unwatch == '' ) document.getElementById( "WLaddsubpages-results" ).innerHTML = document.getElementById( "WLaddsubpages-results" ).innerHTML + '
';
else document.getElementById( "WLaddsubpages-results" ).innerHTML += '
';
document.getElementById( "WLaddsubpages-results-count" ).innerHTML = parseInt( document.getElementById( "WLaddsubpages-results-count" ).innerHTML ) + 1;
document.location.hash = "WLaddsubpages-results-bottom";
}
}
return true;
}
function addEphemeridesJourMois( months, basepageaffixes, unwatch ) {
if ( unwatch ) unwatch = "&unwatch";
else unwatch = '';
if ( !basepageaffixes.length ) basepageaffixes = new Array( '', 'dans l\'animation et bande dessinée', 'dans les chemins de fer', 'en sport' );
if ( !months.length ) { months = new Array( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ); }
var api = sajax_init_object();
var monthsListLocalized = {"1": "janvier", "2": "février", "3": "mars", "4": "avril", "5": "mai", "6": "juin", "7": "juillet", "8": "août", "9": "septembre", "10": "octobre", "11": "novembre", "12": "décembre"};
if ( months.length > 3 ) {
var monthsListConfirm = new Array();
for ( i = 0 ; i < months.length ; i++ ) {
monthsListConfirm.push( monthsListLocalized[months[i]] );
}
if ( !confirm( "Voulez-vous vraiment ajouter les mois de " + monthsListConfirm.join( ", " ) + " ? Cela risque de prendre du temps !" ) ) return false;
}
document.getElementById( "WL-results-maindiv" ).style.height = "300px";
for ( var i = 0 ; i < months.length ; i++ ) {
for ( var j = 1 ; j <= daysInMonth30fevrier( months[i] ) ; j++ ) {
for ( var k = 0 ; k < basepageaffixes.length ; k++ ) {
if ( basepageaffixes[k] != '' ) basepageaffixes[k] = ' ' + basepageaffixes[k].replace( /^\s*(\S.*\S)\s*$/, '$1' );
if ( !( basepageaffixes[k] in { '':1, ' dans l\'animation et bande dessinée':1, ' dans les chemins de fer':1, ' en sport':1 } ) ) {
document.getElementById( "WLaddsubpages-results" ).innerHTML += 'Il n\'y a pas de pages de la forme "Mois Année ' + basepageaffixes[k] + '"
';
continue;
}
var fullpagename = ( j == 1) ? '1er' : j ;
fullpagename += ' ' + monthsListLocalized[ months[i] ] + basepageaffixes[k];
api.open( 'POST', wgServer + '/w/api.php?action=watch&title=' + fullpagename + unwatch, false );
api.send( null );
document.getElementById( "WLaddsubpages-results" ).innerHTML += fullpagename;
if ( unwatch == '' ) document.getElementById( "WLaddsubpages-results" ).innerHTML = document.getElementById( "WLaddsubpages-results" ).innerHTML + '
';
else document.getElementById( "WLaddsubpages-results" ).innerHTML += '
';
document.getElementById( "WLaddsubpages-results-count" ).innerHTML = parseInt( document.getElementById( "WLaddsubpages-results-count" ).innerHTML ) + 1;
document.location.hash = "WLaddsubpages-results-bottom";
}
}
}
return true;
}
function addEphemeridesMoisAnnees( years, basepageaffixes, unwatch ) {
if ( unwatch ) unwatch = "&unwatch";
else unwatch = '';
if ( !basepageaffixes.length ) basepageaffixes = new Array( '', 'en sport' );
for ( var i = 0 ; i < basepageaffixes.length ; i++ ) if ( basepageaffixes[i] != '' ) basepageaffixes[i] = ' ' + basepageaffixes[i].replace( /^\s*(\S.*\S)\s*$/, '$1' );
if ( !years.length ) {
years = new Array();
for ( var i = 0 ; i <= new Date().getYear() - 10 ; i++ ) { years.push( 1900 + i ); }
}
var api = sajax_init_object();
var monthsListLocalized = {"1": "janvier", "2": "février", "3": "mars", "4": "avril", "5": "mai", "6": "juin", "7": "juillet", "8": "août", "9": "septembre", "10": "octobre", "11": "novembre", "12": "décembre"};
if ( years.length > 7 ) {
if ( !confirm( "Voulez-vous vraiment ajouter les années " + years.join( ", " ) + " ? Cela risque de prendre du temps !" ) ) return false;
}
document.getElementById( "WL-results-maindiv" ).style.height = "300px";
for ( var i = 0 ; i < years.length ; i++ ) {
for ( var j = 1 ; j <= 12 ; j++ ) {
for ( var k = 0 ; k < basepageaffixes.length ; k++ ) {
if ( !( basepageaffixes[k] in { '':1, ' en sport':1 } ) ) {
document.getElementById( "WLaddsubpages-results" ).innerHTML += 'Il n\'y a pas de pages de la forme "Mois Année ' + basepageaffixes[k] + '"
';
continue;
}
var fullpagename = monthsListLocalized[ j ] + ' ' + years[i] + basepageaffixes[k];
api.open( 'POST', wgServer + '/w/api.php?action=watch&title=' + fullpagename + unwatch, false );
api.send( null );
document.getElementById( "WLaddsubpages-results" ).innerHTML += fullpagename;
if ( unwatch == '' ) document.getElementById( "WLaddsubpages-results" ).innerHTML = document.getElementById( "WLaddsubpages-results" ).innerHTML + '
';
else document.getElementById( "WLaddsubpages-results" ).innerHTML += '
';
document.getElementById( "WLaddsubpages-results-count" ).innerHTML = parseInt( document.getElementById( "WLaddsubpages-results-count" ).innerHTML ) + 1;
document.location.hash = "WLaddsubpages-results-bottom";
}
}
}
return true;
}
function addWatchUnWatchButtons() {
if ( wgCanonicalNamespace != "Special" ) return false;
if ( wgCanonicalSpecialPageName != "Watchlist" ) return false;
var WLdiv = document.createElement( "form" );
document.getElementById( "bodyContent" ).appendChild( WLdiv );
var monthsListLocalized = {"1": "janvier", "2": "février", "3": "mars", "4": "avril", "5": "mai", "6": "juin", "7": "juillet", "8": "août", "9": "septembre", "10": "octobre", "11": "novembre", "12": "décembre"};
var WLyearFieldSet = document.createElement( "fieldset" );
WLdiv.appendChild( WLyearFieldSet );
var WLyearLegend = document.createElement( "legend" );
WLyearLegend.innerHTML = "Année";
WLyearFieldSet.appendChild( WLyearLegend );
var WLmin2YearLabel = document.createElement( "label" );
WLmin2YearLabel.innerHTML = new Date().getFullYear() - 2;
WLmin2YearLabel.htmlFor = "WL-min2year";
WLmin2YearLabel.style.marginLeft = "20px";
WLyearFieldSet.appendChild( WLmin2YearLabel );
var WLmin2Year = document.createElement( "input" );
WLmin2Year.type = "radio";
WLmin2Year.name = "WL-year";
WLmin2Year.id = "WL-min2year";
WLmin2Year.value = new Date().getFullYear() - 2;
WLyearFieldSet.appendChild( WLmin2Year );
var WLpreviousYearLabel = document.createElement( "label" );
WLpreviousYearLabel.innerHTML = new Date().getFullYear() - 1;
WLpreviousYearLabel.htmlFor = "WL-previousyear";
WLpreviousYearLabel.style.marginLeft = "20px";
WLyearFieldSet.appendChild( WLpreviousYearLabel );
var WLpreviousYear = document.createElement( "input" );
WLpreviousYear.type = "radio";
WLpreviousYear.name = "WL-year";
WLpreviousYear.id = "WL-previousyear";
WLpreviousYear.value = new Date().getFullYear() - 1;
WLyearFieldSet.appendChild( WLpreviousYear );
var WLcurrentYearLabel = document.createElement( "label" );
WLcurrentYearLabel.innerHTML = new Date().getFullYear();
WLcurrentYearLabel.htmlFor = "WL-currentyear";
WLcurrentYearLabel.style.marginLeft = "20px";
WLyearFieldSet.appendChild( WLcurrentYearLabel );
var WLcurrentYear = document.createElement( "input" );
WLcurrentYear.type = "radio";
WLcurrentYear.name = "WL-year";
WLcurrentYear.id = "WL-currentyear";
WLcurrentYear.checked = true;
WLcurrentYear.value = new Date().getFullYear();
WLyearFieldSet.appendChild( WLcurrentYear );
var WLnextYearLabel = document.createElement( "label" );
WLnextYearLabel.innerHTML = new Date().getFullYear() + 1;
WLnextYearLabel.htmlFor = "WL-nextyear";
WLnextYearLabel.style.marginLeft = "20px";
WLyearFieldSet.appendChild( WLnextYearLabel );
var WLnextYear = document.createElement( "input" );
WLnextYear.type = "radio";
WLnextYear.name = "WL-year";
WLnextYear.id = "WL-nextyear";
WLnextYear.value = new Date().getFullYear() + 1;
WLyearFieldSet.appendChild( WLnextYear );
var WLmonthFieldSet = document.createElement( "fieldset" );
WLmonthFieldSet.id = "WL-month-fieldset";
WLdiv.appendChild( WLmonthFieldSet );
var WLmonthLegend = document.createElement( "legend" );
WLmonthLegend.innerHTML = 'Mois (ne sera pris en compte que pour le Bistro et les Éphémérides)';
WLmonthFieldSet.appendChild( WLmonthLegend );
var monthsListLocalized = {"1": "janvier", "2": "février", "3": "mars", "4": "avril", "5": "mai", "6": "juin", "7": "juillet", "8": "août", "9": "septembre", "10": "octobre", "11": "novembre", "12": "décembre"};
var WLmonthLabel = new Array();
var WLmonth = new Array();
for ( var i=1 ; i < 13 ; i++ ) {
WLmonthLabel[i] = document.createElement( "label" );
WLmonthLabel[i].innerHTML = monthsListLocalized[i];
WLmonthLabel[i].htmlFor = "WL-month" + i;
WLmonthLabel[i].style.marginLeft = "20px";
WLmonthFieldSet.appendChild( WLmonthLabel[i] );
WLmonth[i] = document.createElement( "input" )
WLmonth[i].type = "checkbox";
WLmonth[i].name = "WL-month";
WLmonth[i].value = i;
WLmonth[i].id = "WL-month" + i;
WLmonthFieldSet.appendChild( WLmonth[i] );
}
var WLmonthButtonsDiv = document.createElement( "div" );
WLmonthFieldSet.appendChild( WLmonthButtonsDiv );
var WLmonthTickAll = document.createElement( "input" );
WLmonthTickAll.type = "button";
WLmonthTickAll.value = "Cocher tout";
WLmonthTickAll.onclick = function() { var monthCheckboxList = document.getElementById( "WL-month-fieldset" ).getElementsByTagName( "input" ); for ( var i = 0; i < monthCheckboxList.length ; i++ ) { if ( monthCheckboxList[i].type == "checkbox" ) monthCheckboxList[i].checked = true; } };
WLmonthButtonsDiv.appendChild( WLmonthTickAll );
var WLmonthUntickAll = document.createElement( "input" );
WLmonthUntickAll.type = "button";
WLmonthUntickAll.value = "Décocher tout";
WLmonthUntickAll.onclick = function() { var monthCheckboxList = document.getElementById( "WL-month-fieldset" ).getElementsByTagName( "input" ); for ( var i = 0; i < monthCheckboxList.length ; i++ ) {if ( monthCheckboxList[i].type == "checkbox" ) monthCheckboxList[i].checked = false; } };
WLmonthButtonsDiv.appendChild( WLmonthUntickAll );
var WLmonthDisTickAll = document.createElement( "input" );
WLmonthDisTickAll.type = "button";
WLmonthDisTickAll.value = "Inverser la sélection";
WLmonthDisTickAll.onclick = function() { var monthCheckboxList = document.getElementById( "WL-month-fieldset" ).getElementsByTagName( "input" ); for ( var i = 0; i < monthCheckboxList.length ; i++ ) {if ( monthCheckboxList[i].type != "checkbox" ) continue; if ( monthCheckboxList[i].checked ) monthCheckboxList[i].checked = false; else monthCheckboxList[i].checked = true; } };
WLmonthButtonsDiv.appendChild( WLmonthDisTickAll );
var WLoptionsFieldSet = document.createElement( "fieldset" );
WLdiv.appendChild( WLoptionsFieldSet );
var WLoptionsLegend = document.createElement( "legend" );
WLoptionsLegend.innerHTML = "Options générales";
WLoptionsFieldSet.appendChild( WLoptionsLegend );
var WLoptionsWatchFieldSet = document.createElement( "fieldset" );
WLoptionsFieldSet.appendChild( WLoptionsWatchFieldSet );
var WLoptionsWatchLegend = document.createElement( "legend" );
WLoptionsWatchLegend.innerHTML = "Options de suivi";
WLoptionsWatchFieldSet.appendChild( WLoptionsWatchLegend );
var WLoptionsWatchLabel = document.createElement( "label" );
WLoptionsWatchLabel.htmlFor = "WL-watch";
WLoptionsWatchLabel.innerHTML = "Suivre";
WLoptionsWatchLabel.style.marginLeft = "15px";
WLoptionsWatchFieldSet.appendChild( WLoptionsWatchLabel );
var WLoptionsWatch = document.createElement( "input" );
WLoptionsWatch.type = "radio";
WLoptionsWatch.id = "WL-watch";
WLoptionsWatch.value = "watch";
WLoptionsWatch.name = "WL-watch";
WLoptionsWatch.checked = true;
WLoptionsWatchFieldSet.appendChild( WLoptionsWatch );
var WLoptionsUnwatch = document.createElement( "input" );
WLoptionsUnwatch.type = "radio";
WLoptionsUnwatch.id = "WL-unwatch";
WLoptionsUnwatch.value = "unwatch";
WLoptionsUnwatch.name = "WL-watch";
WLoptionsWatchFieldSet.appendChild( WLoptionsUnwatch );
var WLoptionsUnwatchLabel = document.createElement( "label" );
WLoptionsUnwatchLabel.htmlFor = "WL-unwatch";
WLoptionsUnwatchLabel.innerHTML = "Ne plus suivre";
WLoptionsWatchFieldSet.appendChild( WLoptionsUnwatchLabel );
var WLoptionsEphemeridesFieldSet = document.createElement( "fieldset" );
WLoptionsFieldSet.appendChild( WLoptionsEphemeridesFieldSet );
var WLoptionsEphemeridesLegend = document.createElement( "legend" );
WLoptionsEphemeridesLegend.innerHTML = 'Éphémérides (cliquer pour afficher/masquer)';
WLoptionsEphemeridesLegend.cursor = 'pointer';
WLoptionsEphemeridesLegend.onclick = function(){if ( document.getElementById( "WL-ephemerides-year-div" ).style.display == "none" ) { document.getElementById( "WL-ephemerides-year-div" ).style.display = "block"; document.getElementById( "WL-ephemerides-types-div" ).style.display = "block"; } else { document.getElementById( "WL-ephemerides-year-div" ).style.display = "none"; document.getElementById( "WL-ephemerides-types-div" ).style.display = "none"; } };
WLoptionsEphemeridesFieldSet.appendChild( WLoptionsEphemeridesLegend );
var WLoptionsEphemeridesYearFieldSet = document.createElement( "fieldset" );
WLoptionsEphemeridesYearFieldSet.id = "WL-ephemerides-year-div";
WLoptionsEphemeridesYearFieldSet.style.display = "none";
WLoptionsEphemeridesFieldSet.appendChild( WLoptionsEphemeridesYearFieldSet );
var WLoptionsEphemeridesYearLegend = document.createElement( "legend" );
WLoptionsEphemeridesYearLegend.innerHTML = "Années à prendre en considération";
WLoptionsEphemeridesYearFieldSet.appendChild( WLoptionsEphemeridesYearLegend );
var WLoptionsEphemeridesYearsCheckbox = new Array();
var WLoptionsEphemeridesYearsLabel = new Array();
for ( var i = 1900 ; i <= new Date().getFullYear() + 10 ; i++ ) {
WLoptionsEphemeridesYearsLabel[i] = document.createElement( "label" );
WLoptionsEphemeridesYearsLabel[i].innerHTML = i;
WLoptionsEphemeridesYearsLabel[i].htmlFor = "WL-ephemerides-year-" + i;
WLoptionsEphemeridesYearsLabel[i].style.marginLeft = "20px";
WLoptionsEphemeridesYearFieldSet.appendChild( WLoptionsEphemeridesYearsLabel[i] );
WLoptionsEphemeridesYearsCheckbox[i] = document.createElement( "input" );
WLoptionsEphemeridesYearsCheckbox[i].type = "checkbox";
WLoptionsEphemeridesYearsCheckbox[i].id = "WL-ephemerides-year-" + i;
WLoptionsEphemeridesYearsCheckbox[i].value = i + '';
WLoptionsEphemeridesYearsCheckbox[i].name = 'WL-ephemerides-years';
if ( i >= new Date().getFullYear() - 1 ) WLoptionsEphemeridesYearsCheckbox[i].checked = true;
WLoptionsEphemeridesYearFieldSet.appendChild( WLoptionsEphemeridesYearsCheckbox[i] );
if ( ( i % 10 ) == 9 ) WLoptionsEphemeridesYearFieldSet.appendChild( document.createElement( "br" ) );
}
var WLEphemeridesButtonsYearDiv = document.createElement( "div" );
WLEphemeridesButtonsYearDiv.style.margin = '10px 50px 0 0';
WLoptionsEphemeridesYearFieldSet.appendChild( WLEphemeridesButtonsYearDiv );
var WLoptionsEphemeridesYearTickAll = document.createElement( "input" );
WLoptionsEphemeridesYearTickAll.type = "button";
WLoptionsEphemeridesYearTickAll.value = "Cocher toutes les années";
WLoptionsEphemeridesYearTickAll.onclick = function() { var yearCheckboxList = document.getElementById( "WL-ephemerides-year-div" ).getElementsByTagName( "input" ); for ( var i = 0; i < yearCheckboxList.length ; i++ ) { if ( yearCheckboxList[i].type == "checkbox" ) yearCheckboxList[i].checked = true; } };
WLEphemeridesButtonsYearDiv.appendChild( WLoptionsEphemeridesYearTickAll );
var WLoptionsEphemeridesYearUntickAll = document.createElement( "input" );
WLoptionsEphemeridesYearUntickAll.type = "button";
WLoptionsEphemeridesYearUntickAll.value = "Décocher toutes les années";
WLoptionsEphemeridesYearUntickAll.onclick = function() { var yearCheckboxList = document.getElementById( "WL-ephemerides-year-div" ).getElementsByTagName( "input" ); for ( var i = 0; i < yearCheckboxList.length ; i++ ) {if ( yearCheckboxList[i].type == "checkbox" ) yearCheckboxList[i].checked = false; } };
WLEphemeridesButtonsYearDiv.appendChild( WLoptionsEphemeridesYearUntickAll );
var WLoptionsEphemeridesYearDisTickAll = document.createElement( "input" );
WLoptionsEphemeridesYearDisTickAll.type = "button";
WLoptionsEphemeridesYearDisTickAll.value = "Inverser la sélection d'années";
WLoptionsEphemeridesYearDisTickAll.onclick = function() { var yearCheckboxList = document.getElementById( "WL-ephemerides-year-div" ).getElementsByTagName( "input" ); for ( var i = 0; i < yearCheckboxList.length ; i++ ) {if ( yearCheckboxList[i].type != "checkbox" ) continue; if ( yearCheckboxList[i].checked ) yearCheckboxList[i].checked = false; else yearCheckboxList[i].checked = true; } };
WLEphemeridesButtonsYearDiv.appendChild( WLoptionsEphemeridesYearDisTickAll );
var WLEphemeridesTypesFieldSet = document.createElement( "fieldset" );
WLEphemeridesTypesFieldSet.style.marginTop = "25px";
WLEphemeridesTypesFieldSet.id = 'WL-ephemerides-types-div';
WLEphemeridesTypesFieldSet.style.display = 'none';
WLoptionsEphemeridesFieldSet.appendChild( WLEphemeridesTypesFieldSet );
var WLEphemeridesTypesLegend = document.createElement( "legend" );
WLEphemeridesTypesLegend.innerHTML = "Types de pages d'Éphéméride à considérer";
WLEphemeridesTypesFieldSet.appendChild( WLEphemeridesTypesLegend );
var WLEphemeridesTypesArray = new Array( '', 'dans l\'animation et bande dessinée', 'dans les chemins de fer', 'en sport' );
var WLEphemeridesTypesCheckboxes = new Array();
var WLEphemeridesTypesLabels = new Array();
for ( var i = 0 ; i < WLEphemeridesTypesArray.length ; i++ ) {
WLEphemeridesTypesLabels[i] = document.createElement( "label" );
WLEphemeridesTypesLabels[i].innerHTML = ( WLEphemeridesTypesArray[i] == '' ) ? '(pages générales)' : WLEphemeridesTypesArray[i] ;
if ( WLEphemeridesTypesArray[i] == '' ) WLEphemeridesTypesLabels[i].style.fontStyle = "italic";
WLEphemeridesTypesLabels[i].htmlFor = "WL-ephemerides-types-" + i;
WLEphemeridesTypesLabels[i].style.marginLeft = "15px";
WLEphemeridesTypesFieldSet.appendChild( WLEphemeridesTypesLabels[i] );
WLEphemeridesTypesCheckboxes[i] = document.createElement( "input" );
WLEphemeridesTypesCheckboxes[i].type = "checkbox";
if ( WLEphemeridesTypesArray[i] == '' ) WLEphemeridesTypesCheckboxes[i].checked = true;
WLEphemeridesTypesCheckboxes[i].id = "WL-ephemerides-types-" + i;
WLEphemeridesTypesCheckboxes[i].value = WLEphemeridesTypesArray[i];
WLEphemeridesTypesCheckboxes[i].name = "WL-ephemerides-types";
WLEphemeridesTypesFieldSet.appendChild( WLEphemeridesTypesCheckboxes[i] );
}
var WLEphemeridesTypesButtonDiv = document.createElement( "div" );
WLEphemeridesTypesButtonDiv.style.margin = '10px 50px 0 0';
WLEphemeridesTypesFieldSet.appendChild( WLEphemeridesTypesButtonDiv );
var WLEphemeridesTypesTickAll = document.createElement( "input" );
WLEphemeridesTypesTickAll.type = "button";
WLEphemeridesTypesTickAll.value = "Cocher tous les types";
WLEphemeridesTypesTickAll.onclick = function() { var monthCheckboxList = document.getElementById( "WL-ephemerides-types-div" ).getElementsByTagName( "input" ); for ( var i = 0; i < monthCheckboxList.length ; i++ ) { if ( monthCheckboxList[i].type == "checkbox" ) monthCheckboxList[i].checked = true; } };
WLEphemeridesTypesButtonDiv.appendChild( WLEphemeridesTypesTickAll );
var WLEphemeridesTypesUntickAll = document.createElement( "input" );
WLEphemeridesTypesUntickAll.type = "button";
WLEphemeridesTypesUntickAll.value = "Décocher tous les types";
WLEphemeridesTypesUntickAll.onclick = function() { var monthCheckboxList = document.getElementById( "WL-ephemerides-types-div" ).getElementsByTagName( "input" ); for ( var i = 0; i < monthCheckboxList.length ; i++ ) {if ( monthCheckboxList[i].type == "checkbox" ) monthCheckboxList[i].checked = false; } };
WLEphemeridesTypesButtonDiv.appendChild( WLEphemeridesTypesUntickAll );
var WLEphemeridesTypesDisTickAll = document.createElement( "input" );
WLEphemeridesTypesDisTickAll.type = "button";
WLEphemeridesTypesDisTickAll.value = "Inverser la sélection de types";
WLEphemeridesTypesDisTickAll.onclick = function() { var monthCheckboxList = document.getElementById( "WL-ephemerides-types-div" ).getElementsByTagName( "input" ); for ( var i = 0; i < monthCheckboxList.length ; i++ ) {if ( monthCheckboxList[i].type != "checkbox" ) continue; if ( monthCheckboxList[i].checked ) monthCheckboxList[i].checked = false; else monthCheckboxList[i].checked = true; } };
WLEphemeridesTypesButtonDiv.appendChild( WLEphemeridesTypesDisTickAll );
var WLwatchedPagesFieldSet = document.createElement( "fieldset" );
WLdiv.appendChild( WLwatchedPagesFieldSet );
var WLwatchedPagesLegend = document.createElement( "legend" );
WLwatchedPagesLegend.innerHTML = "Pages à suivre/ne plus suivre";
WLwatchedPagesFieldSet.appendChild( WLwatchedPagesLegend );
var WLbuttonBistro = document.createElement( "input" );
WLbuttonBistro.type = "button";
WLbuttonBistro.value = "Le Bistro";
WLbuttonBistro.onclick = function() { if ( addBistroSubpages( checkRadioByName( "WL-year" ), checkBoxesByName( "WL-month" ), ( checkRadioByName( "WL-watch" ) == "unwatch" ) ) ) { if ( checkRadioByName( "WL-watch" ) == "unwatch" ) alert( "Retrait des pages du Bistro de votre LdS" ); else alert( "Ajout des pages du Bistro à votre LdS" ); } };
WLwatchedPagesFieldSet.appendChild( WLbuttonBistro );
var WLbuttonBA = document.createElement( "input" );
WLbuttonBA.type = "button";
WLbuttonBA.value = "Bulletin des administrateurs";
WLbuttonBA.onclick = function() { if ( addWeeksSubpages( "Wikipédia:Bulletin des administrateurs", true, checkRadioByName( "WL-year" ), true, ( checkRadioByName( "WL-watch" ) == "unwatch" ) ) ) { if ( checkRadioByName( "WL-watch" ) == "unwatch" ) alert( "Retrait des pages du BA de votre LdS" ); else alert( "Ajout des pages du BA à votre LdS" ); } };
WLwatchedPagesFieldSet.appendChild( WLbuttonBA );
var WLbuttonOracle = document.createElement( "input" );
WLbuttonOracle.type = "button";
WLbuttonOracle.value = "Oracle";
WLbuttonOracle.onclick = function() { if ( addWeeksSubpages( "Wikipédia:Oracle", false, checkRadioByName( "WL-year" ), false, ( checkRadioByName( "WL-watch" ) == "unwatch" ) ) ) { if ( checkRadioByName( "WL-watch" ) == "unwatch" ) alert( "Retrait des pages de l'Oracle de votre LdS" ); else alert( "Ajout des pages de l'Oracle à votre LdS" ); } };
WLwatchedPagesFieldSet.appendChild( WLbuttonOracle );
var WLbuttonQT = document.createElement( "input" );
WLbuttonQT.type = "button";
WLbuttonQT.value = "Questions techniques";
WLbuttonQT.onclick = function() { if ( addWeeksSubpages( "Wikipédia:Questions techniques", false, checkRadioByName( "WL-year" ), false, ( checkRadioByName( "WL-watch" ) == "unwatch" ) ) ) { if ( checkRadioByName( "WL-watch" ) == "unwatch" ) alert( "Retrait des pages de Questions techniques de votre LdS" ); else alert( "Ajout des pages de Questions techniques à votre LdS" ); } };
WLwatchedPagesFieldSet.appendChild( WLbuttonQT );
var WLbuttonEphJM = document.createElement( "input" );
WLbuttonEphJM.type = "button";
WLbuttonEphJM.value = "Éphémérides Jour du Mois";
WLbuttonEphJM.onclick = function() { if ( addEphemeridesJourMois( checkBoxesByName( "WL-month" ), checkBoxesByName( "WL-ephemerides-types" ), ( checkRadioByName( "WL-watch" ) == "unwatch" ) ) ) { if ( checkRadioByName( "WL-watch" ) == "unwatch" ) alert( "Retrait des pages d'Éphémérides Jour du Mois de votre LdS" ); else alert( "Ajout des pages d'Éphémérides Jour du Mois à votre LdS" ); } };
WLwatchedPagesFieldSet.appendChild( WLbuttonEphJM );
var WLbuttonEphMA = document.createElement( "input" );
WLbuttonEphMA.type = "button";
WLbuttonEphMA.value = "Éphémérides Mois de l'Année";
WLbuttonEphMA.onclick = function() { if ( addEphemeridesMoisAnnees( checkBoxesByName( "WL-ephemerides-years" ), checkBoxesByName( "WL-ephemerides-types" ), ( checkRadioByName( "WL-watch" ) == "unwatch" ) ) ) { if ( checkRadioByName( "WL-watch" ) == "unwatch" ) alert( "Retrait des pages d'Éphéméride Mois de l'Année de votre LdS" ); else alert( "Ajout des pages dÉphéméride Mois de l'année à votre LdS" ); } };
WLwatchedPagesFieldSet.appendChild( WLbuttonEphMA );
var WLresultsFieldSet = document.createElement( "fieldset" );
WLdiv.appendChild( WLresultsFieldSet );
var WLresultsLegend = document.createElement( "legend" );
WLresultsLegend.innerHTML = "Résultats (pages ajoutées et supprimées)";
WLresultsFieldSet.appendChild( WLresultsLegend );
var WLresultsCountDiv = document.createElement( "div" );
WLresultsFieldSet.appendChild( WLresultsCountDiv );
WLresultsCountDiv.innerHTML = '0 pages ajoutées ou supprimées de votre LdS';
var WLresultsMainDiv = document.createElement( "div" );
WLresultsMainDiv.style.height = "50px";
WLresultsMainDiv.style.width = "650px";
WLresultsMainDiv.style.overflow = "auto";
WLresultsMainDiv.id = "WL-results-maindiv";
WLresultsFieldSet.appendChild( WLresultsMainDiv );
var WLresultsDiv = document.createElement( "div" );
WLresultsDiv.id = "WLaddsubpages-results";
WLresultsDiv.style.fontSize = ".8em";
WLresultsMainDiv.appendChild( WLresultsDiv );
var WLresultsBottom = document.createElement( "a" );
WLresultsBottom.id = "WLaddsubpages-results-bottom";
WLresultsBottom.name = "WLaddsubpages-results-bottom";
WLresultsBottom.href= document.location.href.replace( /#(.*)$/,'' );
WLresultsBottom.innerHTML = "Recharger la page";
WLresultsMainDiv.appendChild( WLresultsBottom );
return true;
}
addOnloadHook( addWatchUnWatchButtons );
function checkRadioByName( checkedname ) {
var namedElementsList = document.getElementsByName( checkedname );
for ( var i = 0 ; i < namedElementsList.length ; i++ ) {
if ( namedElementsList[i].checked ) {
return namedElementsList[i].value;
}
}
return false;
}
function checkBoxesByName( checkedname ) {
var namedElementsList = document.getElementsByName( checkedname );
var listedValues = new Array();
for ( var i = 0 ; i < namedElementsList.length ; i++ ) {
if ( namedElementsList[i].checked ) {
listedValues.push( namedElementsList[i].value );
}
}
if ( listedValues[0] !== false) return listedValues;
return false;
}