about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2025-03-15 22:01:17 -0400
committerelioat <elioat@tilde.institute>2025-03-15 22:01:17 -0400
commit4a461013efdbc66c2b13c9c90dc4163de130be7c (patch)
treea00bfae9aa3e233097dc8db233fe7269ac3ebcb0
parent77f3163772a4667b44e98bde33e755d610c30653 (diff)
downloadtour-4a461013efdbc66c2b13c9c90dc4163de130be7c.tar.gz
*
-rw-r--r--html/immoral/app.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/html/immoral/app.js b/html/immoral/app.js
index dcea768..e1d1e65 100644
--- a/html/immoral/app.js
+++ b/html/immoral/app.js
@@ -1,5 +1,5 @@
 /**
- * An Immoral Web Font Vacuum
+ * Web Font Vacuum
  * A tool to find and extract web fonts from any website
  * 
  * We sort of set up a pipeline where each step processes the data and passes it to the next:
@@ -145,7 +145,7 @@ function getFontMimeType(url) {
 /**
  * Event listeners and initialization.
  * 
- * 1. User enters URL and clicks Analyze
+ * 1. Enter URL and analyze
  * 2. Fetch the HTML through a CORS proxy
  * 3. Parse HTML to find:
  *    - Direct font links
@@ -544,7 +544,6 @@ document.addEventListener('DOMContentLoaded', () => {
             fontFamilies.get(fontData.family).variants.push(fontData);
         });
 
-        // Convert back to array format but with grouped variants
         fontsArray = Array.from(fontFamilies.entries()).map(([family, data]) => ({
             family,
             variants: data.variants,
@@ -615,7 +614,7 @@ document.addEventListener('DOMContentLoaded', () => {
             previewContainer.style.padding = '1rem';
             previewContainer.style.border = '1px dashed var(--dark)';
             
-            // Hide preview container initially if not auto-previewing
+            // Assume hidden if not auto-previewing
             if (!shouldAutoPreview) {
                 previewContainer.style.display = 'none';
             }
@@ -627,13 +626,13 @@ document.addEventListener('DOMContentLoaded', () => {
             previewContainer.appendChild(previewLabel);
 
             // Create preview for each style variation
-            const previewText = 'Society for me my misery<br>Since Gift of Thee --';
+            const previewText = 'Society for me my misery<br>Since Gift of Thee --'; // Emily Dickinson
             const styleVariations = document.createElement('div');
             styleVariations.style.display = 'flex';
             styleVariations.style.flexDirection = 'column';
             styleVariations.style.gap = '1rem';
 
-            // Add a preview for each variant
+            // Preview for each variant
             fontData.variants.forEach((variant, index) => {
                 const variantPreview = document.createElement('div');
                 variantPreview.style.marginBottom = '1rem';
@@ -667,7 +666,6 @@ document.addEventListener('DOMContentLoaded', () => {
 
             previewContainer.appendChild(styleVariations);
 
-            // Add CSS Rule section
             if (fontData.cssRule) {
                 const cssContainer = document.createElement('div');
                 cssContainer.style.marginTop = '1rem';
@@ -690,7 +688,6 @@ document.addEventListener('DOMContentLoaded', () => {
                 cssLabel.textContent = '@font-face';
                 cssContainer.appendChild(cssLabel);
                 
-                // Show all CSS rules for the font family
                 const cssContent = document.createElement('pre');
                 cssContent.style.margin = '0';
                 cssContent.style.fontFamily = 'monospace';
@@ -698,7 +695,6 @@ document.addEventListener('DOMContentLoaded', () => {
                 cssContent.style.whiteSpace = 'pre-wrap';
                 cssContent.style.wordBreak = 'break-all';
                 
-                // Combine and format all CSS rules
                 const allCssRules = fontData.variants.map(variant => {
                     if (!variant.cssRule) return '';
                     return variant.cssRule
@@ -735,12 +731,21 @@ document.addEventListener('DOMContentLoaded', () => {
             buttonContainer.style.marginTop = '1rem';
             buttonContainer.style.flexWrap = 'wrap';
 
-            // Create download buttons for each variant
+            const uniqueDownloads = new Map();
             fontData.variants.forEach(variant => {
+                if (!uniqueDownloads.has(variant.url)) {
+                    uniqueDownloads.set(variant.url, {
+                        filename: variant.filename,
+                        url: variant.url
+                    });
+                }
+            });
+
+            uniqueDownloads.forEach(({filename, url}) => {
                 const downloadBtn = document.createElement('button');
-                downloadBtn.textContent = `⬇ Download ${variant.filename}`;
+                downloadBtn.textContent = `⬇ Download ${filename}`;
                 downloadBtn.style.flex = '1';
-                downloadBtn.addEventListener('click', () => downloadFont(variant.url, variant.filename));
+                downloadBtn.addEventListener('click', () => downloadFont(url, filename));
                 buttonContainer.appendChild(downloadBtn);
             });
 
@@ -754,7 +759,6 @@ document.addEventListener('DOMContentLoaded', () => {
                     if (!isPreviewVisible) {
                         previewContainer.style.display = 'block';
                         
-                        // Load all variants
                         const loadPromises = fontData.variants.map(async (variant, index) => {
                             const previewElement = document.getElementById(`preview-${variant.filename}-${index}`);
                             if (await previewFont(variant.url, fontData.family)) {
@@ -770,7 +774,7 @@ document.addEventListener('DOMContentLoaded', () => {
                         
                         await Promise.all(loadPromises);
                         
-                        // Apply font to size variations
+                        // Apply font to size variants
                         sizeVariations.querySelectorAll('div').forEach(div => {
                             div.style.fontFamily = fontData.family;
                         });