diff --git a/index.html b/index.html
index f409182d..7a621773 100644
--- a/index.html
+++ b/index.html
@@ -37,7 +37,7 @@
-
+
diff --git a/model.js b/model.js
index 9fd2afc1..3513df8b 100644
--- a/model.js
+++ b/model.js
@@ -3,9 +3,10 @@ $("#source").val('');
$('#luckBased').prop('checked', false);
$('#tableType').val("minecraft:generic");
$('#indentationSelect').val("2");
+
let indentation = 2;
let luck_based = false;
-let nodes = '.loot-table, .pool, .entry, .child, .term, .terms, .function, .condition, .modifier, .operation';
+const nodes = '.loot-table, .pool, .entry, .child, .term, .terms, .function, .condition, .modifier, .operation';
let table = {
type: "minecraft:generic",
pools: []
@@ -13,6 +14,12 @@ let table = {
addPool();
addEntry($('#structure .pool').get());
+const params = new URLSearchParams(window.location.search);
+if (params.has('q')) {
+ $('#source').val(params.get('q'));
+ updateSouce();
+}
+
function updateTableType() {
table.type = $('#tableType').val();
invalidated();
@@ -23,6 +30,17 @@ function updateLuckBased() {
invalidated();
}
+function linkSource() {
+ let link = window.location.origin + window.location.pathname + '?q=' + JSON.stringify(table);
+ console.log(link);
+ $('#copyTextarea').removeClass('d-none').val(link);
+ $('#copyTextarea').get()[0].select();
+ document.execCommand('copy');
+ setTimeout(() => {
+ $('#copyTextarea').addClass('d-none');
+ }, 2000);
+}
+
function updateSouce() {
$('#source').removeClass('invalid');
try {