Difference between revisions of "MediaWiki:Common.js"

From L'avenir de l'humanité
 
 
(51 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
  
/* Any JavaScript here will be loaded for all users on every page load. */
+
//collapsible table column test, based on: https://codepen.io/feger/pen/eDybC
 
+
$("#btnHideEnglish").click(function(){
$( document ).ready(function() {
+
  console.log ('Hiding first column of table with an id of report');
        console.log( "document loaded" );
+
  $( "table#collapsible_report tbody tr th:nth-child(1)" ).toggle();
 
+
  $( "table#collapsible_report tbody tr td:nth-child(1)" ).toggle();
var monthNames = [ "January / Januar", "February / Februar", "March / März", "April", "May / Mai", "June / Juni", "July / Juli", "August", "September", "October / Oktober", "November", "December / Dezember" ];  
+
  if ($(this).text() == "Cacher l'anglais"){
var dayNames= ["Sunday / Sonntag,","Monday / Montag,","Tuesday / Dienstag,","Wednesday / Mittwoch,","Thursday / Donnerstag,","Friday / Freitag,","Saturday / Samstag,"]
+
    $(this).text("Montrer l'anglais");
 
+
  } else {
var newDate = new Date();
+
    $(this).text("Cacher l'anglais");
 
+
  }
newDate.setDate(newDate.getDate());
+
});
 
 
$('#FOMdate').html(dayNames[newDate.getDay()] + " " + newDate.getUTCDate() + ' ' + monthNames[newDate.getUTCMonth()] + ' ' + newDate.getUTCFullYear());
 
 
 
setInterval( function() {
 
  
var seconds = new Date().getSeconds();
+
$("#btnHideGerman").click(function(){
 
+
  console.log ('Hiding second column of table with an id of report');
$("#sec").html(( seconds < 10 ? "0" : "" ) + seconds);
+
  $( "table#collapsible_report tbody tr th:nth-child(2)" ).toggle();
},1000);
+
  $( "table#collapsible_report tbody tr td:nth-child(2)" ).toggle();
 
+
  if ($(this).text() == "Cacher l'allemand"){
setInterval( function() {
+
    $(this).text("Montrer l'allemand");
 
+
  } else {
var minutes = new Date().getMinutes();
+
    $(this).text("Cacher l'allemand");
 
+
  }
$("#min").html(( minutes < 10 ? "0" : "" ) + minutes);
 
},1000);
 
 
 
setInterval( function() {
 
 
 
var hours = new Date().getHours();
 
 
 
$("#hours").html(( hours < 10 ? "0" : "" ) + hours);
 
}, 1000);
 
 
});
 
});
  
$(function() {
+
// hide the german by default, on page load, but only if the btnHideGerman element exists on the page
  $(".DateDiv").each(function(index) {
+
if (document.getElementById("btnHideGerman")) {
    var sRange = $(this).find(".DateRange").html();
+
  console.log('btnHideGerman exists');
    var arrTemp = sRange.split(" to ");
+
  //$("#btnHideGerman").click();
    var dtFrom = new Date(arrTemp[0]);
+
} else {
    var dtTo = new Date(arrTemp[1]);
+
  // do stuff
    var dtNow = new Date();
+
  console.log('btnHideGerman does not exist');
    if (dtNow >= dtFrom && dtNow <= dtTo)
+
}
      $(this).show();
 
  });
 
});
 

Latest revision as of 19:58, 30 December 2021

/* Any JavaScript here will be loaded for all users on every page load. */

//collapsible table column test, based on: https://codepen.io/feger/pen/eDybC
$("#btnHideEnglish").click(function(){
  console.log ('Hiding first column of table with an id of report');
  $( "table#collapsible_report tbody tr th:nth-child(1)" ).toggle();
  $( "table#collapsible_report tbody tr td:nth-child(1)" ).toggle();
  if ($(this).text() == "Cacher l'anglais"){
    $(this).text("Montrer l'anglais");
  } else {
    $(this).text("Cacher l'anglais");
  }
});

$("#btnHideGerman").click(function(){
  console.log ('Hiding second column of table with an id of report');
  $( "table#collapsible_report tbody tr th:nth-child(2)" ).toggle();
  $( "table#collapsible_report tbody tr td:nth-child(2)" ).toggle();
  if ($(this).text() == "Cacher l'allemand"){
    $(this).text("Montrer l'allemand");
  } else {
    $(this).text("Cacher l'allemand");
  }
});

// hide the german by default, on page load, but only if the btnHideGerman element exists on the page
if (document.getElementById("btnHideGerman")) {
  console.log('btnHideGerman exists');
  //$("#btnHideGerman").click();
} else {
  // do stuff
  console.log('btnHideGerman does not exist');
}