pipo
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
pipo [20/08/2022 11:02] – créée cyrille | pipo [20/08/2022 17:09] (Version actuelle) – typo cyrille | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ====== | + | ====== |
+ | |||
+ | <WRAP center round box 95%> | ||
+ | ---- | ||
< | < | ||
+ | <select id=" | ||
+ | </ | ||
+ | <button id=" | ||
+ | < | ||
+ | <p id=" | ||
+ | <p id=" | ||
+ | </ | ||
< | < | ||
- | alert('hello'); | + | "use strict"; |
+ | /* | ||
+ | https:// | ||
+ | */ | ||
+ | if ( | ||
+ | document.readyState === " | ||
+ | (document.readyState !== " | ||
+ | ) { | ||
+ | pipoInit(); | ||
+ | } else { | ||
+ | document.addEventListener(" | ||
+ | } | ||
+ | |||
+ | var pipos ; | ||
+ | |||
+ | function pipoInit( loaded ) { | ||
+ | |||
+ | if( ! loaded ) | ||
+ | { | ||
+ | const req = new XMLHttpRequest(); | ||
+ | req.addEventListener('load', (a) => { | ||
+ | pipos = JSON.parse( req.responseText ); | ||
+ | pipoInit(true); | ||
+ | } ); | ||
+ | req.open(' | ||
+ | req.send(); | ||
+ | } | ||
+ | |||
+ | var $pipos = document.getElementById(' | ||
+ | var s ; | ||
+ | |||
+ | s = '< | ||
+ | Object.keys(pipos).forEach(item => { | ||
+ | s += '< | ||
+ | }); | ||
+ | $pipos.innerHTML = s ; | ||
+ | |||
+ | document.getElementById(' | ||
+ | s = pipote( $pipos.options[$pipos.selectedIndex].value ); | ||
+ | document.getElementById(' | ||
+ | }); | ||
+ | |||
+ | s = pipote(); | ||
+ | document.getElementById(' | ||
+ | |||
+ | function pipote(pipoName) { | ||
+ | |||
+ | var pipo = ''; | ||
+ | if (!pipoName) { | ||
+ | var names = Object.keys(pipos); | ||
+ | pipoName = names[Math.floor(Math.random() * names.length)]; | ||
+ | } | ||
+ | document.getElementById(' | ||
+ | |||
+ | var parts = []; | ||
+ | pipos[pipoName].forEach(items => | ||
+ | parts.push(items[Math.floor(Math.random() * items.length)]) | ||
+ | ); | ||
+ | // Pour faire une liaison avec ou sans apostrophe " | ||
+ | var aeiouy = [' | ||
+ | var n = parts.length; | ||
+ | parts.forEach((s, | ||
+ | if (i == (n - 1)) { | ||
+ | s += ' | ||
+ | } | ||
+ | else if (s.at(-1) == '#' | ||
+ | if (aeiouy.find(l => l == (parts[i + 1].at(0)).toLowerCase())) { | ||
+ | s = s.substring(0, | ||
+ | } | ||
+ | else { | ||
+ | s = s.substring(0, | ||
+ | } | ||
+ | } | ||
+ | else { | ||
+ | s += ' '; | ||
+ | } | ||
+ | pipo += s; | ||
+ | }); | ||
+ | return pipo; | ||
+ | } | ||
+ | }; | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ---- | ||
+ | </ | ||
+ | |||
+ | Voir/ | ||
+ | |||
+ | <WRAP center round info 60%> | ||
+ | Le pipotron est une invention originale du génial concepteur Yves -> http:// | ||
+ | |||
+ | Une autre adaptation -> http:// | ||
+ | |||
+ | </ | ||
+ |
pipo.1660986177.txt.gz · Dernière modification : 20/08/2022 11:02 de cyrille