finish removing costco

This commit is contained in:
steven 2025-04-07 02:33:50 -04:00
parent 7b28513204
commit 695ffb1dc9

View file

@ -2,51 +2,47 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta property="og:site_name" content="Gas">
<meta property="og:title" content="Gas Prices">
<meta property="og:description" content="Track the gas prices of Sam's Club and Costco locations across the United States">
<title>Gas Prices</title> <title>Gas Prices</title>
<meta name="description" content="Track the gas prices of Sam's Club and Costco locations across the United States"> <meta name="description" content="Track the gas prices of Sam's Club and Costco locations across the United States">
<meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="icon" type="image/x-icon" href="/gas.svg"> <link rel="icon" href="gas.svg" type="image/svg+xml">
<script src="https://stevenalexander.org/leaflet/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin="anonymous"></script> <script src="static/leaflet/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stevenalexander.org/leaflet/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="anonymous"> <link rel="stylesheet" href="static/leaflet/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="anonymous">
<base target="_blank"> <base target="_blank">
<style>html,body{height:100%;margin:0;}#map{height:100vh;} <style>html,body{height:100%;margin:0;}#map{height:100vh;}
.leaflet-container a{ .leaflet-container a{
color:black; color:black;
text-decoration:none; text-decoration:none;
} }
.Costco,.Sams{ .Sams{
display:flex; display:flex;
border-radius:33%; border-radius:33%;
text-align:center; text-align:center;
align-items:center; align-items:center;
font-size:14px; font-size:14px;
font-weight:bold; font-weight:bold;
background-color:rgba(0,103,160,0.5);
} }
.Costco{background-color:rgba(227,42,54,0.5);}
.Sams{background-color:rgba(0,103,160,0.5);}
</style> </style>
</head> </head>
<body> <body>
<div id="map"></div> <div id="map"></div>
<script> <script>
let osm=L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png') let osm=L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
let map=L.map('map',{center:[38.243,-85.647],zoom:11,layers:[osm]}); let map=L.map("map",{center:[38.243,-85.647],zoom:11,layers:[osm]});
let layerControl=L.control.layers({"fetching gas prices...":osm},null,{collapsed:false}).addTo(map); let layerControl=L.control.layers({"fetching gas prices...":osm},null,{collapsed:false}).addTo(map);
fetch('gas.csv').then(response=>{ fetch("gas.csv").then(response=>{
layerControl.remove(); layerControl.remove();
if(!response.ok){ if(!response.ok){
L.control.layers({'fetch failed. try reloading?':osm},null,{collapsed:false}).addTo(map); L.control.layers({"fetch failed. try reloading?":osm},null,{collapsed:false}).addTo(map);
return return
} }
return response.text() return response.text()
}).then(csv=>{ }).then(csv=>{
let storeLayers={},store,url; let storeLayers={},store,url;
csv.split('\n').forEach(line=>{ csv.split("\n").forEach(line=>{
if(line.includes(',')){ if(line.includes(",")){
let [u,p,lat,lng,id]=line.split(','); let [u,p,lat,lng,id]=line.split(",");
[u,p]=[u,p].map(cents=>"$"+(cents/100).toFixed(2)); [u,p]=[u,p].map(cents=>"$"+(cents/100).toFixed(2));
L.marker([lat,lng],{icon:L.divIcon({className:store,html:`<a href="${url.replace("X",id)}">${u}\n${p}</a>`,iconSize:[44,44]})}).addTo(storeLayers[store]) L.marker([lat,lng],{icon:L.divIcon({className:store,html:`<a href="${url.replace("X",id)}">${u}\n${p}</a>`,iconSize:[44,44]})}).addTo(storeLayers[store])
}else{ }else{