Front-end almost complete!
This commit is contained in:
parent
9e8fdcac95
commit
a8b9d9ff32
10 changed files with 684 additions and 505 deletions
|
|
@ -17,11 +17,13 @@
|
|||
<script type="module" src="/assets/js/modules/parser/ore.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/parser/stone.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/events.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/generators.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/renderer/components.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/renderer/ore.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/renderer/stone.module.js"></script>
|
||||
<script type="module" src="/assets/js/modules/init.module.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="fade">
|
||||
<nav class="navbar navbar-expand-lg navbar-dark sticky-top bg-dark">
|
||||
<div class="container-fluid">
|
||||
<a href="/" class="navbar-brand">
|
||||
|
|
@ -89,7 +91,7 @@
|
|||
<div class="accordion mb-4" id="oreconfig">
|
||||
</div>
|
||||
|
||||
<h4>Stones - 🛠 WIP 😭</h4>
|
||||
<h4>Stones</h4>
|
||||
|
||||
|
||||
<div class="accordion mb-4" id="stoneconfig">
|
||||
|
|
@ -122,9 +124,6 @@
|
|||
<div class="modal-body">
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<title>Geolosys Configurator Login</title>
|
||||
|
||||
<link rel="shortcut icon" href="/assets/img/logo.png" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="stylesheet" href="/Libraries/font-awesome/css/all.min.css">
|
||||
<link rel="stylesheet" href="/Libraries/bootstrap/css/bootstrap.css">
|
||||
<script src="/Libraries/bootstrap/js/bootstrap.js"></script>
|
||||
|
|
@ -51,9 +51,6 @@
|
|||
<div class="modal-body">
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import * as OreParser from './parser/ore.module.js';
|
||||
import * as StoneParser from './parser/stone.module.js';
|
||||
import { makeNotification } from './util.module.js';
|
||||
|
||||
export const preInit = () => {
|
||||
switch112Listener();
|
||||
|
|
@ -15,10 +16,37 @@ const generateJSONListener = () => {
|
|||
btn.addEventListener('click', async () => {
|
||||
btn.attributes.disabled = true;
|
||||
|
||||
await OreParser.read();
|
||||
await StoneParser.read();
|
||||
const ores = OreParser.read();
|
||||
const stones = StoneParser.read();
|
||||
|
||||
if (ores != -1 && stones != -1) {
|
||||
const asJson = JSON.parse(
|
||||
JSON.stringify({
|
||||
"ores": ores,
|
||||
"stones": stones
|
||||
})
|
||||
);
|
||||
|
||||
const resp = await fetch('/', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
json: asJson
|
||||
})
|
||||
});
|
||||
|
||||
const newDoc = await resp.json();
|
||||
makeNotification('Config Upload Complete!', `
|
||||
<center>
|
||||
You can view your JSON at
|
||||
<br>
|
||||
<a href="${location.origin}/configs/${newDoc.shortid}">${location.origin}/configs/${newDoc.shortid}</a>
|
||||
</center>
|
||||
`);
|
||||
}
|
||||
|
||||
btn.attributes.disabled = false;
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,465 +0,0 @@
|
|||
import * as events from './events.module.js';
|
||||
|
||||
export const init = () => {
|
||||
makeAccordionCard(document.getElementById('oreconfig'), true);
|
||||
// makeAccordionCard(document.getElementById('stoneconfig'), false);
|
||||
};
|
||||
|
||||
const depositTypeOptions = {
|
||||
'deposit': 'Normal',
|
||||
'depositMulti': 'Multi-Ore',
|
||||
'depositBiome': 'Biome Specific',
|
||||
'depositBiomeMulti': 'Multi-Ore & Biome Specific'
|
||||
};
|
||||
|
||||
const structureTypeOptions = {
|
||||
'dense': 'Dense',
|
||||
'sparse': 'Sparse',
|
||||
'dike': 'Dike',
|
||||
'layer': 'Layer'
|
||||
};
|
||||
|
||||
export const makeAccordionCard = (container, isOre) => {
|
||||
const dataId = `${container.id}-config-${container.childNodes.length}`;
|
||||
const lblId = `${container.id}-config-header-${container.childNodes.length}`;
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card';
|
||||
|
||||
const cardHdr = document.createElement('div');
|
||||
cardHdr.className = 'card-header';
|
||||
cardHdr.id = lblId;
|
||||
|
||||
const cardHdrTxt = document.createElement('h2');
|
||||
cardHdrTxt.className = 'mb-0';
|
||||
|
||||
const cardBtns = document.createElement('div');
|
||||
cardBtns.className = 'btn-group';
|
||||
cardBtns.setAttribute('role', 'group');
|
||||
cardBtns.setAttribute('aria-label', 'Card Controls');
|
||||
|
||||
const collapseCtrlBtn = document.createElement('button');
|
||||
collapseCtrlBtn.className = 'btn btn-outline-secondary ';
|
||||
collapseCtrlBtn.type = 'button';
|
||||
collapseCtrlBtn.setAttribute('data-toggle', 'collapse');
|
||||
collapseCtrlBtn.setAttribute('data-target', `#${dataId}`);
|
||||
collapseCtrlBtn.setAttribute('aria-expanded', 'true');
|
||||
collapseCtrlBtn.setAttribute('aria-controls', `${dataId}`);
|
||||
collapseCtrlBtn.innerText = `Config Entry`;
|
||||
|
||||
const addAccordionBtn = document.createElement('button');
|
||||
addAccordionBtn.className = 'btn btn-success';
|
||||
addAccordionBtn.innerHTML = '<i class="fas fa-plus"></i>';
|
||||
addAccordionBtn.addEventListener('click', () => {
|
||||
makeAccordionCard(container, isOre);
|
||||
});
|
||||
|
||||
cardBtns.appendChild(collapseCtrlBtn);
|
||||
cardBtns.appendChild(addAccordionBtn);
|
||||
|
||||
if (container.childNodes.length > 1) {
|
||||
const delAccordionBtn = document.createElement('button');
|
||||
delAccordionBtn.className = 'btn btn-danger';
|
||||
delAccordionBtn.innerHTML = '<i class="fas fa-minus"></i>';
|
||||
delAccordionBtn.addEventListener('click', () => {
|
||||
container.removeChild(card);
|
||||
});
|
||||
cardBtns.appendChild(delAccordionBtn);
|
||||
}
|
||||
|
||||
cardHdrTxt.appendChild(cardBtns);
|
||||
cardHdr.appendChild(cardHdrTxt);
|
||||
card.appendChild(cardHdr);
|
||||
|
||||
const data = document.createElement('div');
|
||||
data.id = dataId;
|
||||
data.classList.add('collapse');
|
||||
data.setAttribute('aria-labelledby', lblId);
|
||||
data.setAttribute('data-parent', `#${container.id}`);
|
||||
if (container.childNodes.length == 1) {
|
||||
data.classList.add('show');
|
||||
}
|
||||
|
||||
if (isOre) {
|
||||
data.appendChild(makeOreForm(
|
||||
container.childNodes.length,
|
||||
document.getElementById('switch-112-mode').checked
|
||||
));
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
card.appendChild(data);
|
||||
container.appendChild(card);
|
||||
};
|
||||
|
||||
const makeOreForm = (formId, usingNewConfig) => {
|
||||
const form = document.createElement('form');
|
||||
form.style.padding = "12px";
|
||||
|
||||
form.appendChild(makeHeader('Deposit Name [Optional]'));
|
||||
|
||||
const nameWrapper = document.createElement('div');
|
||||
nameWrapper.className = 'mb-3';
|
||||
const nameInput = document.createElement('input');
|
||||
nameInput.type = 'text';
|
||||
nameInput.className = 'form-control';
|
||||
nameInput.name = 'name';
|
||||
nameWrapper.appendChild(nameInput);
|
||||
form.appendChild(nameWrapper);
|
||||
|
||||
form.appendChild(makeHeader('Deposit Type'));
|
||||
|
||||
const depWrapper = document.createElement('div');
|
||||
depWrapper.className = 'mb-3';
|
||||
const depositType = document.createElement('select');
|
||||
depositType.className = 'form-select';
|
||||
depositType.name = 'DepositType';
|
||||
for (const [idx, key] of Object.keys(depositTypeOptions).entries()) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = key;
|
||||
opt.innerText = depositTypeOptions[key];
|
||||
if (idx == 0) {
|
||||
opt.selected = true;
|
||||
}
|
||||
depositType.appendChild(opt);
|
||||
}
|
||||
depWrapper.appendChild(depositType);
|
||||
form.appendChild(depWrapper);
|
||||
|
||||
if (usingNewConfig) {
|
||||
form.appendChild(makeHeader('Deposit Structure Type (<b>1.14+ Only</b>)'));
|
||||
|
||||
const strWrapper = document.createElement('div');
|
||||
strWrapper.className = 'mb-3';
|
||||
const structureType = document.createElement('select');
|
||||
structureType.className = 'form-select';
|
||||
structureType.name = 'type';
|
||||
for (const [idx, key] of Object.keys(structureTypeOptions).entries()) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = key;
|
||||
opt.innerText = structureTypeOptions[key];
|
||||
if (idx == 0) {
|
||||
opt.selected = true;
|
||||
}
|
||||
structureType.appendChild(opt);
|
||||
}
|
||||
strWrapper.appendChild(structureType);
|
||||
form.appendChild(strWrapper);
|
||||
}
|
||||
|
||||
form.appendChild(makeHeader('Ore Blocks'));
|
||||
const oreWrapper = document.createElement('div');
|
||||
const oreInputs = makePair('ore', ['deposit', 'depositBiome'].includes(depositType.value), oreWrapper);
|
||||
oreWrapper.appendChild(oreInputs);
|
||||
form.appendChild(oreWrapper);
|
||||
|
||||
/* Update type of ore wrapper based on change of depositType */
|
||||
depositType.addEventListener('change', () => {
|
||||
const type = depositType.value;
|
||||
oreWrapper.innerHTML = '';
|
||||
|
||||
if (type == 'deposit' || type == 'depositBiome') {
|
||||
const newInput = makePair('ore', true, oreWrapper);
|
||||
oreWrapper.appendChild(newInput);
|
||||
} else if (type == 'depositMulti' || type == 'depositBiomeMulti') {
|
||||
const newInput = makePair('ore', false, oreWrapper);
|
||||
oreWrapper.appendChild(newInput);
|
||||
} else {
|
||||
alert(`Invalid type: ${type}`);
|
||||
}
|
||||
});
|
||||
|
||||
form.appendChild(makeHeader('Sample Blocks'));
|
||||
const sampleWrapper = document.createElement('div');
|
||||
const sampleInputs = makePair('sample', ['deposit', 'depositBiome'].includes(depositType.value), sampleWrapper);
|
||||
sampleWrapper.appendChild(sampleInputs);
|
||||
form.appendChild(sampleWrapper);
|
||||
|
||||
/* Update type of sample wrapper based on change of depositType */
|
||||
depositType.addEventListener('change', () => {
|
||||
const type = depositType.value;
|
||||
|
||||
// delChildren(sampleWrapper);
|
||||
sampleWrapper.innerHTML = '';
|
||||
|
||||
if (type == 'deposit' || type == 'depositBiome') {
|
||||
const newInput = makePair('ore', true, sampleWrapper);
|
||||
sampleWrapper.appendChild(newInput);
|
||||
} else if (type == 'depositMulti' || type == 'depositBiomeMulti') {
|
||||
const newInput = makePair('ore', false, sampleWrapper);
|
||||
sampleWrapper.appendChild(newInput);
|
||||
} else {
|
||||
alert(`Invalid type: ${type}`);
|
||||
}
|
||||
});
|
||||
|
||||
form.appendChild(makeHeader('Minimum Y-Level'));
|
||||
const yMinWrapper = document.createElement('div');
|
||||
yMinWrapper.className = 'mb-3';
|
||||
const yMin = document.createElement('input');
|
||||
yMin.className = 'form-control';
|
||||
yMin.value = 0;
|
||||
yMin.type = 'number';
|
||||
yMin.min = 0;
|
||||
yMin.max = 255;
|
||||
yMin.name = 'yMin';
|
||||
yMin.setAttribute('required', 'required');
|
||||
yMinWrapper.appendChild(yMin);
|
||||
form.appendChild(yMinWrapper);
|
||||
|
||||
form.appendChild(makeHeader('Maximum Y-Level'));
|
||||
const yMaxWrapper = document.createElement('div');
|
||||
yMaxWrapper.className = 'mb-3';
|
||||
const yMax = document.createElement('input');
|
||||
yMax.className = 'form-control';
|
||||
yMax.value = 1;
|
||||
yMax.type = 'number';
|
||||
yMax.min = 0;
|
||||
yMax.max = 255;
|
||||
yMax.name = 'yMax';
|
||||
yMax.setAttribute('required', 'required');
|
||||
yMaxWrapper.appendChild(yMax);
|
||||
form.appendChild(yMaxWrapper);
|
||||
|
||||
events.initYListeners(yMin, yMax);
|
||||
|
||||
form.appendChild(makeHeader('Chance <a href="https://oitsjustjo.se/M3NfQxBsZ" target="_blank">(Relative to All Chances)</a>'));
|
||||
const chanceTheWrapper = document.createElement('div');
|
||||
chanceTheWrapper.className = 'mb-3';
|
||||
const chance = document.createElement('input');
|
||||
chance.className = 'form-control';
|
||||
chance.type = 'number';
|
||||
chance.min = 1;
|
||||
chance.name = 'chance';
|
||||
chance.setAttribute('required', 'required');
|
||||
chanceTheWrapper.appendChild(chance);
|
||||
form.appendChild(chanceTheWrapper);
|
||||
|
||||
|
||||
form.appendChild(makeHeader('Size'));
|
||||
const sizeWrapper = document.createElement('div');
|
||||
sizeWrapper.className = 'mb-3';
|
||||
const size = document.createElement('input');
|
||||
size.className = 'form-control';
|
||||
size.type = 'number';
|
||||
size.min = 1;
|
||||
size.name = 'size';
|
||||
size.setAttribute('required', 'required');
|
||||
sizeWrapper.appendChild(size);
|
||||
form.appendChild(sizeWrapper);
|
||||
|
||||
form.appendChild(makeHeader('Density'));
|
||||
const densityWrapper = document.createElement('div');
|
||||
densityWrapper.className = 'mb-3';
|
||||
const density = document.createElement('input');
|
||||
density.className = 'form-control';
|
||||
density.type = 'number';
|
||||
density.min = 0;
|
||||
density.max = 1;
|
||||
density.step = '0.000000001';
|
||||
density.name = 'density';
|
||||
density.setAttribute('required', 'required');
|
||||
densityWrapper.appendChild(density);
|
||||
form.appendChild(densityWrapper);
|
||||
|
||||
form.appendChild(makeHeader('Dimension Blacklist'));
|
||||
const dimBlWrapper = document.createElement('div');
|
||||
dimBlWrapper.className = 'mb-3';
|
||||
dimBlWrapper.appendChild(
|
||||
makeExpandableSet(
|
||||
'dimBlacklist',
|
||||
dimBlWrapper,
|
||||
document.getElementById('switch-112-mode').checked ? 'text' : 'number',
|
||||
document.getElementById('switch-112-mode').checked ? '<modid:dimension>' : null
|
||||
)
|
||||
);
|
||||
form.appendChild(dimBlWrapper);
|
||||
|
||||
/* Dynamically show biome white/blacklist if a biome-selective type has been chosen */
|
||||
const biomeHeader = makeHeader('Biomes To Spawn / Not Spawn');
|
||||
biomeHeader.style.display = 'none';
|
||||
form.appendChild(biomeHeader);
|
||||
|
||||
const biomeWrapper = document.createElement('div');
|
||||
biomeWrapper.className = 'mb-3';
|
||||
form.appendChild(biomeWrapper);
|
||||
|
||||
depositType.addEventListener('change', () => {
|
||||
const type = depositType.value;
|
||||
|
||||
biomeWrapper.innerHTML = '';
|
||||
/* Hide the label first */
|
||||
biomeHeader.style.display = 'none';
|
||||
|
||||
if (type == 'depositBiomeMulti' || type == 'depositBiome') {
|
||||
/* Reveal the header if applicable */
|
||||
const biomeGroup = makeExpandableSet(
|
||||
'biomes',
|
||||
biomeWrapper,
|
||||
'text',
|
||||
'Format: <modid:biome> OR <a href="https://oitsjustjo.se/GelX-uC1s" target="_blank">Biome Type</a>'
|
||||
);
|
||||
const checkWrapper = document.createElement('div');
|
||||
checkWrapper.className = 'input-group-text';
|
||||
|
||||
const checkLbl = document.createElement('label');
|
||||
checkLbl.for = 'isWhitelist';
|
||||
checkLbl.className = 'mr-2';
|
||||
checkLbl.innerText = 'Whitelist?';
|
||||
|
||||
const checkInput = document.createElement('input');
|
||||
checkInput.className = 'form-check-input';
|
||||
checkInput.type = 'checkbox';
|
||||
checkInput.name = 'isWhitelist';
|
||||
checkInput.value = '';
|
||||
checkInput.setAttribute('aria-label', 'Checkbox for Text Input:');
|
||||
checkWrapper.appendChild(checkLbl);
|
||||
checkWrapper.appendChild(checkInput);
|
||||
|
||||
biomeGroup.insertBefore(checkWrapper, biomeGroup.childNodes[biomeGroup.childNodes.length - 1]);
|
||||
|
||||
// biomeGroup.appendChild()
|
||||
biomeHeader.style.display = 'block';
|
||||
biomeWrapper.appendChild(biomeGroup);
|
||||
}
|
||||
});
|
||||
|
||||
form.appendChild(makeHeader('Blocks This Deposit May Replace'));
|
||||
const replWrapper = document.createElement('div');
|
||||
replWrapper.className = 'mb-3';
|
||||
replWrapper.appendChild(
|
||||
makeExpandableSet(
|
||||
'blockStateMatchers',
|
||||
replWrapper,
|
||||
'text',
|
||||
'Format: <modid:block> or <modid:block:meta>'
|
||||
)
|
||||
);
|
||||
replWrapper.querySelector('input').removeAttribute('required');
|
||||
form.appendChild(replWrapper);
|
||||
|
||||
return form;
|
||||
};
|
||||
|
||||
const makePair = (prefix, single, container) => {
|
||||
const group = document.createElement('div');
|
||||
group.className = 'mb-3 input-group';
|
||||
|
||||
const lbl = document.createElement('span');
|
||||
lbl.className = 'input-group-text';
|
||||
lbl.innerText = 'Block and Chance';
|
||||
|
||||
const block = document.createElement('input');
|
||||
block.type = 'text';
|
||||
block.className = 'form-control';
|
||||
block.setAttribute('data-toggle', 'tooltip');
|
||||
block.setAttribute('data-placement', 'top');
|
||||
block.setAttribute('title', 'Format: modid:block or modid:block:meta');
|
||||
block.name = `block-${prefix}-${container.childNodes.length}`;
|
||||
block.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(block, {});
|
||||
|
||||
const weight = document.createElement('input');
|
||||
weight.type = 'number';
|
||||
weight.min = '1';
|
||||
weight.max = '100';
|
||||
weight.className = 'form-control';
|
||||
weight.name = `weight-${prefix}-${container.childNodes.length}`;
|
||||
|
||||
if (single) {
|
||||
weight.value = 100;
|
||||
weight.setAttribute('disabled', '');
|
||||
} else {
|
||||
weight.setAttribute('data-toggle', 'tooltip');
|
||||
weight.setAttribute('data-placement', 'top');
|
||||
weight.setAttribute('data-html', 'true');
|
||||
weight.setAttribute('title', 'All Chances <b>MUST</b> Add To 100');
|
||||
weight.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(weight, {});
|
||||
}
|
||||
|
||||
group.appendChild(lbl);
|
||||
group.appendChild(block);
|
||||
group.appendChild(weight);
|
||||
|
||||
if (!single) {
|
||||
const addBtn = document.createElement('button');
|
||||
addBtn.className = 'btn btn-success';
|
||||
addBtn.innerHTML = `<i class="fas fa-plus"></i>`;
|
||||
addBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.appendChild(makePair(prefix, single, container));
|
||||
});
|
||||
|
||||
group.appendChild(addBtn);
|
||||
|
||||
if (container.childNodes.length) {
|
||||
const rmBtn = document.createElement('button');
|
||||
rmBtn.className = 'btn btn-danger';
|
||||
rmBtn.innerHTML = `<i class="fas fa-minus"></i>`;
|
||||
rmBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.removeChild(group);
|
||||
});
|
||||
group.appendChild(rmBtn);
|
||||
}
|
||||
}
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
const makeExpandableSet = (prefix, container, type, tooltip) => {
|
||||
const group = document.createElement('div');
|
||||
group.className = 'mb-3 input-group';
|
||||
|
||||
const input = document.createElement('input');
|
||||
input.type = type;
|
||||
input.className = 'form-control';
|
||||
input.name = `${prefix}-${container.childNodes.length}`;
|
||||
if (tooltip) {
|
||||
input.setAttribute('data-toggle', 'tooltip');
|
||||
input.setAttribute('data-placement', 'top');
|
||||
input.setAttribute('data-html', 'true');
|
||||
input.setAttribute('title', tooltip);
|
||||
input.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(input, {});
|
||||
}
|
||||
|
||||
group.appendChild(input);
|
||||
|
||||
const addBtn = document.createElement('button');
|
||||
addBtn.className = 'btn btn-success';
|
||||
addBtn.innerHTML = `<i class="fas fa-plus"></i>`;
|
||||
addBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.appendChild(makeExpandableSet(prefix, container, type, tooltip));
|
||||
});
|
||||
|
||||
group.appendChild(addBtn);
|
||||
|
||||
if (container.childNodes.length) {
|
||||
const rmBtn = document.createElement('button');
|
||||
rmBtn.className = 'btn btn-danger';
|
||||
rmBtn.innerHTML = `<i class="fas fa-minus"></i>`;
|
||||
rmBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.removeChild(group);
|
||||
});
|
||||
group.appendChild(rmBtn);
|
||||
}
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
const delChildren = (el) => {
|
||||
for (const child of el.children) {
|
||||
el.removeChild(child);
|
||||
}
|
||||
};
|
||||
|
||||
const makeHeader = (txt) => {
|
||||
const tmp = document.createElement('h6');
|
||||
tmp.innerHTML = txt;
|
||||
return tmp;
|
||||
};
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
import * as events from './events.module.js';
|
||||
import * as renderer from './generators.module.js';
|
||||
import * as OreFormRenderer from './renderer/ore.module.js';
|
||||
import * as StoneFormRenderer from './renderer/stone.module.js';
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
events.preInit();
|
||||
renderer.init();
|
||||
OreFormRenderer.init();
|
||||
StoneFormRenderer.init();
|
||||
events.init();
|
||||
document.body.classList.add('show');
|
||||
});
|
||||
|
|
@ -5,7 +5,7 @@ import { parsed, makeNotification } from '../util.module.js';
|
|||
*
|
||||
* @returns {null}
|
||||
*/
|
||||
export const read = async () => {
|
||||
export const read = () => {
|
||||
const oreCfg = document.getElementById('oreconfig');
|
||||
|
||||
let ores = Array();
|
||||
|
|
@ -23,31 +23,10 @@ export const read = async () => {
|
|||
});
|
||||
|
||||
if (err) {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
const asJson = JSON.parse(
|
||||
JSON.stringify({
|
||||
"ores": ores
|
||||
})
|
||||
);
|
||||
|
||||
const resp = await fetch('/', {
|
||||
method: 'PUT',
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
json: asJson,
|
||||
})
|
||||
});
|
||||
|
||||
const newDoc = await resp.json();
|
||||
makeNotification('Config Upload Complete!', `
|
||||
<center>
|
||||
You can view your JSON at
|
||||
<br>
|
||||
<a href="${location.origin}/configs/${newDoc.shortid}">${location.origin}/configs/${newDoc.shortid}</a>
|
||||
</center>
|
||||
`);
|
||||
return ores;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -78,7 +57,15 @@ const parse = (form) => {
|
|||
}
|
||||
|
||||
if (err) {
|
||||
alert("There was an error in your form (see outlined in red). Your JSON will not be generated until you correct this.");
|
||||
makeNotification(
|
||||
`One of Your Forms is Incomplete`,
|
||||
`
|
||||
There was an error in one of your Ore Configs that needs to be resolved (see in red).
|
||||
<br>
|
||||
<br>
|
||||
Your config file will not be available until this issue is resolved.
|
||||
`
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,76 @@
|
|||
import { parsed, makeNotification } from '../util.module.js';
|
||||
|
||||
export const read = () => {
|
||||
const stoneCfg = document.getElementById('stoneconfig');
|
||||
|
||||
console.warn('stone.module.read was called but has not been implemented');
|
||||
let stones = Array();
|
||||
let err = false;
|
||||
|
||||
stoneCfg.querySelectorAll('form').forEach((form) => {
|
||||
const stone = parse(form);
|
||||
|
||||
if (stone == -1) {
|
||||
err = true;
|
||||
return;
|
||||
} else {
|
||||
stones.push(stone);
|
||||
}
|
||||
});
|
||||
|
||||
if (err) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return stones;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {HTMLFormElement} form
|
||||
*/
|
||||
const parse = (form) => {
|
||||
let stone = {};
|
||||
|
||||
const allInputs = Array.from(form.querySelectorAll('input'));
|
||||
|
||||
for (let inp of allInputs) {
|
||||
let err = false;
|
||||
if (inp.required && !inp.value || (inp.type == 'number' && (parsed(inp.value) > parsed(inp.max) || parsed(inp.value) < parsed(inp.min)))) {
|
||||
err = true;
|
||||
inp.classList.add('is-invalid');
|
||||
} else {
|
||||
if (inp.classList.contains('is-invalid')) {
|
||||
inp.classList.remove('is-invalid');
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
makeNotification(
|
||||
`One of Your Forms is Incomplete`,
|
||||
`
|
||||
There was an error in one of your Stone Configs that needs to be resolved (see in red).
|
||||
<br>
|
||||
<br>
|
||||
Your config file will not be available until this issue is resolved.
|
||||
`
|
||||
);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (inp.name.includes('-')) { /* parse out any JSONArray() objs */
|
||||
const key = inp.name.substr(0, inp.name.indexOf('-'));
|
||||
|
||||
if (Object.keys(stone).includes(key)) {
|
||||
stone[key].push(parsed(inp.value));
|
||||
} else {
|
||||
stone[key] = [parsed(inp.value)];
|
||||
}
|
||||
} else {
|
||||
stone[inp.name] = parsed(inp.value);
|
||||
}
|
||||
}
|
||||
|
||||
return stone;
|
||||
};
|
||||
189
src/public/assets/js/modules/renderer/components.module.js
Normal file
189
src/public/assets/js/modules/renderer/components.module.js
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
export const makeHeader = (txt) => {
|
||||
const tmp = document.createElement('h6');
|
||||
tmp.innerHTML = txt;
|
||||
return tmp;
|
||||
};
|
||||
|
||||
export const makeExpandableSet = (prefix, container, type, tooltip) => {
|
||||
const group = document.createElement('div');
|
||||
group.className = 'mb-3 input-group';
|
||||
|
||||
const input = document.createElement('input');
|
||||
input.type = type;
|
||||
input.className = 'form-control';
|
||||
input.name = `${prefix}-${container.childNodes.length}`;
|
||||
if (tooltip) {
|
||||
input.setAttribute('data-toggle', 'tooltip');
|
||||
input.setAttribute('data-placement', 'top');
|
||||
input.setAttribute('data-html', 'true');
|
||||
input.setAttribute('title', tooltip);
|
||||
input.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(input, {});
|
||||
}
|
||||
|
||||
group.appendChild(input);
|
||||
|
||||
const addBtn = document.createElement('button');
|
||||
addBtn.className = 'btn btn-success';
|
||||
addBtn.innerHTML = `<i class="fas fa-plus"></i>`;
|
||||
addBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.appendChild(makeExpandableSet(prefix, container, type, tooltip));
|
||||
});
|
||||
|
||||
group.appendChild(addBtn);
|
||||
|
||||
if (container.childNodes.length) {
|
||||
const rmBtn = document.createElement('button');
|
||||
rmBtn.className = 'btn btn-danger';
|
||||
rmBtn.innerHTML = `<i class="fas fa-minus"></i>`;
|
||||
rmBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.removeChild(group);
|
||||
});
|
||||
group.appendChild(rmBtn);
|
||||
}
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
export const makePair = (prefix, single, container) => {
|
||||
const group = document.createElement('div');
|
||||
group.className = 'mb-3 input-group';
|
||||
|
||||
const lbl = document.createElement('span');
|
||||
lbl.className = 'input-group-text';
|
||||
lbl.innerText = 'Block and Chance';
|
||||
|
||||
const block = document.createElement('input');
|
||||
block.type = 'text';
|
||||
block.className = 'form-control';
|
||||
block.setAttribute('data-toggle', 'tooltip');
|
||||
block.setAttribute('data-placement', 'top');
|
||||
block.setAttribute('title', 'Format: modid:block or modid:block:meta');
|
||||
block.name = `block-${prefix}-${container.childNodes.length}`;
|
||||
block.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(block, {});
|
||||
|
||||
const weight = document.createElement('input');
|
||||
weight.type = 'number';
|
||||
weight.min = '1';
|
||||
weight.max = '100';
|
||||
weight.className = 'form-control';
|
||||
weight.name = `weight-${prefix}-${container.childNodes.length}`;
|
||||
|
||||
if (single) {
|
||||
weight.value = 100;
|
||||
weight.setAttribute('disabled', '');
|
||||
} else {
|
||||
weight.setAttribute('data-toggle', 'tooltip');
|
||||
weight.setAttribute('data-placement', 'top');
|
||||
weight.setAttribute('data-html', 'true');
|
||||
weight.setAttribute('title', 'All Chances <b>MUST</b> Add To 100');
|
||||
weight.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(weight, {});
|
||||
}
|
||||
|
||||
group.appendChild(lbl);
|
||||
group.appendChild(block);
|
||||
group.appendChild(weight);
|
||||
|
||||
if (!single) {
|
||||
const addBtn = document.createElement('button');
|
||||
addBtn.className = 'btn btn-success';
|
||||
addBtn.innerHTML = `<i class="fas fa-plus"></i>`;
|
||||
addBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.appendChild(makePair(prefix, single, container));
|
||||
});
|
||||
|
||||
group.appendChild(addBtn);
|
||||
|
||||
if (container.childNodes.length) {
|
||||
const rmBtn = document.createElement('button');
|
||||
rmBtn.className = 'btn btn-danger';
|
||||
rmBtn.innerHTML = `<i class="fas fa-minus"></i>`;
|
||||
rmBtn.addEventListener('click', (evt) => {
|
||||
evt.preventDefault();
|
||||
container.removeChild(group);
|
||||
});
|
||||
group.appendChild(rmBtn);
|
||||
}
|
||||
}
|
||||
|
||||
return group;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {HTMLDivElement} container
|
||||
* @param {Function} formCallback
|
||||
*/
|
||||
export const makeCard = (container, formCallback) => {
|
||||
const dataId = `${container.id}-config-${container.childNodes.length}`;
|
||||
const lblId = `${container.id}-config-header-${container.childNodes.length}`;
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card';
|
||||
|
||||
const cardHdr = document.createElement('div');
|
||||
cardHdr.className = 'card-header';
|
||||
cardHdr.id = lblId;
|
||||
|
||||
const cardHdrTxt = document.createElement('h2');
|
||||
cardHdrTxt.className = 'mb-0';
|
||||
|
||||
const cardBtns = document.createElement('div');
|
||||
cardBtns.className = 'btn-group';
|
||||
cardBtns.setAttribute('role', 'group');
|
||||
cardBtns.setAttribute('aria-label', 'Card Controls');
|
||||
|
||||
const collapseCtrlBtn = document.createElement('button');
|
||||
collapseCtrlBtn.className = 'btn btn-outline-secondary ';
|
||||
collapseCtrlBtn.type = 'button';
|
||||
collapseCtrlBtn.setAttribute('data-toggle', 'collapse');
|
||||
collapseCtrlBtn.setAttribute('data-target', `#${dataId}`);
|
||||
collapseCtrlBtn.setAttribute('aria-expanded', 'true');
|
||||
collapseCtrlBtn.setAttribute('aria-controls', `${dataId}`);
|
||||
collapseCtrlBtn.innerText = `Config Entry`;
|
||||
|
||||
const addAccordionBtn = document.createElement('button');
|
||||
addAccordionBtn.className = 'btn btn-success';
|
||||
addAccordionBtn.innerHTML = '<i class="fas fa-plus"></i>';
|
||||
addAccordionBtn.addEventListener('click', () => {
|
||||
makeCard(container, formCallback);
|
||||
});
|
||||
|
||||
cardBtns.appendChild(collapseCtrlBtn);
|
||||
cardBtns.appendChild(addAccordionBtn);
|
||||
|
||||
if (container.childNodes.length > 1) {
|
||||
const delAccordionBtn = document.createElement('button');
|
||||
delAccordionBtn.className = 'btn btn-danger';
|
||||
delAccordionBtn.innerHTML = '<i class="fas fa-minus"></i>';
|
||||
delAccordionBtn.addEventListener('click', () => {
|
||||
container.removeChild(card);
|
||||
});
|
||||
cardBtns.appendChild(delAccordionBtn);
|
||||
}
|
||||
|
||||
cardHdrTxt.appendChild(cardBtns);
|
||||
cardHdr.appendChild(cardHdrTxt);
|
||||
card.appendChild(cardHdr);
|
||||
|
||||
const data = document.createElement('div');
|
||||
data.id = dataId;
|
||||
data.classList.add('collapse');
|
||||
data.setAttribute('aria-labelledby', lblId);
|
||||
data.setAttribute('data-parent', `#${container.id}`);
|
||||
if (container.childNodes.length == 1) {
|
||||
data.classList.add('show');
|
||||
}
|
||||
|
||||
data.appendChild(formCallback(
|
||||
document.getElementById('switch-112-mode').checked
|
||||
));
|
||||
|
||||
card.appendChild(data);
|
||||
container.appendChild(card);
|
||||
};
|
||||
274
src/public/assets/js/modules/renderer/ore.module.js
Normal file
274
src/public/assets/js/modules/renderer/ore.module.js
Normal file
|
|
@ -0,0 +1,274 @@
|
|||
import * as components from './components.module.js';
|
||||
import * as events from '../events.module.js';
|
||||
|
||||
const depositTypeOptions = {
|
||||
'deposit': 'Normal',
|
||||
'depositMulti': 'Multi-Ore',
|
||||
'depositBiome': 'Biome Specific',
|
||||
'depositBiomeMulti': 'Multi-Ore & Biome Specific'
|
||||
};
|
||||
|
||||
const structureTypeOptions = {
|
||||
'dense': 'Dense',
|
||||
'sparse': 'Sparse',
|
||||
'dike': 'Dike',
|
||||
'layer': 'Layer'
|
||||
};
|
||||
|
||||
export const init = () => {
|
||||
components.makeCard(document.getElementById('oreconfig'), makeForm);
|
||||
};
|
||||
|
||||
const makeForm = (usingNewConfig) => {
|
||||
const form = document.createElement('form');
|
||||
form.style.padding = '12px';
|
||||
|
||||
form.appendChild(components.makeHeader('Deposit Name [Optional]'));
|
||||
|
||||
const nameWrapper = document.createElement('div');
|
||||
nameWrapper.className = 'mb-3';
|
||||
const nameInput = document.createElement('input');
|
||||
nameInput.type = 'text';
|
||||
nameInput.className = 'form-control';
|
||||
nameInput.name = 'name';
|
||||
nameWrapper.appendChild(nameInput);
|
||||
form.appendChild(nameWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Deposit Type'));
|
||||
|
||||
const depWrapper = document.createElement('div');
|
||||
depWrapper.className = 'mb-3';
|
||||
const depositType = document.createElement('select');
|
||||
depositType.className = 'form-select';
|
||||
depositType.name = 'DepositType';
|
||||
for (const [idx, key] of Object.keys(depositTypeOptions).entries()) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = key;
|
||||
opt.innerText = depositTypeOptions[key];
|
||||
if (idx == 0) {
|
||||
opt.selected = true;
|
||||
}
|
||||
depositType.appendChild(opt);
|
||||
}
|
||||
depWrapper.appendChild(depositType);
|
||||
form.appendChild(depWrapper);
|
||||
|
||||
if (usingNewConfig) {
|
||||
form.appendChild(components.makeHeader('Deposit Structure Type (<b>1.14+ Only</b>)'));
|
||||
|
||||
const strWrapper = document.createElement('div');
|
||||
strWrapper.className = 'mb-3';
|
||||
const structureType = document.createElement('select');
|
||||
structureType.className = 'form-select';
|
||||
structureType.name = 'type';
|
||||
for (const [idx, key] of Object.keys(structureTypeOptions).entries()) {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = key;
|
||||
opt.innerText = structureTypeOptions[key];
|
||||
if (idx == 0) {
|
||||
opt.selected = true;
|
||||
}
|
||||
structureType.appendChild(opt);
|
||||
}
|
||||
strWrapper.appendChild(structureType);
|
||||
form.appendChild(strWrapper);
|
||||
}
|
||||
|
||||
form.appendChild(components.makeHeader('Ore Blocks'));
|
||||
const oreWrapper = document.createElement('div');
|
||||
const oreInputs = components.makePair('ore', ['deposit', 'depositBiome'].includes(depositType.value), oreWrapper);
|
||||
oreWrapper.appendChild(oreInputs);
|
||||
form.appendChild(oreWrapper);
|
||||
|
||||
/* Update type of ore wrapper based on change of depositType */
|
||||
depositType.addEventListener('change', () => {
|
||||
const type = depositType.value;
|
||||
oreWrapper.innerHTML = '';
|
||||
|
||||
if (type == 'deposit' || type == 'depositBiome') {
|
||||
const newInput = components.makePair('ore', true, oreWrapper);
|
||||
oreWrapper.appendChild(newInput);
|
||||
} else if (type == 'depositMulti' || type == 'depositBiomeMulti') {
|
||||
const newInput = components.makePair('ore', false, oreWrapper);
|
||||
oreWrapper.appendChild(newInput);
|
||||
} else {
|
||||
alert(`Invalid type: ${type}`);
|
||||
}
|
||||
});
|
||||
|
||||
form.appendChild(components.makeHeader('Sample Blocks'));
|
||||
const sampleWrapper = document.createElement('div');
|
||||
const sampleInputs = components.makePair('sample', ['deposit', 'depositBiome'].includes(depositType.value), sampleWrapper);
|
||||
sampleWrapper.appendChild(sampleInputs);
|
||||
form.appendChild(sampleWrapper);
|
||||
|
||||
/* Update type of sample wrapper based on change of depositType */
|
||||
depositType.addEventListener('change', () => {
|
||||
const type = depositType.value;
|
||||
|
||||
// delChildren(sampleWrapper);
|
||||
sampleWrapper.innerHTML = '';
|
||||
|
||||
if (type == 'deposit' || type == 'depositBiome') {
|
||||
const newInput = components.makePair('ore', true, sampleWrapper);
|
||||
sampleWrapper.appendChild(newInput);
|
||||
} else if (type == 'depositMulti' || type == 'depositBiomeMulti') {
|
||||
const newInput = components.makePair('ore', false, sampleWrapper);
|
||||
sampleWrapper.appendChild(newInput);
|
||||
} else {
|
||||
alert(`Invalid type: ${type}`);
|
||||
}
|
||||
});
|
||||
|
||||
form.appendChild(components.makeHeader('Maximum Y-Level'));
|
||||
const yMaxWrapper = document.createElement('div');
|
||||
yMaxWrapper.className = 'mb-3';
|
||||
const yMax = document.createElement('input');
|
||||
yMax.className = 'form-control';
|
||||
yMax.value = 1;
|
||||
yMax.type = 'number';
|
||||
yMax.min = 0;
|
||||
yMax.max = 255;
|
||||
yMax.name = 'yMax';
|
||||
yMax.setAttribute('required', 'required');
|
||||
yMaxWrapper.appendChild(yMax);
|
||||
form.appendChild(yMaxWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Minimum Y-Level'));
|
||||
const yMinWrapper = document.createElement('div');
|
||||
yMinWrapper.className = 'mb-3';
|
||||
const yMin = document.createElement('input');
|
||||
yMin.className = 'form-control';
|
||||
yMin.value = 0;
|
||||
yMin.type = 'number';
|
||||
yMin.min = 0;
|
||||
yMin.max = 255;
|
||||
yMin.name = 'yMin';
|
||||
yMin.setAttribute('required', 'required');
|
||||
yMinWrapper.appendChild(yMin);
|
||||
form.appendChild(yMinWrapper);
|
||||
|
||||
events.initYListeners(yMin, yMax);
|
||||
|
||||
form.appendChild(components.makeHeader('Chance <a href="https://oitsjustjo.se/M3NfQxBsZ" target="_blank">(Relative to All Chances)</a>'));
|
||||
const chanceTheWrapper = document.createElement('div');
|
||||
chanceTheWrapper.className = 'mb-3';
|
||||
const chance = document.createElement('input');
|
||||
chance.className = 'form-control';
|
||||
chance.type = 'number';
|
||||
chance.min = 1;
|
||||
chance.name = 'chance';
|
||||
chance.setAttribute('required', 'required');
|
||||
chanceTheWrapper.appendChild(chance);
|
||||
form.appendChild(chanceTheWrapper);
|
||||
|
||||
|
||||
form.appendChild(components.makeHeader('Size'));
|
||||
const sizeWrapper = document.createElement('div');
|
||||
sizeWrapper.className = 'mb-3';
|
||||
const size = document.createElement('input');
|
||||
size.className = 'form-control';
|
||||
size.type = 'number';
|
||||
size.min = 1;
|
||||
size.name = 'size';
|
||||
size.setAttribute('required', 'required');
|
||||
sizeWrapper.appendChild(size);
|
||||
form.appendChild(sizeWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Density'));
|
||||
const densityWrapper = document.createElement('div');
|
||||
densityWrapper.className = 'mb-3';
|
||||
const density = document.createElement('input');
|
||||
density.className = 'form-control';
|
||||
density.type = 'number';
|
||||
density.min = 0;
|
||||
density.max = 1;
|
||||
density.step = '0.000000001';
|
||||
density.name = 'density';
|
||||
density.setAttribute('data-toggle', 'tooltip');
|
||||
density.setAttribute('data-placement', 'top');
|
||||
density.setAttribute('data-html', 'true');
|
||||
density.setAttribute('title', 'Any Decimal Between 0-1');
|
||||
density.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(density, {});
|
||||
densityWrapper.appendChild(density);
|
||||
form.appendChild(densityWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Dimension Blacklist'));
|
||||
const dimBlWrapper = document.createElement('div');
|
||||
dimBlWrapper.className = 'mb-3';
|
||||
dimBlWrapper.appendChild(
|
||||
components.makeExpandableSet(
|
||||
'dimBlacklist',
|
||||
dimBlWrapper,
|
||||
document.getElementById('switch-112-mode').checked ? 'text' : 'number',
|
||||
document.getElementById('switch-112-mode').checked ? '<modid:dimension>' : null
|
||||
)
|
||||
);
|
||||
form.appendChild(dimBlWrapper);
|
||||
|
||||
/* Dynamically show biome white/blacklist if a biome-selective type has been chosen */
|
||||
const biomeHeader = components.makeHeader('Biomes To Spawn / Not Spawn');
|
||||
biomeHeader.style.display = 'none';
|
||||
form.appendChild(biomeHeader);
|
||||
|
||||
const biomeWrapper = document.createElement('div');
|
||||
biomeWrapper.className = 'mb-3';
|
||||
form.appendChild(biomeWrapper);
|
||||
|
||||
depositType.addEventListener('change', () => {
|
||||
const type = depositType.value;
|
||||
|
||||
biomeWrapper.innerHTML = '';
|
||||
/* Hide the label first */
|
||||
biomeHeader.style.display = 'none';
|
||||
|
||||
if (type == 'depositBiomeMulti' || type == 'depositBiome') {
|
||||
/* Reveal the header if applicable */
|
||||
const biomeGroup = components.makeExpandableSet(
|
||||
'biomes',
|
||||
biomeWrapper,
|
||||
'text',
|
||||
'Format: <modid:biome> OR <a href="https://oitsjustjo.se/GelX-uC1s" target="_blank">Biome Type</a>'
|
||||
);
|
||||
const checkWrapper = document.createElement('div');
|
||||
checkWrapper.className = 'input-group-text';
|
||||
|
||||
const checkLbl = document.createElement('label');
|
||||
checkLbl.for = 'isWhitelist';
|
||||
checkLbl.className = 'mr-2';
|
||||
checkLbl.innerText = 'Whitelist?';
|
||||
|
||||
const checkInput = document.createElement('input');
|
||||
checkInput.className = 'form-check-input';
|
||||
checkInput.type = 'checkbox';
|
||||
checkInput.name = 'isWhitelist';
|
||||
checkInput.value = '';
|
||||
checkInput.setAttribute('aria-label', 'Checkbox for Text Input:');
|
||||
checkWrapper.appendChild(checkLbl);
|
||||
checkWrapper.appendChild(checkInput);
|
||||
|
||||
biomeGroup.insertBefore(checkWrapper, biomeGroup.childNodes[biomeGroup.childNodes.length - 1]);
|
||||
|
||||
biomeHeader.style.display = 'block';
|
||||
biomeWrapper.appendChild(biomeGroup);
|
||||
}
|
||||
});
|
||||
|
||||
form.appendChild(components.makeHeader('Blocks This Deposit May Replace'));
|
||||
const replWrapper = document.createElement('div');
|
||||
replWrapper.className = 'mb-3';
|
||||
replWrapper.appendChild(
|
||||
components.makeExpandableSet(
|
||||
'blockStateMatchers',
|
||||
replWrapper,
|
||||
'text',
|
||||
'Format: <modid:block> or <modid:block:meta>'
|
||||
)
|
||||
);
|
||||
replWrapper.querySelector('input').removeAttribute('required');
|
||||
form.appendChild(replWrapper);
|
||||
|
||||
return form;
|
||||
};
|
||||
|
||||
97
src/public/assets/js/modules/renderer/stone.module.js
Normal file
97
src/public/assets/js/modules/renderer/stone.module.js
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
import * as components from './components.module.js';
|
||||
import * as events from '../events.module.js';
|
||||
|
||||
export const init = () => {
|
||||
components.makeCard(document.getElementById('stoneconfig'), makeForm);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {boolean} usingNewConfig
|
||||
*/
|
||||
const makeForm = (usingNewConfig) => {
|
||||
const form = document.createElement('form');
|
||||
form.style.padding = '12px';
|
||||
|
||||
form.appendChild(components.makeHeader('Stone Block'));
|
||||
const stoneWrapper = document.createElement('div');
|
||||
stoneWrapper.className = 'mb-3';
|
||||
const nameInput = document.createElement('input');
|
||||
nameInput.className = 'form-control';
|
||||
nameInput.type = 'text';
|
||||
nameInput.name = 'name';
|
||||
nameInput.setAttribute('data-toggle', 'tooltip');
|
||||
nameInput.setAttribute('data-placement', 'top');
|
||||
nameInput.setAttribute('data-html', 'true');
|
||||
nameInput.setAttribute('title', 'Format: <modid:block> or <modid:block:meta>');
|
||||
nameInput.setAttribute('required', 'required');
|
||||
new bootstrap.Tooltip(nameInput, {});
|
||||
stoneWrapper.appendChild(nameInput);
|
||||
form.appendChild(stoneWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Maximum Y-Level'));
|
||||
const yMaxWrapper = document.createElement('div');
|
||||
yMaxWrapper.className = 'mb-3';
|
||||
const yMax = document.createElement('input');
|
||||
yMax.className = 'form-control';
|
||||
yMax.value = 1;
|
||||
yMax.type = 'number';
|
||||
yMax.min = 0;
|
||||
yMax.max = 255;
|
||||
yMax.name = 'yMax';
|
||||
yMax.setAttribute('required', 'required');
|
||||
yMaxWrapper.appendChild(yMax);
|
||||
form.appendChild(yMaxWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Minimum Y-Level'));
|
||||
const yMinWrapper = document.createElement('div');
|
||||
yMinWrapper.className = 'mb-3';
|
||||
const yMin = document.createElement('input');
|
||||
yMin.className = 'form-control';
|
||||
yMin.value = 0;
|
||||
yMin.type = 'number';
|
||||
yMin.min = 0;
|
||||
yMin.max = 255;
|
||||
yMin.name = 'yMin';
|
||||
yMin.setAttribute('required', 'required');
|
||||
yMinWrapper.appendChild(yMin);
|
||||
form.appendChild(yMinWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Chance <a href="https://oitsjustjo.se/M3NfQxBsZ" target="_blank">(Relative to All Chances)</a>'));
|
||||
const chanceTheWrapper = document.createElement('div');
|
||||
chanceTheWrapper.className = 'mb-3';
|
||||
const chance = document.createElement('input');
|
||||
chance.className = 'form-control';
|
||||
chance.type = 'number';
|
||||
chance.min = 1;
|
||||
chance.name = 'chance';
|
||||
chance.setAttribute('required', 'required');
|
||||
chanceTheWrapper.appendChild(chance);
|
||||
form.appendChild(chanceTheWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Size'));
|
||||
const sizeWrapper = document.createElement('div');
|
||||
sizeWrapper.className = 'mb-3';
|
||||
const size = document.createElement('input');
|
||||
size.className = 'form-control';
|
||||
size.type = 'number';
|
||||
size.min = 1;
|
||||
size.name = 'size';
|
||||
size.setAttribute('required', 'required');
|
||||
sizeWrapper.appendChild(size);
|
||||
form.appendChild(sizeWrapper);
|
||||
|
||||
form.appendChild(components.makeHeader('Dimension Blacklist'));
|
||||
const dimBlWrapper = document.createElement('div');
|
||||
dimBlWrapper.className = 'mb-3';
|
||||
dimBlWrapper.appendChild(
|
||||
components.makeExpandableSet(
|
||||
'dimBlacklist',
|
||||
dimBlWrapper,
|
||||
document.getElementById('switch-112-mode').checked ? 'text' : 'number',
|
||||
document.getElementById('switch-112-mode').checked ? '<modid:dimension>' : null
|
||||
)
|
||||
);
|
||||
form.appendChild(dimBlWrapper);
|
||||
|
||||
return form;
|
||||
};
|
||||
Loading…
Reference in a new issue