mirror of
https://github.com/misode/misode.github.io.git
synced 2026-05-06 07:21:48 +00:00
Implement URL sharing
This commit is contained in:
+3
-1
@@ -37,7 +37,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-5">
|
||||
<div class="mb-3 float-lg-right">
|
||||
<div class="mb-3 float-lg-right menu-right">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">Indentation</span>
|
||||
@@ -47,9 +47,11 @@
|
||||
<option value="4">4 Spaces</option>
|
||||
<option value="tab">Tabs</option>
|
||||
</select>
|
||||
<button id="linkSource" type="button" class="btn btn-secondary ml-3" onclick="linkSource(this)">Link</button>
|
||||
<button type="button" class="btn btn-secondary ml-3" onclick="copySource(this)">Copy</button>
|
||||
</div>
|
||||
</div>
|
||||
<textarea id="copyTextarea" rows="1" class="form-control mb-3 d-none"></textarea>
|
||||
<textarea id="source" class="form-control code" onchange="updateSouce()" rows="20" spellcheck="false"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user