{"id":115,"date":"2025-12-17T14:22:31","date_gmt":"2025-12-17T13:22:31","guid":{"rendered":"https:\/\/petanque.albertnet.fr\/?page_id=115"},"modified":"2025-12-17T14:29:43","modified_gmt":"2025-12-17T13:29:43","slug":"test","status":"publish","type":"page","link":"https:\/\/petanque.albertnet.fr\/index.php\/test\/","title":{"rendered":"test"},"content":{"rendered":"<div class=\"et_d4_element et_pb_section et_pb_section_0  et_pb_css_mix_blend_mode et_section_regular et_block_section\" >\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_d4_element et_pb_row et_pb_row_0  et_pb_css_mix_blend_mode et_block_row\">\n\t\t\t\t<div class=\"et_d4_element et_pb_column_4_4 et_pb_column et_pb_column_0  et_pb_css_mix_blend_mode et-last-child et_block_column\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_module et_d4_element et_pb_code et_pb_code_0\">\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t<div class=\"et_pb_code_inner\"><!DOCTYPE html>\n<html lang=\"fr\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Gestionnaire de Tournoi<\/title>\n    <style>\n        body { font-family: sans-serif; max-width: 800px; margin: 20px auto; background: #f4f4f4; }\n        .container { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }\n        .controls { margin-bottom: 20px; display: flex; gap: 10px; }\n        input { padding: 8px; flex-grow: 1; }\n        button { padding: 8px 15px; cursor: pointer; background: #007bff; color: white; border: none; border-radius: 4px; }\n        button:hover { background: #0056b3; }\n        .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }\n        .list-section { border-right: 1px solid #ddd; padding-right: 15px; }\n        .player-item { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #eee; }\n        .team-card { background: #e9ecef; padding: 10px; margin-bottom: 10px; border-radius: 4px; position: relative; }\n        .winner { border: 2px solid #28a745; background: #d4edda; }\n        .delete-btn { color: red; cursor: pointer; font-weight: bold; }\n    <\/style>\n<\/head>\n<body>\n\n<div class=\"container\">\n    <h2>Gestionnaire de P\u00e9tanque \/ Tournoi<\/h2>\n\n    <div class=\"controls\">\n        <input type=\"text\" id=\"playerInput\" placeholder=\"Nom du joueur...\" onkeypress=\"if(event.key === 'Enter') addPlayer()\">\n        <button onclick=\"addPlayer()\">Ajouter<\/button>\n        <button onclick=\"drawTeams()\" style=\"background: #28a745;\">Tirage au Sort<\/button>\n    <\/div>\n\n    <div class=\"grid\">\n        <div class=\"list-section\">\n            <h3>Joueurs (<span id=\"count\">0<\/span>)<\/h3>\n            <div id=\"playerList\"><\/div>\n        <\/div>\n\n        <div>\n            <h3>\u00c9quipes<\/h3>\n            <div id=\"teamsDisplay\"><\/div>\n        <\/div>\n    <\/div>\n<\/div>\n\n<script>\n\/* ===============================\n   DONN\u00c9ES & LOGIQUE\n================================ *\/\n\nlet players = [\n    { id: 1, name: \"Yves LABAT\" }, { id: 2, name: \"Vincent GROSSELLE\" },\n    { id: 3, name: \"Guy LAFFAURE\" }, { id: 4, name: \"Charles LORENTE\" },\n    { id: 5, name: \"Wesley MAILLE\" }, { id: 6, name: \"Andr\u00e9 DENAYROUZE\" },\n    { id: 7, name: \"Remi STANDAERT\" }, { id: 8, name: \"Didier PESLIER\" },\n    { id: 9, name: \"Jean Marie ROUSSET\" }, { id: 10, name: \"G\u00e9rard TROGNO\" }\n    \/\/ ... (J'ai raccourci pour l'exemple, mais vous pouvez remettre votre liste compl\u00e8te)\n];\n\nlet playerCounter = 11;\nlet teams = [];\nlet winnerIndices = [];\n\nfunction shuffle(array) {\n    return array.map(a => ({ sort: Math.random(), value: a }))\n                .sort((a, b) => a.sort - b.sort)\n                .map(a => a.value);\n}\n\nfunction addPlayer() {\n    const input = document.getElementById('playerInput');\n    const name = input.value.trim();\n    if (!name) return;\n\n    players.push({ id: playerCounter++, name });\n    input.value = '';\n    render();\n}\n\nfunction removePlayer(id) {\n    players = players.filter(p => p.id !== id);\n    teams = []; \/\/ On r\u00e9initialise les \u00e9quipes si la liste change\n    render();\n}\n\nfunction drawTeams() {\n    if (players.length < 2) {\n        alert(\"Il faut au moins 2 joueurs !\");\n        return;\n    }\n\n    let shuffled = shuffle([...players]);\n    teams = [];\n    winnerIndices = [];\n\n    \/\/ Logique pour cr\u00e9er des bin\u00f4mes (et g\u00e9rer le cas de 3 joueurs restants)\n    while (shuffled.length > 0) {\n        if (shuffled.length === 3) {\n            teams.push(shuffled.splice(0, 3)); \/\/ Un triplet si impair\n        } else {\n            teams.push(shuffled.splice(0, 2)); \/\/ Un duo\n        }\n    }\n    render();\n}\n\nfunction toggleWinner(index) {\n    const i = winnerIndices.indexOf(index);\n    if (i === -1) winnerIndices.push(index);\n    else winnerIndices.splice(i, 1);\n    render();\n}\n\n\/* ===============================\n   AFFICHAGE (RENDER)\n================================ *\/\n\nfunction render() {\n    \/\/ 1. Afficher la liste des joueurs\n    const playerList = document.getElementById('playerList');\n    document.getElementById('count').innerText = players.length;\n    playerList.innerHTML = players.map(p => `\n        <div class=\"player-item\">\n            ${p.name} \n            <span class=\"delete-btn\" onclick=\"removePlayer(${p.id})\">\u2715<\/span>\n        <\/div>\n    `).join('');\n\n    \/\/ 2. Afficher les \u00e9quipes\n    const teamsDisplay = document.getElementById('teamsDisplay');\n    teamsDisplay.innerHTML = teams.map((team, index) => {\n        const isWinner = winnerIndices.includes(index);\n        return `\n            <div class=\"team-card ${isWinner ? 'winner' : ''}\" onclick=\"toggleWinner(${index})\">\n                <strong>\u00c9quipe ${index + 1}<\/strong><br \/>\n                ${team.map(p => p.name).join(' & ')}\n                ${isWinner ? ' \u2b50' : ''}\n            <\/div>\n        `;\n    }).join('');\n}\n\n\/\/ Premier affichage au chargement\nrender();\n<\/script>\n\n<\/body>\n<\/html><\/div>\n\t\t\t<\/div>\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\t\n\t\t\t\t\n\t\t\t<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-115","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/pages\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":5,"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/pages\/115\/revisions"}],"predecessor-version":[{"id":120,"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/pages\/115\/revisions\/120"}],"wp:attachment":[{"href":"https:\/\/petanque.albertnet.fr\/index.php\/wp-json\/wp\/v2\/media?parent=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}