synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
22
README.md
22
README.md
@@ -1,3 +1,21 @@
|
|||||||
# ploxion-survie
|
# ⛺ Survie
|
||||||
|
|
||||||
PLOXION · Planifier une expédition nature/forêt et être PRÊT, offline : check-list générée, calcul eau + nourriture (est-ce assez ? = jauge de certitude), fiches savoir-faire (abris, feu), exercices/wargames. Le xerboxion = plus de certitude. · fournit: survie, expedition, checklist, offline
|
Planifier une expédition nature/forêt et être PRÊT, offline : check-list générée, calcul eau + nourriture (est-ce assez ? = jauge de certitude), fiches savoir-faire (abris, feu), exercices/wargames. Le xerboxion = plus de certitude.
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `survie` |
|
||||||
|
| fournit | `survie` `expedition` `checklist` `offline` |
|
||||||
|
| bions qu'il nomme | `jOSApps` `jOSBoxion` `jOSGame` `jOSXui` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/survie/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=survie — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre survie` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
|
||||||
|
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
|
||||||
|
|
||||||
|
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
|
||||||
|
|
||||||
|
© 2026 chill-tekk · ne pas nuire
|
||||||
|
|||||||
519
app.blade.php
Normal file
519
app.blade.php
Normal file
@@ -0,0 +1,519 @@
|
|||||||
|
{{-- PL0XI0N survie — SURVIE 🏕️ : planifier ton expédition nature/forêt AVEC CERTITUDE.
|
||||||
|
1) Planificateur d'expédition (nom, lieu, dates, personnes, saison, type) → check-list
|
||||||
|
auto-générée (abri, couchage, eau, feu, bouffe, habits, navigation, secours, outils…).
|
||||||
|
2) CALCULATEUR DE CERTITUDE (le cœur) : eau (2-3 L/pers/jour + cuisine), bouffe (kcal selon
|
||||||
|
effort 2200-3500, aliments courants embarqués kcal/100g), poids du sac vs 20% du poids
|
||||||
|
corporel → verdict « CERTITUDE : XX% » + le détail de ce qui manque.
|
||||||
|
3) Shelter : 5 fiches abri illustrées SVG (tarp A-frame, lean-to, hamac+tarp, débris hut,
|
||||||
|
abri neige) + matériaux improvisables.
|
||||||
|
4) Survie de base : règle des 3, priorités, signalisation, eau potable, hypothermie (b.a.-ba
|
||||||
|
reconnu, zéro invention médicale). 5) Wargames = placeholder v2 (RS-7 feede solo/groupe).
|
||||||
|
100% offline-first : base embarquée, zéro fetch bloquant ; état jOSBoxion ns='survie'
|
||||||
|
+ fallback localStorage ; tsoin à la création (file locale rejouée si hors-ligne).
|
||||||
|
window.jOSApps['survie']. mount(container, ctx) -> { unmount }. --}}
|
||||||
|
<style>
|
||||||
|
.srv{display:flex;flex-direction:column;height:100%;background:var(--xr-bg,#080a12);color:var(--xr-text,#e9eef7);font-family:ui-sans-serif,system-ui,sans-serif;font-size:.88rem;overflow:hidden}
|
||||||
|
.srv__tabs{flex:0 0 auto;display:flex;gap:6px;padding:9px 10px;overflow-x:auto;border-bottom:1px solid var(--xr-border,rgba(120,200,150,.25));background:var(--xr-surface,rgba(10,14,12,.9));position:sticky;top:0;z-index:3;-webkit-overflow-scrolling:touch}
|
||||||
|
.srv__tab{cursor:pointer;white-space:nowrap;font-size:.8rem;min-height:44px;display:inline-flex;align-items:center;padding:0 14px;border-radius:11px;border:1px solid var(--xr-border,rgba(120,200,150,.3));background:rgba(30,60,40,.3);color:var(--xr-text,#d6f0dd)}
|
||||||
|
.srv__tab.on{background:var(--xr-accent,#37c871);color:#04160a;border-color:var(--xr-accent,#37c871);font-weight:700}
|
||||||
|
.srv__pane{flex:1;min-height:0;overflow:auto;padding:12px 12px 60px;-webkit-overflow-scrolling:touch}
|
||||||
|
.srv__card{background:var(--xr-surface,rgba(16,24,19,.75));border:1px solid var(--xr-border,rgba(120,200,150,.2));border-radius:14px;padding:14px;margin:0 auto 12px;max-width:680px}
|
||||||
|
.srv__h{font-size:1rem;font-weight:700;margin:0 0 8px;color:var(--xr-accent,#6fe3a0)}
|
||||||
|
.srv__lbl{display:block;font-size:.66rem;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--xr-muted,#8fb99d);margin:10px 0 4px}
|
||||||
|
.srv__in,.srv__sel{width:100%;box-sizing:border-box;min-height:44px;padding:8px 12px;border-radius:10px;border:1px solid var(--xr-border,rgba(120,200,150,.3));background:rgba(8,14,10,.8);color:inherit;font:inherit}
|
||||||
|
.srv__in:focus,.srv__sel:focus{outline:none;border-color:var(--xr-accent,#37c871)}
|
||||||
|
.srv__row{display:flex;gap:8px}.srv__row>*{flex:1;min-width:0}
|
||||||
|
.srv__btn{cursor:pointer;min-height:48px;width:100%;border:none;border-radius:12px;background:var(--xr-accent,#37c871);color:#04160a;font-size:.95rem;font-weight:800;margin-top:14px}
|
||||||
|
.srv__btn:active{transform:scale(.98)}
|
||||||
|
.srv__ghost{cursor:pointer;min-height:44px;border-radius:10px;border:1px solid var(--xr-border,rgba(120,200,150,.35));background:rgba(30,60,40,.25);color:var(--xr-text,#d6f0dd);padding:0 14px;font:inherit}
|
||||||
|
.srv__exp{cursor:pointer;display:flex;align-items:center;gap:10px;padding:12px;border-radius:12px;border:1px solid var(--xr-border,rgba(120,200,150,.2));background:rgba(16,24,19,.6);margin-bottom:8px;min-height:56px}
|
||||||
|
.srv__exp:active{background:rgba(55,200,113,.12)}
|
||||||
|
.srv__exp .srv .e{font-size:1.5rem}.srv__exp .srv .n{flex:1;min-width:0}.srv__exp .n b{display:block}.srv__exp .n span{font-size:.72rem;color:var(--xr-muted,#8fb99d)}
|
||||||
|
.srv__badge{flex:0 0 auto;font-weight:800;font-size:.86rem;padding:6px 10px;border-radius:9px;background:rgba(0,0,0,.3)}
|
||||||
|
.srv__back{cursor:pointer;background:none;border:none;color:var(--xr-accent,#6fe3a0);font-size:.86rem;padding:10px 0;min-height:44px}
|
||||||
|
.c-ok{color:#3ddc84}.c-warn{color:#ffb347}.c-bad{color:#ff5d5d}
|
||||||
|
.b-ok{background:#3ddc84}.b-warn{background:#ffb347}.b-bad{background:#ff5d5d}
|
||||||
|
.srv__big{font-size:1.9rem;font-weight:900;letter-spacing:.02em}
|
||||||
|
.srv__bar{height:10px;border-radius:6px;background:rgba(255,255,255,.09);overflow:hidden;margin:5px 0 2px}
|
||||||
|
.srv__bar i{display:block;height:100%;border-radius:6px}
|
||||||
|
.srv__gr{margin:10px 0}.srv__gr .t{display:flex;justify-content:space-between;font-size:.8rem;gap:8px}
|
||||||
|
.srv__miss{margin:10px 0 0;padding:10px 12px;border-radius:10px;background:rgba(255,93,93,.08);border:1px solid rgba(255,93,93,.25);font-size:.82rem;line-height:1.6}
|
||||||
|
.srv__miss.ok{background:rgba(61,220,132,.08);border-color:rgba(61,220,132,.3)}
|
||||||
|
.srv__cat{font-size:.68rem;font-weight:800;text-transform:uppercase;letter-spacing:.06em;color:var(--xr-accent,#6fe3a0);margin:14px 0 4px}
|
||||||
|
.srv__it{display:flex;align-items:center;gap:10px;min-height:48px;padding:2px 4px;border-bottom:1px solid rgba(255,255,255,.05)}
|
||||||
|
.srv__it input[type=checkbox]{width:24px;height:24px;flex:0 0 auto;accent-color:var(--xr-accent,#37c871)}
|
||||||
|
.srv__it .srv .l{flex:1;min-width:0;line-height:1.3}.srv__it .l small{color:var(--xr-muted,#8fb99d)}
|
||||||
|
.srv__it.done .srv .l{opacity:.5;text-decoration:line-through}
|
||||||
|
.srv__x{cursor:pointer;flex:0 0 auto;width:40px;height:40px;border:none;background:none;color:#f88;font-size:1.05rem;border-radius:8px}
|
||||||
|
.srv__food{display:flex;align-items:center;gap:8px;min-height:44px;border-bottom:1px solid rgba(255,255,255,.05);font-size:.84rem}
|
||||||
|
.srv__food .srv .l{flex:1;min-width:0}
|
||||||
|
.srv__note{font-size:.76rem;color:var(--xr-muted,#9dc3aa);line-height:1.5;margin-top:6px}
|
||||||
|
.srv__svg{display:block;width:100%;max-width:340px;margin:6px auto;color:var(--xr-accent,#6fe3a0)}
|
||||||
|
.srv__steps{margin:8px 0 0;padding-left:0;list-style:none;counter-reset:st}
|
||||||
|
.srv__steps li{counter-increment:st;position:relative;padding:6px 0 6px 34px;line-height:1.5}
|
||||||
|
.srv__steps li::before{content:counter(st);position:absolute;left:0;top:6px;width:22px;height:22px;border-radius:50%;background:var(--xr-accent,#37c871);color:#04160a;font-weight:800;font-size:.74rem;display:flex;align-items:center;justify-content:center}
|
||||||
|
.srv__tagrow{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
|
||||||
|
.srv__tag{font-size:.74rem;padding:5px 10px;border-radius:16px;background:rgba(120,200,150,.12);border:1px solid rgba(120,200,150,.3)}
|
||||||
|
.srv__rule{display:flex;gap:10px;align-items:baseline;padding:6px 0;border-bottom:1px solid rgba(255,255,255,.05)}
|
||||||
|
.srv__rule b{flex:0 0 74px;color:var(--xr-accent,#6fe3a0)}
|
||||||
|
.srv__soon{text-align:center;color:var(--xr-muted,#9dc3aa);line-height:1.8;padding:34px 16px}
|
||||||
|
.srv__del{cursor:pointer;margin-top:16px;background:none;border:1px solid rgba(255,120,120,.35);color:#f99;border-radius:10px;padding:10px 14px;min-height:44px;font:inherit;width:100%;max-width:680px;display:block;margin-left:auto;margin-right:auto}
|
||||||
|
@media (min-width:760px){ .srv__pane{padding:16px 20px 60px} }
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
var ID='survie', NS='survie';
|
||||||
|
var LK='xb:survie:exps', QK='xb:survie:tsoinq';
|
||||||
|
|
||||||
|
function esc(s){ if(window.jOSb&&window.jOSb.esc) return window.jOSb.esc(s); var d=document.createElement('div'); d.textContent=(s==null?'':s); return d.innerHTML; }
|
||||||
|
var seq=0;
|
||||||
|
function uid(){ return 's'+Date.now().toString(36)+(seq++).toString(36); }
|
||||||
|
|
||||||
|
var TYPES=[
|
||||||
|
{k:'jour', e:'🥾', l:'Rando à la journée'},
|
||||||
|
{k:'bivouac',e:'⛺', l:'Bivouac (tente / sursac)'},
|
||||||
|
{k:'trek', e:'🎒', l:'Trek multi-jours'},
|
||||||
|
{k:'hamac', e:'🌲', l:'Hamac + tarp'},
|
||||||
|
{k:'hiver', e:'❄️', l:'Sortie hiver / neige'}
|
||||||
|
];
|
||||||
|
var TMAP={}; TYPES.forEach(function(t){ TMAP[t.k]=t; });
|
||||||
|
var SAISONS=[ {k:'ete',l:'Été'}, {k:'misaison',l:'Printemps / automne'}, {k:'hiver',l:'Hiver'} ];
|
||||||
|
|
||||||
|
// aliments courants embarqués — kcal / 100 g (valeurs usuelles, offline)
|
||||||
|
var FOODS=[
|
||||||
|
{k:'riz',l:'Riz (sec)',kcal:350},{k:'pates',l:'Pâtes (sèches)',kcal:370},
|
||||||
|
{k:'flocons',l:'Flocons d\'avoine',kcal:370},{k:'semoule',l:'Semoule / couscous',kcal:360},
|
||||||
|
{k:'lyo',l:'Repas lyophilisé',kcal:400},{k:'fruitssecs',l:'Fruits secs (raisins, abricots)',kcal:300},
|
||||||
|
{k:'noix',l:'Noix / amandes',kcal:620},{k:'choco',l:'Chocolat',kcal:550},
|
||||||
|
{k:'barres',l:'Barres de céréales',kcal:450},{k:'saucisson',l:'Saucisson',kcal:410},
|
||||||
|
{k:'fromage',l:'Fromage à pâte dure',kcal:390},{k:'pain',l:'Pain',kcal:260},
|
||||||
|
{k:'conserve',l:'Conserve (raviolis, thon…)',kcal:110},{k:'soupe',l:'Soupe instantanée',kcal:340},
|
||||||
|
{k:'beurrepc',l:'Beurre de cacahuète',kcal:590},{k:'puree',l:'Purée en flocons',kcal:355}
|
||||||
|
];
|
||||||
|
var FMAP={}; FOODS.forEach(function(f){ FMAP[f.k]=f; });
|
||||||
|
|
||||||
|
// ---------- check-list auto-générée selon type + saison + durée ----------
|
||||||
|
function genGear(exp){
|
||||||
|
var t=exp.type, s=exp.saison, out=[];
|
||||||
|
var multi=(t!=='jour');
|
||||||
|
function it(cat,l,w,ess){ out.push({id:uid(),cat:cat,l:l,w:w||0,ess:ess?1:0,done:0}); }
|
||||||
|
it('Portage','Sac à dos '+(multi?'45-60 L':'20-30 L')+' + housse pluie', multi?1800:900,1);
|
||||||
|
if(t==='hamac'){ it('Abri','Hamac + suspentes',800,1); it('Abri','Tarp + cordelettes',700,1); it('Abri','Isolation sous le hamac (underquilt / matelas)',900, s==='ete'?0:1); }
|
||||||
|
else if(t==='bivouac'){ it('Abri','Tente légère OU sursac (bivy)',1900,1); it('Abri','Tarp d\'appoint (pluie)',700,0); }
|
||||||
|
else if(t==='trek'||t==='hiver'){ it('Abri','Tente + sardines + arceaux',2500,1); }
|
||||||
|
else { it('Abri','Poncho / abri d\'urgence léger',350,1); }
|
||||||
|
if(multi){
|
||||||
|
var temp=(s==='hiver'?'-10 °C':(s==='misaison'?'0 °C':'+10 °C'));
|
||||||
|
it('Couchage','Sac de couchage (confort '+temp+')', s==='hiver'?2000:(s==='misaison'?1500:1100),1);
|
||||||
|
it('Couchage','Matelas isolant'+(s==='hiver'?' (R ≥ 4)':''),500,1);
|
||||||
|
}
|
||||||
|
it('Eau','Gourdes / poche à eau (capacité = voir calcul 💧)',250,1);
|
||||||
|
it('Eau','Filtre à eau OU pastilles purifiantes',120,1);
|
||||||
|
it('Feu','Briquet ×2 (dans 2 poches différentes)',40,1);
|
||||||
|
it('Feu','Allume-feu (coton vaseliné, pastilles…)',60, multi?1:0);
|
||||||
|
if(multi){ it('Cuisine','Réchaud + cartouche',450,1); it('Cuisine','Popote + cuillère',320,1); }
|
||||||
|
it('Bouffe','Rations (couverture = voir calcul 🍚)',0,1);
|
||||||
|
it('Bouffe','Snacks d\'effort accessibles en marchant',200,0);
|
||||||
|
it('Habits','Couche de base respirante (pas de coton)',250,1);
|
||||||
|
it('Habits','Isolation : polaire / doudoune', s==='ete'?350:600,1);
|
||||||
|
it('Habits','Veste imperméable',350,1);
|
||||||
|
if(s!=='ete'){ it('Habits','Bonnet + gants',150,1); }
|
||||||
|
if(t==='hiver'||s==='hiver'){ it('Habits','Pantalon chaud + guêtres',600,1); it('Habits','2e paire de gants (au sec)',120,0); }
|
||||||
|
if(multi){ it('Habits','Chaussettes de rechange',80,1); }
|
||||||
|
it('Navigation','Carte papier + boussole',150,1);
|
||||||
|
it('Navigation','Frontale + piles de rechange',120,1);
|
||||||
|
it('Secours','Trousse de premiers secours',250,1);
|
||||||
|
it('Secours','Couverture de survie',60,1);
|
||||||
|
it('Secours','Sifflet',10,1);
|
||||||
|
it('Outils','Couteau',150,1);
|
||||||
|
it('Outils','Paracorde 10-15 m',100, (t==='hamac'||multi)?1:0);
|
||||||
|
if(t==='trek'||t==='hamac'){ it('Outils','Scie pliante (bois d\'abri / de feu)',200,0); }
|
||||||
|
it('Hygiène','PQ + sacs poubelle (tout redescend)',100,1);
|
||||||
|
if(multi){ it('Hygiène','Brosse à dents + mini savon',60,0); }
|
||||||
|
it('Énergie','Téléphone chargé + mode avion',0,1);
|
||||||
|
if(multi){ it('Énergie','Batterie externe + câble',250,1); }
|
||||||
|
it('Papiers','ID + cash + numéros d\'urgence (112 / REGA 1414)',50,1);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- LE CALCULATEUR DE CERTITUDE ----------
|
||||||
|
function days(exp){
|
||||||
|
if(exp.type==='jour') return 1;
|
||||||
|
try{
|
||||||
|
var a=new Date(exp.du+'T12:00:00').getTime(), b=new Date(exp.au+'T12:00:00').getTime();
|
||||||
|
if(isNaN(a)||isNaN(b)||b<a) return 1;
|
||||||
|
return Math.max(1, Math.round((b-a)/864e5)+1);
|
||||||
|
}catch(e){ return 1; }
|
||||||
|
}
|
||||||
|
function calc(exp){
|
||||||
|
var d=days(exp), p=Math.max(1, exp.people|0);
|
||||||
|
var perDay=exp.effortEau?3:2; // 2 L base, 3 L effort / chaleur
|
||||||
|
var eauBesoin=p*d*perDay + (exp.type!=='jour'? d*0.5 : 0); // + cuisine 0.5 L/jour
|
||||||
|
var eauA=Math.max(0,+exp.eauL||0);
|
||||||
|
var eauCov=eauBesoin>0? Math.round(eauA/eauBesoin*100) : 100;
|
||||||
|
var kcalJ=(exp.effort==='intense')?3500:((exp.effort==='leger')?2200:2800);
|
||||||
|
var kcalBesoin=p*d*kcalJ, kcalA=0, foodG=0;
|
||||||
|
(exp.food||[]).forEach(function(f){
|
||||||
|
var per=(f.k==='perso')?(+f.kcal||0):((FMAP[f.k]||{}).kcal||0);
|
||||||
|
kcalA+=(+f.g||0)*per/100; foodG+=(+f.g||0);
|
||||||
|
});
|
||||||
|
kcalA=Math.round(kcalA);
|
||||||
|
var kcalCov=kcalBesoin>0? Math.round(kcalA/kcalBesoin*100) : 100;
|
||||||
|
var gearG=0, essT=0, essD=0, hasEauSecu=false;
|
||||||
|
(exp.gear||[]).forEach(function(g){
|
||||||
|
gearG+=(+g.w||0);
|
||||||
|
if(g.ess){ essT++; if(g.done) essD++; }
|
||||||
|
if(g.cat==='Eau' && /filtre|pastille/i.test(g.l||'') && g.done) hasEauSecu=true;
|
||||||
|
});
|
||||||
|
var essCov=essT?Math.round(essD/essT*100):100;
|
||||||
|
var totalG=gearG + eauA*1000 + foodG;
|
||||||
|
var limitG=Math.max(1,(+exp.poids||75))*1000*0.20; // règle : sac ≤ 20% du poids corporel
|
||||||
|
var wScore=totalG<=limitG?100:(totalG<=limitG*1.1?50:0);
|
||||||
|
var cert=Math.round(Math.min(100,eauCov)*0.35 + Math.min(100,kcalCov)*0.35 + essCov*0.20 + wScore*0.10);
|
||||||
|
return { d:d,p:p, eauBesoin:eauBesoin,eauA:eauA,eauCov:eauCov,
|
||||||
|
kcalBesoin:kcalBesoin,kcalA:kcalA,kcalCov:kcalCov,
|
||||||
|
essT:essT,essD:essD,essCov:essCov, totalG:totalG,limitG:limitG,wOk:totalG<=limitG,
|
||||||
|
hasEauSecu:hasEauSecu, cert:cert };
|
||||||
|
}
|
||||||
|
function tone(cov){ return cov>=100?'ok':(cov>=70?'warn':'bad'); }
|
||||||
|
function fmtL(n){ var s=n.toFixed(1); return (s.slice(-2)==='.0')?s.slice(0,-2):s; }
|
||||||
|
|
||||||
|
// ---------- fiches SHELTER (SVG simples, offline) ----------
|
||||||
|
var SVGA='<svg class="srv__svg" viewBox="0 0 200 100" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round">';
|
||||||
|
var SVGZ='<'+'/svg>';
|
||||||
|
var SHELTERS=[
|
||||||
|
{e:'⛺',l:'Tarp A-frame',why:'Le plus rapide et polyvalent : bonne protection pluie + vent des deux côtés.',
|
||||||
|
svg:SVGA+'<line x1="20" y1="14" x2="20" y2="88"/><line x1="180" y1="14" x2="180" y2="88"/><line x1="20" y1="30" x2="180" y2="30" stroke-dasharray="5 5"/><path d="M100 30 L62 86 M100 30 L138 86"/><line x1="6" y1="88" x2="194" y2="88"/>'+SVGZ,
|
||||||
|
steps:['Tends une corde (faîtière) entre 2 arbres, à hauteur de hanche/poitrine.','Pose le tarp par-dessus, à cheval sur la corde, moitié de chaque côté.','Tends les 4 coins vers le sol avec cordelettes + piquets (ou pierres).','Oriente le dos au vent ; au sol : matelas ou couche de feuillage sec.']},
|
||||||
|
{e:'🛖',l:'Lean-to (appentis)',why:'Un seul pan incliné : ouvert d\'un côté, parfait avec un feu devant.',
|
||||||
|
svg:SVGA+'<line x1="40" y1="20" x2="40" y2="88"/><line x1="40" y1="26" x2="150" y2="86"/><line x1="40" y1="26" x2="92" y2="26" stroke-dasharray="5 5"/><line x1="6" y1="88" x2="194" y2="88"/><path d="M166 72 q7 -13 0 -22" stroke-width="2"/>'+SVGZ,
|
||||||
|
steps:['Fixe une perche horizontale entre 2 supports (arbres, trépieds).','Appuie le tarp (ou des branches serrées) en pente depuis la perche jusqu\'au sol.','Ancre le bas au sol (piquets, pierres, bûche).','Dos au vent ; le feu se fait devant l\'ouverture, à distance sûre.']},
|
||||||
|
{e:'🌲',l:'Hamac + tarp',why:'Hors du sol (humidité, cailloux) — mais isole-toi du froid PAR-DESSOUS.',
|
||||||
|
svg:SVGA+'<line x1="28" y1="10" x2="28" y2="88"/><line x1="172" y1="10" x2="172" y2="88"/><path d="M40 56 C 80 78 120 78 160 56"/><path d="M36 26 L100 14 L164 26"/><line x1="6" y1="88" x2="194" y2="88"/>'+SVGZ,
|
||||||
|
steps:['Choisis 2 arbres sains, espacés de 3-4 m.','Accroche le hamac avec un angle de suspente d\'environ 30°.','Tends le tarp au-dessus, en faîtière, débordant bien du hamac.','Isolation sous le corps (underquilt ou matelas DANS le hamac) : indispensable dès qu\'il fait frais.']},
|
||||||
|
{e:'🍂',l:'Débris hut (hutte de débris)',why:'Sans matériel : structure de branches + gros tas de débris isolants. Long à faire, mais chaud.',
|
||||||
|
svg:SVGA+'<path d="M18 86 L140 34 L140 86"/><path d="M52 74 L60 86 M78 62 L92 86 M104 52 L122 86"/><path d="M30 84 q10 -6 18 0 M62 82 q10 -6 18 0 M98 80 q10 -6 18 0" stroke-width="2"/><line x1="6" y1="88" x2="194" y2="88"/>'+SVGZ,
|
||||||
|
steps:['Pose une perche faîtière du sol jusqu\'à un support (fourche, souche) à hauteur de hanche.','Appuie des côtes (branches) des deux côtés, serrées, en laissant une petite entrée.','Recouvre de 40-60 cm de débris secs (feuilles, fougères, mousse) — plus c\'est épais, plus c\'est chaud.','Remplis aussi l\'intérieur de feuilles sèches : tu dors DEDANS, pas sur le sol nu.','Bouche l\'entrée derrière toi (sac, tas de feuilles).']},
|
||||||
|
{e:'❄️',l:'Abri neige (tranchée couverte)',why:'La neige isole. La tranchée couverte = l\'abri neige le plus simple et le plus sûr à faire seul.',
|
||||||
|
svg:SVGA+'<path d="M6 88 L60 88 L60 56 L140 56 L140 88 L194 88"/><path d="M56 56 L100 36 L144 56"/><path d="M70 72 h60" stroke-dasharray="4 5" stroke-width="2"/>'+SVGZ,
|
||||||
|
steps:['Creuse une tranchée d\'environ 1 m de profondeur, à ta taille (pelle, raquette, gamelle).','Couvre : bâtons/skis + tarp (ou blocs de neige posés en toit), lesté de neige sur les bords.','Isole le fond : matelas, sac, branches de sapin — jamais à même la neige.','Garde une petite ouverture d\'aération ; marque l\'abri (bâton visible).']}
|
||||||
|
];
|
||||||
|
var IMPRO=['Bâche / poncho / couverture de survie','Branches mortes droites (perches, côtes)','Feuillage, fougères, mousse (isolation)','Cordage : paracorde, lacets, sangles de sac','Mur naturel : rocher, tronc couché, talus','Neige compacte (blocs, tranchée)'];
|
||||||
|
|
||||||
|
// ---------- fiches SURVIE DE BASE (b.a.-ba reconnu) ----------
|
||||||
|
function survieHtml(){
|
||||||
|
var h='';
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">3️⃣ La règle des 3</div>';
|
||||||
|
h+='<div class="srv__rule"><b>3 min</b><span>sans air — dégage d\'abord tout danger immédiat (avalanche, eau, fumée).</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>3 h</b><span>sans abri par conditions extrêmes (froid, vent, pluie) — l\'abri et le sec passent AVANT tout.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>3 jours</b><span>sans eau — trouve, filtre, purifie.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>3 sem</b><span>sans nourriture — la bouffe est la DERNIÈRE priorité en urgence.</span></div>';
|
||||||
|
h+='<div class="srv__note">Ordre des priorités en situation réelle : 1. sécurité + abri/chaleur → 2. signalisation → 3. eau → 4. feu → 5. nourriture. Avant d\'agir : STOP — S\'asseoir, Te calmer, Observer, Planifier.</div></div>';
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">📣 Signalisation</div>';
|
||||||
|
h+='<div class="srv__rule"><b>3 ×</b><span><b>3 signaux répétés = détresse</b> : 3 coups de sifflet, 3 cris, 3 flashs de frontale — pause — recommence.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>🪞</b><span>Miroir / écran de téléphone au soleil : vise l\'avion ou l\'hélico entre deux doigts tendus.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>📞</b><span><b>112</b> (urgence européenne) · <b>1414 REGA</b> (secours héliportés, Suisse). Donne : position, nombre de personnes, état.</span></div>';
|
||||||
|
h+='<div class="srv__note">Reste visible : terrain dégagé, couleurs vives, couverture de survie côté brillant. Si tu es perdu et que tu as signalé ta position : ne bouge plus, on te cherche là où tu es.</div></div>';
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">💧 Potabiliser l\'eau</div>';
|
||||||
|
h+='<div class="srv__rule"><b>🔥</b><span><b>Ébullition</b> : gros bouillons pendant 1 min et + (3 min en haute altitude). Le plus fiable.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>💊</b><span><b>Pastilles</b> : respecte la dose ET le temps d\'attente de la notice (souvent 30 min).</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>🧃</b><span><b>Filtre</b> (0,1-0,2 µm) : retient bactéries et protozoaires. Eau trouble → préfiltre à travers un tissu d\'abord.</span></div>';
|
||||||
|
h+='<div class="srv__note">Neige : fais-la fondre avant de la boire (manger de la neige refroidit le corps). Préfère l\'eau qui coule à l\'eau stagnante.</div></div>';
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">🥶 Hypothermie — reconnaître et agir</div>';
|
||||||
|
h+='<div class="srv__rule"><b>Signes</b><span>frissons violents → puis maladresse, confusion, parole pâteuse ; l\'arrêt des frissons alors qu\'il fait toujours froid = signe GRAVE.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>Agir</b><span>à l\'abri du vent et de la pluie · retire les habits mouillés · isole du sol · couches + couverture de survie · boisson chaude sucrée si la personne est bien consciente.</span></div>';
|
||||||
|
h+='<div class="srv__rule"><b>Jamais</b><span>d\'alcool, pas de friction brutale. Confusion ou aggravation → appelle les secours (112 / 1414).</span></div>';
|
||||||
|
h+='<div class="srv__note">La prévention = la vraie compétence : rester sec, couper le vent, manger et boire régulièrement, s\'arrêter AVANT d\'être épuisé.</div></div>';
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- tsoins : file locale offline → POST /px/tsoins/capture/survie ----------
|
||||||
|
function tsoinPush(ev){
|
||||||
|
var q=[]; try{ q=JSON.parse(localStorage.getItem(QK)||'[]')||[]; }catch(e){ q=[]; }
|
||||||
|
q.push({t:Date.now(),topic:'survie.'+ev.type,data:ev});
|
||||||
|
try{ localStorage.setItem(QK,JSON.stringify(q.slice(-50))); }catch(e){}
|
||||||
|
tsoinFlush();
|
||||||
|
}
|
||||||
|
function tsoinFlush(){
|
||||||
|
var q=[]; try{ q=JSON.parse(localStorage.getItem(QK)||'[]')||[]; }catch(e){ return; }
|
||||||
|
if(!q.length) return;
|
||||||
|
try{
|
||||||
|
fetch('/px/tsoins/capture/survie',{method:'POST',credentials:'same-origin',
|
||||||
|
headers:{'Content-Type':'application/json'},body:JSON.stringify({events:q})})
|
||||||
|
.then(function(r){ if(r&&r.ok){ try{ localStorage.setItem(QK,'[]'); }catch(e){} } })
|
||||||
|
.catch(function(){});
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =======================================================================
|
||||||
|
function mount(container, ctx){
|
||||||
|
var tab='exp', sel=null, state={v:1,exps:[]};
|
||||||
|
|
||||||
|
function loadLocal(){ try{ var d=JSON.parse(localStorage.getItem(LK)); if(d&&d.exps) state=d; }catch(e){} }
|
||||||
|
function persist(){
|
||||||
|
try{ localStorage.setItem(LK,JSON.stringify(state)); }catch(e){}
|
||||||
|
try{ if(window.jOSBoxion) window.jOSBoxion.saveSoon(NS,'exps',state,'Expéditions survie'); }catch(e){}
|
||||||
|
}
|
||||||
|
function expById(id){ for(var i=0;i<state.exps.length;i++) if(state.exps[i].id===id) return state.exps[i]; return null; }
|
||||||
|
|
||||||
|
container.innerHTML=''
|
||||||
|
+'<div class="srv"><div class="srv__tabs">'
|
||||||
|
+ '<span class="srv__tab on" data-tab="exp">🎒 Expéditions</span>'
|
||||||
|
+ '<span class="srv__tab" data-tab="shelter">⛺ Shelter</span>'
|
||||||
|
+ '<span class="srv__tab" data-tab="base">🧭 Survie de base</span>'
|
||||||
|
+ '<span class="srv__tab" data-tab="wargames">🎖 Wargames</span>'
|
||||||
|
+'</div><div class="srv__pane" data-pane></div></div>';
|
||||||
|
var pane=container.querySelector('[data-pane]');
|
||||||
|
container.querySelectorAll('[data-tab]').forEach(function(t){
|
||||||
|
t.onclick=function(){ tab=t.getAttribute('data-tab'); container.querySelectorAll('[data-tab]').forEach(function(x){ x.classList.toggle('on',x===t); }); render(); };
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---------------- liste + création ----------------
|
||||||
|
function renderList(){
|
||||||
|
var h='';
|
||||||
|
if(state.exps.length){
|
||||||
|
h+='<div class="srv__card" style="padding:10px">';
|
||||||
|
state.exps.forEach(function(x){
|
||||||
|
var c=calc(x);
|
||||||
|
var col=c.cert>=80?'ok':(c.cert>=55?'warn':'bad');
|
||||||
|
var ty=TMAP[x.type]||{e:'🏕️',l:x.type};
|
||||||
|
h+='<div class="srv__exp" data-open="'+x.id+'"><span class="e">'+ty.e+'</span><span class="n"><b>'+(esc(x.name)||'<i>sans nom</i>')+'</b><span>'+esc(x.lieu||'')+' · '+c.d+' j · '+c.p+' pers.</span></span><span class="srv__badge c-'+col+'">'+c.cert+'%</span></div>';
|
||||||
|
});
|
||||||
|
h+='</div>';
|
||||||
|
}
|
||||||
|
var today=new Date().toISOString().slice(0,10);
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">➕ Nouvelle expédition</div>'
|
||||||
|
+'<label class="srv__lbl">Nom</label><input class="srv__in" data-f="name" placeholder="Bivouac au Suchet…">'
|
||||||
|
+'<label class="srv__lbl">Lieu</label><input class="srv__in" data-f="lieu" placeholder="Jura, forêt de…">'
|
||||||
|
+'<div class="srv__row"><div><label class="srv__lbl">Du</label><input class="srv__in" type="date" data-f="du" value="'+today+'"></div>'
|
||||||
|
+'<div><label class="srv__lbl">Au</label><input class="srv__in" type="date" data-f="au" value="'+today+'"></div></div>'
|
||||||
|
+'<div class="srv__row"><div><label class="srv__lbl">Personnes</label><input class="srv__in" type="number" min="1" value="1" data-f="people"></div>'
|
||||||
|
+'<div><label class="srv__lbl">Saison</label><select class="srv__sel" data-f="saison">'+SAISONS.map(function(s){return '<option value="'+s.k+'">'+s.l+'</option>';}).join('')+'</select></div></div>'
|
||||||
|
+'<label class="srv__lbl">Type</label><select class="srv__sel" data-f="type">'+TYPES.map(function(t){return '<option value="'+t.k+'">'+t.e+' '+t.l+'</option>';}).join('')+'</select>'
|
||||||
|
+'<button class="srv__btn" data-create>Créer + générer la check-list</button>'
|
||||||
|
+'<div class="srv__note">La check-list s\'adapte au type, à la saison et à la durée. Ensuite le calculateur de certitude te dit si l\'eau, la bouffe et le poids tiennent la route.</div></div>';
|
||||||
|
pane.innerHTML=h;
|
||||||
|
pane.querySelectorAll('[data-open]').forEach(function(b){ b.onclick=function(){ sel=b.getAttribute('data-open'); render(); }; });
|
||||||
|
var btn=pane.querySelector('[data-create]');
|
||||||
|
if(btn) btn.onclick=function(){
|
||||||
|
function v(f){ var el=pane.querySelector('[data-f="'+f+'"]'); return el?el.value:''; }
|
||||||
|
var x={ id:uid(), name:v('name').trim(), lieu:v('lieu').trim(), du:v('du'), au:v('au'),
|
||||||
|
people:Math.max(1,parseInt(v('people'),10)||1), saison:v('saison'), type:v('type'),
|
||||||
|
effort:(v('type')==='trek'||v('type')==='hiver')?'intense':'moyen',
|
||||||
|
effortEau:(v('saison')==='ete'||v('type')==='trek'), eauL:0, food:[], poids:75 };
|
||||||
|
x.gear=genGear(x);
|
||||||
|
state.exps.unshift(x); persist();
|
||||||
|
try{ tsoinPush({type:'expedition.create',id:x.id,name:x.name,lieu:x.lieu,typeExp:x.type,saison:x.saison,jours:days(x),personnes:x.people}); }catch(e){}
|
||||||
|
try{ if(window.jOSGame&&window.jOSGame.award) window.jOSGame.award('survie.expedition',{id:x.id,type:x.type}); }catch(e){}
|
||||||
|
sel=x.id; render();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- détail : verdict + calculs + check-list ----------------
|
||||||
|
function verdictHtml(x){
|
||||||
|
var c=calc(x);
|
||||||
|
var col=c.cert>=80?'ok':(c.cert>=55?'warn':'bad');
|
||||||
|
function bar(cov,t){ return '<div class="srv__bar"><i class="b-'+t+'" style="width:'+Math.max(2,Math.min(100,cov))+'%"></i></div>'; }
|
||||||
|
var wPct=Math.round(c.totalG/Math.max(1,c.limitG)*100);
|
||||||
|
var h='<div class="srv__big c-'+col+'">CERTITUDE : '+c.cert+'%</div>'
|
||||||
|
+'<div class="srv__note">'+c.p+' pers. × '+c.d+' jour'+(c.d>1?'s':'')+' — '+esc((TMAP[x.type]||{}).l||'')+'</div>'
|
||||||
|
+'<div class="srv__gr"><div class="t"><span>💧 Eau</span><span class="c-'+tone(c.eauCov)+'">'+fmtL(c.eauA)+' / '+fmtL(c.eauBesoin)+' L</span></div>'+bar(c.eauCov,tone(c.eauCov))+'</div>'
|
||||||
|
+'<div class="srv__gr"><div class="t"><span>🍚 Bouffe</span><span class="c-'+tone(c.kcalCov)+'">'+c.kcalA+' / '+c.kcalBesoin+' kcal</span></div>'+bar(c.kcalCov,tone(c.kcalCov))+'</div>'
|
||||||
|
+'<div class="srv__gr"><div class="t"><span>✅ Essentiels cochés</span><span class="c-'+tone(c.essCov)+'">'+c.essD+' / '+c.essT+'</span></div>'+bar(c.essCov,tone(c.essCov))+'</div>'
|
||||||
|
+'<div class="srv__gr"><div class="t"><span>⚖️ Poids du sac</span><span class="c-'+(c.wOk?'ok':'bad')+'">'+(c.totalG/1000).toFixed(1)+' kg / max '+(c.limitG/1000).toFixed(1)+' kg</span></div>'+bar(wPct,(c.wOk?'ok':'bad'))+'</div>';
|
||||||
|
var miss=[];
|
||||||
|
if(c.eauCov<100){ miss.push('💧 il te manque <b>'+fmtL(c.eauBesoin-c.eauA)+' L</b> d\'eau'+(c.hasEauSecu?' — ton filtre/pastilles couvre le manque SEULEMENT s\'il y a des sources sur le trajet':' — et le filtre/pastilles n\'est pas coché : c\'est TA sécurité, prends-le')); }
|
||||||
|
else if(!c.hasEauSecu){ miss.push('💧 eau OK, mais coche quand même le <b>filtre ou les pastilles</b> : c\'est la sécurité si ça dure plus longtemps que prévu'); }
|
||||||
|
if(c.kcalCov<100){ var mk=c.kcalBesoin-c.kcalA; miss.push('🍚 il te manque <b>'+mk+' kcal</b> (≈ '+Math.round(mk/3.5)+' g de riz ou '+Math.round(mk/5.5)+' g de chocolat)'); }
|
||||||
|
if(c.essD<c.essT){ var n=c.essT-c.essD; miss.push('✅ <b>'+n+' item'+(n>1?'s':'')+' essentiel'+(n>1?'s':'')+' ★</b> pas encore coché'+(n>1?'s':'')); }
|
||||||
|
if(!c.wOk){ miss.push('⚖️ sac trop lourd de <b>'+((c.totalG-c.limitG)/1000).toFixed(1)+' kg</b> (règle : ≤ 20% du poids corporel) — allège ou répartis dans le groupe'); }
|
||||||
|
if(miss.length){ h+='<div class="srv__miss">'+miss.join('<br>')+'</div>'; }
|
||||||
|
else { h+='<div class="srv__miss ok">✔ Tout est couvert. Pars tranquille — et dis à quelqu\'un où tu vas et quand tu rentres.</div>'; }
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
function updateVerdict(x){ var v=pane.querySelector('[data-verdict]'); if(v) v.innerHTML=verdictHtml(x); }
|
||||||
|
|
||||||
|
function renderDetail(x){
|
||||||
|
var ty=TMAP[x.type]||{e:'🏕️',l:x.type};
|
||||||
|
var sais=(SAISONS.filter(function(s){ return s.k===x.saison; })[0]||{l:x.saison}).l;
|
||||||
|
var h='<button class="srv__back" data-back>◂ expéditions</button>';
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">'+ty.e+' '+(esc(x.name)||'Expédition')+'</div>'
|
||||||
|
+'<div class="srv__note">'+esc(x.lieu||'—')+' · '+esc(x.du||'')+' → '+esc(x.au||'')+' · '+esc(sais)+'</div></div>';
|
||||||
|
h+='<div class="srv__card" data-verdict>'+verdictHtml(x)+'</div>';
|
||||||
|
// --- eau ---
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">💧 Eau</div>'
|
||||||
|
+'<label class="srv__lbl">Litres emportés (gourdes + poches)</label>'
|
||||||
|
+'<input class="srv__in" type="number" min="0" step="0.5" data-eaul value="'+(+x.eauL||0)+'">'
|
||||||
|
+'<label class="srv__lbl" style="display:flex;align-items:center;gap:10px;min-height:44px;text-transform:none;font-size:.84rem;font-weight:400;color:inherit;letter-spacing:0">'
|
||||||
|
+'<input type="checkbox" data-effeau style="width:24px;height:24px;accent-color:var(--xr-accent,#37c871)"'+(x.effortEau?' checked':'')+'> Effort soutenu / chaleur (3 L par personne et par jour au lieu de 2)</label>'
|
||||||
|
+'<div class="srv__note">Formule : personnes × jours × 2-3 L'+(x.type!=='jour'?' + 0,5 L/jour pour la cuisine':'')+'. Le filtre/pastilles ne remplace pas l\'eau de départ : c\'est la sécurité.</div></div>';
|
||||||
|
// --- bouffe ---
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">🍚 Bouffe</div>'
|
||||||
|
+'<label class="srv__lbl">Effort (fixe le besoin en kcal / jour / personne)</label>'
|
||||||
|
+'<select class="srv__sel" data-effort>'
|
||||||
|
+'<option value="leger"'+(x.effort==='leger'?' selected':'')+'>Léger — 2200 kcal/j</option>'
|
||||||
|
+'<option value="moyen"'+(x.effort==='moyen'?' selected':'')+'>Moyen — 2800 kcal/j</option>'
|
||||||
|
+'<option value="intense"'+(x.effort==='intense'?' selected':'')+'>Intense (trek, hiver) — 3500 kcal/j</option></select>'
|
||||||
|
+'<label class="srv__lbl">Ce que tu prends</label><div data-foodlist></div>'
|
||||||
|
+'<div class="srv__row" style="margin-top:8px"><select class="srv__sel" data-foodsel style="flex:2">'
|
||||||
|
+FOODS.map(function(f){ return '<option value="'+f.k+'">'+f.l+' ('+f.kcal+' kcal/100g)</option>'; }).join('')
|
||||||
|
+'<option value="perso">Autre aliment…</option></select>'
|
||||||
|
+'<input class="srv__in" type="number" min="0" step="50" placeholder="grammes" data-foodg style="flex:1"></div>'
|
||||||
|
+'<div class="srv__row" data-persorow style="display:none;margin-top:8px"><input class="srv__in" placeholder="nom" data-persol style="flex:2"><input class="srv__in" type="number" min="0" placeholder="kcal/100g" data-persok style="flex:1"></div>'
|
||||||
|
+'<button class="srv__ghost" data-foodadd style="width:100%;margin-top:8px">+ ajouter</button></div>';
|
||||||
|
// --- poids ---
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">⚖️ Poids</div>'
|
||||||
|
+'<label class="srv__lbl">Ton poids corporel (kg) — règle : sac ≤ 20%</label>'
|
||||||
|
+'<input class="srv__in" type="number" min="30" max="200" data-poids value="'+(+x.poids||75)+'">'
|
||||||
|
+'<div class="srv__note">Le total = matériel de la check-list + eau (1 kg/L) + bouffe. En groupe : répartissez tente, réchaud, popote.</div></div>';
|
||||||
|
// --- check-list ---
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">✅ Check-list <small style="font-weight:400;color:var(--xr-muted,#8fb99d)">(★ = essentiel)</small></div><div data-gear></div>'
|
||||||
|
+'<div class="srv__row" style="margin-top:12px"><input class="srv__in" placeholder="item perso…" data-newit style="flex:2"><input class="srv__in" type="number" min="0" placeholder="g" data-newg style="flex:1"></div>'
|
||||||
|
+'<button class="srv__ghost" data-addit style="width:100%;margin-top:8px">+ ajouter à la liste</button></div>';
|
||||||
|
h+='<button class="srv__del" data-del>🗑 supprimer cette expédition</button>';
|
||||||
|
pane.innerHTML=h;
|
||||||
|
|
||||||
|
pane.querySelector('[data-back]').onclick=function(){ sel=null; render(); };
|
||||||
|
pane.querySelector('[data-del]').onclick=function(){
|
||||||
|
if(!confirm('Supprimer « '+(x.name||'cette expédition')+' » ?')) return;
|
||||||
|
state.exps=state.exps.filter(function(e){ return e.id!==x.id; });
|
||||||
|
sel=null; persist(); render();
|
||||||
|
};
|
||||||
|
// eau
|
||||||
|
var ie=pane.querySelector('[data-eaul]'); ie.oninput=function(){ x.eauL=+ie.value||0; persist(); updateVerdict(x); };
|
||||||
|
var fe=pane.querySelector('[data-effeau]'); fe.onchange=function(){ x.effortEau=!!fe.checked; persist(); updateVerdict(x); };
|
||||||
|
// bouffe
|
||||||
|
var se=pane.querySelector('[data-effort]'); se.onchange=function(){ x.effort=se.value; persist(); updateVerdict(x); };
|
||||||
|
var fsel=pane.querySelector('[data-foodsel]'), prow=pane.querySelector('[data-persorow]');
|
||||||
|
fsel.onchange=function(){ prow.style.display=(fsel.value==='perso')?'flex':'none'; };
|
||||||
|
function drawFood(){
|
||||||
|
var fl=pane.querySelector('[data-foodlist]'); if(!fl) return;
|
||||||
|
if(!(x.food||[]).length){ fl.innerHTML='<div class="srv__note">Rien pour l\'instant — ajoute riz, fruits secs, chocolat, lyophilisé…</div>'; return; }
|
||||||
|
fl.innerHTML=x.food.map(function(f,i){
|
||||||
|
var def=(f.k==='perso')?{l:f.l||'perso',kcal:+f.kcal||0}:(FMAP[f.k]||{l:f.k,kcal:0});
|
||||||
|
var kc=Math.round((+f.g||0)*def.kcal/100);
|
||||||
|
return '<div class="srv__food"><span class="l">'+esc(def.l)+'</span><span>'+(+f.g||0)+' g</span><span class="c-ok" style="min-width:70px;text-align:right">'+kc+' kcal</span><button class="srv__x" data-rmf="'+i+'">×</button></div>';
|
||||||
|
}).join('');
|
||||||
|
fl.querySelectorAll('[data-rmf]').forEach(function(b){ b.onclick=function(){ x.food.splice(+b.getAttribute('data-rmf'),1); persist(); drawFood(); updateVerdict(x); }; });
|
||||||
|
}
|
||||||
|
drawFood();
|
||||||
|
pane.querySelector('[data-foodadd]').onclick=function(){
|
||||||
|
var gEl=pane.querySelector('[data-foodg]'), g=+gEl.value||0; if(g<=0) return;
|
||||||
|
var k=fsel.value, f={k:k,g:g};
|
||||||
|
if(k==='perso'){
|
||||||
|
f.l=((pane.querySelector('[data-persol]')||{}).value||'aliment').trim();
|
||||||
|
f.kcal=+((pane.querySelector('[data-persok]')||{}).value)||0;
|
||||||
|
if(f.kcal<=0) return;
|
||||||
|
}
|
||||||
|
x.food=x.food||[]; x.food.push(f); persist();
|
||||||
|
gEl.value='';
|
||||||
|
drawFood(); updateVerdict(x);
|
||||||
|
};
|
||||||
|
// poids
|
||||||
|
var ip=pane.querySelector('[data-poids]'); ip.oninput=function(){ x.poids=+ip.value||75; persist(); updateVerdict(x); };
|
||||||
|
// check-list
|
||||||
|
function drawGear(){
|
||||||
|
var gw=pane.querySelector('[data-gear]'); if(!gw) return;
|
||||||
|
var cats=[], byCat={};
|
||||||
|
(x.gear||[]).forEach(function(g){ if(!byCat[g.cat]){ byCat[g.cat]=[]; cats.push(g.cat); } byCat[g.cat].push(g); });
|
||||||
|
gw.innerHTML=cats.map(function(c){
|
||||||
|
return '<div class="srv__cat">'+esc(c)+'</div>'+byCat[c].map(function(g){
|
||||||
|
return '<label class="srv__it'+(g.done?' done':'')+'" data-row="'+g.id+'"><input type="checkbox" data-ck="'+g.id+'"'+(g.done?' checked':'')+'><span class="l">'+(g.ess?'★ ':'')+esc(g.l)+(g.w?' <small>'+g.w+' g</small>':'')+'</span><button type="button" class="srv__x" data-rmi="'+g.id+'">×</button></label>';
|
||||||
|
}).join('');
|
||||||
|
}).join('');
|
||||||
|
gw.querySelectorAll('[data-ck]').forEach(function(cb){
|
||||||
|
cb.onchange=function(){
|
||||||
|
var id=cb.getAttribute('data-ck'), g=null;
|
||||||
|
(x.gear||[]).forEach(function(o){ if(o.id===id) g=o; });
|
||||||
|
if(!g) return;
|
||||||
|
g.done=cb.checked?1:0;
|
||||||
|
var row=gw.querySelector('[data-row="'+id+'"]'); if(row) row.classList.toggle('done',!!g.done);
|
||||||
|
persist(); updateVerdict(x);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
gw.querySelectorAll('[data-rmi]').forEach(function(b){
|
||||||
|
b.onclick=function(ev){ ev.preventDefault(); x.gear=(x.gear||[]).filter(function(o){ return o.id!==b.getAttribute('data-rmi'); }); persist(); drawGear(); updateVerdict(x); };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
drawGear();
|
||||||
|
pane.querySelector('[data-addit]').onclick=function(){
|
||||||
|
var li=pane.querySelector('[data-newit]'), wi=pane.querySelector('[data-newg]');
|
||||||
|
var l=(li.value||'').trim(); if(!l) return;
|
||||||
|
x.gear=x.gear||[]; x.gear.push({id:uid(),cat:'Perso',l:l,w:+wi.value||0,ess:0,done:0}); persist();
|
||||||
|
li.value=''; wi.value='';
|
||||||
|
drawGear(); updateVerdict(x);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------- shelter / base / wargames ----------------
|
||||||
|
function renderShelter(){
|
||||||
|
var h='';
|
||||||
|
SHELTERS.forEach(function(s){
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">'+s.e+' '+s.l+'</div><div class="srv__note" style="margin-top:0">'+s.why+'</div>'+s.svg
|
||||||
|
+'<ol class="srv__steps">'+s.steps.map(function(st){ return '<li>'+st+'</li>'; }).join('')+'</ol></div>';
|
||||||
|
});
|
||||||
|
h+='<div class="srv__card"><div class="srv__h">🧰 Faire un shelter avec ce qu\'on trouve</div>'
|
||||||
|
+'<div class="srv__note" style="margin-top:0">Matériaux improvisables — repère-les autour de toi AVANT la nuit :</div>'
|
||||||
|
+'<div class="srv__tagrow">'+IMPRO.map(function(m){ return '<span class="srv__tag">'+m+'</span>'; }).join('')+'</div>'
|
||||||
|
+'<div class="srv__note">Règles d\'or : petit = plus chaud · isole-toi du SOL avant de penser au toit · dos au vent · jamais dans un creux où l\'eau (ou le froid) s\'accumule.</div></div>';
|
||||||
|
pane.innerHTML=h;
|
||||||
|
}
|
||||||
|
function renderWargames(){
|
||||||
|
pane.innerHTML='<div class="srv__card"><div class="srv__soon"><div style="font-size:2.6rem">🎖</div>'
|
||||||
|
+'<b>Wargames / simulations</b><br>Scénarios de survie solo et en groupe, comme à l\'armée : exercices, rôles, timings, débriefs.'
|
||||||
|
+'<br><br><span style="opacity:.7">v2 — RS-7 va feeder le contenu (solo / groupe). Rien n\'est inventé ici en attendant.</span></div></div>';
|
||||||
|
}
|
||||||
|
function render(){
|
||||||
|
try{
|
||||||
|
if(tab==='exp'){ var x=sel?expById(sel):null; if(x){ renderDetail(x); } else { sel=null; renderList(); } return; }
|
||||||
|
if(tab==='shelter') return renderShelter();
|
||||||
|
if(tab==='base'){ pane.innerHTML=survieHtml(); return; }
|
||||||
|
if(tab==='wargames') return renderWargames();
|
||||||
|
}catch(e){ pane.innerHTML='<div class="srv__card srv__note">⚠ pépin d\'affichage — réouvre le ploxion.</div>'; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// boot : local d'abord (instantané, offline), puis boxion si dispo — jamais bloquant
|
||||||
|
loadLocal(); render();
|
||||||
|
try{
|
||||||
|
if(window.jOSBoxion && window.jOSBoxion.authed && window.jOSBoxion.authed()){
|
||||||
|
window.jOSBoxion.load(NS,'exps').then(function(d){
|
||||||
|
if(d&&d.data&&d.data.exps){ state=d.data; if(tab==='exp'&&!sel) render(); }
|
||||||
|
}).catch(function(){});
|
||||||
|
}
|
||||||
|
}catch(e){}
|
||||||
|
tsoinFlush();
|
||||||
|
var onOnline=function(){ tsoinFlush(); };
|
||||||
|
try{ window.addEventListener('online',onOnline); }catch(e){}
|
||||||
|
|
||||||
|
return { unmount:function(){ try{ window.removeEventListener('online',onOnline); }catch(e){} container.innerHTML=''; } };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== XUI (contrat v0, bion jOSXui) : describe() = mes expéditions, non monté =====
|
||||||
|
// p1 = la prochaine/dernière expédition planifiée (LA donnée maîtresse : xb:survie:exps) ;
|
||||||
|
// p3 = la file de tsoins hors-ligne en attente. Pur, jamais le DOM, ne throw jamais.
|
||||||
|
function describe(){
|
||||||
|
var items=[];
|
||||||
|
try{
|
||||||
|
var st=null; try{ st=JSON.parse(localStorage.getItem(LK)); }catch(e){}
|
||||||
|
var exps=(st&&st.exps)||[];
|
||||||
|
if(exps.length){
|
||||||
|
var x=exps[0];
|
||||||
|
items.push({ p:1, kind:'stat', label:'⛺ '+String(x.name||'expédition'), value:(x.lieu?String(x.lieu):'')+(x.du?' · '+String(x.du):'') || String(x.type||'') });
|
||||||
|
items.push({ p:2, kind:'stat', label:'expéditions', value:exps.length });
|
||||||
|
if(exps.length>1) items.push({ p:3, kind:'list', label:'autres', items:exps.slice(1,4).map(function(e2){
|
||||||
|
return { label:String(e2.name||'exp'), value:String(e2.lieu||e2.type||'') }; }) });
|
||||||
|
} else {
|
||||||
|
items.push({ p:1, kind:'stat', label:'⛺ expéditions', value:0 });
|
||||||
|
items.push({ p:2, kind:'text', label:'survie', value:'aucune expédition planifiée' });
|
||||||
|
}
|
||||||
|
var q=[]; try{ q=JSON.parse(localStorage.getItem(QK)||'[]')||[]; }catch(e){}
|
||||||
|
if(q.length) items.push({ p:4, kind:'stat', label:'tsoins en file (hors-ligne)', value:q.length });
|
||||||
|
}catch(e){ items=[{ p:1, kind:'text', label:'⛺ survie', value:'état indisponible' }]; }
|
||||||
|
return { v:1, id:ID, title:'Survie', icon:'🏕️', items:items };
|
||||||
|
}
|
||||||
|
|
||||||
|
window.jOSApps=window.jOSApps||{};
|
||||||
|
window.jOSApps[ID]={ manifest:{ id:ID, name:'Survie', icon:'🏕️' }, mount:mount, describe:describe };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user