{"size": 1051, "ext": "js", "max_stars_repo_path": "js-tp2/exo8.js", "max_stars_repo_name": "ComfortablyDumb/IAW-S2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js-tp2/exo8.js", "max_issues_repo_name": "ComfortablyDumb/IAW-S2", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js-tp2/exo8.js", "max_forks_repo_name": "ComfortablyDumb/IAW-S2", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.4385964912, "max_line_length": 55, "alphanum_fraction": 0.6384395814}

window.onload = function () {

	// le "handler" du setTimeout
	let chrono = null;

	// si 'ok' est 'true', alors l'utilisateur
	// a choisi la bonne réponse
	let ok = false;

	// affiche le message 'm' avec la couleur 'c'
	// dans l'élément prévu à cet effet
	function msg(m, c) {

		let message = document.getElementById("message");
		message.innerHTML = m;
		message.style.color = c;
		

	}

	// cette fonction est appelée à l'issue
	// du setTimeout
	function stop() {
		let checked = false;
		let reponses = document.getElementsByName("reponse");
		for(let reponse of reponses){
			if(reponse.checked){
				verifier(reponse);
				checked = true;

			}
		}
		if(!checked){
			msg("Trop lent","#FF00FF");
		}
		
	}

	// traite le "clic" sur un bouton radio
	function verifier(reponse) {
		if(reponse.value == 60){
			msg("Bonne réponse","green");
		}
		else{
			msg("Mauvaise réponse","red");
			console.log(reponse.value)
		}
		
	}

	// ici, on lance le setTimeout et stocke
	// le "handler" dans la variable 'chrono'
	setTimeout(stop,5000);
	
};
