]> git.ipfire.org Git - thirdparty/google/fonts.git/commitdiff
further development
authorMarc Foley <m.foley.88@gmail.com>
Thu, 17 Jul 2025 15:27:24 +0000 (16:27 +0100)
committerMarc Foley <m.foley.88@gmail.com>
Fri, 18 Jul 2025 12:46:42 +0000 (13:46 +0100)
tagger2/AddTags.js
tagger2/TagsByCategories.js
tagger2/TagsByFont.js
tagger2/index.html

index 678b8ea301ac0648e5a4d5904c7b8b49f3af3d00..259eb02911a8959fc74c43ef2d9ba8ea90f3b8de 100644 (file)
 export default {
     
-    schema: {
-        categories: ["a", "b", "c"],
-        lowTag: {
-            filters: [],
-            score: 10
-        },
-        highTag: {
-            filters: [],
-            score: 100
-        }
-    },
+//    schema: {
+//        categories: ["a", "b", "c"],
+//        lowTag: {
+//            filters: [],
+//            score: 10
+//        },
+//        highTag: {
+//            filters: [],
+//            score: 100
+//        }
+//    },
 
     props: ["categories"],
     data: function() {
         return {
             currentCategories: [],
-            currentAxis: "",
-            currentPosition: 0,
-            currentOp: "",
-            currentScore: 0,
-            filters: [],
+            lowTag: {
+                filters: [],
+                score: 0
+            },
+            highTag: {
+                filters: [],
+                score: 0
+            },
+            currentLowAxis: "",
+            currentLowPosition: 0,
+            currentLowOp: "",
+            currentLowScore: 0,
+            currentHighAxis: "",
+            currentHighPosition: 0,
+            currentHighOp: "",
+            currentHighScore: 0,
         }
     },
     methods: {
         addFilter() {
-            this.filters.push(
+            this.lowTag.filters.push(
+                {
+                    axis: this.currentLowAxis,
+                    op: this.currentLowOp,
+                    value: this.currentLowPosition,
+                    score: this.currentLowScore
+                }
+            );
+            this.highTag.filters.push(
                 {
-                    axis: this.currentAxis,
-                    op: this.currentOp,
-                    value: this.currentPosition,
-                    score: this.currentScore
+                    axis: this.currentHighAxis,
+                    op: this.currentHighOp,
+                    value: this.currentHighPosition,
+                    score: this.currentHighScore
                 }
-            )
+            );
+            this.currentLowAxis = "";
+            this.currentLowPosition = 0;
+            this.currentLowOp = "";
+            this.currentHighAxis = "";
+            this.currentHighPosition = 0;
+            this.currentHighOp = "";
         },
         addTags() {
             const filterSet = {
                 categories: this.currentCategories,
-                filters: this.filters
+                lowTag: this.lowTag,
+                highTag: this.highTag
             };
+            filterSet.lowTag.score = this.currentLowScore;
+            filterSet.highTag.score = this.currentHighScore;
             this.$emit('tags-added', filterSet);
-            this.filters = [];
+            this.currentCategories = [];
+            this.lowTag = { filters: [], score: 0 };
+            this.highTag = { filters: [], score: 0 };
+            this.currentLowAxis = "";
+            this.currentLowPosition = 0;
+            this.currentLowOp = "";
+            this.currentLowScore = 0;
+            this.currentHighAxis = "";
+            this.currentHighPosition = 0;
+            this.currentHighOp = "";
+            this.currentHighScore = 0;
         }
     },
     template: `
     <div>
         <h3>Add Tags</h3>
-        <h3>Category</h3>
+        <div>
+            <h3>Categories</h3>
             <select v-model="currentCategories" multiple>
                 <option v-for="category in categories" :key="category">
                     {{ category }}
                 </option>
             </select>
-        <div>
-            <input type="text" v-model="currentAxis" placeholder="Axis name" />
-            <input type="number" v-model="currentPosition" placeholder="Position" />
-            <select v-model="currentOp">
+            <h3>Low Tag:</h3>
+            Score:
+            <input type="number" v-model="currentLowScore" placeholder="Score" />
+            <br>
+            <input type="text" v-model="currentLowAxis" placeholder="Axis name" />
+            <input type="number" v-model="currentLowPosition" placeholder="Position" />
+            <select v-model="currentLowOp">
+                <option value="<=">&lt;=</option>
+                <option value=">=">&gt;=</option>
+                <option value="=">=</option>
+            </select>
+
+            <h3>High Tag:</h3>
+            Score:
+            <input type="number" v-model="currentHighScore" placeholder="Score" />
+            <br>
+            <input type="text" v-model="currentHighAxis" placeholder="Axis name" />
+            <input type="number" v-model="currentHighPosition" placeholder="Position" />
+            <select v-model="currentHighOp">
                 <option value="<=">&lt;=</option>
                 <option value=">=">&gt;=</option>
                 <option value="=">=</option>
             </select>
-            <input type="number" v-model="currentScore" placeholder="Score" />
             <button @click="addFilter">Add Filter</button>
         </div>
         <div>
             <h3>Current Filters</h3>
+            <h3>Low Tag</h3>
+            <ul>
+                <li v-for="filter in lowTag.filters" :key="filter.axis + filter.value">
+                    {{ filter.axis }} {{ filter.op }} {{ filter.value }}
+                    <button @click="lowTag.filters.splice(lowTag.filters.indexOf(filter), 1)">Remove</button>
+                </li>
+            </ul>
+            <h3>High Tag</h3>
             <ul>
-                <li v-for="filter in filters" :key="filter.axis + filter.value">
+                <li v-for="filter in highTag.filters" :key="filter.axis + filter.value">
                     {{ filter.axis }} {{ filter.op }} {{ filter.value }}
-                    <button @click="filters.splice(filters.indexOf(filter), 1)">Remove</button>
+                    <button @click="highTag.filters.splice(highTag.filters.indexOf(filter), 1)">Remove</button>
                 </li>
             </ul>
         </div>
index 38ab87395c9547a26f9fec47728d10d2619f9281..2654089bb962510dcd6e7b311f9e1e4e5cf33387 100644 (file)
@@ -48,7 +48,7 @@ export default {
           {{ category }}
         </option>
       </select>
-        <div v-for="tag in filteredTags" :key="tag.family.name + tag.tagName">
+        <div v-for="tag in filteredTags" :key="tag.family.name + tag.tagName + tag.score">
           <tag-view :tag="tag"></tag-view>
         </div>
     </div>
index 4844b4dab70b13fa3acc8e8524deff5a49d2699a..22d5c67eae9bd6db8f91691e7b948b901d6a92fc 100644 (file)
@@ -29,7 +29,7 @@ export default {
         </option>
       </select>
       <ul>
-        <li v-for="tag in filteredTags" :key="tag.tagName + tag.family.name">
+        <li v-for="tag in filteredTags" :key="tag.tagName + tag.family.name + tag.score">
           {{ tag.tagName }}
            <input type="number" v-model="tag.score" @change="$emit('update:tags', tags)" />
            <button @click="removeTag(tag)">Remove</button>
index ed266274128f3c835c4dd52a1e1d592cc2641014..5c278011f256925a8c18344877b2d5f532050be0 100644 (file)
@@ -28,7 +28,7 @@
     </div>
   </div>
   <script type="module">
-    import { GF, Tags } from './models.js';
+    import { GF, Tags, FontTag } from './models.js';
     import TagsByFont from "./TagsByFont.js";
     import TagsByCategories from "./TagsByCategories.js";
     import Panel from "./Panel.js";
           this.tags.items.push(tag);
         },
         addTags(filterSet) {
-            let tags = []
-            let filteredFamilies = []
-            for (let family of this.gf.families) {
-              let includeFamily = false;
-              for (let axis of family.axes) {
-                if (
-                  filterSet.filters.map(f => f.axis).includes(axis.tag) &&
-                  axis.min <= filterSet.filters.find(f => f.axis === axis.tag).value &&
-                  axis.max >= filterSet.filters.find(f => f.axis === axis.tag).value) {
-                    includeFamily = true;
-                  }
+          for (let family of this.gf.families) {
+            let addFamily = false;
+            for (let axis of family.axes) {
+              if (
+                filterSet.lowTag.filters.some(f => f.axis == axis.tag) &&
+                filterSet.highTag.filters.some(f => f.axis == axis.tag) &&
+                filterSet.lowTag.filters.some(f => f.value >= axis.min) &&
+                filterSet.highTag.filters.some(f => f.value <= axis.max)
+              ) {
+                addFamily = true;
               }
-              if (includeFamily) {
-                console.log("Including family:", family);
+            }
+            if (addFamily) {
+              for (let category of filterSet.categories) {
+                const lowTag = new FontTag(category, family, filterSet.lowTag.filters, filterSet.lowTag.score);
+                const highTag = new FontTag(category, family, filterSet.highTag.filters, filterSet.highTag.score);
+                console.log(lowTag, highTag, "tt");
+                this.tags.items.push(lowTag);
+                this.tags.items.push(highTag);
               }
-              includeFamily = false;
             }
+          }
         },
         addCategory(category) {
           console.log("Adding category", category);