Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!listItem.hasAttribute('data-control-type')) {
// There could be other items - placeholders
// and clear-row elements
continue
}
var values = getControlPropertyValues(listItem)
if (values === null) {
throw new Error('Property values are not found for a control list item.')
}
if (values['oc.fieldName'] === undefined) {
throw new Error('Field name property is not found for a control.')
}
var fieldName = values['oc.fieldName']
values.type = listItem.getAttribute('data-control-type')
preProcessSpecialProperties(values)
if (injectProperties !== undefined) {
values = $.extend(values, injectProperties)
}
if (result[fieldName] !== undefined) {
throw new Error('Duplicate field name: ' + fieldName)
}
// If a control contains control containers, parse them
// and assign parsed object to the current control property.
var childControls = parseControlControlContainer(listItem)
for (var i=0, len=listItems.length; i
DomToJson.getAllControlNames = function(rootContainer) {
var controls = rootContainer.querySelectorAll('ul[data-control-list] > li.control'),
result = []
for (var i=controls.length-1; i>=0; i--) {
var properties = getControlPropertyValues(controls[i])
if (typeof properties !== 'object') {
continue
}
if (properties['oc.fieldName'] === undefined) {
continue
}
var name = properties['oc.fieldName']
if (result.indexOf(name) === -1) {
result.push(name)
}
}
result.sort()
return result
}
function preProcessSpecialProperties(properties) {
delete properties['oc.fieldName']
if (String(properties['oc.comment']).length > 0 && properties['oc.commentPosition'] == 'above') {
properties['commentAbove'] = properties['oc.comment']
if (properties['comment'] !== undefined) {
delete properties['comment']
}
delete properties['oc.comment']
delete properties['oc.commentPosition']
}
if (String(properties['oc.comment']).length > 0 && properties['oc.commentPosition'] == 'below') {
properties['comment'] = properties['oc.comment']
if (properties['comentAbove'] !== undefined) {
DomToJson.getAllControlNames = function(rootContainer) {
var controls = rootContainer.querySelectorAll('ul[data-control-list] > li.control'),
result = []
for (var i=controls.length-1; i>=0; i--) {
var properties = getControlPropertyValues(controls[i])
if (typeof properties !== 'object') {
continue
}
if (properties['oc.fieldName'] === undefined) {
continue
}
var name = properties['oc.fieldName']
if (result.indexOf(name) === -1) {
result.push(name)
}
}
result.sort()
return result
}
FormBuilder.prototype.fieldNameExistsInContainer = function(container, fieldName) {
var valueInputs = container.querySelectorAll('li.control[data-inspectable] input[data-inspector-values]')
for (var i=valueInputs.length-1; i>=0; i--) {
var value = String(valueInputs[i].value)
if (value.length === 0) {
continue
}
var properties = $.parseJSON(value)
if (properties['oc.fieldName'] == fieldName) {
return true
}
}
return false
}