mirror of
https://git.j0bot.ch/admin_j0bot/ploxion-wc.git
synced 2026-11-29 07:25:10 +00:00
synchro du labo (0bf0da65) : app.blade.php, README.md
This commit is contained in:
parent
b32d39e958
commit
adceef736e
22
README.md
22
README.md
@ -1,3 +1,21 @@
|
|||||||
# ploxion-wc
|
# 🚻 WC
|
||||||
|
|
||||||
PLOXION · Les toilettes les plus proches (Overpass/OSM) sur une carte + liste triée par distance (accès, payant, PMR). · fournit: carte, geoloc, osm, toilettes
|
Les toilettes les plus proches (Overpass/OSM) sur une carte + liste triée par distance (accès, payant, PMR).
|
||||||
|
|
||||||
|
| | |
|
||||||
|
| --- | --- |
|
||||||
|
| id | `wc` |
|
||||||
|
| fournit | `carte` `geoloc` `osm` `toilettes` |
|
||||||
|
| bions qu'il nomme | `jOSApps` |
|
||||||
|
| fichiers | `app.blade.php` |
|
||||||
|
| dans le labo | `resources/views/ploxions/wc/` (dépôt `my_website2`) |
|
||||||
|
|
||||||
|
## Contribuer
|
||||||
|
|
||||||
|
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=wc — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
|
||||||
|
- **Dans VS Code** : `xb prendre wc` (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
|
||||||
|
|||||||
228
app.blade.php
Normal file
228
app.blade.php
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
{{-- PL0XI0N WC 🚻 — trouver les toilettes les plus proches. Géoloc → Overpass (OSM amenity=toilets) →
|
||||||
|
carte Leaflet dark (marqueurs 🚻 + 📍 toi) + liste triée par distance haversine. RS-7 « ploxion wc ».
|
||||||
|
Reste DANS le xerboxion : Leaflet self-hosté /vendor, tuiles = fetch d'images, aucune navigation externe. --}}
|
||||||
|
<style>
|
||||||
|
.pxwc{display:flex;flex-direction:column;height:100%;background:#070c16;color:#eaf3ff;font-family:ui-sans-serif,system-ui,sans-serif}
|
||||||
|
.pxwc__bar{flex:0 0 auto;display:flex;align-items:center;gap:10px;padding:8px 12px;border-bottom:1px solid rgba(63,224,208,.18);font-size:.8rem;flex-wrap:wrap}
|
||||||
|
.pxwc__title{font-weight:700;color:#fff;display:flex;align-items:center;gap:6px}
|
||||||
|
.pxwc__sub{color:rgba(180,205,225,.5);font-size:.72rem}
|
||||||
|
.pxwc__count{margin-left:auto;color:#3fe0d0;font-size:.74rem;font-family:ui-monospace,'Share Tech Mono',monospace}
|
||||||
|
.pxwc__btn{cursor:pointer;border:1px solid rgba(63,224,208,.35);background:#0e1a30;color:#eaf3ff;border-radius:9px;padding:6px 11px;font-size:.76rem;font-weight:600;transition:background .15s,border-color .15s}
|
||||||
|
.pxwc__btn:hover{background:#12253f;border-color:#3fe0d0}
|
||||||
|
.pxwc__btn:active{transform:translateY(1px)}
|
||||||
|
.pxwc__body{flex:1;min-height:0;display:flex}
|
||||||
|
.pxwc__mapwrap{flex:1 1 60%;min-width:0;position:relative}
|
||||||
|
.pxwc__mapwrap .leaflet-container{width:100%;height:100%;background:#0a1120}
|
||||||
|
.pxwc__list{flex:0 0 40%;max-width:340px;overflow-y:auto;border-left:1px solid rgba(63,224,208,.14);background:#0a1120}
|
||||||
|
.pxwc__msg{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:rgba(180,205,225,.6);font-size:.85rem;text-align:center;padding:20px;pointer-events:none}
|
||||||
|
.pxwc__item{padding:9px 12px;border-bottom:1px solid rgba(63,224,208,.09);cursor:pointer;transition:background .12s}
|
||||||
|
.pxwc__item:hover{background:#12203a}
|
||||||
|
.pxwc__item.is-on{background:#15294a;box-shadow:inset 3px 0 0 #3fe0d0}
|
||||||
|
.pxwc__name{font-size:.82rem;font-weight:600;color:#fff;display:flex;align-items:center;gap:6px}
|
||||||
|
.pxwc__dist{color:#3fe0d0;font-family:ui-monospace,monospace;font-size:.74rem;margin-left:auto;flex:0 0 auto}
|
||||||
|
.pxwc__tags{margin-top:5px;display:flex;flex-wrap:wrap;gap:5px}
|
||||||
|
.pxwc__tag{font-size:.66rem;padding:2px 7px;border-radius:20px;background:#12253f;color:rgba(200,220,240,.85);border:1px solid rgba(63,224,208,.16)}
|
||||||
|
.pxwc__tag.ok{color:#8ff0d8;border-color:rgba(63,224,208,.4)}
|
||||||
|
.pxwc__tag.no{color:#ff9db0;border-color:rgba(255,120,150,.3)}
|
||||||
|
.pxwc__empty{padding:26px 16px;text-align:center;color:rgba(180,205,225,.55);font-size:.8rem}
|
||||||
|
.pxwc__pin{font-size:20px;line-height:20px;text-align:center;filter:drop-shadow(0 1px 2px rgba(0,0,0,.7))}
|
||||||
|
@media(max-width:640px){
|
||||||
|
.pxwc__body{flex-direction:column}
|
||||||
|
.pxwc__mapwrap{flex:1 1 46%;min-height:180px}
|
||||||
|
.pxwc__list{flex:1 1 54%;max-width:none;border-left:none;border-top:1px solid rgba(63,224,208,.14)}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
(function(){
|
||||||
|
'use strict';
|
||||||
|
var ID='wc';
|
||||||
|
var LIVE=null; // posé au mount : {count:function()}
|
||||||
|
function describe(){
|
||||||
|
var n = LIVE ? LIVE.count() : 0;
|
||||||
|
return { v:1, id:ID, title:'WC', icon:'🚻', items:[
|
||||||
|
{ p:1, kind:'stat', label:'WC trouvés à proximité', value:n }
|
||||||
|
]};
|
||||||
|
}
|
||||||
|
function loadLeaflet(){
|
||||||
|
if(window.L) return Promise.resolve(window.L);
|
||||||
|
if(window.__leafletPromise) return window.__leafletPromise;
|
||||||
|
window.__leafletPromise=new Promise(function(resolve,reject){
|
||||||
|
var css=document.createElement('link'); css.rel='stylesheet'; css.href='/vendor/css/leaflet.min.css'; document.head.appendChild(css);
|
||||||
|
var s=document.createElement('script'); s.src='/vendor/js/leaflet.min.js'; // JS = /vendor/js/ (le .css est dans /vendor/css/)
|
||||||
|
s.onload=function(){ resolve(window.L); }; s.onerror=function(){ reject(new Error('leaflet load failed')); };
|
||||||
|
document.head.appendChild(s);
|
||||||
|
});
|
||||||
|
return window.__leafletPromise;
|
||||||
|
}
|
||||||
|
function esc(s){ return String(s==null?'':s).replace(/[&<>"']/g,function(c){
|
||||||
|
return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]; }); }
|
||||||
|
function haversine(a,b,c,d){ // (lat1,lon1,lat2,lon2) → mètres
|
||||||
|
var R=6371000, r=Math.PI/180;
|
||||||
|
var dLat=(c-a)*r, dLon=(d-b)*r, la1=a*r, la2=c*r;
|
||||||
|
var x=Math.sin(dLat/2)*Math.sin(dLat/2)+Math.cos(la1)*Math.cos(la2)*Math.sin(dLon/2)*Math.sin(dLon/2);
|
||||||
|
return 2*R*Math.asin(Math.min(1,Math.sqrt(x)));
|
||||||
|
}
|
||||||
|
function fmtDist(m){ return m<1000 ? Math.round(m)+' m' : (m/1000).toFixed(m<10000?2:1)+' km'; }
|
||||||
|
|
||||||
|
function mount(container){
|
||||||
|
var LAUSANNE=[46.52,6.63];
|
||||||
|
container.innerHTML=''
|
||||||
|
+'<div class="pxwc">'
|
||||||
|
+ '<div class="pxwc__bar">'
|
||||||
|
+ '<span class="pxwc__title">🚻 WC</span>'
|
||||||
|
+ '<span class="pxwc__sub">toilettes proches · OSM</span>'
|
||||||
|
+ '<span class="pxwc__count" data-count></span>'
|
||||||
|
+ '<button class="pxwc__btn" data-locate>📍 ma position</button>'
|
||||||
|
+ '</div>'
|
||||||
|
+ '<div class="pxwc__body">'
|
||||||
|
+ '<div class="pxwc__mapwrap" data-mapwrap><div class="pxwc__msg" data-msg>chargement de la carte…</div></div>'
|
||||||
|
+ '<div class="pxwc__list" data-list><div class="pxwc__empty">📍 clique « ma position » pour chercher.</div></div>'
|
||||||
|
+ '</div>'
|
||||||
|
+'</div>';
|
||||||
|
|
||||||
|
var mapwrap=container.querySelector('[data-mapwrap]'),
|
||||||
|
msgEl=container.querySelector('[data-msg]'),
|
||||||
|
listEl=container.querySelector('[data-list]'),
|
||||||
|
countEl=container.querySelector('[data-count]'),
|
||||||
|
locateBtn=container.querySelector('[data-locate]');
|
||||||
|
|
||||||
|
var L=null, map=null, meMarker=null, wcLayer=null, dead=false, myPos=null, items=[], markers=[];
|
||||||
|
LIVE = { count: function () { return items.length; } };
|
||||||
|
|
||||||
|
function setMsg(t){ if(!msgEl) return; if(t){ msgEl.textContent=t; msgEl.style.display='flex'; } else msgEl.style.display='none'; }
|
||||||
|
function setCount(t){ if(countEl) countEl.textContent=t||''; }
|
||||||
|
|
||||||
|
function pinIcon(emoji){
|
||||||
|
return L.divIcon({ className:'', html:'<div class="pxwc__pin">'+emoji+'</div>',
|
||||||
|
iconSize:[24,24], iconAnchor:[12,12] });
|
||||||
|
}
|
||||||
|
|
||||||
|
function tag(label, val, kind){
|
||||||
|
return '<span class="pxwc__tag'+(kind?(' '+kind):'')+'">'+esc(label)+'</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderList(){
|
||||||
|
if(!items.length){ listEl.innerHTML='<div class="pxwc__empty">Aucun WC trouvé dans un rayon de 1.2 km. 😬<br>Essaie ailleurs.</div>'; return; }
|
||||||
|
var h='';
|
||||||
|
for(var i=0;i<items.length;i++){
|
||||||
|
var it=items[i], t=it.tags||{};
|
||||||
|
var name=t.name||t.operator||'WC public';
|
||||||
|
var tags='';
|
||||||
|
if(t.access){ tags+=tag('accès: '+t.access, 1, /(yes|public|permissive|customers)/i.test(t.access)?'ok':''); }
|
||||||
|
if(t.fee!=null){ var free=/^(no|0)$/i.test(String(t.fee)); tags+=tag(free?'gratuit':'payant', 1, free?'ok':'no'); }
|
||||||
|
if(t.wheelchair){ var ok=/^yes$/i.test(t.wheelchair); tags+=tag('♿ '+t.wheelchair, 1, ok?'ok':(/^no$/i.test(t.wheelchair)?'no':'')); }
|
||||||
|
if(t.unisex&&/^yes$/i.test(t.unisex)) tags+=tag('unisexe',1,'');
|
||||||
|
if(t.opening_hours) tags+=tag('🕑 '+t.opening_hours,1,'');
|
||||||
|
h+='<div class="pxwc__item" data-idx="'+i+'">'
|
||||||
|
+'<div class="pxwc__name">🚻 <span>'+esc(name)+'</span><span class="pxwc__dist">'+fmtDist(it.dist)+'</span></div>'
|
||||||
|
+(tags?('<div class="pxwc__tags">'+tags+'</div>'):'')
|
||||||
|
+'</div>';
|
||||||
|
}
|
||||||
|
listEl.innerHTML=h;
|
||||||
|
}
|
||||||
|
|
||||||
|
function focusItem(i){
|
||||||
|
var it=items[i]; if(!it||!map) return;
|
||||||
|
try{ map.setView([it.lat,it.lon], Math.max(map.getZoom(),17)); }catch(e){}
|
||||||
|
var nodes=listEl.querySelectorAll('.pxwc__item');
|
||||||
|
for(var k=0;k<nodes.length;k++) nodes[k].classList.toggle('is-on', k===i);
|
||||||
|
if(markers[i]){ try{ markers[i].openPopup(); }catch(e){} }
|
||||||
|
}
|
||||||
|
|
||||||
|
listEl.addEventListener('click', function(ev){
|
||||||
|
var el=ev.target.closest ? ev.target.closest('.pxwc__item') : null;
|
||||||
|
if(el){ focusItem(parseInt(el.getAttribute('data-idx'),10)); }
|
||||||
|
});
|
||||||
|
|
||||||
|
function drawMarkers(){
|
||||||
|
if(!map||!L) return;
|
||||||
|
if(wcLayer){ try{ map.removeLayer(wcLayer); }catch(e){} }
|
||||||
|
wcLayer=L.layerGroup().addTo(map); markers=[];
|
||||||
|
for(var i=0;i<items.length;i++){
|
||||||
|
var it=items[i], t=it.tags||{};
|
||||||
|
var name=t.name||t.operator||'WC public';
|
||||||
|
var m=L.marker([it.lat,it.lon],{icon:pinIcon('🚻')}).addTo(wcLayer);
|
||||||
|
m.bindPopup('<b>'+esc(name)+'</b><br>'+esc(fmtDist(it.dist))
|
||||||
|
+(t.fee!=null?('<br>'+(/^(no|0)$/i.test(String(t.fee))?'gratuit':'payant')):'')
|
||||||
|
+(t.wheelchair?('<br>♿ '+esc(t.wheelchair)):''));
|
||||||
|
(function(idx){ m.on('click',function(){ focusItem(idx); }); })(i);
|
||||||
|
markers.push(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function query(lat,lon){
|
||||||
|
myPos=[lat,lon];
|
||||||
|
setMsg(null);
|
||||||
|
if(map){ try{ map.setView([lat,lon],16); }catch(e){}
|
||||||
|
if(meMarker){ try{ meMarker.setLatLng([lat,lon]); }catch(e){} }
|
||||||
|
else { try{ meMarker=L.marker([lat,lon],{icon:pinIcon('📍'),zIndexOffset:1000}).addTo(map).bindPopup('Toi 📍'); }catch(e){} }
|
||||||
|
}
|
||||||
|
listEl.innerHTML='<div class="pxwc__empty">🔎 recherche des WC autour de toi…</div>';
|
||||||
|
setCount('…');
|
||||||
|
var q='[out:json][timeout:15];('
|
||||||
|
+'node["amenity"="toilets"](around:1200,'+lat+','+lon+');'
|
||||||
|
+'way["amenity"="toilets"](around:1200,'+lat+','+lon+');'
|
||||||
|
+');out center 60;';
|
||||||
|
fetch('https://overpass-api.de/api/interpreter',{
|
||||||
|
method:'POST',
|
||||||
|
headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
||||||
|
body:'data='+encodeURIComponent(q)
|
||||||
|
}).then(function(r){ if(!r.ok) throw new Error('overpass '+r.status); return r.json(); })
|
||||||
|
.then(function(j){
|
||||||
|
if(dead) return;
|
||||||
|
var els=(j&&j.elements)||[]; items=[];
|
||||||
|
for(var i=0;i<els.length;i++){
|
||||||
|
var e=els[i];
|
||||||
|
var la = e.lat!=null ? e.lat : (e.center&&e.center.lat);
|
||||||
|
var lo = e.lon!=null ? e.lon : (e.center&&e.center.lon);
|
||||||
|
if(la==null||lo==null) continue;
|
||||||
|
items.push({ lat:la, lon:lo, tags:e.tags||{}, dist:haversine(lat,lon,la,lo) });
|
||||||
|
}
|
||||||
|
items.sort(function(a,b){ return a.dist-b.dist; });
|
||||||
|
setCount(items.length+(items.length===1?' WC':' WC'));
|
||||||
|
renderList();
|
||||||
|
drawMarkers();
|
||||||
|
}).catch(function(err){
|
||||||
|
if(dead) return;
|
||||||
|
setCount('');
|
||||||
|
listEl.innerHTML='<div class="pxwc__empty">😕 Overpass indisponible.<br><small>'+esc(err&&err.message||'erreur réseau')+'</small><br><br>Réessaie dans un instant.</div>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function locate(){
|
||||||
|
if(!navigator.geolocation){ query(LAUSANNE[0],LAUSANNE[1]); return; }
|
||||||
|
locateBtn.textContent='📍 …';
|
||||||
|
navigator.geolocation.getCurrentPosition(function(p){
|
||||||
|
locateBtn.textContent='📍 ma position';
|
||||||
|
if(!dead) query(p.coords.latitude, p.coords.longitude);
|
||||||
|
}, function(){
|
||||||
|
locateBtn.textContent='📍 ma position';
|
||||||
|
if(!dead) query(LAUSANNE[0],LAUSANNE[1]); // fallback Lausanne
|
||||||
|
}, {timeout:8000, enableHighAccuracy:true, maximumAge:60000});
|
||||||
|
}
|
||||||
|
|
||||||
|
locateBtn.addEventListener('click', locate);
|
||||||
|
|
||||||
|
loadLeaflet().then(function(_L){
|
||||||
|
if(dead) return;
|
||||||
|
L=_L; setMsg(null);
|
||||||
|
map=L.map(mapwrap,{zoomControl:true,attributionControl:false}).setView(LAUSANNE,13);
|
||||||
|
L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{z}/{y}/{x}',{maxZoom:20,maxNativeZoom:16}).addTo(map);
|
||||||
|
setTimeout(function(){ try{ map.invalidateSize(); }catch(e){} }, 60);
|
||||||
|
locate(); // auto-géoloc au démarrage
|
||||||
|
}).catch(function(){
|
||||||
|
if(!dead) setMsg('carte indisponible (Leaflet /vendor manquant)');
|
||||||
|
});
|
||||||
|
|
||||||
|
return { unmount:function(){
|
||||||
|
dead=true;
|
||||||
|
LIVE=null;
|
||||||
|
try{ if(map) map.remove(); }catch(e){}
|
||||||
|
map=null; container.innerHTML='';
|
||||||
|
} };
|
||||||
|
}
|
||||||
|
|
||||||
|
window.jOSApps=window.jOSApps||{};
|
||||||
|
window.jOSApps[ID]={ manifest:{id:ID,name:'WC',icon:'🚻'}, mount:mount, describe:describe };
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user