src/main/ChatController.js
/**
 * Displays all contacts of user, attaching whatever function to its click event (opening a chat with it or selecting it to create group)
 * Chats are removed at the left and contacts shown instead.
 * Adding contacts option is enabled.
 */
Displays all contacts of user, attaching whatever function to its click event (opening a chat with it or selecting it to create group)
Chats are removed at the left and contacts shown instead.
Adding contacts option is enabled.
Displays all contacts of user attaching whatever function to its click event ( opening a chat with it or selecting it to create group ) Chats are removed at the left and contacts shown instead . Adding contacts option is enabled .
async function displayContacts(func) {
    $(".contact-list").html("");
    $("#data-url").prop("value", baseService.getDefaultDataUrl(userWebId));
    if (!showingContacts) {
        $(".search").addClass("hidden");
        $(".addcontact").removeClass("hidden");
        $(".writecontact").removeClass("hidden");
    } else {
        $(".search").removeClass("hidden");
        $(".addcontact").addClass("hidden");
        $(".writecontact").addClass("hidden");
    }
    if (!showingContacts) {
        $("#show-contacts").addClass("hidden");
        $("#create-group").addClass("hidden");
        for await (const friend of data[userWebId].friends) {
            let name = await baseService.getFormattedName(friend.value);
            var friendPhoto = await baseService.getPhoto(friend.value);
            if (!friendPhoto) {
                friendPhoto = baseService.getDefaultFriendPhoto();
            }
            var html = "<div style='cursor: pointer;' class='contact' id='openchatwindow" + friend.value + "'><img src='" +
                friendPhoto + "' alt='!' onerror='this.onerror=null;this.src='http://www.philosophica.info/voces/aquino/Aquino.jpg';'><div class='contact-preview'><div class='contact-text'><h1 class='font-name'>" +
                name + "</h1><p class='font-preview' id='ctmsg" + friend.value.split("/")[2].split(".")[0] +
                "'></p></div></div><div class='contact-time'><p>" + "</p></div></div>";
            $(".contact-list").prepend(html);
            document.getElementById("openchatwindow" + friend.value).addEventListener("click", func, false);
        }
        showingContacts = true;
        $("#show-contacts").removeClass("hidden");
        $("#create-group").removeClass("hidden");
    } else {
        await showChats();
        showingContacts = false;
    }
}
async function displayContacts ( func ) { $ ( ".contact-list" ) . html ( "" ) ; $ ( "#data-url" ) . prop ( "value" , baseService . getDefaultDataUrl ( userWebId ) ) ; if ( ! showingContacts ) { $ ( ".search" ) . addClass ( "hidden" ) ; $ ( ".addcontact" ) . removeClass ( "hidden" ) ; $ ( ".writecontact" ) . removeClass ( "hidden" ) ; } else { $ ( ".search" ) . removeClass ( "hidden" ) ; $ ( ".addcontact" ) . addClass ( "hidden" ) ; $ ( ".writecontact" ) . addClass ( "hidden" ) ; } if ( ! showingContacts ) { $ ( "#show-contacts" ) . addClass ( "hidden" ) ; $ ( "#create-group" ) . addClass ( "hidden" ) ; for await ( const friend of data [ userWebId ] . friends ) { let name = await baseService . getFormattedName ( friend . value ) ; var friendPhoto = await baseService . getPhoto ( friend . value ) ; if ( ! friendPhoto ) { friendPhoto = baseService . getDefaultFriendPhoto ( ) ; } var html = "<div style='cursor: pointer;' class='contact' id='openchatwindow" + friend . value + "'><img src='" + friendPhoto + "' alt='!' onerror='this.onerror=null;this.src='http://www.philosophica.info/voces/aquino/Aquino.jpg';'><div class='contact-preview'><div class='contact-text'><h1 class='font-name'>" + name + "</h1><p class='font-preview' id='ctmsg" + friend . value . split ( "/" ) [ 2 ] . split ( "." ) [ 0 ] + "'></p></div></div><div class='contact-time'><p>" + "</p></div></div>" ; $ ( ".contact-list" ) . prepend ( html ) ; document . getElementById ( "openchatwindow" + friend . value ) . addEventListener ( "click" , func , false ) ; } showingContacts = true ; $ ( "#show-contacts" ) . removeClass ( "hidden" ) ; $ ( "#create-group" ) . removeClass ( "hidden" ) ; } else { await showChats ( ) ; showingContacts = false ; } }
Displays all contacts of user, attaching whatever function to its click event (opening a chat with it or selecting it to create group)
 Chats are removed at the left and contacts shown instead.
Displays all contacts of user attaching whatever function to its click event ( opening a chat with it or selecting it to create group ) Chats are removed at the left and contacts shown instead .