{"size": 1523, "ext": "js", "max_stars_repo_path": "js/config_menu.js", "max_stars_repo_name": "ctsit/data_driven_project_banner", "max_stars_repo_stars_event_min_datetime": "2019-10-15T00:54:51.000Z", "max_stars_repo_stars_event_max_datetime": "2019-10-15T00:54:51.000Z", "max_issues_repo_path": "js/config_menu.js", "max_issues_repo_name": "ctsit/data_driven_project_banner", "max_issues_repo_issues_event_min_datetime": "2019-07-19T00:26:01.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-21T20:45:42.000Z", "max_forks_repo_path": "js/config_menu.js", "max_forks_repo_name": "ctsit/data_driven_project_banner", "max_forks_repo_forks_event_min_datetime": "2019-11-14T16:06:43.000Z", "max_forks_repo_forks_event_max_datetime": "2021-12-15T18:51:07.000Z"}
{"max_stars_count": 1, "max_issues_count": 14, "max_forks_count": 4, "avg_line_length": 47.59375, "max_line_length": 125, "alphanum_fraction": 0.6323046619}
$(document).ready(function() {
    var $modal = $('#external-modules-configure-modal');

    // check if other modules have set this to avoid infinite redefinition loop
    if (typeof ExternalModules.Settings.prototype.resetConfigInstancesOld === 'undefined') {
        ExternalModules.Settings.prototype.resetConfigInstancesOld = ExternalModules.Settings.prototype.resetConfigInstances;
    }

    // fire on clicking "configure" for any module
    $modal.on('show.bs.modal', function() {
        // Making sure we are overriding this modules's modal only.
        if ($(this).data('module') !== DDPB.modulePrefix) { return; }

        ExternalModules.Settings.prototype.resetConfigInstances = function() {
            ExternalModules.Settings.prototype.resetConfigInstancesOld();

            // Check that resetConfigInstances is not acting on a different module
            if ($modal.data('module') !== DDPB.modulePrefix) { return; }

            // Add "SELECT" prefix to custom SQL query fields
            $('[name^="custom_"][name$="_sql"]').each(function() {
                // prevent duplicate prepend, necessary if config menu is closed and reopened for this module
                if ($(this).hasClass('ddpb-select-prefix-set')) { return; }

                $(this).parent().prepend('<span>SELECT</span>');
                $(this).addClass('ddpb-select-prefix-set');
                $(this).attr('placeholder', "* FROM redcap_projects WHERE project_id = [project_id];");
            });
        }
    });
});
