미디어위키:Gadget-JSONEditor.js: 두 판 사이의 차이
보이기
새 문서: function LoadJSONEditor() { if (document.getElementsByClassName("jsoneditor-container").length === 0) return; Promise.All([ "https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js", "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" ]).then((result) => { var jsonEditorContainer = document.que... |
잔글편집 요약 없음 |
||
5번째 줄: | 5번째 줄: | ||
"https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js", | "https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js", | ||
"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" | "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" | ||
]).then((result) | ]).then(function (result) { | ||
var jsonEditorContainer = document.querySelector('.json-editor-container'); | var jsonEditorContainer = document.querySelector('.json-editor-container'); | ||
var value = document.querySelector('#value'); | var value = document.querySelector('#value'); | ||
26번째 줄: | 26번째 줄: | ||
editor.setValue({ test: 0 }); | editor.setValue({ test: 0 }); | ||
}); | }); | ||
}).catch((e) | }).catch(function (e) { | ||
console.log("JSON 에디터 로딩 중 장애 발생"); | console.log("JSON 에디터 로딩 중 장애 발생"); | ||
}); | }); |
2024년 12월 21일 (토) 00:01 판
function LoadJSONEditor() {
if (document.getElementsByClassName("jsoneditor-container").length === 0) return;
Promise.All([
"https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js",
"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"
]).then(function (result) {
var jsonEditorContainer = document.querySelector('.json-editor-container');
var value = document.querySelector('#value');
var schema = result[1];
var editor = new JSONEditor(jsonEditorContainer, {
schema: schema,
theme: 'bootstrap4',
show_errors: 'always',
iconlib: 'fontawesome5',
keep_oneof_values: false
});
editor.on('change', function () {
value.value = JSON.stringify(editor.getValue());
});
document.querySelector('.set-value').addEventListener('click', function () {
editor.setValue({ test: 0 });
});
}).catch(function (e) {
console.log("JSON 에디터 로딩 중 장애 발생");
});
}
$(LoadJSONEditor);