Browser extension that sorts Pratt books by distance to patron

Display available copies

modamo-gh dfdfd871 3adc1555

+50 -3
+11 -2
src/popup.css
··· 68 68 } 69 69 70 70 input[type="range"] { 71 + accent-color: white; 71 72 box-sizing: border-box; 72 73 margin: 0; 73 74 padding: 0; ··· 75 76 } 76 77 77 78 #copies { 78 - background-color: green; 79 79 flex: 1; 80 80 flex-direction: column; 81 81 gap: 8px; 82 82 height: 256px; 83 + overflow-y: auto; 83 84 width: 100%; 84 85 } 85 86 ··· 90 91 .copy { 91 92 background-color: white; 92 93 border-radius: 8px; 93 - height: 48px; 94 + display: flex; 95 + flex-direction: column; 96 + gap: 4px; 97 + padding: 8px; 94 98 width: 100%; 95 99 } 100 + 101 + .copyText { 102 + color: black; 103 + margin: 0; 104 + }
+1
src/popup.html
··· 46 46 >Radius</label 47 47 > 48 48 </div> 49 + <h2 id="available"></h2> 49 50 <div 50 51 class="hidden" 51 52 id="copies"
+38 -1
src/popup.ts
··· 4 4 const MAPBOX = "publicKey"; 5 5 6 6 const addressInput = document.querySelector("input"); 7 + const availableCopies = document.querySelector("#available"); 7 8 const browserLocationButton = document.querySelector("#browserLocation"); 8 9 const copiesDiv = document.querySelector("#copies"); 9 10 const manualLocationButton = document.querySelector("#manualLocation"); ··· 39 40 const displayCopies = () => { 40 41 copiesDiv!.innerHTML = ""; 41 42 43 + availableCopies!.textContent = `Available Copies Nearby: ${ 44 + (window as any).__enochPrattCopies.filter( 45 + (copy) => copy.distance <= Number(sliderInput?.value) 46 + ).length 47 + }`; 48 + 42 49 (window as any).__enochPrattCopies 43 50 .sort( 44 51 (a: { distance: number }, b: { distance: number }) => ··· 50 57 51 58 copyDiv.classList.add("copy"); 52 59 60 + const branch = document.createElement("h3"); 61 + branch.classList.add("copyText"); 62 + branch.textContent = copy.library; 63 + 64 + const distance = document.createElement("p"); 65 + distance.classList.add("copyText"); 66 + distance.textContent = `Distance: ${copy.distance.toFixed( 67 + 2 68 + )} mi`; 69 + 70 + const status = document.createElement("p"); 71 + status.classList.add("copyText"); 72 + status.textContent = `Status: ${copy.status}`; 73 + 74 + copyDiv.appendChild(branch); 75 + copyDiv.appendChild(distance); 76 + copyDiv.appendChild(status); 77 + 53 78 copiesDiv?.appendChild(copyDiv); 54 79 } 55 80 }); ··· 97 122 status: div?.innerHTML || "" 98 123 }; 99 124 100 - copies.push(copy); 125 + if ( 126 + !copy.status.toLowerCase().includes("due") && 127 + !copy.status.toLowerCase().includes("hold") && 128 + !copy.status.toLowerCase().includes("in transit") 129 + ) { 130 + copies.push(copy); 131 + } 101 132 }); 102 133 103 134 return copies; ··· 317 348 displayCopies(); 318 349 319 350 label.textContent = `${miles} mi`; 351 + 352 + availableCopies!.textContent = `Available Copies Nearby: ${ 353 + (window as any).__enochPrattCopies.filter( 354 + (copy) => copy.distance <= Number(sliderInput?.value) 355 + ).length 356 + }`; 320 357 321 358 if ( 322 359 circleInstance &&