nb mot a generer variable
This commit is contained in:
parent
4755395c21
commit
81deece11d
BIN
FUSION.apk
BIN
FUSION.apk
Binary file not shown.
53
index.html
53
index.html
|
@ -68,14 +68,18 @@
|
||||||
font-size: 4rem;
|
font-size: 4rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#nb_input {
|
||||||
|
width: 3rem;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>FUSION</h1>
|
<h1>FUSION</h1>
|
||||||
<p>Trouvez l'inspiration et les idées pour vos projets grâce au subtil mélange de deux mots aléatoires.</p>
|
<p>Trouvez l'inspiration et les idées pour vos projets grâce au subtil mélange de deux mots aléatoires.</p>
|
||||||
|
<p>Nombre de mots a générer : <input id="nb_input" type="number" min="1"></p>
|
||||||
<main>
|
<main>
|
||||||
<input type="text" disabled value="tpust" />
|
<input type="text" disabled value="tpust" />
|
||||||
<br>
|
|
||||||
<input type="text" disabled value="tpust" />
|
<input type="text" disabled value="tpust" />
|
||||||
<br>
|
<br>
|
||||||
<button onclick="generer()">Générer</button>
|
<button onclick="generer()">Générer</button>
|
||||||
|
@ -106,14 +110,49 @@
|
||||||
"création", "imaginaire", "four", "bois", "hélicoptère", "repos", "repas", "nourriture", "cuisiner", "couper", "ego", "surpasser", "super",
|
"création", "imaginaire", "four", "bois", "hélicoptère", "repos", "repas", "nourriture", "cuisiner", "couper", "ego", "surpasser", "super",
|
||||||
"flamme", "enfant", "sauver", "programme", "voleur", "banque", "gouverner", "famille", "groupe", "coopérer", "police", "armée", "tank", "avion",
|
"flamme", "enfant", "sauver", "programme", "voleur", "banque", "gouverner", "famille", "groupe", "coopérer", "police", "armée", "tank", "avion",
|
||||||
"chasse", "pêche", "science", "mouvement", "statue", "créature", "son", "bureau", "travail", "mythologie", "livre", "feuille", "artifice", "explosion",
|
"chasse", "pêche", "science", "mouvement", "statue", "créature", "son", "bureau", "travail", "mythologie", "livre", "feuille", "artifice", "explosion",
|
||||||
|
// Le D
|
||||||
|
"effondrement ", "empreinte", "fragile", "horizon", "blessure", "otage", "tapis", "inspecter", "copie", "fraction", "siamois", "arome", "cible",
|
||||||
|
"rivage", "relation", "harem", "mutation", "cadre", "loup", "effacer", "cavalier", "religion", "hallucination", "faux", "bocal", "ancien", "ancêtre",
|
||||||
|
"transport", "verre",
|
||||||
];
|
];
|
||||||
|
|
||||||
function generer() {
|
var nbInput = document.getElementById("nb_input");
|
||||||
var inputs = document.getElementsByTagName("input");
|
nbInput.value = 2;
|
||||||
inputs[0].value = mots[Math.floor(Math.random() * mots.length)];
|
nbInput.onchange = (state) => {
|
||||||
do {
|
var val = nbInput.value;
|
||||||
inputs[1].value = mots[Math.floor(Math.random() * mots.length)];
|
var inputs = document.getElementsByTagName("main")[0].getElementsByTagName("input");
|
||||||
} while (inputs[1].value == inputs[0].value);
|
if (val < 1) {
|
||||||
|
val = 1;
|
||||||
|
nbInput.value = 1;
|
||||||
|
}
|
||||||
|
if (val > inputs.length)
|
||||||
|
addInput(inputs, val - inputs.length);
|
||||||
|
else if (val < inputs.length)
|
||||||
|
removeInput(inputs, inputs.length - val);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeInput(inputs, n) {
|
||||||
|
for (let i=0; i<n; i++) {
|
||||||
|
inputs[inputs.length-1].remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addInput(inputs, n) {
|
||||||
|
var begin = inputs.length;
|
||||||
|
for (let i=0; i<n; i++) {
|
||||||
|
inputs[inputs.length-1].insertAdjacentHTML("afterend", '<input type="text" disabled="disabled">');
|
||||||
|
}
|
||||||
|
generer(begin);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generer(begin = 0) {
|
||||||
|
var inputs = document.getElementsByTagName("main")[0].getElementsByTagName("input");
|
||||||
|
inputs[begin].value = mots[Math.floor(Math.random() * mots.length)];
|
||||||
|
for (let i=begin+1; i<inputs.length; i++) {
|
||||||
|
do {
|
||||||
|
inputs[i].value = mots[Math.floor(Math.random() * mots.length)];
|
||||||
|
} while (inputs[i].value == inputs[i-1].value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
generer();
|
generer();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue