chatMakeRoom.js 3.42 KB
Newer Older
Kang Donghun committed
1 2 3
$(function() {
  // メンバー検索

4 5 6 7 8 9
  $('#chatMakeRoom .search_form input[type="search"]').keyup(function(e) {
    if (e.key == "Enter" || e.KeyCode == 13) {
        $('#chatMakeRoom .search_form input[type="search"]').blur();
        return false;
    }

Kang Donghun committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    var isAllGroup = $('#tabAllGroupOnMakeRoom').is(':checked');
    $('.overlay_src_msg').empty();

    //全グループ検索画面
    if (isAllGroup) {
        var keyword = $('#chatMakeRoom .search_form input[type="search"]').val();
        if (keyword == '') {
            return;
        }

        //グループデータ検索
        var groupList = CHAT_DB.getGroupByName(keyword);
        var groupTemplate;
        $.get({ url: "./template/template_make_room_group_list.html", async: false }
            , function(text) {
                groupTemplate = text;
        });

        groupList.forEach(function(group) {
            let html = Mustache.render(groupTemplate, {
                name: group.groupName,
                id: group.groupId,
            });

            let obj = jQuery.parseHTML(html);
            $('.overlay_src_msg').append(obj);
        })

        //ユーザデータ検索
        var userList = CHAT_DB.getAllGroupShopMemberByName(keyword);
        var userTemplate;
        $.get({ url: "./template/template_make_room_user_list.html", async: false }
            , function(text) {
                userTemplate = text;
        });
        userList.forEach(function(user) {
            user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
            let findObj = CHAT.globalSelectedUserList.find(function(shopMemberId) {
Kang Donghun committed
48
                return shopMemberId == user.shopMemberId;
Kang Donghun committed
49 50
            })
            if (findObj) {
Kang Donghun committed
51
                user.checked = 'checked';
Kang Donghun committed
52 53 54 55 56 57 58
            }
        });
        let html = Mustache.render(userTemplate, {
            userList: userList
        });
        let obj = jQuery.parseHTML(html);
        $('.overlay_src_msg').append(obj);
Lee Munkyeong committed
59 60 61 62 63
        if (groupList.length == 0 && userList.length == 0) {
            const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'});
            noResultMsg.append(getLocalizedString("noResult"))
            $('.overlay_src_msg').append(noResultMsg);
        }
Kang Donghun committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
  //連絡先画面
    } else {
        var keyword = $('#chatMakeRoom .search_form input[type="search"]').val();
        if (keyword == '') {
            return;
        }
        var userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
        var userTemplate;
        $.get({ url: "./template/template_make_room_user_list.html", async: false }
            , function(text) {
                userTemplate = text;
        });
        userList.forEach(function(user) {
            user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
            let findObj = CHAT.globalSelectedUserList.find(function(shopMemberId) {
Kang Donghun committed
79
                return shopMemberId == user.shopMemberId;
Kang Donghun committed
80 81
            })
            if (findObj) {
Kang Donghun committed
82
                user.checked = 'checked';
Kang Donghun committed
83 84 85 86 87 88 89
            }
        });
        let html = Mustache.render(userTemplate, {
            userList: userList
        });
        let obj = jQuery.parseHTML(html);
        $('.overlay_src_msg').html(obj);
Lee Munkyeong committed
90 91 92 93 94
        if (userList.length == 0) {
            const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'});
            noResultMsg.append(getLocalizedString("noResult"))
            $('.overlay_src_msg').append(noResultMsg);
        }
Kang Donghun committed
95 96 97
    }
  });
});