Compare commits
No commits in common. "2aad9dacb9bba3df42292c7162b96e5f255388ff" and "f19894b45465ef5489aa793a1ea17cbb90d92efd" have entirely different histories.
2aad9dacb9
...
f19894b454
9 changed files with 83 additions and 281 deletions
166
.vscode/bookdetails-schema.json
vendored
166
.vscode/bookdetails-schema.json
vendored
|
@ -1,166 +0,0 @@
|
||||||
{
|
|
||||||
"$id": "bookdetails-schema.json#",
|
|
||||||
"default": {
|
|
||||||
"code": "ID3xx",
|
|
||||||
"title": "New book",
|
|
||||||
"desc": ["Nice", "A *new* book"],
|
|
||||||
"cover": {
|
|
||||||
"src": "",
|
|
||||||
"alt": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"properties": {
|
|
||||||
"code": {
|
|
||||||
"title": "Book code, follow the ID3xx pattern - Not used",
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^[A-Z0-9]{3}\\d{2}$"
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "string",
|
|
||||||
"maxLength": 30
|
|
||||||
},
|
|
||||||
"author": {
|
|
||||||
"title": "Book authors",
|
|
||||||
"type": "array",
|
|
||||||
"maxLength": 5,
|
|
||||||
"items": {
|
|
||||||
"title": "Author",
|
|
||||||
"type": "string",
|
|
||||||
"examples": ["Neil Gailman", "Team Agate"]
|
|
||||||
},
|
|
||||||
"examples": [["Team Agate"], ["Neil Gailman", "Rachida Dati"]]
|
|
||||||
},
|
|
||||||
"desc": {
|
|
||||||
"title": "Book desc, markdown formated, each row is a paragraph.",
|
|
||||||
"type": "array"
|
|
||||||
},
|
|
||||||
"cover": {
|
|
||||||
"title": "Book cover",
|
|
||||||
"type": "object",
|
|
||||||
"required": ["src"],
|
|
||||||
"properties": {
|
|
||||||
"src": {
|
|
||||||
"title": "Source file path, in relative path",
|
|
||||||
"type": "string",
|
|
||||||
"format": "uri-reference",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["img\\books\\ADV01_BC_FR.png"]
|
|
||||||
},
|
|
||||||
"alt": {
|
|
||||||
"type": "string",
|
|
||||||
"examples": ["ADV01_BC_FR"]
|
|
||||||
},
|
|
||||||
"title": {
|
|
||||||
"type": "string",
|
|
||||||
"examples": ["ADV01_BC_FR"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"examples": [
|
|
||||||
{
|
|
||||||
"src": "img\\books\\ADV01_BC_FR.png",
|
|
||||||
"alt": "ADV01_BC_FR",
|
|
||||||
"title": "ADV01_BC_FR"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"published-date": {
|
|
||||||
"title": "The published-date Schema",
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["01/04/2018"]
|
|
||||||
},
|
|
||||||
"cf-date": {
|
|
||||||
"title": "The cf-date Schema",
|
|
||||||
"type": "string",
|
|
||||||
"format": "date",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["14/03/2016"]
|
|
||||||
},
|
|
||||||
"physical-link": {
|
|
||||||
"title": "The physical-link Schema",
|
|
||||||
"type": "object",
|
|
||||||
"default": {},
|
|
||||||
"required": ["title", "href"],
|
|
||||||
"properties": {
|
|
||||||
"title": {
|
|
||||||
"title": "The title Schema",
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["Acheter un exemplaire"]
|
|
||||||
},
|
|
||||||
"href": {
|
|
||||||
"title": "The href Schema",
|
|
||||||
"type": "string",
|
|
||||||
"format":"uri",
|
|
||||||
"default": "",
|
|
||||||
"examples": [
|
|
||||||
"https://www.philibertnet.com/fr/dragons/62090-dragons-1-aventuriers-livre-de-base-9782919256365.html"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"examples": [
|
|
||||||
{
|
|
||||||
"title": "Acheter un exemplaire",
|
|
||||||
"href": "https://www.philibertnet.com/fr/dragons/62090-dragons-1-aventuriers-livre-de-base-9782919256365.html"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"pdf-link": {
|
|
||||||
"title": "The pdf-link Schema",
|
|
||||||
"type": "object",
|
|
||||||
"default": {},
|
|
||||||
"required": ["title", "href"],
|
|
||||||
"properties": {
|
|
||||||
"title": {
|
|
||||||
"title": "The title Schema",
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["Acheter le pdf"]
|
|
||||||
},
|
|
||||||
"href": {
|
|
||||||
"title": "The href Schema",
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"examples": [
|
|
||||||
"https://www.drivethrurpg.com/product/422886/Dragons--1--Livre-de-base--Aventuriers"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"examples": [
|
|
||||||
{
|
|
||||||
"title": "Acheter le pdf",
|
|
||||||
"href": "https://www.drivethrurpg.com/product/422886/Dragons--1--Livre-de-base--Aventuriers"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"cf-link": {
|
|
||||||
"title": "The cf-link Schema",
|
|
||||||
"type": "object",
|
|
||||||
"default": {},
|
|
||||||
"required": ["title", "href"],
|
|
||||||
"properties": {
|
|
||||||
"title": {
|
|
||||||
"title": "The title Schema",
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["Ulule"]
|
|
||||||
},
|
|
||||||
"href": {
|
|
||||||
"title": "The href Schema",
|
|
||||||
"type": "string",
|
|
||||||
"default": "",
|
|
||||||
"examples": ["https://fr.ulule.com/dragons-5e/"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"examples": [
|
|
||||||
{
|
|
||||||
"title": "Ulule",
|
|
||||||
"href": "https://fr.ulule.com/dragons-5e/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": ["title", "desc", "cover"]
|
|
||||||
}
|
|
12
.vscode/books-schemas.json
vendored
12
.vscode/books-schemas.json
vendored
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
||||||
"type": "object",
|
|
||||||
"patternProperties": {
|
|
||||||
"^[A-Z0-9]{3}\\d{2}$": {
|
|
||||||
"title": "Book code, follow the ID3xx pattern",
|
|
||||||
"type": "object",
|
|
||||||
"$ref": "bookdetails-schema.json#"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
|
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
@ -1,16 +1,11 @@
|
||||||
{
|
{
|
||||||
"json.schemas": [
|
"json.schemas": [
|
||||||
|
|
||||||
{
|
{
|
||||||
"fileMatch": [
|
"fileMatch": [
|
||||||
"data/spells/*.json"
|
"data/spells/*.json"
|
||||||
],
|
],
|
||||||
"url": "/./.vscode/spells-schemas.json"
|
"url": "/./.vscode/spells-schemas.json"
|
||||||
},
|
|
||||||
{
|
|
||||||
"fileMatch": [
|
|
||||||
"data/books*.json"
|
|
||||||
],
|
|
||||||
"url": "/./.vscode/books-schemas.json"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stenography.apiKey": "caac2b35-1682-4741-a409-d687f69d9767",
|
"stenography.apiKey": "caac2b35-1682-4741-a409-d687f69d9767",
|
||||||
|
|
35
books.html
35
books.html
|
@ -3,26 +3,27 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Books - fateforge.tools</title>
|
<title>Books - fateforge.tools</title>
|
||||||
<link rel="stylesheet" href="css/water.css" />
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css" />
|
||||||
<link href="css/all.min.css" rel="stylesheet" />
|
<link href="css/all.min.css" rel="stylesheet" />
|
||||||
|
|
||||||
<script src="lib/flickity.pkgd.min.js"></script>
|
<script src="lib/flickity.pkgd.min.js"></script>
|
||||||
<script src="lib/flickity.hash.js"></script>
|
<script src="lib/flickity.hash.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<link rel="icon" type="image/x-icon" href="/img/FateforgeTool_logo_80.png" />
|
<link rel="icon" type="image/x-icon" href="/img/FateforgeTool_logo_80.png" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<button onclick="changeLangEN()">
|
<button onclick="changeLangEN()">
|
||||||
<img src="img\flags\en-UK-400.png" width="20" />
|
<img src="img\flags\en-UK-400.png" width="20" />
|
||||||
English
|
English
|
||||||
</button>
|
</button>
|
||||||
<button onclick="changeLangFR()">
|
<button onclick="changeLangFR()">
|
||||||
<img src="img\flags\fr-FR-400.png" width="20" />
|
<img src="img\flags\fr-FR-400.png" width="20" />
|
||||||
Français
|
Français
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="index.html">
|
<a href="index.html">
|
||||||
<h1>FateforgeTools</h1>
|
<h1>FateforgeTools</h1>
|
||||||
|
@ -30,17 +31,14 @@
|
||||||
|
|
||||||
<div class="gallery"></div>
|
<div class="gallery"></div>
|
||||||
|
|
||||||
<div class="view-container" style="display: flex; align-items: center; flex-direction: column">
|
|
||||||
|
|
||||||
|
<div class="view-container" style="display: flex;align-items: center;flex-direction: column;">
|
||||||
<h1 id="book_title"></h1>
|
<h1 id="book_title"></h1>
|
||||||
<i id="book_author" ></i>
|
|
||||||
<div class="view-container">
|
<div class="view-container">
|
||||||
<div>
|
<div><a target="_blank" id="book_cf-link"><i class="fa-solid fa-hand-holding-dollar icon" ></i></a><span class="view-details" id="cf-date"></span></div>
|
||||||
<a target="_blank" id="book_cf-link"><i class="fa-solid fa-hand-holding-dollar icon"></i></a>
|
<div class="view-container row"><a target="_blank" id="physical-link"><i class="fa-solid fa-cart-shopping icon"></i></a>
|
||||||
<span class="view-details" id="book_cf-date"></span>
|
<a target="_blank" id="pdf-link"><i class="fa-solid fa-file-pdf icon"></i></a>
|
||||||
</div>
|
|
||||||
<div class="view-container row">
|
|
||||||
<a target="_blank" id="book_physical-link"><i class="fa-solid fa-cart-shopping icon"></i></a>
|
|
||||||
<a target="_blank" id="book_pdf-link"><i class="fa-solid fa-file-pdf icon"></i></a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="book-desc" id="book_desc"></div>
|
<div class="book-desc" id="book_desc"></div>
|
||||||
|
@ -54,7 +52,8 @@
|
||||||
|
|
||||||
<script type="text/javascript" src="js/language.js"></script>
|
<script type="text/javascript" src="js/language.js"></script>
|
||||||
<script type="module" src="js/books.js"></script>
|
<script type="module" src="js/books.js"></script>
|
||||||
<script rel="preload" src="lib/fontawesome.js" crossorigin="anonymous"></script>
|
<script rel="preload" src="https://kit.fontawesome.com/126cdd0e29.js" crossorigin="anonymous"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
101
js/books.js
101
js/books.js
|
@ -1,16 +1,16 @@
|
||||||
var lastbook;
|
var lastbook;
|
||||||
var currentbook;
|
var currentbook;
|
||||||
|
|
||||||
fetch("/data/books-en.json")
|
fetch("/lang/books-en.json")
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
||||||
const gallery = document.getElementsByClassName("gallery")[0];
|
const gallery = document.getElementsByClassName("gallery")[0];
|
||||||
|
|
||||||
for (const key in data) {
|
for (const key in data) {
|
||||||
console.log(data[key].code, data[key].title, data[key].cover);
|
console.log(data[key].code, data[key].title, data[key].cover);
|
||||||
var bookHTML = `<div class="gallery-cell" id="${data[key].code}">
|
var bookHTML = `<div class="gallery-cell" id="${data[key].code}">
|
||||||
<div class="book-container">
|
<div class="book-container">
|
||||||
<div class="book">
|
<div class="book">
|
||||||
<img data-localize="${data[key].code}.cover" />
|
<img data-localize="${data[key].code}.cover" />
|
||||||
|
@ -19,50 +19,57 @@ fetch("/data/books-en.json")
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
gallery.insertAdjacentHTML("afterbegin", bookHTML);
|
gallery.insertAdjacentHTML("afterbegin", bookHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
var flkty = new Flickity(".gallery", {
|
var flkty = new Flickity(".gallery", {
|
||||||
freeScroll: true,
|
freeScroll: true,
|
||||||
wrapAround: true,
|
wrapAround: true,
|
||||||
hash: true, // options
|
hash: true, // options
|
||||||
});
|
});
|
||||||
refreshBooks();
|
refreshBooks();
|
||||||
currentbook = document
|
currentbook = document
|
||||||
.getElementsByClassName("gallery-cell is-selected")[0]
|
.getElementsByClassName("gallery-cell is-selected")[0]
|
||||||
.getAttribute("id");
|
.getAttribute("id");
|
||||||
fillBookView();
|
//TODO: Fill view-container with books
|
||||||
|
fillBookView();
|
||||||
|
|
||||||
flkty.on("select", function (index) {
|
flkty.on("select", function(index) {
|
||||||
currentbook = document
|
currentbook = document
|
||||||
.getElementsByClassName("gallery-cell is-selected")[0]
|
.getElementsByClassName("gallery-cell is-selected")[0]
|
||||||
.getAttribute("id");
|
.getAttribute("id");
|
||||||
if (currentbook == lastbook) {
|
if (currentbook == lastbook) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fillBookView();
|
//TODO: Fill view-container with books
|
||||||
});
|
fillBookView();
|
||||||
/*flkty.on("settle", function (index) {
|
});
|
||||||
|
/*flkty.on("settle", function (index) {
|
||||||
console.log("Flickity settled at " + index);
|
console.log("Flickity settled at " + index);
|
||||||
refreshBooks();
|
refreshBooks();
|
||||||
});*/
|
});*/
|
||||||
});
|
});
|
||||||
|
|
||||||
function fillBookView() {
|
function fillBookView() {
|
||||||
var bookAttributes = [
|
var bookAttributes = [
|
||||||
"book_title",
|
"book_title",
|
||||||
"book_desc",
|
"book_desc",
|
||||||
"book_cf-date",
|
"cf-date",
|
||||||
"book_physical-link",
|
"physical-link",
|
||||||
"book_pdf-link",
|
"pdf-link",
|
||||||
"book_cf-link",
|
"book_cf-link",
|
||||||
"book_author"
|
];
|
||||||
];
|
|
||||||
bookAttributes.forEach(function (attr) {
|
bookAttributes.forEach(function(attr) {
|
||||||
setLocalizeDataAttr(attr, currentbook + "." + attr.split("_")[1]);
|
setLocalizeDataAttr(attr, currentbook + "." + attr.split("_")[1]);
|
||||||
});
|
});
|
||||||
lastbook = currentbook;
|
setLocalizeDataAttr("view-title", currentbook + ".title");
|
||||||
console.log(currentLang);
|
setLocalizeDataAttr("view-desc", currentbook + ".desc");
|
||||||
//call to language.js
|
setLocalizeDataAttr("cf-date", currentbook + ".cf-date");
|
||||||
refreshBooks();
|
setLocalizeDataAttr("physical-link", currentbook + ".physical-link");
|
||||||
|
setLocalizeDataAttr("pdf-link", currentbook + ".pdf-link");
|
||||||
|
setLocalizeDataAttr("cf-link", currentbook + ".cf-link");
|
||||||
|
lastbook = currentbook;
|
||||||
|
console.log(currentLang);
|
||||||
|
refreshBooks();
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ function changeLangEN() {
|
||||||
|
|
||||||
function refreshBooks() {
|
function refreshBooks() {
|
||||||
$("[data-localize]").localize("books", {
|
$("[data-localize]").localize("books", {
|
||||||
pathPrefix: "data",
|
pathPrefix: "lang",
|
||||||
language: currentLang,
|
language: currentLang,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,15 @@ function refreshLoc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to fill a data-localize attribute and update DOM
|
// Function to fill a data-localize attribute and update DOM
|
||||||
function setLocalizeDataAttr(id, dataValue) {
|
function setLocalizeDataAttr(className, dataValue) {
|
||||||
const all = $('[id="' + id + '"]');
|
$("#" + className)
|
||||||
all.each(function() {
|
.data("localize", dataValue)
|
||||||
console.log(this.id)
|
.attr("data-localize", dataValue);
|
||||||
$(this).data("localize", dataValue).attr("data-localize", dataValue);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function localize(lang) {
|
function localize(lang) {
|
||||||
$("[data-localize]")
|
$("[data-localize]")
|
||||||
.localize("main", { pathPrefix: "lang", language: lang })
|
.localize("main", { pathPrefix: "lang", language: lang })
|
||||||
.localize("books", { pathPrefix: "data", language: lang });
|
.localize("books", { pathPrefix: "lang", language: lang });
|
||||||
currentLang=lang;
|
currentLang=lang;
|
||||||
}
|
}
|
|
@ -12,14 +12,7 @@
|
||||||
"title":"Acheter un exemplaire",
|
"title":"Acheter un exemplaire",
|
||||||
"href":"https://www.philibertnet.com/fr/dragons/62090-dragons-1-aventuriers-livre-de-base-9782919256365.html"
|
"href":"https://www.philibertnet.com/fr/dragons/62090-dragons-1-aventuriers-livre-de-base-9782919256365.html"
|
||||||
},
|
},
|
||||||
"pdf-link":{
|
"pdf-link": "https://www.drivethrurpg.com/product/422886/Dragons--1--Livre-de-base--Aventuriers",
|
||||||
"title":"Acheter le pdf",
|
|
||||||
"href":"https://www.drivethrurpg.com/product/422886/Dragons--1--Livre-de-base--Aventuriers"
|
|
||||||
},
|
|
||||||
"cf-link":{
|
|
||||||
"title":"Ulule",
|
|
||||||
"href":"https://fr.ulule.com/dragons-5e/"
|
|
||||||
},
|
|
||||||
"author": ["Agate Team"],
|
"author": ["Agate Team"],
|
||||||
"published-date": "01/04/2018",
|
"published-date": "01/04/2018",
|
||||||
"cf-date": "14/03/2016",
|
"cf-date": "14/03/2016",
|
|
@ -16,7 +16,7 @@
|
||||||
"title":"Acheter le pdf",
|
"title":"Acheter le pdf",
|
||||||
"href":"https://www.drivethrurpg.com/product/422886/Dragons--1--Livre-de-base--Aventuriers"
|
"href":"https://www.drivethrurpg.com/product/422886/Dragons--1--Livre-de-base--Aventuriers"
|
||||||
},
|
},
|
||||||
"cf-link":{
|
"cf-link:":{
|
||||||
"title":"Ulule",
|
"title":"Ulule",
|
||||||
"href":"https://fr.ulule.com/dragons-5e/"
|
"href":"https://fr.ulule.com/dragons-5e/"
|
||||||
},
|
},
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
"CRE02": {
|
"CRE02": {
|
||||||
"code": "CRE02",
|
"code": "CRE02",
|
||||||
"title": "Créatures : Inframonde",
|
"title": "Créatures : Inframonde",
|
||||||
"desc": [],
|
"desc": ["*"],
|
||||||
"physical-link": {
|
"physical-link": {
|
||||||
"title":"Acheter un exemplaire",
|
"title":"Acheter un exemplaire",
|
||||||
"href":""
|
"href":""
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
"title":"Acheter le pdf",
|
"title":"Acheter le pdf",
|
||||||
"href":"https://www.drivethrurpg.com/product/422893/Dragons--5--Bestiaire--Creatures-2-Inframonde"
|
"href":"https://www.drivethrurpg.com/product/422893/Dragons--5--Bestiaire--Creatures-2-Inframonde"
|
||||||
},
|
},
|
||||||
"cf-link":{
|
"cf-link:":{
|
||||||
"title":"Ulule",
|
"title":"Ulule",
|
||||||
"href":"https://fr.ulule.com/dragons-creatures-de-l-inframonde/"
|
"href":"https://fr.ulule.com/dragons-creatures-de-l-inframonde/"
|
||||||
},
|
},
|
||||||
|
@ -53,15 +53,5 @@
|
||||||
"alt": "CRE02_BC_FR",
|
"alt": "CRE02_BC_FR",
|
||||||
"title": "CRE02_BC_FR"
|
"title": "CRE02_BC_FR"
|
||||||
}
|
}
|
||||||
},"ADV02":{
|
|
||||||
"code": "ID3xx",
|
|
||||||
"title": "New book",
|
|
||||||
"desc": [
|
|
||||||
"Nice",
|
|
||||||
"A *new* book"
|
|
||||||
],
|
|
||||||
"cover": ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue