Super calculateur myciculture

Super calculateur myciculture

Calcule tes recettes en temps reel - substrat, agar, culture liquide et monotub.

1 Etape 1 - Methode
2 Etape 2 - Espece
3 Etape 3 - Quantite

Poids total du sac pret a fructifier, spawn inclus.

4 Etape 4 - Humidite cible
💧 % d'eau dans le substrat (hors spawn)
65%
50% - sec80% - tres humide
5 Etape 5 - Composition
Son de ble
0%
Pellets de paille
100%
Pellets de bois
0%
Total composition100% ✓
Additif - Gypse (hors total)
🪨 Gypse (% du poids sec)
0%
0% - aucun10% - max
6 Etape 6 - Grain spawn
% du poids total humide du sac
7%
3% - economique25% - rapide
Avertissements
Aucun avertissement.
Mode cout (optionnel)
📋 Recette complete
-
Humidite du substrat (hors spawn)-
Liste de courses
✓ Copie !
Mes recettes sauvegardees
Recette

Ingredients
🧫 Agar-agar (g/L)
15 g/L
5 g/L25 g/L
✓ Dose recommandée : 15 g/L — standard pour MEA/PDA
🌾 Extrait de malt (g/L)
20 g/L
10 g/L - leger40 g/L - tres riche
Dose recommandee : 20 g/L
Ingredients personnalises
Avertissements
Quantite
📋 Recette agar

⚠️ Sterilisation : autoclave 121C pendant 20 min. Couler les boites sous flux laminaire ou en still air box.

✓ Copie !
Mes recettes agar sauvegardees
Recette

Concentration
🌾 Extrait de malt (g/L)
4 g/L
2 g/L - tres leger15 g/L - riche
Dose recommandee : 4 g/L
Ingredients personnalises
Avertissements
Quantite
📋 Recette culture liquide

⚠️ Sterilisation : autoclave 121C pendant 20 min, ou cocotte-minute 30 min. Inoculer sous flux laminaire.

✓ Copie !
Mes recettes LC sauvegardees
1 Etape 1 — Nombre de monotubs
2 Etape 2 — Dimensions interieures du bac

Dimensions interieures du bac en centimetres.

3 Etape 3 — Profondeur cible du substrat
📏 Profondeur cible
10 cm (23.5 L)
5 cm — minimum20 cm — maximum
4 Etape 4 — Taux de grain spawn
🍄 Grain spawn (% du volume final)
25%
15% — economique35% — rapide
Recommande : 20–30% du volume final. Plus le taux est eleve, plus la colonisation est rapide.
5 Etape 5 — Ingrédients CVG
🔒 Valeurs recommandées
A ajuster uniquement selon la marque de coco utilisée — les quantités d’eau varient. Faites le test de la poignée après refroidissement.
🥥 Fibre de coco
g/L CVG
🟡 Vermiculite
L/L CVG
💧 Eau bouillante
L/kg coco
🪨 Gypse (additif)
% coco
🍄 Grain spawn
kg/L spawn
Avertissements
Aucun avertissement.
Mode cout (optionnel)
📋 Recette Monotub CVG
Liste de courses
✓ Copie !
Mes recettes monotub sauvegardees
🌱 Prêt à monter votre monotub ?
');win.document.close();win.focus();setTimeout(function(){win.print();},500);} function mkGLMgr(prefix,calcFn,max){var ings=[],cnt=0;function add(name,conc){if(ings.length>=max){alert('Max '+max);return;}var id=prefix+'_'+cnt++;ings.push({id:id,name:name||'',conc:conc||0});render();calcFn();}function rem(id){ings=ings.filter(function(c){return c.id!==id;});render();calcFn();}function render(){var con=document.getElementById(prefix+'-custom-ing');if(!con)return;con.innerHTML='';ings.forEach(function(ci){var d=document.createElement('div');d.className='myc-custom-row-gl';d.innerHTML='
'+ci.conc+' g/L
';con.appendChild(d);document.getElementById(ci.id+'-d').addEventListener('click',function(){rem(ci.id);});document.getElementById(ci.id+'-n').addEventListener('input',function(){var c=ings.find(function(x){return x.id===ci.id;});if(c)c.name=this.value;calcFn();});var sl=document.getElementById(ci.id+'-s');sl.addEventListener('input',function(){var c=ings.find(function(x){return x.id===ci.id;});if(!c)return;c.conc=parseInt(this.value);document.getElementById(ci.id+'-v').textContent=c.conc+' g/L';sC(sl,c.conc,0,30);calcFn();});sC(sl,ci.conc,0,30);});var btn=document.getElementById(prefix+'-add-ing-btn');if(btn)btn.style.display=ings.length>=max?'none':'flex';}return{add:add,render:render,getIngs:function(){return ings;}};} // ================================================================ // SUBSTRAT // ================================================================ (function(){ var ESP=[{n:'Pleurote Gris',ne:'Grey Oyster',cs:'7-10 j',cs2:'5-8 j',fr:'18-22\u00b0C',df:'easy',s:{h:65,sp:7,son:0,pai:100,boi:0,sm:5,hmin:62,hmax:72},t:{h:65,sp:5,son:10,pai:80,boi:10,sm:15,hmin:62,hmax:72}},{n:'Pleurote Blanc',ne:'White Oyster',cs:'7-10 j',cs2:'5-8 j',fr:'18-22\u00b0C',df:'easy',s:{h:65,sp:7,son:0,pai:100,boi:0,sm:5,hmin:62,hmax:72},t:{h:65,sp:5,son:10,pai:80,boi:10,sm:15,hmin:62,hmax:72}},{n:'Pleurote Bleu',ne:'Blue Oyster',cs:'7-10 j',cs2:'5-8 j',fr:'16-20\u00b0C',df:'easy',s:{h:65,sp:7,son:0,pai:100,boi:0,sm:5,hmin:62,hmax:72},t:{h:65,sp:5,son:10,pai:80,boi:10,sm:15,hmin:62,hmax:72}},{n:'Pleurote Jaune',ne:'Yellow Oyster',cs:'8-12 j',cs2:'6-9 j',fr:'22-28\u00b0C',df:'easy',s:{h:65,sp:7,son:0,pai:100,boi:0,sm:5,hmin:62,hmax:72},t:{h:65,sp:5,son:10,pai:80,boi:10,sm:15,hmin:62,hmax:72}},{n:'Pleurote Rose',ne:'Pink Oyster',cs:'7-10 j',cs2:'5-8 j',fr:'26-30\u00b0C',df:'easy',s:{h:65,sp:7,son:0,pai:100,boi:0,sm:5,hmin:62,hmax:72},t:{h:65,sp:5,son:10,pai:80,boi:10,sm:15,hmin:62,hmax:72}},{n:'Black Pearl',ne:'Black Pearl',cs:'14-21 j',cs2:'10-16 j',fr:'15-18\u00b0C',df:'intermediate',s:{h:65,sp:7,son:0,pai:30,boi:70,sm:5,hmin:62,hmax:70},t:{h:65,sp:5,son:5,pai:20,boi:75,sm:10,hmin:62,hmax:70}},{n:'Eryngii',ne:'King Oyster',cs:'15-25 j',cs2:'12-18 j',fr:'15-18\u00b0C',df:'intermediate',s:{h:65,sp:10,son:5,pai:0,boi:95,sm:5,hmin:60,hmax:68},t:{h:62,sp:5,son:10,pai:5,boi:85,sm:15,hmin:58,hmax:66}},{n:'Shiitake',ne:'Shiitake',cs:'30-60 j',cs2:'25-40 j',fr:'15-20\u00b0C',df:'intermediate',s:{h:62,sp:15,son:0,pai:0,boi:100,sm:2,hmin:58,hmax:65},t:{h:60,sp:5,son:10,pai:5,boi:85,sm:20,hmin:55,hmax:63}},{n:"Lion's Mane",ne:"Lion's Mane",cs:'10-14 j',cs2:'8-12 j',fr:'18-24\u00b0C',df:'intermediate',s:{h:65,sp:10,son:5,pai:0,boi:95,sm:8,hmin:62,hmax:70},t:{h:65,sp:5,son:20,pai:5,boi:75,sm:20,hmin:62,hmax:70}},{n:'Reishi',ne:'Reishi',cs:'60-90 j',cs2:'45-70 j',fr:'24-28\u00b0C',df:'advanced',s:{h:60,sp:15,son:0,pai:0,boi:100,sm:0,hmin:55,hmax:63},t:{h:60,sp:5,son:0,pai:0,boi:100,sm:8,hmin:55,hmax:63}}]; function eN(e){return MYC_LANG==='en'?e.ne:e.n;} var CI=[],CIC=0; var S={m:'superpasteurisation',i:0,custom:false,u:'g',h:65,son:0,pai:100,boi:0,sp:7,gy:0,lk:{son:false,pai:false,boi:false},cost:false}; function gd(){return ESP[S.i][S.m==='superpasteurisation'?'s':'t'];} function svLS(){try{localStorage.setItem('myc6',JSON.stringify({m:S.m,i:S.i,u:S.u,h:S.h,son:S.son,pai:S.pai,boi:S.boi,sp:S.sp,gy:S.gy,cost:S.cost,ci:CI}));}catch(e){}} function ldLS(){try{var d=localStorage.getItem('myc6');if(d){var p=JSON.parse(d);S.m=p.m||S.m;S.i=p.i!=null?p.i:S.i;S.u=p.u||S.u;S.h=p.h||S.h;S.son=p.son!=null?p.son:S.son;S.pai=p.pai!=null?p.pai:S.pai;S.boi=p.boi!=null?p.boi:S.boi;S.sp=p.sp||S.sp;S.gy=p.gy||0;S.cost=p.cost||S.cost;if(p.ci)CI=p.ci;}}catch(e){}} function gURL(){var p=new URLSearchParams();p.set('m',S.m);p.set('i',S.i);p.set('u',S.u);p.set('h',S.h);p.set('son',S.son);p.set('pai',S.pai);p.set('boi',S.boi);p.set('sp',S.sp);p.set('gy',S.gy);p.set('qty',document.getElementById('m-qty').value);p.set('sacs',document.getElementById('m-sacs').value);return window.location.href.split('?')[0]+'?'+p.toString();} function ldURL(){var p=new URLSearchParams(window.location.search);if(!p.get('m'))return false;S.m=p.get('m')||S.m;S.i=parseInt(p.get('i'))||0;S.u=p.get('u')||S.u;S.h=parseInt(p.get('h'))||S.h;S.son=parseInt(p.get('son'))||0;S.pai=parseInt(p.get('pai'))||100;S.boi=parseInt(p.get('boi'))||0;S.sp=parseInt(p.get('sp'))||7;S.gy=parseFloat(p.get('gy'))||0;if(p.get('qty'))document.getElementById('m-qty').value=p.get('qty');if(p.get('sacs'))document.getElementById('m-sacs').value=p.get('sacs');return true;} function gSv(){try{return JSON.parse(localStorage.getItem('myc-saved')||'[]');}catch(e){return[];}} function sSv(a){try{localStorage.setItem('myc-saved',JSON.stringify(a));}catch(e){}} function saveRec(){var nm=document.getElementById('m-save-name').value.trim();if(!nm){alert(T('give_name'));return;}var sv=gSv();sv.unshift({name:nm,date:Date.now(),m:S.m,i:S.i,u:S.u,h:S.h,son:S.son,pai:S.pai,boi:S.boi,sp:S.sp,gy:S.gy,qty:document.getElementById('m-qty').value,sacs:document.getElementById('m-sacs').value,ci:CI.map(function(c){return{name:c.name,pct:c.pct};})});if(sv.length>20)sv=sv.slice(0,20);sSv(sv);document.getElementById('m-save-name').value='';renderSv();mycToast(T('toast_saved'));} function ldRec(r){S.m=r.m;S.i=r.i;S.u=r.u;S.h=r.h;S.son=r.son;S.pai=r.pai;S.boi=r.boi;S.sp=r.sp;S.gy=r.gy||0;document.getElementById('m-qty').value=r.qty||3000;document.getElementById('m-sacs').value=r.sacs||1;CI=[];document.getElementById('myc-custom-ing').innerHTML='';CIC=0;if(r.ci)r.ci.forEach(function(c){addCI(c.name,c.pct);});S.custom=false;S.lk={son:false,pai:false,boi:false};['son','pai','boi'].forEach(function(k){updLUI(k);});document.getElementById('m-bs').classList.toggle('active',S.m==='superpasteurisation');document.getElementById('m-bt').classList.toggle('active',S.m==='sterilisation');buildGrid();updFiche();if(S.u==='kg'){document.getElementById('m-bg').classList.remove('active');document.getElementById('m-bk').classList.add('active');}else{document.getElementById('m-bg').classList.add('active');document.getElementById('m-bk').classList.remove('active');}synSl();synCol();mRC();} function renderSv(){var sv=gSv();var list=document.getElementById('m-saved-list');if(!list)return;if(!sv.length){list.innerHTML=''+T('no_saved')+'';return;}list.innerHTML=sv.map(function(r,i){var d=new Date(r.date).toLocaleDateString(MYC_LANG==='fr'?'fr-CH':'en-GB',{day:'2-digit',month:'2-digit',year:'numeric'});return'
'+r.name+' - '+d+'
';}).join('');list.querySelectorAll('.myc-saved-name').forEach(function(el){el.addEventListener('click',function(){ldRec(gSv()[parseInt(this.dataset.i)]);});});list.querySelectorAll('.myc-saved-del').forEach(function(el){el.addEventListener('click',function(){var s=gSv();s.splice(parseInt(this.dataset.i),1);localStorage.setItem('myc-saved',JSON.stringify(s));renderSv();});});} function addCI(name,pct){if(CI.length>=3){alert('Max 3');return;}var id='ci'+CIC++;CI.push({id:id,name:name||'',pct:pct||0,locked:false});renderCI();updAB();mRC();} function remCI(id){CI=CI.filter(function(c){return c.id!==id;});renderCI();updAB();rebal('son');mRC();svLS();} function updAB(){var b=document.getElementById('myc-add-ing-btn');if(b)b.style.display=CI.length>=3?'none':'flex';} function renderCI(){var con=document.getElementById('myc-custom-ing');con.innerHTML='';CI.forEach(function(ci){var d=document.createElement('div');d.className='myc-custom-row';d.id='crow-'+ci.id;d.innerHTML='
'+ci.pct+'%
';con.appendChild(d);document.getElementById('dl-'+ci.id).addEventListener('click',function(){remCI(ci.id);});document.getElementById('nm-'+ci.id).addEventListener('input',function(){var c=CI.find(function(x){return x.id===ci.id;});if(c)c.name=this.value;renderCIP();svLS();mRC();});var sl=document.getElementById('sl-'+ci.id);sl.addEventListener('input',function(){var c=CI.find(function(x){return x.id===ci.id;});if(!c)return;c.pct=parseInt(this.value);document.getElementById('vl-'+ci.id).textContent=c.pct+'%';sC(this,c.pct,0,100);rebal(ci.id);mRC();svLS();});document.getElementById('lk-'+ci.id).addEventListener('click',function(){var c=CI.find(function(x){return x.id===ci.id;});if(!c)return;c.locked=!c.locked;document.getElementById('lk-'+ci.id).classList.toggle('locked',c.locked);var sle=document.getElementById('sl-'+ci.id);if(sle)sle.disabled=c.locked;var pe=document.getElementById('ph-'+ci.id);if(pe)pe.setAttribute('d',c.locked?'M7 11V7a5 5 0 0 1 9.9-1':'M7 11V7a5 5 0 0 1 10 0v4');});sC(sl,ci.pct,0,100);if(ci.locked){var sle=document.getElementById('sl-'+ci.id);if(sle)sle.disabled=true;}});renderCIP();} function renderCIP(){var con=document.getElementById('myc-custom-prices');if(!con)return;var ev={};CI.forEach(function(ci){var el=document.getElementById('p-'+ci.id);if(el)ev[ci.id]=el.value;});con.innerHTML='';CI.forEach(function(ci){var d=document.createElement('div');d.className='mcf';var sym=devSym();d.innerHTML='';con.appendChild(d);document.getElementById('p-'+ci.id).addEventListener('input',function(){mRC();});});} function rebal(changed){var tot=S.son+S.pai+S.boi+CI.reduce(function(a,c){return a+c.pct;},0);if(tot===100)return;var diff=tot-100;var unl=[];if(!S.lk.son&&changed!=='son')unl.push('son');if(!S.lk.pai&&changed!=='pai')unl.push('pai');if(!S.lk.boi&&changed!=='boi')unl.push('boi');CI.forEach(function(c){if(!c.locked&&c.id!==changed)unl.push(c.id);});if(!unl.length)return;var per=Math.round(diff/unl.length);var rem2=diff-per*unl.length;unl.forEach(function(k,idx){var adj=per+(idx===0?rem2:0);if(k==='son'){S.son=Math.max(0,S.son-adj);document.getElementById('m-ss').value=S.son;document.getElementById('m-sv').textContent=S.son+'%';sC(document.getElementById('m-ss'),S.son,0,40);}else if(k==='pai'){S.pai=Math.max(0,S.pai-adj);document.getElementById('m-ps').value=S.pai;document.getElementById('m-pv').textContent=S.pai+'%';sC(document.getElementById('m-ps'),S.pai,0,100);}else if(k==='boi'){S.boi=Math.max(0,S.boi-adj);document.getElementById('m-bs2').value=S.boi;document.getElementById('m-bv').textContent=S.boi+'%';sC(document.getElementById('m-bs2'),S.boi,0,100);}else{var c=CI.find(function(x){return x.id===k;});if(c){c.pct=Math.max(0,c.pct-adj);var se=document.getElementById('sl-'+k),ve=document.getElementById('vl-'+k);if(se)se.value=c.pct;if(ve)ve.textContent=c.pct+'%';if(se)sC(se,c.pct,0,100);}}});updTot();} function buildGrid(){var g=document.getElementById('m-eg');g.innerHTML=ESP.map(function(e,i){return'';}).join('')+'';ESP.forEach(function(_,i){document.getElementById('meb'+i).addEventListener('click',function(){mSelE(i);});});document.getElementById('meb-c').addEventListener('click',function(){mSelC();});ESP.forEach(function(_,j){var el=document.getElementById('meb'+j);if(el)el.classList.toggle('active',j===S.i);});if(S.custom){var ec=document.getElementById('meb-c');if(ec)ec.classList.add('active');}} function mSelE(i){S.i=i;S.custom=false;ESP.forEach(function(_,j){var el=document.getElementById('meb'+j);if(el)el.classList.toggle('active',j===i);});var ec=document.getElementById('meb-c');if(ec)ec.classList.remove('active');applyDef();updFiche();synCol();mRC();svLS();} function mSelC(){S.custom=true;ESP.forEach(function(_,j){var el=document.getElementById('meb'+j);if(el)el.classList.remove('active');});var ec=document.getElementById('meb-c');if(ec)ec.classList.add('active');document.getElementById('m-fiche-title').style.display='none';document.getElementById('m-fiche').innerHTML=''+T('custom_mode')+'';} function applyDef(){var d=gd();S.h=d.h;S.son=d.son;S.pai=d.pai;S.boi=d.boi;S.sp=d.sp;S.lk={son:false,pai:false,boi:false};['son','pai','boi'].forEach(function(k){updLUI(k);});synSl();} function synSl(){document.getElementById('m-hs').value=S.h;document.getElementById('m-ss').value=S.son;document.getElementById('m-ps').value=S.pai;document.getElementById('m-bs2').value=S.boi;document.getElementById('m-sps').value=S.sp;document.getElementById('m-gys').value=S.gy;document.getElementById('m-hv').textContent=S.h+'%';document.getElementById('m-sv').textContent=S.son+'%';document.getElementById('m-pv').textContent=S.pai+'%';document.getElementById('m-bv').textContent=S.boi+'%';document.getElementById('m-spv').textContent=S.sp+'%';document.getElementById('m-gyv').textContent=S.gy+'%';updTot();} function updFiche(){if(S.custom)return;var e=ESP[S.i],col=S.m==='superpasteurisation'?e.cs:e.cs2;document.getElementById('m-fiche-title').style.display='flex';document.getElementById('m-fiche-title').textContent=T('characteristics');document.getElementById('m-fiche').innerHTML='
'+T('col')+'
'+col+'
'+T('fru')+'
'+e.fr+'
'+T('dif')+'
'+T(e.df)+'
';} function mSetM(m){S.m=m;document.getElementById('m-bs').classList.toggle('active',m==='superpasteurisation');document.getElementById('m-bt').classList.toggle('active',m==='sterilisation');document.getElementById('bdg-steam').textContent=T('steam_badge');document.getElementById('mtt-steam').textContent=T('steam_title');document.getElementById('bdg-press').textContent=T('press_badge');document.getElementById('mtt-press').textContent=T('press_title');if(!S.custom){applyDef();updFiche();}synCol();mRC();svLS();} function mSetU(u){S.u=u;document.getElementById('m-bg').classList.toggle('active',u==='g');document.getElementById('m-bk').classList.toggle('active',u==='kg');mRC();} function mOnH(){S.h=parseInt(document.getElementById('m-hs').value);document.getElementById('m-hv').textContent=S.h+'%';sC(document.getElementById('m-hs'),S.h,50,80);mRC();svLS();} function mOnSp(){S.sp=parseInt(document.getElementById('m-sps').value);document.getElementById('m-spv').textContent=S.sp+'%';sC(document.getElementById('m-sps'),S.sp,3,25);mRC();svLS();} function mTLk(k){S.lk[k]=!S.lk[k];updLUI(k);} function updLUI(k){var ids={son:['m-lson','m-rson','m-sson','m-ss'],pai:['m-lpai','m-rpai','m-spai','m-ps'],boi:['m-lboi','m-rboi','m-sboi','m-bs2']};var id=ids[k],lk=S.lk[k];var btn=document.getElementById(id[0]),row=document.getElementById(id[1]);if(!btn||!row)return;btn.classList.toggle('locked',lk);row.classList.toggle('is-locked',lk);document.getElementById(id[2]).setAttribute('d',lk?'M7 11V7a5 5 0 0 1 9.9-1':'M7 11V7a5 5 0 0 1 10 0v4');document.getElementById(id[3]).disabled=lk;} function mOnS(changed){S.son=parseInt(document.getElementById('m-ss').value);S.pai=parseInt(document.getElementById('m-ps').value);S.boi=parseInt(document.getElementById('m-bs2').value);rebal(changed);document.getElementById('m-ss').value=S.son;document.getElementById('m-ps').value=S.pai;document.getElementById('m-bs2').value=S.boi;document.getElementById('m-sv').textContent=S.son+'%';document.getElementById('m-pv').textContent=S.pai+'%';document.getElementById('m-bv').textContent=S.boi+'%';updTot();synCol();mRC();svLS();} function updTot(){var t=S.son+S.pai+S.boi+CI.reduce(function(a,c){return a+c.pct;},0);var el=document.getElementById('m-ti');el.textContent=t===100?'100% \u2713':t+'% \u2717';el.className=t===100?'tok':'tbad';} function mTCost(){S.cost=document.getElementById('m-cc').checked;document.getElementById('m-cz').style.display=S.cost?'block':'none';mRC();svLS();} function setDev(d,noR){_devise=d;['CHF','EUR','USD'].forEach(function(x){var el=document.getElementById('m-d'+x.toLowerCase());if(el)el.classList.toggle('active',x===d);});document.querySelectorAll('.myc-devise-sym').forEach(function(el){el.textContent=devSym();});var ti=document.getElementById('m-taux-info');if(ti)ti.textContent=taux_info();renderCIP();if(!noR)mRC();svLS();} function mRC(){var raw=parseFloat(document.getElementById('m-qty').value)||0;var n=Math.max(1,parseInt(document.getElementById('m-sacs').value)||1);var inG=S.u==='kg'?raw*1000:raw,H=S.h/100,sr=S.sp/100;var sec,eau,spawn,total;total=inG;spawn=total*sr;var sh=total-spawn;sec=sh*(1-H);eau=sh*H;var sonG=sec*S.son/100,paiG=sec*S.pai/100,boiG=sec*S.boi/100,gyG=sec*S.gy/100;var cGs=CI.map(function(c){return{id:c.id,name:c.name,pct:c.pct,g:sec*c.pct/100};});var humF=(eau/(sec+eau))*100;var pr=null;if(S.cost){pr={son:conv(parseFloat(document.getElementById('m-pson').value)||0),pai:conv(parseFloat(document.getElementById('m-ppai').value)||0),boi:conv(parseFloat(document.getElementById('m-pboi').value)||0),sp:conv(parseFloat(document.getElementById('m-psp').value)||0),gy:conv(parseFloat(document.getElementById('m-pgy').value)||0)};cGs.forEach(function(c){var el=document.getElementById('p-'+c.id);pr['c_'+c.id]=conv(el?parseFloat(el.value)||0:0);});}var rc=document.getElementById('m-result-card');rc.classList.add('myc-updating');setTimeout(function(){rc.classList.remove('myc-updating');},400);var esp=S.custom?T('custom_recipe'):eN(ESP[S.i]);var meth=S.m==='superpasteurisation'?T('sup'):T('ster');document.getElementById('m-recap').innerHTML=''+T('validated')+' \u2014 '+n+' '+T(n>1?'bags':'bag')+' '+T('of')+' '+esp+', '+meth+', '+fG(total)+' '+T('each')+'.';renderCols(sonG,paiG,boiG,eau,spawn,gyG,cGs,total,pr,n);document.getElementById('m-hbar').style.width=Math.min(humF,100)+'%';document.getElementById('m-hbp').textContent=humF.toFixed(1)+'%';buildList(sonG,paiG,boiG,eau,spawn,gyG,cGs,total,pr,n,esp,meth);updWarns(humF);document.getElementById('m-sl').textContent=n>1?'- '+T('total_n')+' '+n+' '+T('bags'):'';} function calcTC(son,pai,boi,spawn,gy,cGs,pr){var t=((son/1000)*pr.son)+((pai/1000)*pr.pai)+((boi/1000)*pr.boi)+((spawn/1000)*pr.sp)+((gy/1000)*(pr.gy||0));cGs.forEach(function(c){if(c.pct>0&&pr['c_'+c.id])t+=(c.g/1000)*pr['c_'+c.id];});return t;} function renderCols(son,pai,boi,eau,spawn,gy,cGs,total,pr,n){var sym=devSym();function pc(g,pk){return(pr&&pk>0)?'
'+((g/1000)*pk).toFixed(2)+' '+sym+'
':'';}function card(nm,pct,g,pk,isE){return'
'+nm+'
'+(pct?'
'+pct+'
':'')+'
'+(isE?fL(g):fG(g))+'
'+pc(g,pk)+'
';}function totCard(g,pr2,lbl,n2){var tp='';if(pr2){var tc=calcTC(son,pai,boi,spawn,gy,cGs,pr2)*(n2||1);tp='
'+tc.toFixed(2)+' '+sym+'
';}return'
\uD83D\uDCE6 '+lbl+'
'+fG(g)+'
'+tp+'
';}var rows=[];if(S.son>0)rows.push({n:T('wheat_bran'),pct:S.son+'%',g:son,pk:pr?pr.son:0,e:false});if(S.pai>0)rows.push({n:T('straw'),pct:S.pai+'%',g:pai,pk:pr?pr.pai:0,e:false});if(S.boi>0)rows.push({n:T('wood'),pct:S.boi+'%',g:boi,pk:pr?pr.boi:0,e:false});cGs.forEach(function(c){if(c.pct>0)rows.push({n:c.name||T('custom_ing'),pct:c.pct+'%',g:c.g,pk:pr?pr['c_'+c.id]||0:0,e:false});});rows.push({n:T('water_add'),pct:null,g:eau,pk:0,e:true});rows.push({n:T('grain_spawn')+' ('+S.sp+'%)',pct:null,g:spawn,pk:pr?pr.sp:0,e:false});if(S.gy>0)rows.push({n:T('gypsum_ing')+' ('+S.gy+'%)',pct:MYC_LANG==='fr'?'additif':'additive',g:gy,pk:pr?pr.gy:0,e:false});var c1=rows.map(function(r){return card(r.n,r.pct,r.g,r.pk,r.e);}).join('')+totCard(total,pr,T('total_bag'),1);var html='
'+T('per_bag')+'
'+c1+'
';if(n>1){var c2=rows.map(function(r){return'
'+r.n+'
'+(r.pct?'
'+r.pct+'
':'')+'
'+(r.e?fL(r.g*n):fG(r.g*n))+'
'+(pr&&r.pk>0?'
'+((r.g*n/1000)*r.pk).toFixed(2)+' '+sym+'
':'')+'
';}).join('')+totCard(total*n,pr,T('total_n')+' '+n+' '+T('bags'),n);html+='
'+T('total_n')+' \u2014 '+n+' '+T('bags')+'
'+c2+'
';}document.getElementById('m-cols').innerHTML=html;} function buildList(son,pai,boi,eau,spawn,gy,cGs,total,pr,n,esp,meth){var sym=devSym();var shop=document.getElementById('m-shop');shop.innerHTML='';function pStr(g,pk){return(pr&&pk>0)?((g/1000)*pk).toFixed(2)+' '+sym:null;}function mkR(nm,val,price){var r=document.createElement('div');r.className='mshop-row';var nm2=document.createElement('span');nm2.className='mshop-name';nm2.textContent=nm;var ri=document.createElement('div');ri.className='mshop-right';var vl=document.createElement('span');vl.className='mshop-val';vl.textContent=val;ri.appendChild(vl);if(price){var p=document.createElement('span');p.className='mshop-price';p.textContent=price;ri.appendChild(p);}r.appendChild(nm2);r.appendChild(ri);return r;}function mkS(t){var s=document.createElement('div');s.className='mshop-section';s.textContent=t;return s;}function mkT(nm,val,price){var r=document.createElement('div');r.className='mshop-total-row';var nm2=document.createElement('span');nm2.className='mshop-total-name';nm2.textContent=nm;var ri=document.createElement('div');ri.className='mshop-total-right';var vl=document.createElement('span');vl.className='mshop-total-val';vl.textContent=val;ri.appendChild(vl);if(price){var p=document.createElement('span');p.className='mshop-price';p.textContent=price;ri.appendChild(p);}r.appendChild(nm2);r.appendChild(ri);return r;}function mkD(){var d=document.createElement('div');d.className='mshop-divider';return d;}shop.appendChild(mkS(T('per_bag')));if(S.son>0)shop.appendChild(mkR(T('wheat_bran'),fG(son),pStr(son,pr?pr.son:0)));if(S.pai>0)shop.appendChild(mkR(T('straw'),fG(pai),pStr(pai,pr?pr.pai:0)));if(S.boi>0)shop.appendChild(mkR(T('wood'),fG(boi),pStr(boi,pr?pr.boi:0)));cGs.forEach(function(c){if(c.pct>0)shop.appendChild(mkR(c.name||T('custom_ing'),fG(c.g),pStr(c.g,pr?pr['c_'+c.id]||0:0)));});shop.appendChild(mkR(T('water'),fL(eau),null));shop.appendChild(mkR(T('grain_spawn'),fG(spawn),pStr(spawn,pr?pr.sp:0)));if(S.gy>0)shop.appendChild(mkR(T('gypsum_ing'),fG(gy),pStr(gy,pr?pr.gy:0)));shop.appendChild(mkT(T('total_bag'),fG(total),null));if(n>1){shop.appendChild(mkD());shop.appendChild(mkS(T('total_n')+' '+n+' '+T('bags')));if(S.son>0)shop.appendChild(mkR(T('wheat_bran'),fG(son*n),pStr(son*n,pr?pr.son:0)));if(S.pai>0)shop.appendChild(mkR(T('straw'),fG(pai*n),pStr(pai*n,pr?pr.pai:0)));if(S.boi>0)shop.appendChild(mkR(T('wood'),fG(boi*n),pStr(boi*n,pr?pr.boi:0)));cGs.forEach(function(c){if(c.pct>0)shop.appendChild(mkR(c.name||T('custom_ing'),fG(c.g*n),pStr(c.g*n,pr?pr['c_'+c.id]||0:0)));});shop.appendChild(mkR(T('water'),fL(eau*n),null));shop.appendChild(mkR(T('grain_spawn'),fG(spawn*n),pStr(spawn*n,pr?pr.sp:0)));if(S.gy>0)shop.appendChild(mkR(T('gypsum_ing'),fG(gy*n),pStr(gy*n,pr?pr.gy:0)));if(pr){var tp=calcTC(son,pai,boi,spawn,gy,cGs,pr);shop.appendChild(mkT(T('total_n')+' '+n+' '+T('bags'),fG(total*n),(tp*n).toFixed(2)+' '+sym));}else shop.appendChild(mkT(T('total_n')+' '+n+' '+T('bags'),fG(total*n),null));}var meta=document.createElement('div');meta.className='mshop-meta';meta.innerHTML=''+T('species')+' : '+esp+''+T('method')+' : '+meth+''+T('hum_lbl')+' : '+S.h+'%';shop.appendChild(meta);} function updWarns(humF){var zone=document.getElementById('m-wz'),w=[],d=gd();if(S.h<57)w.push({t:'danger',m:Tw('w_hum_low',{'%H%':S.h+'%'})});else if(S.h<60)w.push({t:'warn',m:Tw('w_hum_low2',{'%H%':S.h+'%'})});if(S.h>72)w.push({t:'danger',m:Tw('w_hum_high',{'%H%':S.h+'%'})});else if(S.h>d.hmax)w.push({t:'warn',m:Tw('w_hum_over',{'%H%':S.h+'%','%MAX%':d.hmax+'%'})});if(S.hd.sm&&S.m==='superpasteurisation')w.push({t:'danger',m:Tw('w_bran_danger',{'%S%':S.son+'%','%M%':d.sm+'%'})});if(S.son>d.sm&&S.m==='sterilisation')w.push({t:'warn',m:Tw('w_bran_warn',{'%S%':S.son+'%','%M%':d.sm+'%'})});if(S.m==='sterilisation'&&S.son===0&&![7,9].includes(S.i))w.push({t:'info',m:T('w_bran_boost')});if(S.i===9&&S.son>0&&S.m==='superpasteurisation')w.push({t:'danger',m:T('w_reishi_no_bran')});if(S.i===9&&S.son>8)w.push({t:'warn',m:T('w_reishi_bran')});if(S.i===7&&S.son>2&&S.m==='superpasteurisation')w.push({t:'danger',m:T('w_shiitake')});if(S.i===8&&S.pai>20&&S.m==='superpasteurisation')w.push({t:'danger',m:T('w_lmane')});if([6,7,8,9].includes(S.i)&&S.pai>30)w.push({t:'warn',m:T('w_lignin')});if([0,1,2,3,4].includes(S.i)&&S.son>5&&S.m==='superpasteurisation')w.push({t:'warn',m:T('w_oyster')});if(S.h>70&&S.son>10)w.push({t:'warn',m:T('w_hum_bran')});if(S.sp<5&&S.m==='superpasteurisation')w.push({t:'warn',m:Tw('w_spawn_low',{'%S%':S.sp+'%'})});}if(S.sp>20)w.push({t:'warn',m:Tw('w_spawn_high',{'%S%':S.sp+'%'})});if(S.son===0&&S.pai===0&&S.boi===0&&CI.every(function(c){return c.pct===0;}))w.push({t:'danger',m:T('w_empty')});var tot=S.son+S.pai+S.boi+CI.reduce(function(a,c){return a+c.pct;},0);if(tot!==100&&tot!==0)w.push({t:'danger',m:Tw('w_total',{'%T%':tot+'%'})});zone.innerHTML=w.length?w.map(function(x){return'
'+x.m+'
';}).join(''):''+T('no_warn')+'';} function mShare(){var url=gURL();navigator.clipboard.writeText(url).then(function(){var el=document.getElementById('m-share-ok');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2500);}).catch(function(){var ta=document.createElement('textarea');ta.value=url;document.body.appendChild(ta);ta.select();document.execCommand('copy');document.body.removeChild(ta);var el=document.getElementById('m-share-ok');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2500);});} function synCol(){sC(document.getElementById('m-hs'),S.h,50,80);sC(document.getElementById('m-ss'),S.son,0,40);sC(document.getElementById('m-ps'),S.pai,0,100);sC(document.getElementById('m-bs2'),S.boi,0,100);sC(document.getElementById('m-sps'),S.sp,3,25);sC(document.getElementById('m-gys'),S.gy,0,10);} function cascade(){var w=document.getElementById('myc-calc-wrap');w.classList.add('myc-ready');var els=w.querySelectorAll('.mc,.mrc,.myc-save-section');els.forEach(function(el,i){setTimeout(function(){el.classList.add('myc-visible');},i*60);});} document.addEventListener('DOMContentLoaded',function(){ var fromURL=ldURL();if(!fromURL)ldLS();buildGrid(); document.getElementById('m-bs').addEventListener('click',function(){mSetM('superpasteurisation');});document.getElementById('m-bt').addEventListener('click',function(){mSetM('sterilisation');});document.getElementById('m-bg').addEventListener('click',function(){mSetU('g');});document.getElementById('m-bk').addEventListener('click',function(){mSetU('kg');});document.getElementById('m-qty').addEventListener('input',mRC);document.getElementById('m-sacs').addEventListener('input',mRC);document.getElementById('m-hs').addEventListener('input',function(){mOnH();});document.getElementById('m-ss').addEventListener('input',function(){mOnS('son');});document.getElementById('m-ps').addEventListener('input',function(){mOnS('pai');});document.getElementById('m-bs2').addEventListener('input',function(){mOnS('boi');});document.getElementById('m-sps').addEventListener('input',function(){mOnSp();});document.getElementById('m-gys').addEventListener('input',function(){S.gy=parseFloat(this.value);document.getElementById('m-gyv').textContent=S.gy+'%';sC(this,S.gy,0,10);mRC();svLS();});document.getElementById('m-lson').addEventListener('click',function(){mTLk('son');});document.getElementById('m-lpai').addEventListener('click',function(){mTLk('pai');});document.getElementById('m-lboi').addEventListener('click',function(){mTLk('boi');});document.getElementById('m-cc').addEventListener('change',function(){mTCost();renderCIP();});document.getElementById('m-dchf').addEventListener('click',function(){setDev('CHF');});document.getElementById('m-deur').addEventListener('click',function(){setDev('EUR');});document.getElementById('m-dusd').addEventListener('click',function(){setDev('USD');});['m-pson','m-ppai','m-pboi','m-psp','m-pgy'].forEach(function(id){document.getElementById(id).addEventListener('input',mRC);});document.getElementById('m-reset-inline').addEventListener('click',function(){if(!S.custom){applyDef();synCol();mRC();svLS();}});document.getElementById('m-copy-btn').addEventListener('click',function(){var txt=document.getElementById('m-shop').innerText;navigator.clipboard.writeText(txt).then(function(){var el=document.getElementById('m-cop');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2200);});});document.getElementById('m-share-btn').addEventListener('click',function(){mShare();});document.getElementById('m-print-btn').addEventListener('click',function(){var shop=document.getElementById('m-shop');if(!shop||!shop.innerHTML){alert(T('no_recipe_print'));return;}mkPrintWin(T('recipe_title'),shop.innerHTML);});document.getElementById('myc-add-ing-btn').addEventListener('click',function(){addCI('',0);});document.getElementById('m-save-btn').addEventListener('click',function(){var g=document.getElementById('m-login-gate');if(g&&!g.classList.contains('show')){g.classList.add('show');return;}saveRec();}); document.getElementById('m-bs').classList.toggle('active',S.m==='superpasteurisation');document.getElementById('m-bt').classList.toggle('active',S.m==='sterilisation');updFiche();if(S.u==='kg'){document.getElementById('m-bg').classList.remove('active');document.getElementById('m-bk').classList.add('active');}if(S.cost){document.getElementById('m-cc').checked=true;document.getElementById('m-cz').style.display='block';}setDev(_devise,true);if(CI.length)renderCI();updAB();synSl();synCol();mRC();renderSv();setTimeout(cascade,50); }); })();// ================================================================ // AGAR // ================================================================ (function(){ var _agP='mea';var _agMgr=mkGLMgr('ag',calcAg,3);var _agLocks={}; function initAgLocks(){_agLocks.agar=mkLockBtn('ag-lk-agar','ag-s-agar','ag-ph-agar',true,function(){calcAg();});_agLocks.malt=mkLockBtn('ag-lk-malt','ag-malts','ag-ph-malt',true,function(){calcAg();});_agLocks.dext=mkLockBtn('ag-lk-dext','ag-s-dext','ag-ph-dext',true,function(){calcAg();});} function setAgP(p){_agP=p;['mea','pda','custom'].forEach(function(k){document.getElementById('ag-'+k).classList.toggle('active',k===p);});var DESCS={mea:'mea_desc',pda:'pda_desc',custom:'custom_desc_ag'};document.getElementById('ag-desc-txt').textContent=T(DESCS[p]);var ingsSec=document.getElementById('ag-ingredients-section');var dextRow=document.getElementById('ag-r-dext');if(p==='custom'){if(ingsSec)ingsSec.style.display='none';}else{if(ingsSec)ingsSec.style.display='block';document.getElementById('ag-r-agar').style.display='flex';document.getElementById('ag-r-malt').style.display='flex';if(dextRow)dextRow.style.display=p==='pda'?'flex':'none';}calcAg();} function calcAg(){var petri=Math.max(1,parseInt(document.getElementById('ag-petri').value)||10);var vol=Math.max(10,parseInt(document.getElementById('ag-vol').value)||25);var totMl=petri*vol,totL=totMl/1000;var rows=[];if(_agP!=='custom'){var agarV=parseFloat(document.getElementById('ag-s-agar').value)||15;var maltV=parseFloat(document.getElementById('ag-malts').value)||20;rows.push({n:T('ag_agar_ing').replace(' (g/L)',''),v:fGag(agarV*totL),sub:agarV+' g/L'});rows.push({n:(MYC_LANG==='en'?'Malt extract':'Extrait de malt'),v:fGag(maltV*totL),sub:maltV+' g/L'});if(_agP==='pda'){var dextV=parseFloat(document.getElementById('ag-s-dext').value)||20;rows.push({n:'Dextrose',v:fGag(dextV*totL),sub:dextV+' g/L'});}}_agMgr.getIngs().forEach(function(ci){if(ci.conc>0)rows.push({n:ci.name||T('custom_ing'),v:fGag(ci.conc*totL),sub:ci.conc+' g/L'});});rows.push({n:T('water_dist'),v:totMl+' mL',total:true});var html=rows.map(function(r){return'
'+r.n+''+(r.sub&&!r.total?'
'+r.sub+'
':'')+'
'+r.v+'
';}).join('');var dt=petri>1?T('dishes_pl'):T('dishes');html+='
'+T('for_dishes')+' '+petri+' '+dt+' '+T('of')+' '+vol+' mL \u2014 '+T('total_vol')+' : '+totMl+' mL
';document.getElementById('ag-result').innerHTML=html;updAgW();} function updAgW(){var zone=document.getElementById('ag-wz'),w=[];if(_agP!=='custom'){var malt=parseFloat(document.getElementById('ag-malts').value)||20;if(malt<15)w.push({t:'warn',m:Tw('wa_low',{'%M%':malt,'%O%':20})});else if(malt>25)w.push({t:'warn',m:Tw('wa_high',{'%M%':malt,'%O%':20})});if(malt>35)w.push({t:'danger',m:Tw('wa_vhigh',{'%M%':malt})});if(malt<10)w.push({t:'danger',m:Tw('wa_vlow',{'%M%':malt})});}zone.innerHTML=w.length?w.map(function(x){return'
'+x.m+'
';}).join(''):''+T('no_warn_ag')+'';} function gAgSv(){try{return JSON.parse(localStorage.getItem('myc-ag-saved')||'[]');}catch(e){return[];}} function renderAgSv(){var sv=gAgSv();var list=document.getElementById('ag-saved-list');if(!list)return;if(!sv.length){list.innerHTML=''+T('no_saved')+'';return;}list.innerHTML=sv.map(function(r,i){var d=new Date(r.date).toLocaleDateString(MYC_LANG==='fr'?'fr-CH':'en-GB',{day:'2-digit',month:'2-digit',year:'numeric'});return'
'+r.name+' - '+d+'
';}).join('');list.querySelectorAll('.myc-saved-name').forEach(function(el){el.addEventListener('click',function(){var r=gAgSv()[parseInt(this.dataset.i)];setAgP(r.p||'mea');var sl=document.getElementById('ag-malts');sl.value=r.malt||20;document.getElementById('ag-maltv').textContent=(r.malt||20)+' g/L';sC(sl,r.malt||20,10,40);document.getElementById('ag-petri').value=r.petri||10;document.getElementById('ag-vol').value=r.vol||25;calcAg();});});list.querySelectorAll('.myc-saved-del').forEach(function(el){el.addEventListener('click',function(){var s=gAgSv();s.splice(parseInt(this.dataset.i),1);localStorage.setItem('myc-ag-saved',JSON.stringify(s));renderAgSv();});});} document.addEventListener('DOMContentLoaded',function(){ initAgLocks(); var agSl=document.getElementById('ag-malts');agSl.addEventListener('input',function(){document.getElementById('ag-maltv').textContent=this.value+' g/L';sC(this,parseFloat(this.value),10,40);calcAg();});sC(agSl,20,10,40); var agarSl=document.getElementById('ag-s-agar');agarSl.addEventListener('input',function(){document.getElementById('ag-v-agar').textContent=this.value+' g/L';sC(this,parseFloat(this.value),5,25);calcAg();});sC(agarSl,15,5,25); var dextSl=document.getElementById('ag-s-dext');dextSl.addEventListener('input',function(){document.getElementById('ag-v-dext').textContent=this.value+' g/L';sC(this,parseFloat(this.value),5,40);calcAg();});sC(dextSl,20,5,40); ['ag-mea','ag-pda','ag-custom'].forEach(function(id){document.getElementById(id).addEventListener('click',function(){setAgP(id.replace('ag-',''));});}); ['ag-petri','ag-vol'].forEach(function(id){var el=document.getElementById(id);if(el)el.addEventListener('input',calcAg);}); document.getElementById('ag-add-ing-btn').addEventListener('click',function(){_agMgr.add('',0);}); document.getElementById('ag-copy-btn').addEventListener('click',function(){var txt=document.getElementById('ag-result').innerText;navigator.clipboard.writeText(txt).then(function(){var el=document.getElementById('ag-cop');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2200);});}); document.getElementById('ag-share-btn').addEventListener('click',function(){var url=window.location.href.split('?')[0]+'?mode=agar&agp='+_agP;navigator.clipboard.writeText(url).then(function(){var el=document.getElementById('ag-share-ok');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2500);});}); document.getElementById('ag-print-btn').addEventListener('click',function(){var res=document.getElementById('ag-result');if(!res||!res.innerHTML){alert(T('no_recipe_print'));return;}mkPrintWin(T('ag_title'),res.innerHTML);}); document.getElementById('ag-save-btn').addEventListener('click',function(){var g=document.getElementById('ag-login-gate');if(g&&!g.classList.contains('show')){g.classList.add('show');return;}var nm=document.getElementById('ag-save-name').value.trim();if(!nm){alert(T('give_name_s'));return;}var sv=gAgSv();sv.unshift({name:nm,date:Date.now(),p:_agP,malt:document.getElementById('ag-malts').value,petri:document.getElementById('ag-petri').value,vol:document.getElementById('ag-vol').value});if(sv.length>20)sv=sv.slice(0,20);localStorage.setItem('myc-ag-saved',JSON.stringify(sv));document.getElementById('ag-save-name').value='';renderAgSv();mycToast(T('toast_ag'));}); document.getElementById('ag-desc-txt').textContent=T('mea_desc');calcAg();renderAgSv(); }); })();// ================================================================ // CULTURE LIQUIDE — fix boutons lc-malt, lc-glucose, lc-custom // ================================================================ (function(){ var _lcP='malt';var _lcMgr=mkGLMgr('lc',calcLC,3);var _lcLk=null; var LC_PRESETS={malt:{label:'lc_malt_label',min:'lc_malt_min',max:'lc_malt_max',rec:'lc_malt_rec',smin:2,smax:15,def:4},glucose:{label:'lc_glc_label',min:'lc_glc_min',max:'lc_glc_max',rec:'lc_glc_rec',smin:5,smax:20,def:10}}; function setLcP(p){ _lcP=p; ['malt','glucose','custom'].forEach(function(k){var el=document.getElementById('lc-'+k);if(el)el.classList.toggle('active',k===p);}); var descKeys={malt:'lc_malt_desc',glucose:'lc_glc_desc',custom:'lc_cust_desc'}; var descEl=document.getElementById('lc-desc-txt');if(descEl)descEl.textContent=T(descKeys[p]||'lc_cust_desc'); var stdSlider=document.getElementById('lc-std-slider');var customEmpty=document.getElementById('lc-custom-empty'); if(p==='custom'){if(stdSlider)stdSlider.style.display='none';if(customEmpty)customEmpty.style.display='block';} else{if(stdSlider)stdSlider.style.display='block';if(customEmpty)customEmpty.style.display='none'; var preset=LC_PRESETS[p];if(preset){var sl=document.getElementById('lc-concs');if(sl){sl.min=preset.smin;sl.max=preset.smax;sl.value=preset.def;sC(sl,preset.def,preset.smin,preset.smax);}var lbl=document.getElementById('lc-ing-label');if(lbl)lbl.textContent=T(preset.label);var minLbl=document.getElementById('lc-min-label');if(minLbl)minLbl.textContent=T(preset.min);var maxLbl=document.getElementById('lc-max-label');if(maxLbl)maxLbl.textContent=T(preset.max);var subEl=document.getElementById('lc-sub-main');if(subEl)subEl.textContent=T(preset.rec);var valEl=document.getElementById('lc-concv');if(valEl)valEl.textContent=preset.def+' g/L';}} calcLC();} function calcLC(){var bocaux=Math.max(1,parseInt(document.getElementById('lc-bocaux').value)||1);var vol=Math.max(50,parseInt(document.getElementById('lc-vol').value)||500);var totMl=bocaux*vol,totL=totMl/1000;var rows=[];if(_lcP!=='custom'){var concV=parseFloat(document.getElementById('lc-concs').value)||4;var ingName=_lcP==='malt'?(MYC_LANG==='en'?'Malt extract':'Extrait de malt'):(MYC_LANG==='en'?'Glucose syrup':'Sirop de glucose');rows.push({n:ingName,v:fGag(concV*totL),sub:concV+' g/L'});}_lcMgr.getIngs().forEach(function(ci){if(ci.conc>0)rows.push({n:ci.name||T('custom_ing'),v:fGag(ci.conc*totL),sub:ci.conc+' g/L'});});rows.push({n:T('water_dist'),v:fMl(totMl),total:true});var html=rows.map(function(r){return'
'+r.n+''+(r.sub&&!r.total?'
'+r.sub+'
':'')+'
'+r.v+'
';}).join('');var jt=bocaux>1?T('jars'):T('jar');html+='
'+T('for_jars')+' '+bocaux+' '+jt+' '+T('of')+' '+vol+' mL \u2014 '+T('total_vol')+' : '+fMl(totMl)+'
';document.getElementById('lc-result').innerHTML=html;updLcW();} function updLcW(){var zone=document.getElementById('lc-wz'),w=[];if(_lcP!=='custom'){var conc=parseFloat(document.getElementById('lc-concs').value)||4;var opt=_lcP==='malt'?4:10;if(concopt*2.5)w.push({t:'danger',m:Tw('wl_vhigh',{'%C%':conc})});else if(conc>opt*1.8)w.push({t:'warn',m:Tw('wl_high',{'%C%':conc})});else w.push({t:'info',m:Tw('wl_ok',{'%C%':conc})});}zone.innerHTML=w.length?w.map(function(x){return'
'+x.m+'
';}).join(''):''+T('no_warn_lc')+'';} function gLcSv(){try{return JSON.parse(localStorage.getItem('myc-lc-saved')||'[]');}catch(e){return[];}} function renderLcSv(){var sv=gLcSv();var list=document.getElementById('lc-saved-list');if(!list)return;if(!sv.length){list.innerHTML=''+T('no_saved')+'';return;}list.innerHTML=sv.map(function(r,i){var d=new Date(r.date).toLocaleDateString(MYC_LANG==='fr'?'fr-CH':'en-GB',{day:'2-digit',month:'2-digit',year:'numeric'});return'
'+r.name+' - '+d+'
';}).join('');list.querySelectorAll('.myc-saved-name').forEach(function(el){el.addEventListener('click',function(){var r=gLcSv()[parseInt(this.dataset.i)];setLcP(r.p||'malt');var sl=document.getElementById('lc-concs');if(sl&&r.conc){sl.value=r.conc;document.getElementById('lc-concv').textContent=r.conc+' g/L';var preset=LC_PRESETS[r.p]||LC_PRESETS.malt;sC(sl,r.conc,preset.smin,preset.smax);}if(r.bocaux)document.getElementById('lc-bocaux').value=r.bocaux;if(r.vol)document.getElementById('lc-vol').value=r.vol;calcLC();});});list.querySelectorAll('.myc-saved-del').forEach(function(el){el.addEventListener('click',function(){var s=gLcSv();s.splice(parseInt(this.dataset.i),1);localStorage.setItem('myc-lc-saved',JSON.stringify(s));renderLcSv();});});} document.addEventListener('DOMContentLoaded',function(){ // FIX LC — les 3 boutons preset ['malt','glucose','custom'].forEach(function(id){var el=document.getElementById('lc-'+id);if(el)el.addEventListener('click',function(){setLcP(id);});}); var lcSl=document.getElementById('lc-concs');if(lcSl){lcSl.addEventListener('input',function(){document.getElementById('lc-concv').textContent=this.value+' g/L';var preset=LC_PRESETS[_lcP]||LC_PRESETS.malt;sC(this,parseFloat(this.value),preset.smin,preset.smax);calcLC();});sC(lcSl,4,2,15);} _lcLk=mkLockBtn('lc-lk-main','lc-concs','lc-ph-main',true,function(){calcLC();}); ['lc-bocaux','lc-vol'].forEach(function(id){var el=document.getElementById(id);if(el)el.addEventListener('input',calcLC);}); document.getElementById('lc-add-ing-btn').addEventListener('click',function(){_lcMgr.add('',0);}); document.getElementById('lc-copy-btn').addEventListener('click',function(){var txt=document.getElementById('lc-result').innerText;navigator.clipboard.writeText(txt).then(function(){var el=document.getElementById('lc-cop');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2200);});}); document.getElementById('lc-share-btn').addEventListener('click',function(){var url=window.location.href.split('?')[0]+'?mode=lc&lcp='+_lcP;navigator.clipboard.writeText(url).then(function(){var el=document.getElementById('lc-share-ok');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2500);});}); document.getElementById('lc-print-btn').addEventListener('click',function(){var res=document.getElementById('lc-result');if(!res||!res.innerHTML){alert(T('no_recipe_print'));return;}mkPrintWin(T('lc_title'),res.innerHTML);}); document.getElementById('lc-save-btn').addEventListener('click',function(){var g=document.getElementById('lc-login-gate');if(g&&!g.classList.contains('show')){g.classList.add('show');return;}var nm=document.getElementById('lc-save-name').value.trim();if(!nm){alert(T('give_name_s'));return;}var conc=document.getElementById('lc-concs').value;var sv=gLcSv();sv.unshift({name:nm,date:Date.now(),p:_lcP,conc:conc,bocaux:document.getElementById('lc-bocaux').value,vol:document.getElementById('lc-vol').value});if(sv.length>20)sv=sv.slice(0,20);localStorage.setItem('myc-lc-saved',JSON.stringify(sv));document.getElementById('lc-save-name').value='';renderLcSv();mycToast(T('toast_lc'));}); setLcP('malt');calcLC();renderLcSv(); }); })();// ================================================================ // MONOTUB v5.2 // ================================================================ (function(){ var isEN=function(){return false;}; var DEF_RATIOS={cocoPerCVG:65,vermiPerCVG:0.2,eauPerCoco:6.0,gyPerCoco:15,spawnDens:0.7}; var RATIOS={cocoPerCVG:65,vermiPerCVG:0.2,eauPerCoco:6.0,gyPerCoco:15,spawnDens:0.7}; var MT={l:53,w:37,depth:10,nb:1,spawnPct:25,cost:false}; function cmToIn(cm){return Math.round(cm/2.54*10)/10;}function lToQt(l){return Math.round(l*1.0567*100)/100;}function gToOz(g){return Math.round(g*0.03527*10)/10;}function kgToLbs(kg){return Math.round(kg*2.2046*100)/100;} function fD(cm){return isEN()?cmToIn(cm):cm;}function uD(){return isEN()?'in':'cm';}function fV(l){return isEN()?lToQt(l):l;}function uV(){return isEN()?'qt':'L';}function fGmt(g){return isEN()?gToOz(g):g;}function fKg(kg){return isEN()?kgToLbs(kg):kg;} function fVDisp(l){return fV(l).toFixed(isEN()?2:1)+' '+uV();}function fGDisp(g){return fGmt(g).toFixed(isEN()?1:0)+' '+(isEN()?'oz':'g');}function fKgDisp(kg){return fKg(kg).toFixed(2)+' '+(isEN()?'lbs':'kg');}function fDDisp(cm){return fD(cm).toFixed(isEN()?1:0)+' '+uD();} function calc(){var volFinal=(MT.l*MT.w*MT.depth)/1000;var spawnVol=volFinal*(MT.spawnPct/100);var cvgVol=volFinal*(1-MT.spawnPct/100);var cocoG=Math.round(cvgVol*RATIOS.cocoPerCVG);var vermiL=Math.round(cvgVol*RATIOS.vermiPerCVG*100)/100;var eauL=Math.round(cocoG/1000*RATIOS.eauPerCoco*10)/10;var gyG=Math.round(cocoG*RATIOS.gyPerCoco/100);var spawnKg=Math.round(spawnVol*RATIOS.spawnDens*100)/100;return{volFinal:volFinal,spawnVol:spawnVol,cvgVol:cvgVol,cocoG:cocoG,vermiL:vermiL,eauL:eauL,gyG:gyG,spawnKg:spawnKg};} function calcEp(volFinal){if(!MT.l||!MT.w||MT.l<=0||MT.w<=0)return 0;return Math.round((volFinal*1000)/(MT.l*MT.w)*10)/10;} function updDepthVal(){var r=calc();var ep=calcEp(r.volFinal);var el=document.getElementById('mt-depth-val');if(el)el.innerHTML=fDDisp(MT.depth)+' ('+fVDisp(r.volFinal)+')';updDepthWarn(ep);} function updDepthWarn(ep){var zone=document.getElementById('mt-depth-warn');if(!zone)return;var w=[];if(ep<5)w.push({t:'danger',m:'\u274c '+(isEN()?'Depth too low.':'Epaisseur trop faible.')});else if(ep<7)w.push({t:'warn',m:'\u26a0\ufe0f '+(isEN()?'Low depth \u2014 aim for 7\u201312 cm.':'Epaisseur faible \u2014 viser 7\u201312 cm.')});if(ep>15)w.push({t:'danger',m:'\u26a0\ufe0f '+(isEN()?'Very high depth \u2014 anaerobiosis risk.':'Epaisseur \u00e9lev\u00e9e \u2014 risque d\'ana\u00e9robiose.')});else if(ep>12)w.push({t:'warn',m:'\u26a0\ufe0f '+(isEN()?'High depth.':'Epaisseur \u00e9lev\u00e9e.')});zone.innerHTML=w.map(function(x){return'
'+x.m+'
';}).join('');} function updIngRows(r){var ec=document.getElementById('mt-res-coco');if(ec)ec.textContent=fGDisp(r.cocoG);var ri=document.getElementById('mt-ri-coco');if(ri)ri.value=RATIOS.cocoPerCVG;var rcu=document.getElementById('mt-ratio-coco-unit');if(rcu)rcu.textContent=isEN()?'oz/qt CVG':'g/L CVG';updIngWarn('coco');var ev=document.getElementById('mt-res-vermi');if(ev)ev.textContent=fVDisp(r.vermiL);var rv=document.getElementById('mt-ri-vermi');if(rv)rv.value=RATIOS.vermiPerCVG;var rvu=document.getElementById('mt-ratio-vermi-unit');if(rvu)rvu.textContent=isEN()?'qt/qt CVG':'L/L CVG';updIngWarn('vermi');var ee=document.getElementById('mt-res-eau');if(ee)ee.textContent=fVDisp(r.eauL);var re2=document.getElementById('mt-ri-eau');if(re2)re2.value=RATIOS.eauPerCoco;var reu=document.getElementById('mt-ratio-eau-unit');if(reu)reu.textContent=isEN()?'qt/lbs coco':'L/kg coco';updIngWarn('eau');var eg=document.getElementById('mt-res-gy');if(eg)eg.textContent=fGDisp(r.gyG);var rg=document.getElementById('mt-ri-gy');if(rg)rg.value=RATIOS.gyPerCoco;var rgu=document.getElementById('mt-ratio-gy-unit');if(rgu)rgu.textContent='% coco';updIngWarn('gy');var es=document.getElementById('mt-res-spawn');if(es)es.textContent=fKgDisp(r.spawnKg);var rs=document.getElementById('mt-ri-spawn');if(rs)rs.value=RATIOS.spawnDens;var rsu=document.getElementById('mt-ratio-spawn-unit');if(rsu)rsu.textContent=isEN()?'lbs/qt spawn':'kg/L spawn';updIngWarn('spawn');} function updIngWarn(key){var el=document.getElementById('mt-warn-'+key);if(!el)return;var msg='',cls='';if(key==='eau'){var r=RATIOS.eauPerCoco;if(r<4.5){msg=isEN()?'\u26a0\ufe0f Very low water ratio.':'\u26a0\ufe0f Ratio eau trop faible.';cls='danger';}else if(r<5){msg=isEN()?'\uD83D\uDCA1 Low ratio.':'\uD83D\uDCA1 Ratio faible.';cls='warn';}else if(r>8){msg=isEN()?'\u26a0\ufe0f Very high ratio.':'\u26a0\ufe0f Ratio tr\u00e8s \u00e9lev\u00e9.';cls='danger';}else if(r>7){msg=isEN()?'\u26a0\ufe0f High ratio.':'\u26a0\ufe0f Ratio \u00e9lev\u00e9.';cls='warn';}}else if(key==='gy'){if(RATIOS.gyPerCoco===0){msg=isEN()?'\uD83D\uDCA1 No gypsum.':'\uD83D\uDCA1 Sans gypse.';cls='warn';}else if(RATIOS.gyPerCoco>25){msg=isEN()?'\u26a0\ufe0f Too much gypsum.':'\u26a0\ufe0f Trop de gypse.';cls='danger';}}el.textContent=msg;el.className='mt-ing-warn'+(msg?' show ':' ')+(cls||'');} function updMainWarns(ep){var zone=document.getElementById('mt-wz');if(!zone)return;var w=[];if(ep<5)w.push({t:'danger',m:'\u274c '+(isEN()?'Depth too low.':'Epaisseur trop faible.')});else if(ep<7)w.push({t:'warn',m:'\u26a0\ufe0f '+(isEN()?'Low depth.':'Epaisseur faible.')});if(ep>15)w.push({t:'danger',m:'\u26a0\ufe0f '+(isEN()?'Very high depth.':'Epaisseur tr\u00e8s \u00e9lev\u00e9e.')});if(MT.spawnPct>35)w.push({t:'warn',m:'\uD83D\uDCA1 '+(isEN()?'High spawn ('+MT.spawnPct+'%).':'Spawn \u00e9lev\u00e9 ('+MT.spawnPct+'%).')});if(MT.spawnPct<15)w.push({t:'warn',m:'\uD83D\uDCA1 '+(isEN()?'Low spawn ('+MT.spawnPct+'%).':'Spawn faible ('+MT.spawnPct+'%).')});var eau=RATIOS.eauPerCoco;if(eau<4.5||eau>8)w.push({t:'danger',m:'\uD83D\uDCA7 '+(isEN()?'Extreme water ratio ('+eau+').':'Ratio eau extr\u00eame ('+eau+').')});else if(eau>7)w.push({t:'warn',m:'\uD83D\uDCA7 '+(isEN()?'High water ratio ('+eau+').':'Ratio eau \u00e9lev\u00e9 ('+eau+').')});if(RATIOS.gyPerCoco===0)w.push({t:'warn',m:'\uD83E\uDEA8 '+(isEN()?'No gypsum.':'Sans gypse.')});zone.innerHTML=w.length?w.map(function(x){return'
'+x.m+'
';}).join(''):''+(isEN()?'No warnings.':'Aucun avertissement.')+'';} function updLabels(){var L={'mt-step1-txt':isEN()?'Step 1 \u2014 Number of tubs':'Etape 1 \u2014 Nombre de monotubs','mt-step2-txt':isEN()?'Step 2 \u2014 Tub dimensions':'Etape 2 \u2014 Dimensions du bac','mt-step3-txt':isEN()?'Step 3 \u2014 Target depth':'Etape 3 \u2014 Profondeur cible','mt-step4-txt':isEN()?'Step 4 \u2014 Spawn rate':'Etape 4 \u2014 Taux de spawn','mt-step5-txt':isEN()?'Step 5 \u2014 CVG ingredients':'Etape 5 \u2014 Ingr\u00e9dients CVG','mt-lbl-depth':isEN()?'\uD83D\uDCCF Target depth':'\uD83D\uDCCF Profondeur cible','mt-depth-min':isEN()?'2 in \u2014 min':'5 cm \u2014 minimum','mt-depth-max':isEN()?'8 in \u2014 max':'20 cm \u2014 maximum','mt-lbl-spawn':isEN()?'\uD83C\uDF44 Grain spawn (% of final volume)':'\uD83C\uDF44 Grain spawn (% du volume final)','mt-spawn-min':isEN()?'15% \u2014 economical':'15% \u2014 \u00e9conomique','mt-spawn-max':isEN()?'35% \u2014 fast':'35% \u2014 rapide','mt-spawn-rec':isEN()?'Recommended: 20\u201330% of final volume.':'Recommand\u00e9 : 20\u201330% du volume final.','mt-ing-title':isEN()?'\uD83D\uDD12 Recommended values':'\uD83D\uDD12 Valeurs recommand\u00e9es','mt-ing-hint':isEN()?'Adjust only based on the coco brand. Do the squeeze test after cooling.':'A ajuster selon la marque de coco. Faites le test de la poign\u00e9e apr\u00e8s refroidissement.','mt-lbl-coco':isEN()?'Coco coir (dry)':'Fibre de coco (sec)','mt-lbl-vermi':'Vermiculite','mt-lbl-eau':isEN()?'Boiling water':'Eau bouillante','mt-lbl-gy':isEN()?'Gypsum':'Gypse','mt-lbl-gy-add':isEN()?'(additive)':'(additif)','mt-lbl-spawn2':'Grain spawn','mt-reset-lbl':isEN()?'Recalculate from dimensions':'Recalculer depuis les dimensions','mt-result-title':isEN()?'\uD83D\uDCCB Monotub CVG Recipe':'\uD83D\uDCCB Recette Monotub CVG','mt-list-title':isEN()?'Shopping list':'Liste de courses','mt-saved-title':isEN()?'My saved monotub recipes':'Mes recettes monotub sauvegard\u00e9es','mt-warn-txt':isEN()?'Warnings':'Avertissements','mt-cost-txt':isEN()?'Cost mode (optional)':'Mode co\u00fbt (optionnel)','mt-lbl-cost':isEN()?'Calculate production cost':'Calculer le co\u00fbt de revient','mt-lbl-nb':isEN()?'Number of tubs':'Nombre de monotubs','mt-lbl-l':isEN()?'Length (in)':'Longueur (cm)','mt-lbl-w':isEN()?'Width (in)':'Largeur (cm)','mt-dims-hint':isEN()?'Enter the inner dimensions of the tub.':'Dimensions int\u00e9rieures du bac en centim\u00e8tres.'};Object.keys(L).forEach(function(id){var el=document.getElementById(id);if(el)el.textContent=L[id];});document.querySelectorAll('.mt-devise-sym').forEach(function(el){el.textContent=devSym();});} function calcMT(){var r=calc();var ep=calcEp(r.volFinal);var n=Math.max(1,parseInt(document.getElementById('mt-nb').value)||1);var sym=devSym();var pr=null;if(MT.cost){pr={coco:conv(parseFloat(document.getElementById('mt-p-coco').value)||0),vermi:conv(parseFloat(document.getElementById('mt-p-vermi').value)||0),gy:conv(parseFloat(document.getElementById('mt-p-gy').value)||0),spawn:conv(parseFloat(document.getElementById('mt-p-spawn').value)||0)};}updIngRows(r);updDepthWarn(ep);updMainWarns(ep);var dimStr=isEN()?fD(MT.l).toFixed(1)+' x '+fD(MT.w).toFixed(1)+' in, '+fDDisp(MT.depth):MT.l+' x '+MT.w+' cm, '+MT.depth+' cm';document.getElementById('mt-recap').innerHTML=''+(isEN()?'CVG Recipe':'Recette CVG')+' \u2014 '+n+' '+(n>1?(isEN()?'tubs':'bacs'):(isEN()?'tub':'bac'))+', '+dimStr+'. Spawn : '+MT.spawnPct+'%. '+(isEN()?'Est. depth':'Epaisseur')+' : '+fDDisp(ep)+'.';var lCoco=isEN()?'Coco coir':'Fibre de coco';var lEau=isEN()?'Boiling water':'Eau bouillante';var lGy=isEN()?'Gypsum (additive)':'Gypse (additif)';var cout1=pr?((r.cocoG/1000)*pr.coco+(r.vermiL*pr.vermi)+(r.gyG/1000)*pr.gy+r.spawnKg*pr.spawn):0;function ingRow(emoji,nom,valStr,pkAmt){var pstr='';if(pr&&pkAmt>0)pstr='
'+(pkAmt).toFixed(2)+' '+sym+'
';return'
'+emoji+' '+nom+'
'+valStr+'
'+pstr+'
';}function buildCols(m){var rows='
';rows+=ingRow('\uD83E\uDD65',lCoco,fGDisp(r.cocoG*m),pr?((r.cocoG*m)/1000)*pr.coco:0);rows+=ingRow('\uD83D\uDFE1','Vermiculite',fVDisp(r.vermiL*m),pr?(r.vermiL*m)*pr.vermi:0);rows+=ingRow('\uD83D\uDCA7',lEau,fVDisp(r.eauL*m),0);if(r.gyG>0)rows+=ingRow('\uD83E\uDEA8',lGy,fGDisp(r.gyG*m),pr?((r.gyG*m)/1000)*pr.gy:0);rows+=ingRow('\uD83C\uDF44','Grain spawn',fKgDisp(r.spawnKg*m),pr?(r.spawnKg*m)*pr.spawn:0);rows+='
\uD83D\uDCCB '+(isEN()?'Est. depth':'Epaisseur')+'
~'+fDDisp(ep)+'
'+(pr?'
'+(cout1*m).toFixed(2)+' '+sym+'
':'')+'
';rows+='
';return rows;}var html='
'+(isEN()?'Per tub':'Par bac')+'
'+buildCols(1)+'
';if(n>1)html+='
'+(isEN()?'Total':'Total')+' \u2014 '+n+' '+(isEN()?'tubs':'bacs')+'
'+buildCols(n)+'
';document.getElementById('mt-cols').innerHTML=html;buildMTShop(r,ep,n,pr,cout1,sym,lCoco,lEau,lGy);} function buildMTShop(r,ep,n,pr,cout1,sym,lCoco,lEau,lGy){var shop=document.getElementById('mt-shop');shop.innerHTML='';function mkS(t){var s=document.createElement('div');s.className='mshop-section';s.textContent=t;return s;}function mkR(nm,val,price){var row=document.createElement('div');row.className='mshop-row';var n2=document.createElement('span');n2.className='mshop-name';n2.textContent=nm;var ri=document.createElement('div');ri.className='mshop-right';var vl=document.createElement('span');vl.className='mshop-val';vl.textContent=val;ri.appendChild(vl);if(price){var p=document.createElement('span');p.className='mshop-price';p.textContent=price;ri.appendChild(p);}row.appendChild(n2);row.appendChild(ri);return row;}function mkT(nm,val,price){var row=document.createElement('div');row.className='mshop-total-row';var n2=document.createElement('span');n2.className='mshop-total-name';n2.textContent=nm;var ri=document.createElement('div');ri.className='mshop-total-right';var vl=document.createElement('span');vl.className='mshop-total-val';vl.textContent=val;ri.appendChild(vl);if(price){var p=document.createElement('span');p.className='mshop-price';p.textContent=price;ri.appendChild(p);}row.appendChild(n2);row.appendChild(ri);return row;}function mkD(){var d=document.createElement('div');d.className='mshop-divider';return d;}function pS(amt){return(pr&&amt>0)?amt.toFixed(2)+' '+sym:null;}function addRows(m){shop.appendChild(mkR(lCoco,fGDisp(r.cocoG*m),pS(pr?((r.cocoG*m)/1000)*pr.coco:0)));shop.appendChild(mkR('Vermiculite',fVDisp(r.vermiL*m),pS(pr?(r.vermiL*m)*pr.vermi:0)));shop.appendChild(mkR(lEau,fVDisp(r.eauL*m),null));if(r.gyG>0)shop.appendChild(mkR(lGy,fGDisp(r.gyG*m),pS(pr?((r.gyG*m)/1000)*pr.gy:0)));shop.appendChild(mkR('Grain spawn',fKgDisp(r.spawnKg*m),pS(pr?(r.spawnKg*m)*pr.spawn:0)));}var lEp=isEN()?'Est. depth':'Epaisseur estim\u00e9e';shop.appendChild(mkS(isEN()?'Per tub':'Par bac'));addRows(1);shop.appendChild(mkT(lEp,'~'+fDDisp(ep),pS(pr?cout1:0)));if(n>1){shop.appendChild(mkD());shop.appendChild(mkS((isEN()?'Total':'Total')+' \u2014 '+n+' '+(isEN()?'tubs':'bacs')));addRows(n);shop.appendChild(mkT((isEN()?'Total':'Total'),'',pS(pr?cout1*n:0)));}var meta=document.createElement('div');meta.className='mshop-meta';var dimStr2=isEN()?fD(MT.l).toFixed(1)+' x '+fD(MT.w).toFixed(1)+' x '+fD(MT.depth).toFixed(1)+' in':MT.l+' x '+MT.w+' x '+MT.depth+' cm';meta.innerHTML='Dimensions : '+dimStr2+'Spawn : '+MT.spawnPct+'%Eau : estimation \u2014 le test de la poign\u00e9e prime toujours.';shop.appendChild(meta);} function gMTSv(){try{return JSON.parse(localStorage.getItem('myc-mt2-saved')||'[]');}catch(e){return[];}} function renderMTSv(){var sv=gMTSv();var list=document.getElementById('mt-saved-list');if(!list)return;if(!sv.length){list.innerHTML=''+(isEN()?'No saved recipes.':'Aucune recette sauvegard\u00e9e.')+'';return;}list.innerHTML=sv.map(function(r,i){var d=new Date(r.date).toLocaleDateString(isEN()?'en-GB':'fr-CH',{day:'2-digit',month:'2-digit',year:'numeric'});return'
'+r.name+' \u2014 '+d+'
';}).join('');list.querySelectorAll('.myc-saved-name').forEach(function(el){el.addEventListener('click',function(){var r=gMTSv()[parseInt(this.dataset.i)];MT.l=r.l||53;MT.w=r.w||37;MT.depth=r.depth||10;MT.nb=r.nb||1;MT.spawnPct=r.spawnPct||25;if(r.ratios)RATIOS=Object.assign({},DEF_RATIOS,r.ratios);document.getElementById('mt-l').value=isEN()?cmToIn(MT.l).toFixed(1):MT.l;document.getElementById('mt-w').value=isEN()?cmToIn(MT.w).toFixed(1):MT.w;document.getElementById('mt-depth').value=MT.depth;document.getElementById('mt-nb').value=MT.nb;document.getElementById('mt-s-spawn').value=MT.spawnPct;document.getElementById('mt-v-spawn').textContent=MT.spawnPct+'%';sC(document.getElementById('mt-s-spawn'),MT.spawnPct,15,35);lockAll();updDepthVal();calcMT();});});list.querySelectorAll('.myc-saved-del').forEach(function(el){el.addEventListener('click',function(){var s=gMTSv();s.splice(parseInt(this.dataset.i),1);localStorage.setItem('myc-mt2-saved',JSON.stringify(s));renderMTSv();});});} function setLocked(rk,locked){var map={cocoPerCVG:{lk:'mt-lk-coco',row:'mt-row-coco',pm:'mt-pm-coco',ri:'mt-ri-coco'},vermiPerCVG:{lk:'mt-lk-vermi',row:'mt-row-vermi',pm:'mt-pm-vermi',ri:'mt-ri-vermi'},eauPerCoco:{lk:'mt-lk-eau',row:'mt-row-eau',pm:'mt-pm-eau',ri:'mt-ri-eau'},gyPerCoco:{lk:'mt-lk-gy',row:'mt-row-gy',pm:'mt-pm-gy',ri:'mt-ri-gy'},spawnDens:{lk:'mt-lk-spawn2',row:'mt-row-spawn2',pm:'mt-pm-spawn',ri:'mt-ri-spawn'}};var m=map[rk];if(!m)return;var lkBtn=document.getElementById(m.lk);var row=document.getElementById(m.row);var riEl=document.getElementById(m.ri);var pmM=document.getElementById(m.pm+'-m');var pmP=document.getElementById(m.pm+'-p');var path=lkBtn?lkBtn.querySelector('.mt-lk-path'):null;if(lkBtn)lkBtn.classList.toggle('locked',locked);if(row)row.classList.toggle('unlocked',!locked);if(riEl)riEl.disabled=locked;if(pmM)pmM.disabled=locked;if(pmP)pmP.disabled=locked;if(path)path.setAttribute('d',locked?'M7 11V7a5 5 0 0 1 9.9-1':'M7 11V7a5 5 0 0 1 10 0v4');} function lockAll(){['cocoPerCVG','vermiPerCVG','eauPerCoco','gyPerCoco','spawnDens'].forEach(function(k){setLocked(k,true);});} function updMTDev(){['CHF','EUR','USD'].forEach(function(x){var el=document.getElementById('mt-d'+x.toLowerCase());if(el)el.classList.toggle('active',x===_devise);});document.querySelectorAll('.mt-devise-sym').forEach(function(el){el.textContent=devSym();});var ti=document.getElementById('mt-taux-info');if(ti)ti.textContent=taux_info();calcMT();} document.addEventListener('DOMContentLoaded',function(){ updLabels(); document.getElementById('mt-l').value=isEN()?cmToIn(MT.l).toFixed(1):MT.l;document.getElementById('mt-w').value=isEN()?cmToIn(MT.w).toFixed(1):MT.w; sC(document.getElementById('mt-depth'),MT.depth,5,20);sC(document.getElementById('mt-s-spawn'),MT.spawnPct,15,35); lockAll();updDepthVal();calcMT(); document.getElementById('mt-l').addEventListener('input',function(){MT.l=isEN()?Math.round(parseFloat(this.value)*2.54):parseFloat(this.value)||53;updDepthVal();calcMT();}); document.getElementById('mt-w').addEventListener('input',function(){MT.w=isEN()?Math.round(parseFloat(this.value)*2.54):parseFloat(this.value)||37;updDepthVal();calcMT();}); document.getElementById('mt-depth').addEventListener('input',function(){MT.depth=parseInt(this.value);sC(this,MT.depth,5,20);updDepthVal();calcMT();}); document.getElementById('mt-nb').addEventListener('input',function(){MT.nb=Math.max(1,parseInt(this.value)||1);calcMT();}); document.getElementById('mt-s-spawn').addEventListener('input',function(){MT.spawnPct=parseInt(this.value);document.getElementById('mt-v-spawn').textContent=MT.spawnPct+'%';sC(this,MT.spawnPct,15,35);updDepthVal();calcMT();}); document.getElementById('mt-lk-spawn').addEventListener('click',function(){var sl=document.getElementById('mt-s-spawn');var locked=sl.disabled;sl.disabled=!locked;this.classList.toggle('locked',!locked);document.getElementById('mt-ph-spawn').setAttribute('d',!locked?'M7 11V7a5 5 0 0 1 9.9-1':'M7 11V7a5 5 0 0 1 10 0v4');}); document.querySelectorAll('.mt-ing-lk').forEach(function(btn){btn.addEventListener('click',function(){var rk=this.getAttribute('data-ratio');var locked=this.classList.contains('locked');setLocked(rk,!locked);calcMT();});}); var PM=[{m:'mt-pm-coco-m',p:'mt-pm-coco-p',ri:'mt-ri-coco',key:'cocoPerCVG',step:1,min:30,max:120,dec:0},{m:'mt-pm-vermi-m',p:'mt-pm-vermi-p',ri:'mt-ri-vermi',key:'vermiPerCVG',step:0.01,min:0.05,max:0.8,dec:2},{m:'mt-pm-eau-m',p:'mt-pm-eau-p',ri:'mt-ri-eau',key:'eauPerCoco',step:0.1,min:3,max:10,dec:1},{m:'mt-pm-gy-m',p:'mt-pm-gy-p',ri:'mt-ri-gy',key:'gyPerCoco',step:1,min:0,max:30,dec:0},{m:'mt-pm-spawn-m',p:'mt-pm-spawn-p',ri:'mt-ri-spawn',key:'spawnDens',step:0.01,min:0.5,max:0.9,dec:2}]; PM.forEach(function(cfg){var mi=document.getElementById(cfg.m);var pi=document.getElementById(cfg.p);var ri=document.getElementById(cfg.ri);function applyRatio(v){v=Math.max(cfg.min,Math.min(cfg.max,Math.round(v*10000)/10000));RATIOS[cfg.key]=v;if(ri)ri.value=v.toFixed(cfg.dec);calcMT();}if(mi)mi.addEventListener('click',function(){applyRatio(RATIOS[cfg.key]-cfg.step);});if(pi)pi.addEventListener('click',function(){applyRatio(RATIOS[cfg.key]+cfg.step);});if(ri)ri.addEventListener('input',function(){applyRatio(parseFloat(this.value)||RATIOS[cfg.key]);});}); document.getElementById('mt-reset-btn').addEventListener('click',function(){RATIOS=Object.assign({},DEF_RATIOS);lockAll();calcMT();}); document.getElementById('mt-cc').addEventListener('change',function(){MT.cost=this.checked;document.getElementById('mt-cz').style.display=MT.cost?'block':'none';calcMT();}); document.getElementById('mt-dchf').addEventListener('click',function(){_devise='CHF';updMTDev();});document.getElementById('mt-deur').addEventListener('click',function(){_devise='EUR';updMTDev();});document.getElementById('mt-dusd').addEventListener('click',function(){_devise='USD';updMTDev();}); ['mt-p-coco','mt-p-vermi','mt-p-gy','mt-p-spawn'].forEach(function(id){var el=document.getElementById(id);if(el)el.addEventListener('input',calcMT);}); document.getElementById('mt-copy-btn').addEventListener('click',function(){var txt=document.getElementById('mt-shop').innerText;navigator.clipboard.writeText(txt).then(function(){var el=document.getElementById('mt-cop');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2200);});}); document.getElementById('mt-share-btn').addEventListener('click',function(){var p=new URLSearchParams();p.set('tab','monotub');p.set('l',MT.l);p.set('w',MT.w);p.set('d',MT.depth);p.set('sp',MT.spawnPct);p.set('nb',MT.nb);var url=window.location.href.split('?')[0]+'?'+p.toString();navigator.clipboard.writeText(url).then(function(){var el=document.getElementById('mt-share-ok');el.classList.add('show');setTimeout(function(){el.classList.remove('show');},2500);});}); document.getElementById('mt-print-btn').addEventListener('click',function(){var shop=document.getElementById('mt-shop');if(!shop||!shop.innerHTML.trim()){alert('Configurez votre recette avant d\'imprimer.');return;}var dimStr=MT.l+' x '+MT.w+' x '+MT.depth+' cm';mkPrintWin('Recette Monotub CVG \u2014 '+dimStr,shop.innerHTML);});document.getElementById('mt-save-btn').addEventListener('click',function(){var g=document.getElementById('mt-login-gate');if(g)g.classList.add('show'); }); (function(){var p=new URLSearchParams(window.location.search);if(p.get('tab')==='monotub'){if(p.get('l'))MT.l=parseInt(p.get('l'));if(p.get('w'))MT.w=parseInt(p.get('w'));if(p.get('d'))MT.depth=parseInt(p.get('d'));if(p.get('sp'))MT.spawnPct=parseInt(p.get('sp'));if(p.get('nb'))MT.nb=parseInt(p.get('nb'));document.getElementById('mt-l').value=isEN()?cmToIn(MT.l).toFixed(1):MT.l;document.getElementById('mt-w').value=isEN()?cmToIn(MT.w).toFixed(1):MT.w;document.getElementById('mt-depth').value=MT.depth;document.getElementById('mt-nb').value=MT.nb;document.getElementById('mt-s-spawn').value=MT.spawnPct;document.getElementById('mt-v-spawn').textContent=MT.spawnPct+'%';sC(document.getElementById('mt-s-spawn'),MT.spawnPct,15,35);sC(document.getElementById('mt-depth'),MT.depth,5,20);['substrat','agar','lc','monotub'].forEach(function(t){var btn=document.getElementById('tab-'+t);var cnt=document.getElementById('content-'+t);if(btn)btn.classList.toggle('active',t==='monotub');if(cnt)cnt.classList.toggle('active',t==='monotub');});localStorage.setItem('myc-active-tab','monotub');updDepthVal();calcMT();}})(); renderMTSv(); }); })(); })(); // end main IIFE