/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/assets/src/jsonedit/jsonedit.js
64 строки
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
/** * Редактирование Json шаблона * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2022 */ jQuery(document).ready(function ($) { function initContainer(selectorId) { // create the editor var container = document.getElementById(selectorId); if (container) { var hidden_id = $('#' + selectorId).data('hidden'); var $json_editor = $('#' + hidden_id); var options = { mode: 'code', modes: ['code', 'form', 'text', 'tree', 'view'], // allowed modes onError: function (err) { alert(err.toString()); }, onEditable: function () { return !$json_editor.prop('readonly'); }, onChange: function () { $(document).trigger('json-editor.change'); }, onChangeText: function (value) { $json_editor.val(value) } }; var editor = new JSONEditor(container, options); var val = $json_editor.val(); if (val) { editor.setText(val); } $('.jsoneditor-format').click(); // get json $json_editor .parents('form') .on('beforeValidate', function () { $json_editor.val(editor.getText()); }); } } // Initialize function init($dom, className) { $('.' + className).each(function () { var name = $(this).data('name'); initContainer(name); }); } init($(document), 'json_editor'); $(document).on('ajax-loaded', function (event, form) { init(form, 'json_editor'); }); });