Ver Fonte

And continue...

Cixo há 1 ano atrás
pai
commit
c1ca5cdb07
4 ficheiros alterados com 96 adições e 31 exclusões
  1. 7 0
      assets/database.js
  2. 21 31
      assets/element.js
  3. 47 0
      database/elements.json
  4. 21 0
      tests/element.js

+ 7 - 0
assets/database.js

@@ -0,0 +1,7 @@
+class database {
+    constructor() {
+        
+    }   
+} 
+
+export { database };

+ 21 - 31
assets/element.js

@@ -8,6 +8,7 @@ class element {
     #description;
     #params;
     #links;
+    #thumbnail;
 
     constructor(id) {
         if (typeof(id) !== "number") {
@@ -15,11 +16,12 @@ class element {
         }
 
         this.#id = id;
-        this.#pictures = {};
-        this.#params = {};
-        this.#links = {};
+        this.#pictures = new Set();
+        this.#params = new Map();
+        this.#links = new Map();
         this.#name = undefined;
         this.#mesh = undefined;
+        this.#thumbnail = undefined;
     }
 
     get id() {
@@ -50,39 +52,27 @@ class element {
         this.#mesh = content;
     }
 
-    get links() {
-        const mesh = {};
-        mesh[lang.element.mesh.link] = this.mesh;
-
-        return Object.assign(this.#links, mesh);
+    set thumbnail(content) {
+        if (typeof(content) !== "string") {
+            throw "Thumbnail URL must be string.";
+        }   
     }
-
-    set links(content) {
-        if (typeof(content) !== "object") {
-            throw "Links must be an object.";
-        }
-
-        this.#links = Object.assign({}, content);
+    
+    get thumbnail() {
+        return this.#thumbnail;
     }
-
-    addLink(name, url) {
-        if (typeof(name) !== "string") {
-            throw "Name must be string.";
-        }
-
-        if (typeof(url) !== "string") {
-            throw "Url must be string.";
-        }
-
-        const new_link = {};
-        new_link[name] = url;
-
-        this.#links = Object.assign(new_link, this.#links);
+    
+    get links() {
+        return this.#links;
     }
 
-    get title() {
-        
+    get params() {
+        return this.#params;
     }
+
+    get pictures() {
+        return this.#pictures;
+    }       
 }
 
 export { element };

+ 47 - 0
database/elements.json

@@ -0,0 +1,47 @@
+{
+    "name": "Elements database project.",
+    "description": "This is sample example project documentary.",
+    "submissions": [
+        {
+            "name": "Objects twice submission",
+            "description": "This is first submission",
+            "thumbnail": "https://i.redd.it/jxbc2sbfdkmd1.jpeg",
+            "elements": [
+                {
+                    "name": "Object 1",
+                    "description": "Sample object",
+                    "attributes" : {
+                        "width": "110mm",
+                        "height": "50mm",
+                        "depth": "60mm"
+                    },
+                    "links": {
+                        "Ebay": "https://ebay.com"
+                    },
+                    "thumbnail": "https://preview.redd.it/how-cute-is-this-street-cat-v0-3yt7hznrfhmd1.jpeg?width=640&crop=smart&auto=webp&s=fdf36a3c7b36e52b541421c58fdec811ded8df2f",
+                    "pictures": [
+                        "https://preview.redd.it/she-seems-pleased-with-herself-v0-gk0rylncqfmd1.jpeg?width=640&crop=smart&auto=webp&s=b9f523953de121e5f85d283eb13801e6b10fa13b",
+                        "https://preview.redd.it/how-cute-is-this-street-cat-v0-3yt7hznrfhmd1.jpeg?width=640&crop=smart&auto=webp&s=fdf36a3c7b36e52b541421c58fdec811ded8df2f"
+                    ]   
+                }, 
+                {
+                    "name": "Object 2",
+                    "description": "Sample object",
+                    "attributes" : {
+                        "width": "110mm",
+                        "height": "50mm",
+                        "depth": "60mm"
+                    },
+                    "links": {
+                        "Ebay": "https://ebay.com"
+                    },
+                    "thumbnail": "https://preview.redd.it/how-cute-is-this-street-cat-v0-3yt7hznrfhmd1.jpeg?width=640&crop=smart&auto=webp&s=fdf36a3c7b36e52b541421c58fdec811ded8df2f",
+                    "pictures": [
+                        "https://preview.redd.it/she-seems-pleased-with-herself-v0-gk0rylncqfmd1.jpeg?width=640&crop=smart&auto=webp&s=b9f523953de121e5f85d283eb13801e6b10fa13b",
+                        "https://preview.redd.it/how-cute-is-this-street-cat-v0-3yt7hznrfhmd1.jpeg?width=640&crop=smart&auto=webp&s=fdf36a3c7b36e52b541421c58fdec811ded8df2f"
+                    ]   
+                }
+            ]
+        },
+    ]
+}

+ 21 - 0
tests/element.js

@@ -0,0 +1,21 @@
+import { element } from "./../assets/element.js";
+
+const item = new element(10);
+
+console.log("Create...");
+item.name = "Simple item";
+item.mesh = "sample.stl";
+item.thumbnail = 
+item.description = "This is simple test item.";
+item.links.set("ref", "https://uwu.com");
+item.links.set("ebay", "https://ebay.com/item");
+item.params.set("width", "100mm");
+item.params.set("height", "100mm");
+item.params.set("depth", "100mm");
+
+console.log(item.name);
+console.log(item.mesh);
+console.log(item.description);
+console.log(item.links);
+console.log(item.params);
+console.log(item.pictures);