<commit_before>/*
 Copyright 2015-2016 Eduworks Corporation and other contributing parties.

 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

var commitTimeout = null;
EcIdentityManager.onContactChanged = function (contact) {
    if (commitTimeout != null)
        clearTimeout(commitTimeout);
    commitTimeout = setTimeout(function () {
        commitTimeout = null;
        if (identity == null) return;
        loginServer.commit(function () {}, silent);
        populateContacts();
    }, 1000);
}
EcIdentityManager.onIdentityChanged = function (identity) {
    if (commitTimeout != null)
        clearTimeout(commitTimeout);
    commitTimeout = setTimeout(function () {
        commitTimeout = null;
        if (identity == null) return;
        loginServer.commit(function () {}, silent);
        populateContacts();
    }, 1000);
}

var contactsContact = $(".contactsContact").outerHTML();

function populateContacts() {
    populateContactsActual();
    actionAddContactCheck();
}

function loopPopulateContacts() {
    actionAddContactCheck();
    setTimeout(function () {
        loopPopulateContacts()
    }, 60000);
}

function populateContactsActual() {
    $("#contactsList").html("");
    var contactFilter = $("#contactSearch").val();
    if (contactFilter != null)
        contactFilter = contactFilter.trim();
    if (EcIdentityManager.ids !== undefined && EcIdentityManager.ids.length != 0)
        for (var i = 0; i < EcIdentityManager.ids.length; i++) {
            var identity = EcIdentityManager.ids[i];
            var ui = $("#contactsList").append(contactsContact).children().last();
            ui.find("a").hide();
            ui.find("#identity").attr("title", identity.ppk.toPk().toPem()).text("(You) " + identity.displayName);
            ui.attr("aria-selected", true);
            if (contactFilter != null && contactFilter != "") {
                if (identity.displayName != null)
                    if (identity.displayName.indexOf(contactFilter) == -1)
                        ui.hide();
            }
        }
    if (EcIdentityManager.contacts !== undefined && EcIdentityManager.contacts.length != 0)
        for (var i = 0; i < EcIdentityManager.contacts.length; i++) {
            var contact = EcIdentityManager.contacts[i];

            if (EcIdentityManager.getPpk(contact.pk) == null) {
                var ui = $("#contactsList").append(contactsContact).children().last();
                ui.find("#identity").attr("title", contact.pk.toPem()).text(contact.displayName);
                if (contactFilter != null && contactFilter != "") {
                    if (contact.displayName != null)
                        if (contact.displayName.indexOf(contactFilter) == -1)
                            ui.hide();
                }
            }

        }

    if (EcIdentityManager.contacts == undefined || EcIdentityManager.contacts.length == 0)
        if (EcIdentityManager.ids == undefined || EcIdentityManager.ids.length == 0) {
            $("#contactsList").html("No contacts. Please log in and invite people to connect with you.");
        }
}

function updateContact(me) {
    var pk = EcPk.fromPem($(me).attr("title"));
    var displayName = $(me).text();<commit_msg>Now only selects the first "you" contact.<commit_after>/*
 Copyright 2015-2016 Eduworks Corporation and other contributing parties.

 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

var commitTimeout = null;
EcIdentityManager.onContactChanged = function (contact) {
    if (commitTimeout != null)
        clearTimeout(commitTimeout);
    commitTimeout = setTimeout(function () {
        commitTimeout = null;
        if (identity == null) return;
        loginServer.commit(function () {}, silent);
        populateContacts();
    }, 1000);
}
EcIdentityManager.onIdentityChanged = function (identity) {
    if (commitTimeout != null)
        clearTimeout(commitTimeout);
    commitTimeout = setTimeout(function () {
        commitTimeout = null;
        if (identity == null) return;
        loginServer.commit(function () {}, silent);
        populateContacts();
    }, 1000);
}

var contactsContact = $(".contactsContact").outerHTML();

function populateContacts() {
    populateContactsActual();
    actionAddContactCheck();
}

function loopPopulateContacts() {
    actionAddContactCheck();
    setTimeout(function () {
        loopPopulateContacts()
    }, 60000);
}

function populateContactsActual() {
    $("#contactsList").html("");
    var contactFilter = $("#contactSearch").val();
    if (contactFilter != null)
        contactFilter = contactFilter.trim();
    
    if (EcIdentityManager.ids !== undefined && EcIdentityManager.ids.length != 0)
        for (var i = 0; i < EcIdentityManager.ids.length; i++) {
            var identity = EcIdentityManager.ids[i];
            var ui = $("#contactsList").append(contactsContact).children().last();
            ui.find("a").hide();
            ui.find("#identity").attr("title", identity.ppk.toPk().toPem()).text("(You) " + identity.displayName);
            if (i == 0)
                ui.attr("aria-selected", true);
            if (contactFilter != null && contactFilter != "") {
                if (identity.displayName != null)
                    if (identity.displayName.indexOf(contactFilter) == -1)
                        ui.hide();
            }
        }
    
    if (EcIdentityManager.contacts !== undefined && EcIdentityManager.contacts.length != 0)
        for (var i = 0; i < EcIdentityManager.contacts.length; i++) {
            var contact = EcIdentityManager.contacts[i];

            if (EcIdentityManager.getPpk(contact.pk) == null) {
                var ui = $("#contactsList").append(contactsContact).children().last();
                ui.find("#identity").attr("title", contact.pk.toPem()).text(contact.displayName);
                if (contactFilter != null && contactFilter != "") {
                    if (contact.displayName != null)
                        if (contact.displayName.indexOf(contactFilter) == -1)
                            ui.hide();
                }
            }
        }

    if (EcIdentityManager.contacts == undefined || EcIdentityManager.contacts.length == 0)
        if (EcIdentityManager.ids == undefined || EcIdentityManager.ids.length == 0) {
            $("#contactsList").html("No contacts. Please log in and invite people to connect with you.");
        }
}

function updateContact(me) {
    var pk = EcPk.fromPem($(me).attr("title"));
    var displayName = $(me).text();
{'fraction_non_alphanumeric': 0.13000401660195474, 'fraction_numerical': 0.008970411032266703, 'mean_word_length': 2.7145698657384387, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7056300', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1900, 'n_words': 510}