git.lucas.co / website
source for lucas.co

commitf6d49a0e432024864913a7a5baf94f96e91f4e4c
parent640d36a31d
authorsynthpure <[email protected]>
date2023-08-02 14:31
update json functionality

 info.json | 18 ++++++++++++------
 js.js     | 18 +++++++++++++-----
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/info.json b/info.json
index 064379f..782eebc 100644
--- a/info.json
+++ b/info.json
@@ -3,32 +3,38 @@
 	{
 		"tab_0":
 		{
-			"title": "Morphogen"

+			"title": "Morphogen",

+			"body": "very special & advanced computer programme"

 		},
 
 		"tab_1":
 		{
-			"title": "Moldtek"

+			"title": "Moldtek",

+			"body": "another very special and advanced computer programme"

 		},
 
 		"tab_2":
 		{
-			"title": "Drawing"

+			"title": "Drawing",

+			"body": "a mad dope drawing i done"

 		},
 
 		"tab_3":
 		{
-			"title": "Spoon"

+			"title": "Spoon",

+			"body": "im working on it"

 		},
 
 		"tab_4":
 		{
-			"title": "tab_4_title"

+			"title": "tab_4_title",

+			"body": "tab 4 lol"

 		},
 
 		"tab_5":
 		{
-			"title": "tab_5_title"

+			"title": "tab_5_title",

+			"body": "tab 5 lolol"

 		}
 	}
 }
\ No newline at end of file
diff --git a/js.js b/js.js
index a3f3cde..63abc86 100644
--- a/js.js
+++ b/js.js
@@ -1,8 +1,13 @@
-// import data from "./info.json" assert {type: "json"};
-
-// import_json();
+async function import_json() {
+	const url = "https://lucas.co/info.json";
+	const promise = await fetch(url);
+	const data = await promise.json();
+	return data;
+}
 
-// console.log(data.x);
+import_json().then(
+	function(val) {console.log(val["tabs"])}
+);
 
 const n_tabs = 5;
 
@@ -28,6 +33,7 @@ function main_text(idx) {
 
 function populate() {
 	const body = document.getElementById("body");
+	
 	body.style.backgroundColor = "#c8c7db";
 	const info = tab_idx(n_tabs);
 
@@ -108,7 +114,9 @@ function make_tabs(info, box) {
 		tab.onmouseleave = function() {tab_leave(tab_id)};
 		tab.onclick = function() {tab_click(tab_id, i)};
 		
-		tab.innerText = "title";
+		import_json().then(
+			function(val) { tab.innerText = val["tabs"][tab_id]["title"] }
+		);
 		
 		body.appendChild(tab);
 	}