<commit_before>/*jslint maxerr: 50, indent: 4 */
/*globals $,document,console*/

if(!Object.keys) Object.keys = function(o){
    if (o !== Object(o))
        throw new TypeError('Object.keys called on non-object');
    var ret=[],p;
    for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
    return ret;
}

if (typeof formdesigner === 'undefined') {
    var formdesigner = {};
}

formdesigner.ui = (function () {
    "use strict";
    var that = {},
        question_list = [],
        buttons = {},
        controller = formdesigner.controller,
        questionTree,
        dataTree,
        LINK_CONTROL_MOVES_TO_DATA_TREE = true,
        DEBUG_MODE = false,
        TOKEN_INPUT = false; // change this if you want tokenized xpath mode
        
    that.TOKEN_INPUT = TOKEN_INPUT;
    
    /**
     * Displays an info box on the properties view.
     * Use hideMessage() to hide.
     * @param msg - the actual message contents
     * @param header - message header (optional)
     * @param msgType - can be either 'warning' or 'error' - defaults to 'warning'
     */
    var showMessage  = function (msg, header, msgType) {
        var div, warningClass, iconClass, iconSpan, msgtxt, headertxt, icon;
        div = $('#fd-props-message');
        div.empty();
        if(msgType === 'error') {
            warningClass = 'ui-state-error';
            iconClass = 'ui-icon-alert';
        } else {
            warningClass = 'ui-state-highlight';
            iconClass = 'ui-icon-info';
        }
        iconSpan = '<span class="ui-icon ' + iconClass + '" style="float: left; margin-right: .3em;"></span>';
        icon = $(iconSpan);
        headertxt = '<strong>' + header + '</strong>';
        msgtxt = ' ' + msg;
        div.append(icon).append(headertxt).append(msgtxt);
        div.addClass(warningClass).addClass('ui-corner-all');
        div.show();
    }
    that.showMessage = showMessage;

    /**
     * Hides the question properties message box;
     */
    var hideMessage = function () {
        $('#fd-props-message').hide();
    }


    function init_toolbar() {4
        var toolbar = $(".fd-toolbar"), select, addbutstr, addbut;

        select = $('#fd-question-select');
        addbutstr = '<button id="fd-add-but">Add</button>';
        select.after(addbutstr);
        addbut = $('#fd-add-but');
        addbut.button({
            icons:{
                primary: 'ui-icon-gear'
            }
        });

        function findq () {
            var selVal, qID,qType;
            selVal = $('#fd-question-select').val();
            qID = $('#fd-question-select').find('[value*="'+selVal+'"]').attr('id');
            qType = qID.split('-')[2];
            formdesigner.controller.createQuestion(qType);
        }
        addbut.click(findq);

        select.chosen();

        //debug tools
        (function c_printDataTreeToConsole() {
            var printTreeBut = $(
                    '<button id="fd-print-tree-button" class="toolbarButton questionButton">'+
                'Print tree to Console' +
              '</button>');
            $('#fd-dragons').append(printTreeBut);

            printTreeBut.button().click(function () {
                formdesigner.util.dumpFormTreesToConsole();
            });

        })();

        (function c_showLoadItextXLS() {
            var loadXLSBut = $(
                    '<button id="fd-load-xls-button" class="toolbarButton questionButton">'+
                'Load Itext XLS From Clipboard' +
              '</button>');
            $('#fd-dragons').append(loadXLSBut);

            loadXLSBut.button().click(function () {
                formdesigner.controller.showLoadItextFromClipboard();

            });
        })();

        (function c_showGeneratedItextXLS() {
            var genXLSgbut = $(
                    '<button id="fd-gen-xls-button" class="toolbarButton questionButton">'+
                'Save Itext XLS to Clipboard' +
              '</button>');
            $('#fd-dragons').append(genXLSgbut);

            genXLSgbut.button().click(function () {
                formdesigner.controller.showGeneratedItextXLS();
            });
        })();

        (function c_saveForm() {
            var savebut = $(
                    '<button id="fd-save-button" class="toolbarButton questionButton">'+
                'Save Form to Server' +
              '</button>');
            toolbar.append(savebut);

            savebut.button().click(function () {
                formdesigner.controller.sendXForm();
            });

        })();

        (function c_removeSelected() {
            var removebut = $(
                    '<button id="fd-remove-button" class="toolbarButton questionButton">'+
                'Remove Selected' +
              '</button>');
            toolbar.append(removebut);

            removebut.button().click(function () {
                var selected = formdesigner.controller.getCurrentlySelectedMugType();
                formdesigner.controller.removeMugTypeFromForm(selected);
            });

        })();

    }
    that.buttons = buttons;

    //Sets a visual indicator that the form needs saving on the 'Save Form To Server' Button
    that.setSaveButtonFormUnsaved = function () {
        var saveBut = $('#fd-save-button');
        saveBut.button('enable');
        saveBut.button('option', 'icons', {primary:'ui-icon-alert'});
    }

    //Sets a visual indicator that the form IS saved (on 'Save Form To Server' Button)
    that.setSaveButtonFormSaved = function () {
        var saveBut = $('#fd-save-button');
        saveBut.button('disable');
        saveBut.button('option', 'icons', {primary:'ui-icon-check'});
    }

    function getDataJSTreeTypes() {
        var jquery_icon_url = formdesigner.iconUrl,
            types =  {
            "max_children" : -1,
			"valid_children" : "all",
			"types" : {
                    "default" : {
                        "icon": {
                            "image": jquery_icon_url,
                            "position": "-112px -144px"
                        },
                    "valid_children" : "all"
                }
			}
        }
<commit_msg>update text of "save form to server" to just be "save form"<commit_after>/*jslint maxerr: 50, indent: 4 */
/*globals $,document,console*/

if(!Object.keys) Object.keys = function(o){
    if (o !== Object(o))
        throw new TypeError('Object.keys called on non-object');
    var ret=[],p;
    for(p in o) if(Object.prototype.hasOwnProperty.call(o,p)) ret.push(p);
    return ret;
}

if (typeof formdesigner === 'undefined') {
    var formdesigner = {};
}

formdesigner.ui = (function () {
    "use strict";
    var that = {},
        question_list = [],
        buttons = {},
        controller = formdesigner.controller,
        questionTree,
        dataTree,
        LINK_CONTROL_MOVES_TO_DATA_TREE = true,
        DEBUG_MODE = false,
        TOKEN_INPUT = false; // change this if you want tokenized xpath mode
        
    that.TOKEN_INPUT = TOKEN_INPUT;
    
    /**
     * Displays an info box on the properties view.
     * Use hideMessage() to hide.
     * @param msg - the actual message contents
     * @param header - message header (optional)
     * @param msgType - can be either 'warning' or 'error' - defaults to 'warning'
     */
    var showMessage  = function (msg, header, msgType) {
        var div, warningClass, iconClass, iconSpan, msgtxt, headertxt, icon;
        div = $('#fd-props-message');
        div.empty();
        if(msgType === 'error') {
            warningClass = 'ui-state-error';
            iconClass = 'ui-icon-alert';
        } else {
            warningClass = 'ui-state-highlight';
            iconClass = 'ui-icon-info';
        }
        iconSpan = '<span class="ui-icon ' + iconClass + '" style="float: left; margin-right: .3em;"></span>';
        icon = $(iconSpan);
        headertxt = '<strong>' + header + '</strong>';
        msgtxt = ' ' + msg;
        div.append(icon).append(headertxt).append(msgtxt);
        div.addClass(warningClass).addClass('ui-corner-all');
        div.show();
    }
    that.showMessage = showMessage;

    /**
     * Hides the question properties message box;
     */
    var hideMessage = function () {
        $('#fd-props-message').hide();
    }


    function init_toolbar() {4
        var toolbar = $(".fd-toolbar"), select, addbutstr, addbut;

        select = $('#fd-question-select');
        addbutstr = '<button id="fd-add-but">Add</button>';
        select.after(addbutstr);
        addbut = $('#fd-add-but');
        addbut.button({
            icons:{
                primary: 'ui-icon-gear'
            }
        });

        function findq () {
            var selVal, qID,qType;
            selVal = $('#fd-question-select').val();
            qID = $('#fd-question-select').find('[value*="'+selVal+'"]').attr('id');
            qType = qID.split('-')[2];
            formdesigner.controller.createQuestion(qType);
        }
        addbut.click(findq);

        select.chosen();

        //debug tools
        (function c_printDataTreeToConsole() {
            var printTreeBut = $(
                    '<button id="fd-print-tree-button" class="toolbarButton questionButton">'+
                'Print tree to Console' +
              '</button>');
            $('#fd-dragons').append(printTreeBut);

            printTreeBut.button().click(function () {
                formdesigner.util.dumpFormTreesToConsole();
            });

        })();

        (function c_showLoadItextXLS() {
            var loadXLSBut = $(
                    '<button id="fd-load-xls-button" class="toolbarButton questionButton">'+
                'Load Itext XLS From Clipboard' +
              '</button>');
            $('#fd-dragons').append(loadXLSBut);

            loadXLSBut.button().click(function () {
                formdesigner.controller.showLoadItextFromClipboard();

            });
        })();

        (function c_showGeneratedItextXLS() {
            var genXLSgbut = $(
                    '<button id="fd-gen-xls-button" class="toolbarButton questionButton">'+
                'Save Itext XLS to Clipboard' +
              '</button>');
            $('#fd-dragons').append(genXLSgbut);

            genXLSgbut.button().click(function () {
                formdesigner.controller.showGeneratedItextXLS();
            });
        })();

        (function c_saveForm() {
            var savebut = $(
                    '<button id="fd-save-button" class="toolbarButton questionButton">'+
                'Save Form' +
              '</button>');
            toolbar.append(savebut);

            savebut.button().click(function () {
                formdesigner.controller.sendXForm();
            });

        })();

        (function c_removeSelected() {
            var removebut = $(
                    '<button id="fd-remove-button" class="toolbarButton questionButton">'+
                'Remove Selected' +
              '</button>');
            toolbar.append(removebut);

            removebut.button().click(function () {
                var selected = formdesigner.controller.getCurrentlySelectedMugType();
                formdesigner.controller.removeMugTypeFromForm(selected);
            });

        })();

    }
    that.buttons = buttons;

    //Sets a visual indicator that the form needs saving on the 'Save Form' Button
    that.setSaveButtonFormUnsaved = function () {
        var saveBut = $('#fd-save-button');
        saveBut.button('enable');
        saveBut.button('option', 'icons', {primary:'ui-icon-alert'});
    }

    //Sets a visual indicator that the form IS saved (on 'Save Form' Button)
    that.setSaveButtonFormSaved = function () {
        var saveBut = $('#fd-save-button');
        saveBut.button('disable');
        saveBut.button('option', 'icons', {primary:'ui-icon-check'});
    }

    function getDataJSTreeTypes() {
        var jquery_icon_url = formdesigner.iconUrl,
            types =  {
            "max_children" : -1,
			"valid_children" : "all",
			"types" : {
                    "default" : {
                        "icon": {
                            "image": jquery_icon_url,
                            "position": "-112px -144px"
                        },
                    "valid_children" : "all"
                }
			}
        }

{'fraction_non_alphanumeric': 0.14486434108527133, 'fraction_numerical': 0.002099483204134367, 'mean_word_length': 1.831504343850023, 'pattern_counts': {'":': 6, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6354107', 'n_tokens_mistral': 3548, 'n_tokens_neox': 3439, 'n_words': 697}