JSFiddle - React, Tailwind, and code Playground

by cduret

HTML

<div id="calendrier">

  <span>Changer le mois courant : 
      
      <div>
        
  <img id="bouton-gauche" src="http://boredzo.org/plusminus/plus-8.png" alt="boutton-droit"/>
  <img id="bouton-droit" src="http://boredzo.org/plusminus/minus-8.png" alt="bouton-gauche"/>
      </div>
  </span>
        
  <div id="label"/>
</div>

JavaScript

var weekday=new Array(7);
        weekday[0]='Sunday';
        weekday[1]='Monday';
        weekday[2]='Tuesday';
        weekday[3]='Wednesday';
        weekday[4]='Thursday';
        weekday[5]='Friday';
        weekday[6]='Saturday';
        
        var month=new Array(12);
        month[0]='January';
        month[1]='February';
        month[2]='March';
        month[3]='April';
        month[4]='May';
        month[5]='June';
        month[6]='July';
        month[7]='August';
        month[8]='September';
        month[9]='October';
        month[10]='November';
        month[11]='December';
        
        function Calendrier(date) {
            this.moisActuel = date.getMonth();
            this.annee = date.getFullYear();        
            this.jour = date.getDate();
            this.jour_num = date.getDay();
            
            var date2 = new Date(this.annee,this.moisActuel,1);
        
            this.first_jour_num_mois = date2.getDay();
            this.gris = 'g';
            this.rouge = 'r';
            this.rougebold = 'rb';
        
            this.nbJourMois = this.getNbJoursMois(this.moisActuel,this.annee);
            this.nbJourMoisPassee = this.getNbJoursMois(this.moisActuel,this.annee);
        }

        Calendrier.prototype.getNbJoursMois = function (mois,annee) {
          var lgMois = new Array (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

          if ((annee%4 == 0 && annee%100 != 0) || annee%400 == 0) {
              lgMois[1] += 1;
          }
        
          return lgMois  ; // 0 < mois <11
        }

        Calendrier.prototype.addMonth = function(i) {
          this.moisActuel = (this.moisActuel + i ) % 12;
          if( this.moisActuel < 0 ) {
              this.moisActuel = 11;
          }
        } 

        Calendrier.prototype.refresh_calendrier = function() {
        }       
            
        var calendar = new Calendrier(new Date());
        $('#label').text('mois actuel =...