From 522bdc7d2950543b30d494e4b60ca980dfed95a8 Mon Sep 17 00:00:00 2001 From: Misode Date: Mon, 17 Jun 2019 06:46:37 +0200 Subject: [PATCH] Add indentation dropdown and credits --- index.html | 13 +++++++++++-- script.js | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 0cb506e0..925fa3ac 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,7 @@
@@ -20,8 +21,16 @@
-
- +
+
+ Indentation +
+ +
diff --git a/script.js b/script.js index c48aec81..848c0478 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,7 @@ $("#source").val(''); - +$('#indentationSelect').val("2"); +let indentation = 2; let table = { pools: [] }; @@ -29,6 +30,15 @@ function removePool(el) { invalidated(); } +function updateIndentation(el) { + if (el.value === 'tab') { + indentation = '\t'; + } else { + indentation = parseInt(el.value); + } + invalidated(); +} + function updateRollsField(el) { let $pool = $(el).parent().parent().parent(); let value = parseInt($(el).val()); @@ -37,7 +47,7 @@ function updateRollsField(el) { } function invalidated() { - $('#source').val(JSON.stringify(table, null, 2)); + $('#source').val(JSON.stringify(table, null, indentation)); $('#source').autogrow(); }