From d78084103934217c4273aa820cf93c7318dac5de Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sun, 20 Oct 2019 01:48:37 +0200 Subject: [PATCH] Add support for artistic value and reading components --- style.html.j2 | 9 +++++++++ style.js | 10 ++++++++++ templates/style.xsl.j2 | 31 +++++++++++++++++++++++++++++++ test_card.xml | 13 +++++++++++++ 4 files changed, 63 insertions(+) diff --git a/style.html.j2 b/style.html.j2 index 2a4b981..2b66a21 100644 --- a/style.html.j2 +++ b/style.html.j2 @@ -190,3 +190,12 @@ {% endif %} + +{# +{% for item in xml.components %} +{{item["@x"]}}, +{{item["@y"]}}, +{{item["@db_entry"]}}
+{% endfor %} + +#} diff --git a/style.js b/style.js index c9cd92a..fe6026f 100644 --- a/style.js +++ b/style.js @@ -13,6 +13,16 @@ for (var i=0; i < xml_data_items.length; i++) { context.xml[key] = val; } +var xml_component_items = document.getElementsByClassName("xml_component") +context.xml["components"] = []; +for (var i=0; i < xml_component_items.length/3; i++) { + context.xml["components"].push({ + '@x' : document.getElementById("xml_component_" + (i+1) + "_x").innerHTML, + '@y' : document.getElementById("xml_component_" + (i+1) + "_y").innerHTML, + '@db_entry': document.getElementById("xml_component_" + (i+1) + "_db_entry").innerHTML, + }); +} + var env = new nunjucks.Environment([], { autoescape: true, trimBlocks: true, diff --git a/templates/style.xsl.j2 b/templates/style.xsl.j2 index fb3bbd5..c8cceac 100644 --- a/templates/style.xsl.j2 +++ b/templates/style.xsl.j2 @@ -47,11 +47,42 @@ "symbol", "difficulty", "duration", + "artistic_value", "playcost"] %} {{lt}}script type="text/html" class="xml_data" id="xml_data_{{ value }}"{{gt}}{{lt}}/script{{gt}} {{ newline }} {% endfor %} +{{ newline }} + + + +{{lt}}script type="text/html" class="xml_component" id="xml_component{# +#}__{# +#}x"{{gt}} + +{{lt}}/script{{gt}} +{{ newline }} + +{{lt}}script type="text/html" class="xml_component" id="xml_component{# +#}__{# +#}y"{{gt}} + +{{lt}}/script{{gt}} +{{ newline }} + +{{lt}}script type="text/html" class="xml_component" id="xml_component{# +#}__{# +#}db_entry"{{gt}} + +{{lt}}/script{{gt}} +{{ newline }} + + + + + + {{ newline*2 }}