Commit ed436c28 authored by Boris Kocherov's avatar Boris Kocherov

make code better understandable

parent 5a96bd75
...@@ -109,23 +109,23 @@ ...@@ -109,23 +109,23 @@
return schema; return schema;
} }
function render_selection(json_field, default_value) { function render_selection(schema, json_document) {
var input = document.createElement("select"), var input = document.createElement("select"),
option = document.createElement("option"), option = document.createElement("option"),
option_index, option_index,
optionz; optionz;
input.size = 1; input.size = 1;
option.value = ""; option.value = "";
if (default_value === undefined) { if (json_document === undefined) {
option.selected = "selected"; option.selected = "selected";
} }
input.appendChild(option); input.appendChild(option);
for (option_index in json_field['enum']) { for (option_index in schema['enum']) {
if (json_field['enum'].hasOwnProperty(option_index)) { if (schema['enum'].hasOwnProperty(option_index)) {
optionz = document.createElement("option"); optionz = document.createElement("option");
optionz.value = json_field['enum'][option_index]; optionz.value = schema['enum'][option_index];
optionz.textContent = json_field['enum'][option_index]; optionz.textContent = schema['enum'][option_index];
if (json_field['enum'][option_index] === default_value) { if (schema['enum'][option_index] === json_document) {
optionz.selected = "selected"; optionz.selected = "selected";
} }
input.appendChild(optionz); input.appendChild(optionz);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment