미디어위키:Gadget-JSONEditor.js: 두 판 사이의 차이
보이기
잔글편집 요약 없음 |
잔글편집 요약 없음 |
||
8번째 줄: | 8번째 줄: | ||
fetch(targetJSON) | fetch(targetJSON) | ||
]).then(function (result) { | ]).then(function (result) { | ||
console.log(result); | |||
const jsonEditorContainer = document.querySelector('.json-editor-container'); | const jsonEditorContainer = document.querySelector('.json-editor-container'); | ||
const value = document.querySelector('#value'); | const value = document.querySelector('#value'); |
2024년 12월 22일 (일) 15:45 판
function LoadJSONEditor() {
if (document.getElementsByClassName("jsoneditor-container").length === 0) return;
var targetJSON = "https://dev.libertygame.work/index.php/RPG_in_City/game.json?action=raw";
mw.loader.getScript("https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js").then(function() {
Promise.all([
fetch("https://dev.libertygame.work/index.php/%EB%A6%AC%EB%B2%84%ED%8B%B0%EA%B2%8C%EC%9E%84:%EA%B2%8C%EC%9E%84_%EB%A9%94%ED%83%80%EB%8D%B0%EC%9D%B4%ED%84%B0/%EC%8A%A4%ED%82%A4%EB%A7%88.json?action=raw"),
fetch(targetJSON)
]).then(function (result) {
console.log(result);
const jsonEditorContainer = document.querySelector('.json-editor-container');
const value = document.querySelector('#value');
var schema = result[0];
const editor = new JSONEditor(jsonEditorContainer, {
schema: schema,
theme: 'bootstrap4',
show_errors: 'always',
iconlib: 'fontawesome5',
keep_oneof_values: false
}, result[1]);
editor.on('change', function () {
value.value = JSON.stringify(editor.getValue(), null, 2);
});
}).catch(function (e) {
console.log("JSON 에디터 로딩 중 장애 발생" + e.message);
});
});
}
$(LoadJSONEditor);