ECLille - Présentation

Electif Intelligence ambiante

by gwenaelhagenmuller

HTML

<table id="people">
<thead>
    <tr>
	<th>Prénom</th>
	<th>Nom</th>
    <th>OO</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<button id="next">Prochain à se présenter</button>

CSS

#people {
    border-collapse: collapse;
    width: 100%;
    font-family: verdana, helvetica, arial, sans-serif;
}
#people th {
    color: #ffffff;
    background-color: #555555;
    border: 1px solid #555555;
    padding: 3px;
    vertical-align: top;
    text-align: left;
}
#people tr:nth-child(odd) {
    background-color: #f1f1f1;
}
#people tr:nth-child(even) {
    background-color: #ffffff;
}
#next {
    margin-top: 2em;
}
}

JavaScript

var peopleFirstNames = [];
var peopleLastNames = [];
var peopleOO = [];
peopleFirstNames.push("Gwenaël"); peopleLastNames.push("HAGENMULLER"); peopleOO.push(false);
peopleFirstNames.push("Victor"); peopleLastNames.push("CHANAT"); peopleOO.push(false);
peopleFirstNames.push("Alexis"); peopleLastNames.push("CHARVERIAT"); peopleOO.push(false);
peopleFirstNames.push("Juri"); peopleLastNames.push("FEDJAEV"); peopleOO.push(false);
peopleFirstNames.push("Arnaud"); peopleLastNames.push("JEGLOT"); peopleOO.push(false);
peopleFirstNames.push("Maxence"); peopleLastNames.push("LEDUC"); peopleOO.push(false);
peopleFirstNames.push("Victor"); peopleLastNames.push("MANENTI"); peopleOO.push(false);
peopleFirstNames.push("Nicolas"); peopleLastNames.push("MERCIER"); peopleOO.push(false);
peopleFirstNames.push("Vincent"); peopleLastNames.push("RAES"); peopleOO.push(false);
peopleFirstNames.push("Ming Ye"); peopleLastNames.push("WANG"); peopleOO.push(false);
peopleFirstNames.push("Buyun"); peopleLastNames.push("ZHANG"); peopleOO.push(false);

var doneFirstNames = [];
var doneLastNames = [];
var doneOO = [];

// to debug
window.doneFirstNames = doneFirstNames;
window.doneLastNames = doneLastNames;
window.doneOO = doneOO;

var myButton = document.getElementById("next");
var myTable = document.getElementById("people");

myButton.addEventListener("click", function() {
    var where = pickOne(peopleFirstNames);
    var firstName = peopleFirstNames[where];
    var lastName = peopleLastNames[where];
    
    alert(firstName + " " + lastName);
    
    addPersonToTable(firstName, lastName, doneOO.length); 

    peopleFirstNames.splice(where, 1);
    peopleLastNames.splice(where, 1);
    peopleOO.splice(where, 1);
    
    doneFirstNames.push(firstName);
    doneLastNames.push(lastName);
    doneOO.push(false);
    
    if (peopleFirstNames.length == 0) {
        myButton.style.display = "none";
    }
});

function pickOne(anArray) {
    var i = Math.floor(Math.random() * (anArray.length -...