Commit 6d65e3c3 authored by Boris Kocherov's avatar Boris Kocherov

jslint fix

parent 7df80c9d
......@@ -3,7 +3,8 @@
(function (window, document, rJS, RSVP, jIO) {
"use strict";
var render_object;
var render_object,
expandSchema;
function decodeJsonPointer(_str) {
// https://tools.ietf.org/html/rfc6901#section-5
......@@ -170,6 +171,74 @@
});
}
function allOf(g, schema_array, schema_path) {
return RSVP.Queue()
.push(function () {
var i,
arr = [];
for (i = 0; i < schema_array.length; i += 1) {
arr.push(expandSchema(g, schema_array[i], schema_path));
}
return RSVP.all(arr);
})
.push(function (arr) {
var i,
x,
y,
key,
next_schema,
schema,
schema_item,
summ_arr;
for (i = 0; i < arr.length - 1; i += 1) {
summ_arr = [];
for (x = 0; x < arr[i].length; x += 1) {
for (y = 0; y < arr[i + 1].length; y += 1) {
schema = arr[i][x].schema;
next_schema = arr[i + 1][y].schema;
if (schema === true && next_schema === true) {
schema_item = {
schema: true,
schema_path: arr[i][x].schema_path
};
} else if (schema === false || next_schema === false) {
schema_item = {
schema: false,
schema_path: arr[i][x].schema_path
};
} else {
if (schema === true) {
schema = {};
}
if (next_schema === true) {
next_schema = {};
}
// copy before change
schema = JSON.parse(JSON.stringify(schema));
for (key in next_schema) {
if (next_schema.hasOwnProperty(key)) {
if (schema.hasOwnProperty(key)) {
// XXX need use many many rules for merging
schema[key] = next_schema[key];
} else {
schema[key] = next_schema[key];
}
}
}
schema_item = {
schema: schema,
schema_path: arr[i][x].schema_path
};
}
summ_arr.push(schema_item);
}
}
arr[i + 1] = summ_arr;
}
return arr[arr.length - 1];
});
}
function anyOf(g, schema_array, schema_path) {
return RSVP.Queue()
.push(function () {
......@@ -197,6 +266,31 @@
});
}
expandSchema = function (g, schema, schema_path) {
if (schema === undefined) {
schema = true;
}
if (schema.anyOf !== undefined) {
return anyOf(g, schema.anyOf, schema_path);
}
if (schema.allOf !== undefined) {
return allOf(g, schema.allOf, schema_path);
}
if (schema.$ref) {
return g.loadJSONSchema(schema.$ref, schema_path)
.push(function (schema_part) {
return expandSchema(g, schema_part, schema_path);
});
}
return RSVP.Queue()
.push(function () {
return [{
schema: schema,
schema_path: schema_path
}];
});
};
function render_select_type(gadget, title, schema_arr, event) {
var scope = Math.random().toString(36).substr(2, 9),
type_arr = [],
......@@ -380,99 +474,6 @@
return queue;
}
function expandSchema(g, schema, schema_path) {
if (schema === undefined) {
schema = true;
}
if (schema.anyOf !== undefined) {
return anyOf(g, schema.anyOf, schema_path);
}
if (schema.allOf !== undefined) {
return allOf(g, schema.allOf, schema_path);
}
if (schema.$ref) {
return g.loadJSONSchema(schema.$ref, schema_path)
.push(function (schema_part) {
return expandSchema(g, schema_part, schema_path);
});
}
return RSVP.Queue()
.push(function () {
return [{
schema: schema,
schema_path: schema_path
}];
});
}
function allOf(g, schema_array, schema_path) {
return RSVP.Queue()
.push(function () {
var i,
arr = [];
for (i = 0; i < schema_array.length; i += 1) {
arr.push(expandSchema(g, schema_array[i], schema_path));
}
return RSVP.all(arr);
})
.push(function (arr) {
var i,
x,
y,
key,
next_schema,
schema,
schema_item,
summ_arr;
for (i = 0; i < arr.length - 1; i += 1) {
summ_arr = [];
for (x = 0; x < arr[i].length; x += 1) {
for (y = 0; y < arr[i + 1].length; y += 1) {
schema = arr[i][x].schema;
next_schema = arr[i + 1][y].schema;
if (schema === true && next_schema === true) {
schema_item = {
schema: true,
schema_path: arr[i][x].schema_path
};
} else if (schema === false || next_schema === false) {
schema_item = {
schema: false,
schema_path: arr[i][x].schema_path
};
} else {
if (schema === true) {
schema = {};
}
if (next_schema === true) {
next_schema = {};
}
// copy before change
schema = JSON.parse(JSON.stringify(schema));
for (key in next_schema) {
if (next_schema.hasOwnProperty(key)) {
if (schema.hasOwnProperty(key)) {
// XXX need use many many rules for merging
schema[key] = next_schema[key];
} else {
schema[key] = next_schema[key];
}
}
}
schema_item = {
schema: schema,
schema_path: arr[i][x].schema_path
};
}
summ_arr.push(schema_item);
}
}
arr[i + 1] = summ_arr;
}
return arr[arr.length - 1];
});
}
function render_field(gadget, key, path, json_field, default_value, root, schema_path, type) {
var div,
label,
......
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