1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
   | <!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
  <meta http-equiv="cache-control" content="public, max-age=60">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
  <meta name="author" content="Daniel Hagnoul">
  <title>test</title>
  <style>
    * {
      box-sizing: border-box;
    }
                
    th, td {
      width: 10rem;
      border: 1pt dotted grey;
      padding: 0.3rem;
    }
                
                button {
                        font-size: 2rem;
                }
  </style>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/locale/fr.js"></script>
  <script src="http://danielhagnoul.developpez.com/lib/dvjh/dvjhUtilities-1.3.3.js"></script>
  <script>
    'use strict';
    
    document.addEventListener( "DOMContentLoaded", ev => {
      
      // code
      
    }, false );
    
    window.addEventListener( "load", ev => { 
      moment.locale( "fr" );
      
      // code du test
                        const
                                btnClickMe = document.querySelector( "#btnClickMe" ),
                                countDown = document.querySelector( "#countDown" );
                                
                        let boolGoToLink = false;
                        
                        btnClickMe.addEventListener( "click", ev => {
                                if ( boolGoToLink === false ){
                                        const new_event = new ev.constructor( ev.type, ev );
                                        
                                        ev.preventDefault();
                                        ev.stopPropagation();
                                        
                                        btnClickMe.style.backgroundColor = "rgba( 255, 0, 0, 0.5 )";
                                        
                                        let
                                                seconds = 20,
                                                countdownTimer = null;
                                        
                                        function secondPassed( ){
                                                let
                                                        minutes = Math.round( ( seconds - 30 ) / 60 ),
                                                        remainingSeconds = seconds % 60;
                                                
                                                if ( remainingSeconds < 10 ) {
                                                        remainingSeconds = "0" + remainingSeconds;  
                                                }
                                                
                                                countDown.textContent = minutes + ":" + remainingSeconds;
                                                
                                                if ( seconds === 0 ) {
                                                        clearInterval( countdownTimer );
                                                        btnClickMe.style.backgroundColor= "rgba( 0, 153, 51, 0.5 )";
                                                        countDown.textContent = "Buzz Buzz";
                                                        boolGoToLink = true;
                                                        ev.target.dispatchEvent( new_event ); // bloqué par les sécurités des navigateurs !
                                                } else {
                                                        seconds--;
                                                }
                                        }
                                        
                                        secondPassed();
                                        
                                        countdownTimer = setInterval( secondPassed, 1000 );
                                } else {
                                        boolGoToLink = false;
                                }
                        }, false );
 
      kIDUnique();
    }, false );
  </script>
</head>
<body>
 
	<a href="https://www.google.fr/" rel="noreferrer noopener" target="_blank">
		<button id="btnClickMe">Google <span id="countDown"></span></button>
	</a>
 
</body>
</html> | 
Partager