mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 07:37:10 +00:00
Add predicate mode
This commit is contained in:
30
view.js
30
view.js
@@ -2,10 +2,16 @@ let structure;
|
||||
let components;
|
||||
let collections;
|
||||
|
||||
changeVersion('1.14');
|
||||
changeVersion('1.15');
|
||||
function changeVersion(version) {
|
||||
$.getJSON('schemas/' + version + '.json', json => {
|
||||
structure = json.root;
|
||||
console.log(json);
|
||||
if (json.root) {
|
||||
structure = json.root;
|
||||
} else if (json.roots) {
|
||||
let id = window.location.pathname.replace(/\/$/, '').replace(/^\//, '');
|
||||
structure = json.roots.find(e => e.id === id);
|
||||
}
|
||||
components = json.components;
|
||||
collections = json.collections;
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
@@ -28,19 +34,31 @@ function changeVersion(version) {
|
||||
|
||||
function updateView() {
|
||||
if (structure) {
|
||||
let {out: tableOut, component: $table} = generateTable(table, structure);
|
||||
$('#structure').append($table);
|
||||
let {out: sourceOut, component: $component} = generateSourceAndView(table, structure);
|
||||
$('#structure').removeClass('d-none').html('');
|
||||
$('#descriptionSpan').attr('data-i18n', structure.description);
|
||||
$('title').attr('data-i18n', structure.title);
|
||||
$('#structure').append($component);
|
||||
if (i18next.isInitialized) {
|
||||
$('html').localize();
|
||||
}
|
||||
$('#source').val(JSON.stringify(tableOut, null, indentation));
|
||||
$('#source').val(JSON.stringify(sourceOut, null, indentation));
|
||||
}
|
||||
}
|
||||
|
||||
function generateSourceAndView(data, struct) {
|
||||
if (struct.id === 'loot-table') {
|
||||
$('#lootTableToolbar').removeClass('d-none');
|
||||
$('#structure').attr('data-index', 'pools');
|
||||
return generateTable(data, struct);
|
||||
} else {
|
||||
return generateObject(data, struct, false);
|
||||
}
|
||||
}
|
||||
|
||||
function generateTable(data, struct) {
|
||||
let out = {};
|
||||
let $el = $('<div/>');
|
||||
$('#structure').removeClass('d-none').html('');
|
||||
|
||||
let type = struct.fields.find(e => e.id === 'type');
|
||||
if (type) {
|
||||
|
||||
Reference in New Issue
Block a user