<commit_before>var settings_org = (function () {

var exports = {};

var meta = {
    loaded: false,
};

exports.reset = function () {
    meta.loaded = false;
};

exports.set_create_stream_permission_dropdwon = function () {
    var menu = "id_realm_create_stream_permission";
    $("#id_realm_waiting_period_threshold").parent().hide();
    if (page_params.realm_create_stream_by_admins_only) {
        $("#" + menu + " option[value=by_admins_only]").attr("selected", "selected");
    } else if (page_params.realm_waiting_period_threshold === 0) {
        $("#" + menu + " option[value=by_anyone]").attr("selected", "selected");
    } else if (page_params.realm_waiting_period_threshold === 3) {
        $("#" + menu + " option[value=by_admin_user_with_three_days_old]").attr("selected", "selected");
    } else {
        $("#" + menu + " option[value=by_admin_user_with_custom_time]").attr("selected", "selected");
        $("#id_realm_waiting_period_threshold").parent().show();
    }
};

exports.set_add_emoji_permission_dropdown = function () {
    var menu = "id_realm_add_emoji_by_admins_only";
    if (page_params.realm_add_emoji_by_admins_only) {
        $("#" + menu + " option[value=by_admins_only]").attr("selected", "selected");
    } else {
        $("#" + menu + " option[value=by_anyone]").attr("selected", "selected");
    }
};

exports.populate_realm_domains = function (realm_domains) {
    if (!meta.loaded) {
        return;
    }

    var domains_list = _.map(realm_domains, function (realm_domain) {
        return (realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain);
    });
    var domains = domains_list.join(', ');

    $("#id_realm_restricted_to_domain").prop("checked", page_params.realm_restricted_to_domain);
    if (domains.length === 0) {
        domains = i18n.t("None");
        $("#id_realm_restricted_to_domain").attr("data-toggle", "modal");
        $("#id_realm_restricted_to_domain").attr("href", "#realm_domains_modal");
    }
    if (domains !== "None") {
        $("#id_realm_restricted_to_domain").attr("data-toggle", "none");
    }
    $("#realm_restricted_to_domains_label").text(i18n.t("Restrict new users to the following email domains: __domains__", {domains: domains}));

    var realm_domains_table_body = $("#realm_domains_table tbody").expectOne();
    realm_domains_table_body.find("tr").remove();
    _.each(realm_domains, function (realm_domain) {
        realm_domains_table_body.append(templates.render("admin-realm-domains-list", {realm_domain: realm_domain}));
    });
};

exports.reset_realm_default_language = function () {
    if (!meta.loaded) {
        return;
    }

    $("#id_realm_default_language").val(page_params.realm_default_language);
};


exports.toggle_name_change_display = function () {
    // If user is an org admin, return. Cause org admin can change
    // name or email even name changes or email changes are disabled in org.
    if (!meta.loaded || page_params.is_admin) {
        return;
    }

    if (page_params.realm_name_changes_disabled) {
        $('#full_name').prop('disabled', true);
        $(".change_name_tooltip").show();
    } else {
        $('#full_name').prop('disabled', false);
        $(".change_name_tooltip").hide();
    }
};

exports.toggle_email_change_display = function () {
    if (!meta.loaded || page_params.is_admin) {
        return;
    }

    if (page_params.realm_email_changes_disabled) {
        $('#change_email .button').prop('disabled', true);
        $(".change_email_tooltip").show();
    } else {
        $('#change_email .button').prop('disabled', false);
        $(".change_email_tooltip").hide();
    }
};

exports.toggle_allow_message_editing_pencil = function () {
    if (!meta.loaded) {
        return;
    }
<commit_msg>settings: Fix erroneous meta.loaded check for name/email change.<commit_after>var settings_org = (function () {

var exports = {};

var meta = {
    loaded: false,
};

exports.reset = function () {
    meta.loaded = false;
};

exports.set_create_stream_permission_dropdwon = function () {
    var menu = "id_realm_create_stream_permission";
    $("#id_realm_waiting_period_threshold").parent().hide();
    if (page_params.realm_create_stream_by_admins_only) {
        $("#" + menu + " option[value=by_admins_only]").attr("selected", "selected");
    } else if (page_params.realm_waiting_period_threshold === 0) {
        $("#" + menu + " option[value=by_anyone]").attr("selected", "selected");
    } else if (page_params.realm_waiting_period_threshold === 3) {
        $("#" + menu + " option[value=by_admin_user_with_three_days_old]").attr("selected", "selected");
    } else {
        $("#" + menu + " option[value=by_admin_user_with_custom_time]").attr("selected", "selected");
        $("#id_realm_waiting_period_threshold").parent().show();
    }
};

exports.set_add_emoji_permission_dropdown = function () {
    var menu = "id_realm_add_emoji_by_admins_only";
    if (page_params.realm_add_emoji_by_admins_only) {
        $("#" + menu + " option[value=by_admins_only]").attr("selected", "selected");
    } else {
        $("#" + menu + " option[value=by_anyone]").attr("selected", "selected");
    }
};

exports.populate_realm_domains = function (realm_domains) {
    if (!meta.loaded) {
        return;
    }

    var domains_list = _.map(realm_domains, function (realm_domain) {
        return (realm_domain.allow_subdomains ? "*." + realm_domain.domain : realm_domain.domain);
    });
    var domains = domains_list.join(', ');

    $("#id_realm_restricted_to_domain").prop("checked", page_params.realm_restricted_to_domain);
    if (domains.length === 0) {
        domains = i18n.t("None");
        $("#id_realm_restricted_to_domain").attr("data-toggle", "modal");
        $("#id_realm_restricted_to_domain").attr("href", "#realm_domains_modal");
    }
    if (domains !== "None") {
        $("#id_realm_restricted_to_domain").attr("data-toggle", "none");
    }
    $("#realm_restricted_to_domains_label").text(i18n.t("Restrict new users to the following email domains: __domains__", {domains: domains}));

    var realm_domains_table_body = $("#realm_domains_table tbody").expectOne();
    realm_domains_table_body.find("tr").remove();
    _.each(realm_domains, function (realm_domain) {
        realm_domains_table_body.append(templates.render("admin-realm-domains-list", {realm_domain: realm_domain}));
    });
};

exports.reset_realm_default_language = function () {
    if (!meta.loaded) {
        return;
    }

    $("#id_realm_default_language").val(page_params.realm_default_language);
};


exports.toggle_name_change_display = function () {
    // If user is an org admin, return. Cause org admin can change
    // name or email even name changes or email changes are disabled in org.
    if (page_params.is_admin) {
        return;
    }

    if (page_params.realm_name_changes_disabled) {
        $('#full_name').prop('disabled', true);
        $(".change_name_tooltip").show();
    } else {
        $('#full_name').prop('disabled', false);
        $(".change_name_tooltip").hide();
    }
};

exports.toggle_email_change_display = function () {
    if (page_params.is_admin) {
        return;
    }

    if (page_params.realm_email_changes_disabled) {
        $('#change_email .button').prop('disabled', true);
        $(".change_email_tooltip").show();
    } else {
        $('#change_email .button').prop('disabled', false);
        $(".change_email_tooltip").hide();
    }
};

exports.toggle_allow_message_editing_pencil = function () {
    if (!meta.loaded) {
        return;
    }

{'fraction_non_alphanumeric': 0.16269580097406872, 'fraction_numerical': 0.0018428326971172831, 'mean_word_length': 3.818008877615726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '741817', 'n_tokens_mistral': 2517, 'n_tokens_neox': 2462, 'n_words': 367}