function convert(identifier, head) {
            for (var index in head) {
                var node = head[index];
                if (node.input) {
                    // get node
                    var input = node.input;

                    // create identifier
                    var job_input_id = identifier;
                    if (identifier != '') {
                        job_input_id += '|';
                    }
                    job_input_id += input.name;

                    // process input type
                    switch (input.type) {
                        // handle repeats
                        case 'repeat':
                            // section identifier
                            var section_label = 'section-';

                            // collect repeat block identifiers
                            var block_indices = [];
                            var block_prefix = null;
                            for (var block_label in node) {
                                var pos = block_label.indexOf(section_label);
                                if (pos != -1) {
                                    pos += section_label.length;
                                    block_indices.push(parseInt(block_label.substr(pos)));
                                    if (!block_prefix) {
                                        block_prefix = block_label.substr(0, pos);
                                    }
                                }
                            }

                            // sort repeat blocks
                            block_indices.sort(function(a,b) { return a - b; });

                            // add to response dictionary in created order
                            var index = 0;
                            for (var i in block_indices) {
                                convert(job_input_id + '_' + index++, node[block_prefix + block_indices[i]]);
                            }
                            break;
                        // handle conditionals
                        case 'conditional':
                            // get and patch conditional value
                            var value = self.app.field_list[input.id].value();
                            if (patch[input.test_param.type]) {
                                value = patch[input.test_param.type](value);
                            }

                            // add conditional value
                            add (job_input_id + '|' + input.test_param.name, input.id, value);

                            // identify selected case
                            var selectedCase = self.matchCase(input, value);
                            if (selectedCase != -1) {
                                convert(job_input_id, head[input.id + '-section-' + selectedCase]);
                            }
                            break;
                        // handle custom sub sections
                        case 'section':
                            convert('', node);
                            break;
                        default:
                            // get field
                            var field = self.app.field_list[input.id];
                            if (field && field.value) {
                                // validate field value
                                var value = field.value();

                                // get and patch field value
                                if (patch[input.type]) {
                                    value = patch[input.type](value);
                                }

                                // ignore certain values
                                if (input.ignore === undefined || input.ignore != value) {
                                    // add value to submission
                                    add (job_input_id, input.id, value);

                                    // add payload to submission
                                    if (input.payload) {
                                        for (var p_id in input.payload) {
                                            add (p_id, input.id, input.payload[p_id]);
                                        }
                                    }
                                }
                            }
                    }
                }
            }
        }
// converter between raw dictionary and job dictionary
converter between raw dictionary and job dictionary
converter between raw dictionary and job dictionary
function convert(identifier, head) {
            for (var index in head) {
                var node = head[index];
                if (node.input) {
                    var input = node.input;
                    var job_input_id = identifier;
                    if (identifier != '') {
                        job_input_id += '|';
                    }
                    job_input_id += input.name;
                    switch (input.type) {
                        case 'repeat':
                            var section_label = 'section-';
                            var block_indices = [];
                            var block_prefix = null;
                            for (var block_label in node) {
                                var pos = block_label.indexOf(section_label);
                                if (pos != -1) {
                                    pos += section_label.length;
                                    block_indices.push(parseInt(block_label.substr(pos)));
                                    if (!block_prefix) {
                                        block_prefix = block_label.substr(0, pos);
                                    }
                                }
                            }
                            block_indices.sort(function(a,b) { return a - b; });
                            var index = 0;
                            for (var i in block_indices) {
                                convert(job_input_id + '_' + index++, node[block_prefix + block_indices[i]]);
                            }
                            break;
                        case 'conditional':
                            var value = self.app.field_list[input.id].value();
                            if (patch[input.test_param.type]) {
                                value = patch[input.test_param.type](value);
                            }
                            add (job_input_id + '|' + input.test_param.name, input.id, value);
                            var selectedCase = self.matchCase(input, value);
                            if (selectedCase != -1) {
                                convert(job_input_id, head[input.id + '-section-' + selectedCase]);
                            }
                            break;
                        case 'section':
                            convert('', node);
                            break;
                        default:
                            var field = self.app.field_list[input.id];
                            if (field && field.value) {
                                var value = field.value();
                                if (patch[input.type]) {
                                    value = patch[input.type](value);
                                }
                                if (input.ignore === undefined || input.ignore != value) {
                                    add (job_input_id, input.id, value);
                                    if (input.payload) {
                                        for (var p_id in input.payload) {
                                            add (p_id, input.id, input.payload[p_id]);
                                        }
                                    }
                                }
                            }
                    }
                }
            }
        }
function convert ( identifier , head ) { for ( var index in head ) { var node = head [ index ] ; if ( node . input ) { var input = node . input ; var job_input_id = identifier ; if ( identifier != '' ) { job_input_id += '|' ; } job_input_id += input . name ; switch ( input . type ) { case 'repeat' : var section_label = 'section-' ; var block_indices = [ ] ; var block_prefix = null ; for ( var block_label in node ) { var pos = block_label . indexOf ( section_label ) ; if ( pos != - 1 ) { pos += section_label . length ; block_indices . push ( parseInt ( block_label . substr ( pos ) ) ) ; if ( ! block_prefix ) { block_prefix = block_label . substr ( 0 , pos ) ; } } } block_indices . sort ( function ( a , b ) { return a - b ; } ) ; var index = 0 ; for ( var i in block_indices ) { convert ( job_input_id + '_' + index ++ , node [ block_prefix + block_indices [ i ] ] ) ; } break ; case 'conditional' : var value = self . app . field_list [ input . id ] . value ( ) ; if ( patch [ input . test_param . type ] ) { value = patch [ input . test_param . type ] ( value ) ; } add ( job_input_id + '|' + input . test_param . name , input . id , value ) ; var selectedCase = self . matchCase ( input , value ) ; if ( selectedCase != - 1 ) { convert ( job_input_id , head [ input . id + '-section-' + selectedCase ] ) ; } break ; case 'section' : convert ( '' , node ) ; break ; default : var field = self . app . field_list [ input . id ] ; if ( field && field . value ) { var value = field . value ( ) ; if ( patch [ input . type ] ) { value = patch [ input . type ] ( value ) ; } if ( input . ignore === undefined || input . ignore != value ) { add ( job_input_id , input . id , value ) ; if ( input . payload ) { for ( var p_id in input . payload ) { add ( p_id , input . id , input . payload [ p_id ] ) ; } } } } } } } }
converter between raw dictionary and job dictionary
converter between raw dictionary and job dictionary
// get node // create identifier // process input type // handle repeats // section identifier // collect repeat block identifiers // sort repeat blocks // add to response dictionary in created order // handle conditionals // get and patch conditional value // add conditional value // identify selected case // handle custom sub sections // get field // validate field value // get and patch field value // ignore certain values // add value to submission // add payload to submission