<commit_before>/**
 * Decode a custom config file format into the elements needed to build iOS and Android preference xml
 *
 *
 */

var libxml  = require('libxmljs');


function ucfirst(s) {
    return s.charAt(0).toUpperCase() + s.substring(1);
}


function iosConfigMap(config) {
// iOS
// https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/UserDefaults/Preferences/Preferences.html
/*

mkdir Settings.bundle
cd Settings.bundle
touch Root.plist
mkdir en.lproj
cd en.lproj
touch Root.strings

Identifier

PSGroupSpecifier
Type
Title
FooterText

PSToggleSwitchSpecifier
Title
Key
DefaultValue

PSSliderSpecifier
Key
DefaultValue
MinimumValue
MaximumValue

PSTitleValueSpecifier
Title
Key
DefaultValue

PSTextFieldSpecifier
Title
Key
DefaultValue
IsSecure
KeyboardType (Alphabet , NumbersAndPunctuation , NumberPad , URL , EmailAddress)
AutocapitalizationType
AutocorrectionType

PSMultiValueSpecifier
Title
Key
DefaultValue
Values
Titles

PSRadioGroupSpecifier
Title
FooterText???
Key
DefaultValue
Values
Titles


*/
    var element = {};

    if (config.type) {
        
        if (config.type == 'group') {
            element.Type = 'PSGroupSpecifier';
        }
        else {     
            element.DefaultValue = config['default'];

            element.Key = config['name'];
            element.Title = ucfirst(config['name']);

            switch (config.type) {

                case 'textfield':
                    element.Type = 'PSTextFieldSpecifier';                
                    break;

                case 'switch':
                    element.Type = 'PSToggleSwitchSpecifier';
                    break;

                case 'combo':
                    element.Type = 'PSMultiValueSpecifier';

                    element.Titles = [];
                    element.Values = [];
                    config.items.forEach(function(a) {
                        element.Values.push(a.id || a.value);
                        element.Titles.push(a.title || a.name);
                    });

                    break;
            }<commit_msg>iOS settings controls appear in order<commit_after>/**
 * Decode a custom config file format into the elements needed to build iOS and Android preference xml
 *
 *
 */

var libxml  = require('libxmljs');


function ucfirst(s) {
    return s.charAt(0).toUpperCase() + s.substring(1);
}


function iosConfigMap(config) {
// iOS
// https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/UserDefaults/Preferences/Preferences.html
/*

mkdir Settings.bundle
cd Settings.bundle
touch Root.plist
mkdir en.lproj
cd en.lproj
touch Root.strings

Identifier

PSGroupSpecifier
Type
Title
FooterText

PSToggleSwitchSpecifier
Title
Key
DefaultValue

PSSliderSpecifier
Key
DefaultValue
MinimumValue
MaximumValue

PSTitleValueSpecifier
Title
Key
DefaultValue

PSTextFieldSpecifier
Title
Key
DefaultValue
IsSecure
KeyboardType (Alphabet , NumbersAndPunctuation , NumberPad , URL , EmailAddress)
AutocapitalizationType
AutocorrectionType

PSMultiValueSpecifier
Title
Key
DefaultValue
Values
Titles

PSRadioGroupSpecifier
Title
FooterText???
Key
DefaultValue
Values
Titles


*/
    var element = {
        Title: config['title']
    };

    if (config.type) {
        
        if (config.type == 'group') {
            element.Type = 'PSGroupSpecifier';
        }
        else {     
            element.DefaultValue = config['default'];

            element.Key = config['name'];

            switch (config.type) {

                case 'textfield':
                    element.Type = 'PSTextFieldSpecifier';                
                    break;

                case 'switch':
                    element.Type = 'PSToggleSwitchSpecifier';
                    break;

                case 'combo':
                    element.Type = 'PSMultiValueSpecifier';

                    element.Titles = [];
                    element.Values = [];
                    config.items.forEach(function(a) {
                        element.Values.push(a.id || a.value);
                        element.Titles.push(a.title || a.name);
                    });

                    break;
            }
{'fraction_non_alphanumeric': 0.08862275449101796, 'fraction_numerical': 0.0009580838323353293, 'mean_word_length': 2.0548646671543525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5753567', 'n_tokens_mistral': 1210, 'n_tokens_neox': 1124, 'n_words': 257}