From a1be0791a01d47cfb84adc0e18693d7ec9b3eabd Mon Sep 17 00:00:00 2001 From: LUCASTUCIOUS Date: Sun, 5 Mar 2023 02:03:48 +0100 Subject: [PATCH] start spell.js --- .vscode/launch.json | 15 +++++++++++++++ index.html | 4 ++-- js/language.js | 2 +- js/spells.js | 29 +++++++++++++++++++++++++++++ lang/main-fr.json | 16 ++++++++-------- spells.html | 43 ++++++++++++++++++++++++++++++++++++------- 6 files changed, 91 insertions(+), 18 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..8600fc6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://127.0.0.1:5500", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/index.html b/index.html index 32cccfd..9b87ed7 100644 --- a/index.html +++ b/index.html @@ -24,11 +24,11 @@
spells
- - diff --git a/js/language.js b/js/language.js index afb8220..b4da233 100644 --- a/js/language.js +++ b/js/language.js @@ -1,4 +1,4 @@ -// In a browser where the language is set to French + $("[data-localize]").localize("main", { pathPrefix: "lang" }); // You can also override the language detection, and pass in a language code diff --git a/js/spells.js b/js/spells.js index e69de29..794ec10 100644 --- a/js/spells.js +++ b/js/spells.js @@ -0,0 +1,29 @@ +var normaliseLang; +normaliseLang = function (lang) { + lang = lang.replace(/_/, "-").toLowerCase(); + if (lang.length > 3) { + lang = lang.substring(0, 3) + lang.substring(3).toUpperCase(); + } + return lang; +}; + +$.defaultLanguage = normaliseLang( + navigator.languages && navigator.languages.length > 0 + ? navigator.languages[0] + : navigator.language || navigator.userLanguage +); +var lang = normaliseLang( $.defaultLanguage); + +fetch('data/spells/spells-grimoire-fr.json') + .then((response) => response.json()) + .then((json) => JSON.parse(json)); + + +var string jsonsource = ''.concat("../data/spells/spells-grimoire-",navigator.languages[0].slice(0,2),".json"); + +import data from jsonsource assert { type: 'json' }; +console.log(data); + +var yourHtml = JSON; + +document.getElementById("spell-list").innerHTML = yourHtml; diff --git a/lang/main-fr.json b/lang/main-fr.json index b58f1e5..b61e8a3 100644 --- a/lang/main-fr.json +++ b/lang/main-fr.json @@ -1,12 +1,12 @@ { "title": "FateforgeTools", "desc": "Une gamme d'outils pour les joueurs et les meneurs de Dragons.", - "terms": { - "Fateforge": "Dragons" - }, - "btn-spells": "Sorts", - "btn-monsters": "Créatures", - "btn-items": "Objets Magiques", - "CUVD": "Site non-officiel pour ​Dragons​ créé(e). Utilise des contenus protégés par la propriété intellectuelle © Agate RPG, avec l’aimable permission de l’éditeur dans le cadre de la licence CUVD.", - "link": "Rejoignez la communauté : ​www.dragons-rpg.com" + "terms": { + "Fateforge": "Dragons" + }, + "btn-spells": "Sorts", + "btn-monsters": "Créatures", + "btn-items": "Objets Magiques", + "CUVD": "Site non-officiel pour ​Dragons​ créé(e). Utilise des contenus protégés par la propriété intellectuelle © Agate RPG, avec l’aimable permission de l’éditeur dans le cadre de la licence CUVD.", + "link": "Rejoignez la communauté : ​www.dragons-rpg.com" } diff --git a/spells.html b/spells.html index daa72f0..0e9ae75 100644 --- a/spells.html +++ b/spells.html @@ -1,6 +1,7 @@ + - + fateforge-tools @@ -12,17 +13,45 @@ - +

FateforgeTools

-

Spells

+

Spells

+ +
+ +
+
+
+ + + + + + +
+
+ +
+
+ +
+ + + + +
Select a spell from the list to view it here
+
+
- - - + + + + - + + \ No newline at end of file