Commit c886b040 by Kim Peace

Unified common js logics

parent 9cdbfe65
...@@ -53,24 +53,22 @@ var getArchiveTypeIconURL = function (type) { ...@@ -53,24 +53,22 @@ var getArchiveTypeIconURL = function (type) {
var getArchiveTemplate = function () { var getArchiveTemplate = function () {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
$.get( $.get({ url: TemplateURL.ARCHIVE_LIST, async: false }, function (text) {
{ url: "./template/template_archive_list.html", async: false },
function (text) {
resolve(text); resolve(text);
} });
);
}); });
}; };
var bindArchiveSearch = function () { var bindArchiveSearch = function () {
$('#archive .search_form input[type="search"]').keyup(function (e) { const searchInput = $('#archive .search_form input[type="search"]');
var keyword = $('#archive .search_form input[type="search"]').val(); searchInput.keyup(function (e) {
var keyword = searchInput.val();
const enterKeyPressed = e.KeyCode == 13 || e.key == "Enter"; const enterKeyPressed = e.KeyCode == 13 || e.key == "Enter";
const keywordEmpty = keyword == "" || keyword.length < 2; const keywordEmpty = keyword == "" || keyword.length < 2;
const keywordNotEmpty = keyword.length != 0 && keyword != ""; const keywordNotEmpty = keyword.length != 0 && keyword != "";
if (enterKeyPressed) { if (enterKeyPressed) {
if (keywordNotEmpty) { if (keywordNotEmpty) {
$('#archive .search_form input[type="search"]').blur(); searchInput.blur();
return; return;
} }
} else if (keywordEmpty) { } else if (keywordEmpty) {
...@@ -82,7 +80,7 @@ var bindArchiveSearch = function () { ...@@ -82,7 +80,7 @@ var bindArchiveSearch = function () {
ARCHIVE_UI.refreshSearchScreen(keyword); ARCHIVE_UI.refreshSearchScreen(keyword);
if (enterKeyPressed) { if (enterKeyPressed) {
$('#archive .search_form input[type="search"]').blur(); searchInput.blur();
return; return;
} }
// 検索結果を表示 // 検索結果を表示
...@@ -90,16 +88,14 @@ var bindArchiveSearch = function () { ...@@ -90,16 +88,14 @@ var bindArchiveSearch = function () {
}; };
var bindiOSKeyBoardEvent = function () { var bindiOSKeyBoardEvent = function () {
$('#archive .search_form input[type="search"]').on( const searchInput = $('#archive .search_form input[type="search"]');
"compositionend", searchInput.on("compositionend", function () {
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var keyword = $('#archive .search_form input[type="search"]').val(); var keyword = searchInput.val();
$(".overlay_src_msg").empty(); $(".overlay_src_msg").empty();
ARCHIVE_UI.refreshSearchScreen(keyword); ARCHIVE_UI.refreshSearchScreen(keyword);
} }
} });
);
}; };
var renderArchiveTemplate = function ( var renderArchiveTemplate = function (
......
...@@ -12,6 +12,7 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -12,6 +12,7 @@ document.addEventListener("DOMContentLoaded", function () {
CHAT_ADD_USER.searchUser = function (keyword) { CHAT_ADD_USER.searchUser = function (keyword) {
const isAllGroup = $("#tabAllGroupOnAddUser").is(":checked"); const isAllGroup = $("#tabAllGroupOnAddUser").is(":checked");
const overlayMessage = $(".overlay_src_msg"); const overlayMessage = $(".overlay_src_msg");
let hasNoData = false;
overlayMessage.empty(); overlayMessage.empty();
//全グループ検索画面 //全グループ検索画面
...@@ -23,21 +24,19 @@ CHAT_ADD_USER.searchUser = function (keyword) { ...@@ -23,21 +24,19 @@ CHAT_ADD_USER.searchUser = function (keyword) {
//ユーザデータ検索 //ユーザデータ検索
var userList = CHAT_DB.getAllGroupShopMemberNotInRoomByName(keyword); var userList = CHAT_DB.getAllGroupShopMemberNotInRoomByName(keyword);
searchUserData(userList); searchUserData(userList);
hasNoData = userList.length == 0 && groupList.length == 0;
// Set NoResult //連絡先画面
if (userList.length == 0 && groupList.length == 0) {
const noResultMessage = getNoResultMessage();
overlayMessage.append(noResultMessage);
} //連絡先画面
} else { } else {
var userList = CHAT_DB.getMyGroupShopMemberNotInRoomByName(keyword); var userList = CHAT_DB.getMyGroupShopMemberNotInRoomByName(keyword);
searchUserData(userList); searchUserData(userList);
hasNoData = userList.length == 0;
if (userList.length == 0) { }
// Set NoResult
if (hasNoData) {
const noResultMessage = getNoResultMessage(); const noResultMessage = getNoResultMessage();
overlayMessage.append(noResultMessage); overlayMessage.append(noResultMessage);
} }
}
}; };
/** UTILS */ /** UTILS */
...@@ -76,6 +75,7 @@ var bindMemberSearch = function () { ...@@ -76,6 +75,7 @@ var bindMemberSearch = function () {
}; };
var bindiOSKeyBoardEvent = function () { var bindiOSKeyBoardEvent = function () {
const searchInput = $('#chat_add_user .search_form input[type="search"]');
searchInput.on("compositionend", function () { searchInput.on("compositionend", function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var keyword = searchInput.val(); var keyword = searchInput.val();
...@@ -85,7 +85,7 @@ var bindiOSKeyBoardEvent = function () { ...@@ -85,7 +85,7 @@ var bindiOSKeyBoardEvent = function () {
}; };
var searchGroupData = function (groupList) { var searchGroupData = function (groupList) {
const groupTemplate = getGroupTemplate(); const groupTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_LIST);
groupList.forEach(function (group) { groupList.forEach(function (group) {
let html = renderGroupTemplate( let html = renderGroupTemplate(
...@@ -99,17 +99,6 @@ var searchGroupData = function (groupList) { ...@@ -99,17 +99,6 @@ var searchGroupData = function (groupList) {
}); });
}; };
var getGroupTemplate = function () {
var groupTemplate;
$.get(
{ url: "./template/template_make_room_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
return groupTemplate;
};
var renderGroupTemplate = function (groupTemplate, groupName, groupID) { var renderGroupTemplate = function (groupTemplate, groupName, groupID) {
return Mustache.render(groupTemplate, { return Mustache.render(groupTemplate, {
name: groupName, name: groupName,
...@@ -118,7 +107,7 @@ var renderGroupTemplate = function (groupTemplate, groupName, groupID) { ...@@ -118,7 +107,7 @@ var renderGroupTemplate = function (groupTemplate, groupName, groupID) {
}; };
var searchUserData = function (userList) { var searchUserData = function (userList) {
const userTemplate = getUserTemplate(); const userTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_LIST);
userList.forEach(function (user) { userList.forEach(function (user) {
setUserProfile(user); setUserProfile(user);
checkUser(user); checkUser(user);
...@@ -128,17 +117,6 @@ var searchUserData = function (userList) { ...@@ -128,17 +117,6 @@ var searchUserData = function (userList) {
overlayMessage.append(obj); overlayMessage.append(obj);
}; };
var getUserTemplate = function () {
var userTemplate;
$.get(
{ url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
return userTemplate;
};
var setUserProfile = function (user) { var setUserProfile = function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
}; };
...@@ -157,12 +135,3 @@ var renderUserTemplate = function (userTemplate, userList) { ...@@ -157,12 +135,3 @@ var renderUserTemplate = function (userTemplate, userList) {
userList: userList, userList: userList,
}); });
}; };
var getNoResultMessage = function () {
const noResultMsg = $("<div/>", {
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
return noResultMsg;
};
includeJs("./chat-db-foriOS.js"); includeJs("./js/chat-db-foriOS.js");
// 名前空間 // 名前空間
var CHAT_DB = {}; var CHAT_DB = {};
......
...@@ -10,23 +10,6 @@ $(window).on("resize", function () { ...@@ -10,23 +10,6 @@ $(window).on("resize", function () {
console.log(`width : ${$(this).width()}`); console.log(`width : ${$(this).width()}`);
console.log(`height : ${$(this).height()}`); console.log(`height : ${$(this).height()}`);
/*if(CHAT_UI.isLandscapeMode()) {
$(".group_list").addClass("col-6").removeClass("col-12");
$(".user_list").addClass("col-6").removeClass("col-12");
$(".chat_list").addClass("col-6").removeClass("col-12");
$(".squareBoxContent span").addClass("landscape_span");
$(".mesgs").addClass("landscape_mesgs");
} else {
$(".group_list").removeClass("col-6").addClass("col-12");
$(".user_list").removeClass("col-6").addClass("col-12");
$(".chat_list").removeClass("col-6").addClass("col-12");
$(".squareBoxContent span").removeClass("landscape_span");
$(".mesgs").removeClass("landscape_mesgs");
}*/
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
if (isLandscape == true) { if (isLandscape == true) {
$(".mesgs").addClass("landscape_mesgs"); $(".mesgs").addClass("landscape_mesgs");
...@@ -1189,38 +1172,13 @@ CHAT_UI.refreshContactScreen = function () { ...@@ -1189,38 +1172,13 @@ CHAT_UI.refreshContactScreen = function () {
$("#title").text(contactListTitle); $("#title").text(contactListTitle);
// グループの様式を読み込む // グループの様式を読み込む
var groupTemplate; const groupTemplate = getTemplate(TemplateURL.GROUP_LIST);
$.get(
{ url: "./template/template_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
// ユーザの様式を読み込む // ユーザの様式を読み込む
var userTemplate; var userTemplate = getTemplate(TemplateURL.USER_LIST);
$.get(
{ url: "./template/template_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
var myNamecardTemplate; var myNamecardTemplate = getTemplate(TemplateURL.MY_NAME_CARD);
$.get(
{ url: "./template/template_my_name_card.html", async: false },
function (text) {
myNamecardTemplate = text;
}
);
var groupUserTemplate; var groupUserTemplate = getTemplate(TemplateURL.GROUP_USER_LIST);
$.get(
{ url: "./template/template_group_user_list.html", async: false },
function (text) {
groupUserTemplate = text;
}
);
if (IS_ONLINE == "true") { if (IS_ONLINE == "true") {
if (typeof android != "undefined") { if (typeof android != "undefined") {
...@@ -1353,13 +1311,8 @@ CHAT_UI.refreshRoomList = function (roomType) { ...@@ -1353,13 +1311,8 @@ CHAT_UI.refreshRoomList = function (roomType) {
} }
} }
var template; var template = getTemplate(TemplateURL.ROOM_LIST);
$.get(
{ url: "./template/template_room_list.html", async: false },
function (text) {
template = text;
}
);
rooms.forEach(function (room) { rooms.forEach(function (room) {
room.profileImagePath = ASSET_PATH + "images/user-profile.png"; room.profileImagePath = ASSET_PATH + "images/user-profile.png";
if (room.message) { if (room.message) {
...@@ -1479,57 +1432,22 @@ CHAT_UI.loadMessages = function (roomId, roomName) { ...@@ -1479,57 +1432,22 @@ CHAT_UI.loadMessages = function (roomId, roomName) {
let beforeHeight = jQueryMessages.prop("scrollHeight"); let beforeHeight = jQueryMessages.prop("scrollHeight");
// メッセージ文字列の生成 // メッセージ文字列の生成
let workVal = ""; let workVal = "";
var userTemplate; var userTemplate = getTemplate(TemplateURL.USER_LIST);
$.get(
{ url: "./template/template_user_list.html", async: false }, var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
function (text) {
userTemplate = text; var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
}
); var systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
var userMessageTemplate;
$.get( var openCollaborationMessageTemplate = getTemplate(
{ url: "./template/template_user_message.html", async: false }, TemplateURL.OPEN_COLLABORATION_MESSAGE
function (text) {
userMessageTemplate = text;
}
);
var myMessageTemplate;
$.get(
{ url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text;
}
);
var systemMessageTemplate;
$.get(
{ url: "./template/template_system_message.html", async: false },
function (text) {
systemMessageTemplate = text;
}
);
var openCollaborationMessageTemplate;
$.get(
{
url: "./template/template_open_collaboration_message.html",
async: false,
},
function (text) {
openCollaborationMessageTemplate = text;
}
);
var topUserListTemplate;
$.get(
{ url: "./template/template_chatroom_user_list.html", async: false },
function (text) {
topUserListTemplate = text;
}
); );
var filterUserListTemplate;
$.get( var topUserListTemplate = getTemplate(TemplateURL.CHATROOM_USER_LIST);
{ url: "./template/template_chatroom_user_filter_list.html", async: false },
function (text) { var filterUserListTemplate = getTemplate(
filterUserListTemplate = text; TemplateURL.CHATROOM_USER_FILTER_LIST
}
); );
usersInRoom.forEach(function (user) { usersInRoom.forEach(function (user) {
...@@ -1914,14 +1832,7 @@ CHAT_UI.refreshAllGroupSearch = function (paramGroupId) { ...@@ -1914,14 +1832,7 @@ CHAT_UI.refreshAllGroupSearch = function (paramGroupId) {
$("#parentGroupArea").removeClass("none"); $("#parentGroupArea").removeClass("none");
} }
//該当グループのパースを表示。 //該当グループのパースを表示。
var groupPathTemplate; var groupPathTemplate = getTemplate(TemplateURL.GROUP_PATH);
$.get(
{ url: "./template/template_group_path.html", async: false },
function (text) {
groupPathTemplate = text;
}
);
result.groupPathList.forEach(function (groupPath) { result.groupPathList.forEach(function (groupPath) {
let html = Mustache.render(groupPathTemplate, { let html = Mustache.render(groupPathTemplate, {
name: groupPath.groupName, name: groupPath.groupName,
...@@ -1932,13 +1843,7 @@ CHAT_UI.refreshAllGroupSearch = function (paramGroupId) { ...@@ -1932,13 +1843,7 @@ CHAT_UI.refreshAllGroupSearch = function (paramGroupId) {
}); });
//該当グループの下位グループ表示。 //該当グループの下位グループ表示。
var groupTemplate; var groupTemplate = getTemplate(TemplateURL.GROUP_LIST);
$.get(
{ url: "./template/template_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
result.childGroupList.forEach(function (childGroup) { result.childGroupList.forEach(function (childGroup) {
let html = Mustache.render(groupTemplate, { let html = Mustache.render(groupTemplate, {
name: childGroup.groupName, name: childGroup.groupName,
...@@ -1951,13 +1856,8 @@ CHAT_UI.refreshAllGroupSearch = function (paramGroupId) { ...@@ -1951,13 +1856,8 @@ CHAT_UI.refreshAllGroupSearch = function (paramGroupId) {
}); });
//該当グループの所属ユーザを表示。 //該当グループの所属ユーザを表示。
var userTemplate; var userTemplate = getTemplate(TemplateURL.USER_LIST);
$.get(
{ url: "./template/template_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
result.groupUserList.forEach(function (groupUser) { result.groupUserList.forEach(function (groupUser) {
groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl); groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl);
}); });
...@@ -2027,13 +1927,8 @@ CHAT_UI.makeNameCard = function (shopMemberId) { ...@@ -2027,13 +1927,8 @@ CHAT_UI.makeNameCard = function (shopMemberId) {
return; return;
} }
var nameCardInfo = CHAT_DB.getNameCardData(shopMemberId); var nameCardInfo = CHAT_DB.getNameCardData(shopMemberId);
var namecardTemplate; var namecardTemplate = getTemplate(TemplateURL.USER_NAME_CARD);
$.get(
{ url: "./template/template_user_name_card.html", async: false },
function (text) {
namecardTemplate = text;
}
);
nameCardInfo.profileUrl = CHAT.getProfileImgUrl(nameCardInfo.profileUrl); nameCardInfo.profileUrl = CHAT.getProfileImgUrl(nameCardInfo.profileUrl);
let namecardHtml = Mustache.render(namecardTemplate, { let namecardHtml = Mustache.render(namecardTemplate, {
shopMemberId: nameCardInfo.shopMemberId, shopMemberId: nameCardInfo.shopMemberId,
...@@ -2245,30 +2140,12 @@ CHAT_UI.refreshMyGroupForMakeRoom = function () { ...@@ -2245,30 +2140,12 @@ CHAT_UI.refreshMyGroupForMakeRoom = function () {
$("#title").text(contactListTitle); $("#title").text(contactListTitle);
// グループの様式を読み込む // グループの様式を読み込む
var groupTemplate; var groupTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_LIST);
$.get(
{ url: "./template/template_make_room_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
// ユーザの様式を読み込む // ユーザの様式を読み込む
var userTemplate; var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST);
$.get(
{ url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
var groupUserTemplate; var groupUserTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_USER_LIST);
$.get(
{ url: "./template/template_make_room_group_user_list.html", async: false },
function (text) {
groupUserTemplate = text;
}
);
if (IS_ONLINE == "true") { if (IS_ONLINE == "true") {
if (typeof android != "undefined") { if (typeof android != "undefined") {
...@@ -2400,13 +2277,7 @@ CHAT_UI.refreshAllGroupForMakeRoom = function (paramGroupId) { ...@@ -2400,13 +2277,7 @@ CHAT_UI.refreshAllGroupForMakeRoom = function (paramGroupId) {
$("#parentGroupArea").removeClass("none"); $("#parentGroupArea").removeClass("none");
} }
//該当グループのパースを表示。 //該当グループのパースを表示。
var groupPathTemplate; var groupPathTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_PATH);
$.get(
{ url: "./template/template_make_room_group_path.html", async: false },
function (text) {
groupPathTemplate = text;
}
);
var groupPathCount = 0; var groupPathCount = 0;
result.groupPathList.forEach(function (groupPath) { result.groupPathList.forEach(function (groupPath) {
...@@ -2422,13 +2293,7 @@ CHAT_UI.refreshAllGroupForMakeRoom = function (paramGroupId) { ...@@ -2422,13 +2293,7 @@ CHAT_UI.refreshAllGroupForMakeRoom = function (paramGroupId) {
}); });
//該当グループの下位グループ表示。 //該当グループの下位グループ表示。
var groupTemplate; var groupTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_LIST);
$.get(
{ url: "./template/template_make_room_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
result.childGroupList.forEach(function (childGroup) { result.childGroupList.forEach(function (childGroup) {
let html = Mustache.render(groupTemplate, { let html = Mustache.render(groupTemplate, {
...@@ -2441,13 +2306,8 @@ CHAT_UI.refreshAllGroupForMakeRoom = function (paramGroupId) { ...@@ -2441,13 +2306,8 @@ CHAT_UI.refreshAllGroupForMakeRoom = function (paramGroupId) {
}); });
//該当グループの所属ユーザを表示。 //該当グループの所属ユーザを表示。
var userTemplate; var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST);
$.get(
{ url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
result.groupUserList.forEach(function (groupUser) { result.groupUserList.forEach(function (groupUser) {
groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl); groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
...@@ -2497,16 +2357,7 @@ CHAT_UI.checkForMakeChat = function (checkMemberId) { ...@@ -2497,16 +2357,7 @@ CHAT_UI.checkForMakeChat = function (checkMemberId) {
CHAT_UI.showMakeRoomConfirmView = function () { CHAT_UI.showMakeRoomConfirmView = function () {
$("#selectedUserList").html(""); $("#selectedUserList").html("");
var userTemplate; var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_CONFIRM_USER_LIST);
$.get(
{
url: "./template/template_make_room_confirm_user_list.html",
async: false,
},
function (text) {
userTemplate = text;
}
);
var selectedUserList = CHAT_DB.loadSelectedUsers(); var selectedUserList = CHAT_DB.loadSelectedUsers();
...@@ -2647,17 +2498,7 @@ CHAT_UI.showMakeRoomConfirmView = function () { ...@@ -2647,17 +2498,7 @@ CHAT_UI.showMakeRoomConfirmView = function () {
CHAT_UI.showAddUserConfirmView = function () { CHAT_UI.showAddUserConfirmView = function () {
$("#selectedUserList").html(""); $("#selectedUserList").html("");
var userTemplate; var userTemplate = getTemplate(TemplateURL.ADD_USER_CONFIRM_USER_LIST);
$.get(
{
url: "./template/template_add_user_confirm_user_list.html",
async: false,
},
function (text) {
userTemplate = text;
}
);
var selectedUserList = CHAT_DB.loadSelectedUsers(); var selectedUserList = CHAT_DB.loadSelectedUsers();
selectedUserList.forEach(function (user) { selectedUserList.forEach(function (user) {
...@@ -2697,30 +2538,11 @@ CHAT_UI.refreshMyGroupForAddUser = function () { ...@@ -2697,30 +2538,11 @@ CHAT_UI.refreshMyGroupForAddUser = function () {
$("#title").text(contactListTitle); $("#title").text(contactListTitle);
// グループの様式を読み込む // グループの様式を読み込む
var groupTemplate; var groupTemplate = getTemplate(TemplateURL.ADD_USER_GROUP_LIST);
$.get(
{ url: "./template/template_add_user_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
// ユーザの様式を読み込む // ユーザの様式を読み込む
var userTemplate; var userTemplate = getTemplate(TemplateURL.ADD_USER_USER_LIST);
$.get( var groupUserTemplate = getTemplate(TemplateURL.ADD_USER_GROUP_USER_LIST);
{ url: "./template/template_add_user_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
var groupUserTemplate;
$.get(
{ url: "./template/template_add_user_group_user_list.html", async: false },
function (text) {
groupUserTemplate = text;
}
);
if (IS_ONLINE == "true") { if (IS_ONLINE == "true") {
if (typeof android != "undefined") { if (typeof android != "undefined") {
...@@ -2837,14 +2659,7 @@ CHAT_UI.refreshAllGroupForAddUser = function (paramGroupId) { ...@@ -2837,14 +2659,7 @@ CHAT_UI.refreshAllGroupForAddUser = function (paramGroupId) {
$("#parentGroupArea").removeClass("none"); $("#parentGroupArea").removeClass("none");
} }
//該当グループのパースを表示。 //該当グループのパースを表示。
var groupPathTemplate; var groupPathTemplate = getTemplate(TemplateURL.ADD_USER_GROUP_PATH);
$.get(
{ url: "./template/template_add_user_group_path.html", async: false },
function (text) {
groupPathTemplate = text;
}
);
var groupPathCount = 0; var groupPathCount = 0;
result.groupPathList.forEach(function (groupPath) { result.groupPathList.forEach(function (groupPath) {
if (!(groupPathCount < result.groupPathList.length - 3)) { if (!(groupPathCount < result.groupPathList.length - 3)) {
...@@ -2859,13 +2674,7 @@ CHAT_UI.refreshAllGroupForAddUser = function (paramGroupId) { ...@@ -2859,13 +2674,7 @@ CHAT_UI.refreshAllGroupForAddUser = function (paramGroupId) {
}); });
//該当グループの下位グループ表示。 //該当グループの下位グループ表示。
var groupTemplate; var groupTemplate = getTemplate(TemplateURL.ADD_USER_GROUP_LIST);
$.get(
{ url: "./template/template_add_user_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
result.childGroupList.forEach(function (childGroup) { result.childGroupList.forEach(function (childGroup) {
let html = Mustache.render(groupTemplate, { let html = Mustache.render(groupTemplate, {
...@@ -2878,13 +2687,7 @@ CHAT_UI.refreshAllGroupForAddUser = function (paramGroupId) { ...@@ -2878,13 +2687,7 @@ CHAT_UI.refreshAllGroupForAddUser = function (paramGroupId) {
}); });
//該当グループの所属ユーザを表示。 //該当グループの所属ユーザを表示。
var userTemplate; var userTemplate = getTemplate(TemplateURL.ADD_USER_USER_LIST);
$.get(
{ url: "./template/template_add_user_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
result.groupUserList.forEach(function (groupUser) { result.groupUserList.forEach(function (groupUser) {
groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl); groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
...@@ -3063,38 +2866,17 @@ CHAT_UI.refreshMyGroupForAddUserInCollaboration = function () { ...@@ -3063,38 +2866,17 @@ CHAT_UI.refreshMyGroupForAddUserInCollaboration = function () {
$("#tabMyGroupOnAddUserInCollaboration").prop("checked", true); $("#tabMyGroupOnAddUserInCollaboration").prop("checked", true);
// グループの様式を読み込む // グループの様式を読み込む
var groupTemplate; var groupTemplate = getTemplate(
$.get( TemplateURL.ADD_USER_GROUP_LIST_IN_COLLABORATION
{
url: "./template/template_add_user_group_list_in_collaboration.html",
async: false,
},
function (text) {
groupTemplate = text;
}
); );
// ユーザの様式を読み込む // ユーザの様式を読み込む
var userTemplate; var userTemplate = getTemplate(
$.get( TemplateURL.ADD_USER_USER_LIST_IN_COLLABORATION
{
url: "./template/template_add_user_user_list_in_collaboration.html",
async: false,
},
function (text) {
userTemplate = text;
}
); );
var groupUserTemplate; var groupUserTemplate = getTemplate(
$.get( TemplateURL.ADD_USER_GROUP_USER_LIST_IN_COLLABORATION
{
url: "./template/template_add_user_group_user_list_in_collaboration.html",
async: false,
},
function (text) {
groupUserTemplate = text;
}
); );
if (IS_ONLINE == "true") { if (IS_ONLINE == "true") {
...@@ -3208,15 +2990,8 @@ CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) { ...@@ -3208,15 +2990,8 @@ CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) {
$("#parentGroupAreaInCollaboration").removeClass("none"); $("#parentGroupAreaInCollaboration").removeClass("none");
} }
//該当グループのパースを表示。 //該当グループのパースを表示。
var groupPathTemplate; var groupPathTemplate = getTemplate(
$.get( TemplateURL.ADD_USER_GROUP_PATH_IN_COLLABORATION
{
url: "./template/template_add_user_group_path_in_collaboration.html",
async: false,
},
function (text) {
groupPathTemplate = text;
}
); );
var groupPathCount = 0; var groupPathCount = 0;
...@@ -3233,15 +3008,8 @@ CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) { ...@@ -3233,15 +3008,8 @@ CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) {
}); });
//該当グループの下位グループ表示。 //該当グループの下位グループ表示。
var groupTemplate; var groupTemplate = getTemplate(
$.get( TemplateURL.ADD_USER_GROUP_LIST_IN_COLLABORATION
{
url: "./template/template_add_user_group_list_in_collaboration.html",
async: false,
},
function (text) {
groupTemplate = text;
}
); );
result.childGroupList.forEach(function (childGroup) { result.childGroupList.forEach(function (childGroup) {
...@@ -3255,16 +3023,10 @@ CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) { ...@@ -3255,16 +3023,10 @@ CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) {
}); });
//該当グループの所属ユーザを表示。 //該当グループの所属ユーザを表示。
var userTemplate; var userTemplate = getTemplate(
$.get( TemplateURL.ADD_USER_USER_LIST_IN_COLLABORATION
{
url: "./template/template_add_user_user_list_in_collaboration.html",
async: false,
},
function (text) {
userTemplate = text;
}
); );
result.groupUserList.forEach(function (groupUser) { result.groupUserList.forEach(function (groupUser) {
groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl); groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
......
...@@ -166,37 +166,10 @@ function setSocketAction() { ...@@ -166,37 +166,10 @@ function setSocketAction() {
// #36170 // #36170
socket.on("newMessage", function (message, roomId, roomName) { socket.on("newMessage", function (message, roomId, roomName) {
console.log(message); console.log(message);
var userMessageTemplate; var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
$.get( var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
{ url: "./template/template_user_message.html", async: false }, var systemMessageTemplate = getTemplate(TemplateURL.SYSTEM_MESSAGE);
function (text) { var openCollaborationMessageTemplate = getTemplate(TemplateURL.OPEN_COLLABORATION_MESSAGE);
userMessageTemplate = text;
}
);
var myMessageTemplate;
$.get(
{ url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text;
}
);
var systemMessageTemplate;
$.get(
{ url: "./template/template_system_message.html", async: false },
function (text) {
systemMessageTemplate = text;
}
);
var openCollaborationMessageTemplate;
$.get(
{
url: "./template/template_open_collaboration_message.html",
async: false,
},
function (text) {
openCollaborationMessageTemplate = text;
}
);
let template = userMessageTemplate; let template = userMessageTemplate;
if (message.id === socket.id) { if (message.id === socket.id) {
......
...@@ -582,20 +582,9 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -582,20 +582,9 @@ document.addEventListener('DOMContentLoaded', function() {
return; return;
} }
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(",")); var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
var userMessageTemplate; var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
$.get( var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
{ url: "./template/template_user_message.html", async: false },
function (text) {
userMessageTemplate = text;
}
);
var myMessageTemplate;
$.get(
{ url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text;
}
);
let jQueryMessages = $(".overlay_src_msg"); let jQueryMessages = $(".overlay_src_msg");
messages.forEach(function (message) { messages.forEach(function (message) {
...@@ -647,13 +636,7 @@ CHAT.searchRoom = function (keyword, rooms) { ...@@ -647,13 +636,7 @@ CHAT.searchRoom = function (keyword, rooms) {
rooms = CHAT_DB.getRoomList(ChatRoomType.ALL, keyword); rooms = CHAT_DB.getRoomList(ChatRoomType.ALL, keyword);
let roomListTitle = getLocalizedString("room_search_placeholder"); let roomListTitle = getLocalizedString("room_search_placeholder");
$("#chatTitle").text(roomListTitle); $("#chatTitle").text(roomListTitle);
var template; var template = getTemplate(TemplateURL.ROOM_LIST);
$.get(
{ url: "./template/template_room_list.html", async: false },
function (text) {
template = text;
}
);
rooms.forEach(function (room) { rooms.forEach(function (room) {
room.profileImagePath = ASSET_PATH + "images/user-profile.png"; room.profileImagePath = ASSET_PATH + "images/user-profile.png";
if (room.message) { if (room.message) {
...@@ -704,11 +687,7 @@ CHAT.searchRoom = function (keyword, rooms) { ...@@ -704,11 +687,7 @@ CHAT.searchRoom = function (keyword, rooms) {
$(".overlay_src_msg").append(obj); $(".overlay_src_msg").append(obj);
}); });
if (rooms.length == 0) { if (rooms.length == 0) {
const noResultMsg = $("<div/>", { const noResultMsg = getNoResultMessage();
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg); $(".overlay_src_msg").append(noResultMsg);
} }
}; };
...@@ -722,20 +701,8 @@ CHAT.searchMessage = function (keyword, workVal) { ...@@ -722,20 +701,8 @@ CHAT.searchMessage = function (keyword, workVal) {
checkedUserList.push($(selectedUser).data("user-id")); checkedUserList.push($(selectedUser).data("user-id"));
}); });
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(",")); var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
var userMessageTemplate; var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
$.get( var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
{ url: "./template/template_user_message.html", async: false },
function (text) {
userMessageTemplate = text;
}
);
var myMessageTemplate;
$.get(
{ url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text;
}
);
let jQueryMessages = $(".overlay_src_msg"); let jQueryMessages = $(".overlay_src_msg");
messages.forEach(function (message) { messages.forEach(function (message) {
...@@ -776,11 +743,7 @@ CHAT.searchMessage = function (keyword, workVal) { ...@@ -776,11 +743,7 @@ CHAT.searchMessage = function (keyword, workVal) {
}); });
jQueryMessages.prepend(workVal); jQueryMessages.prepend(workVal);
if (messages.length == 0) { if (messages.length == 0) {
const noResultMsg = $("<div/>", { const noResultMsg = getNoResultMessage();
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
jQueryMessages.append(noResultMsg); jQueryMessages.append(noResultMsg);
} }
}; };
// 名前空間 // 名前空間
var CHAT_MAKE_ROOM = {}; var CHAT_MAKE_ROOM = {};
document.addEventListener('DOMContentLoaded', function() { document.addEventListener("DOMContentLoaded", function () {
// メンバー検索 // メンバー検索
$('#chatMakeRoom .search_form input[type="search"]').click(function (e) { searchMember();
let contactListTitle = getLocalizedString("userSearch");
$("#makeRoomTitle").text(contactListTitle);
});
$('#chatMakeRoom .search_form input[type="search"]').keyup(function (e) {
//画面タイトル設定
var keyword = $('#chatMakeRoom .search_form input[type="search"]').val();
if (e.KeyCode == 13 || e.key == "Enter") {
if (keyword != "" && keyword.length != 0) {
$('#chatMakeRoom .search_form input[type="search"]').blur();
return false;
}
} else if (keyword == "" || keyword.length < 2) {
$(".overlay_src_msg").empty();
return false;
}
CHAT_MAKE_ROOM.searchUser(keyword);
if (e.key == "Enter" || e.KeyCode == 13) {
$('#chatMakeRoom .search_form input[type="search"]').blur();
return;
}
});
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#chatMakeRoom .search_form input[type="search"]').on( bindiOSKeyBoardEvent();
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) {
var keyword = $(
'#chatMakeRoom .search_form input[type="search"]'
).val();
CHAT_MAKE_ROOM.searchUser(keyword);
}
}
);
}); });
// メンバー検索 // メンバー検索
CHAT_MAKE_ROOM.searchUser = function (keyword) { CHAT_MAKE_ROOM.searchUser = function (keyword) {
var isAllGroup = $("#tabAllGroupOnMakeRoom").is(":checked"); const overlayMessage = $(".overlay_src_msg");
$(".overlay_src_msg").empty(); const isAllGroup = $("#tabAllGroupOnMakeRoom").is(":checked");
let hasNoData = false;
overlayMessage.empty();
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
//グループデータ検索 //グループデータ検索
var groupList = CHAT_DB.getGroupByName(keyword); var groupList = CHAT_DB.getGroupByName(keyword);
var groupTemplate; var groupTemplate = getTemplate(TemplateURL.MAKE_ROOM_GROUP_LIST);
$.get(
{ url: "./template/template_make_room_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
);
groupList.forEach(function (group) { groupList.forEach(function (group) {
let html = Mustache.render(groupTemplate, { renderRoomList(groupTemplate, group.groupName, group.groupId);
name: group.groupName,
id: group.groupId,
});
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj); overlayMessage.append(obj);
}); });
//ユーザデータ検索 //ユーザデータ検索
var userList = CHAT_DB.getAllGroupShopMemberByName(keyword); var userList = CHAT_DB.getAllGroupShopMemberByName(keyword);
var userTemplate; searchUserData(userList);
$.get( var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST);
{ url: "./template/template_make_room_user_list.html", async: false }, let html = renderUser(userTemplate, userList);
function (text) { let obj = jQuery.parseHTML(html);
userTemplate = text; overlayMessage.append(obj);
hasNoData = groupList.length == 0 && userList.length == 0;
//連絡先画面
} else {
const userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
searchUserData();
var userTemplate = getTemplate(TemplateURL.MAKE_ROOM_USER_LIST);
let html = renderUser(userTemplate, userList);
let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj);
hasNoData = userList.length == 0;
} }
);
userList.forEach(function (user) { if (hasNoData) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); const noResultMsg = getNoResultMessage();
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) { overlayMessage.append(noResultMsg);
return shopMemberId == user.shopMemberId; }
};
/** UTIL */
var searchMember = function () {
const searchInput = $('#chatMakeRoom .search_form input[type="search"]');
searchInput.click(function (e) {
let contactListTitle = getLocalizedString("userSearch");
$("#makeRoomTitle").text(contactListTitle);
}); });
if (findObj) { searchInput.keyup(function (e) {
user.checked = "checked"; const enterKeyPressed = e.KeyCode == 13 || e.key == "Enter";
const keywordEmpty = keyword == "" || keyword.length < 2;
const keywordNotEmpty = keyword != "" && keyword.length != 0;
//画面タイトル設定
var keyword = searchInput.val();
if (enterKeyPressed) {
if (keywordNotEmpty) {
searchInput.blur();
return false;
}
} else if (keywordEmpty) {
$(".overlay_src_msg").empty();
return false;
}
CHAT_MAKE_ROOM.searchUser(keyword);
if (enterKeyPressed) {
searchInput.blur();
return;
} }
}); });
let html = Mustache.render(userTemplate, { };
userList: userList,
var bindiOSKeyBoardEvent = function () {
const searchInput = $('#chatMakeRoom .search_form input[type="search"]');
searchInput.on("compositionend", function () {
if (CHAT_UTIL.isIOS()) {
var keyword = searchInput.val();
CHAT_MAKE_ROOM.searchUser(keyword);
}
}); });
let obj = jQuery.parseHTML(html); };
$(".overlay_src_msg").append(obj);
if (groupList.length == 0 && userList.length == 0) { var renderRoomList = function (url, groupName, groupID) {
const noResultMsg = $("<div/>", { return Mustache.render(url, {
width: "auto", name: groupName,
style: "text-align: center", id: groupID,
}); });
noResultMsg.append(getLocalizedString("noResult")); };
$(".overlay_src_msg").append(noResultMsg);
} //連絡先画面 var searchUserData = function (userList) {
} else {
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) { userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
...@@ -115,18 +113,10 @@ CHAT_MAKE_ROOM.searchUser = function (keyword) { ...@@ -115,18 +113,10 @@ CHAT_MAKE_ROOM.searchUser = function (keyword) {
user.checked = "checked"; user.checked = "checked";
} }
}); });
let html = Mustache.render(userTemplate, { };
var renderUser = function (url, userList) {
return Mustache.render(url, {
userList: userList, userList: userList,
}); });
let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj);
if (userList.length == 0) {
const noResultMsg = $("<div/>", {
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
}
}
}; };
...@@ -7,6 +7,23 @@ function includeJs(jsFilePath) { ...@@ -7,6 +7,23 @@ function includeJs(jsFilePath) {
document.body.appendChild(js); document.body.appendChild(js);
} }
function getTemplate(url) {
var template;
$.get({ url: url, async: false }, function (text) {
template = text;
});
return template;
}
function getNoResultMessage() {
const noResultMsg = $("<div/>", {
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
return noResultMsg;
}
// アコーディオン // アコーディオン
$(".category").on("click", function () { $(".category").on("click", function () {
$(this).toggleClass("open"); $(this).toggleClass("open");
...@@ -21,7 +38,7 @@ $(".home_btn").on("click", function () { ...@@ -21,7 +38,7 @@ $(".home_btn").on("click", function () {
} }
}); });
document.addEventListener('DOMContentLoaded', function() { document.addEventListener("DOMContentLoaded", function () {
var h = $(window).height(); //画面の高さを取得 var h = $(window).height(); //画面の高さを取得
// ローディング表示 // ローディング表示
......
...@@ -56,3 +56,43 @@ const HostRequestFlag = { ...@@ -56,3 +56,43 @@ const HostRequestFlag = {
const messageSeperator = "<::split>"; const messageSeperator = "<::split>";
const dataMessageScheme = "::NOT_MESSAGE"; const dataMessageScheme = "::NOT_MESSAGE";
const TemplateURL = {
GROUP_PATH: "./template/template_group_path.html",
GROUP_LIST: "./template/template_group_list.html",
ARCHIVE_LIST: "./template/template_archive_list.html",
MAKE_ROOM_GROUP_LIST: "./template/template_make_room_group_list.html",
GROUP_USER_LIST: "./template/template_group_user_list.html",
ROOM_LIST: "./template/template_room_list.html",
SYSTEM_MESSAGE: "./template/template_system_message.html",
USER_LIST: "./template/template_user_list.html",
USER_NAME_CARD: "./template/template_user_name_card.html",
USER_MESSAGE: "./template/template_user_message.html",
MY_NAME_CARD: "./template/template_my_name_card.html",
MY_MESSAGE: "./template/template_my_message.html",
OPEN_COLLABORATION_MESSAGE:
"./template/template_open_collaboration_message.html",
CHATROOM_USER_LIST: "./template/template_chatroom_user_list.html",
CHATROOM_USER_FILTER_LIST:
"./template/template_chatroom_user_filter_list.html",
MAKE_ROOM_USER_LIST: "./template/template_make_room_user_list.html",
MAKE_ROOM_GROUP_USER_LIST:
"./template/template_make_room_group_user_list.html",
MAKE_ROOM_GROUP_PATH: "./template/template_make_room_group_path.html",
MAKE_ROOM_CONFIRM_USER_LIST:
"./template/template_make_room_confirm_user_list.html",
ADD_USER_CONFIRM_USER_LIST:
"./template/template_add_user_confirm_user_list.html",
ADD_USER_USER_LIST: "./template/template_add_user_user_list.html",
ADD_USER_USER_LIST_IN_COLLABORATION:
"./template/template_add_user_user_list_in_collaboration.html",
ADD_USER_GROUP_PATH: "./template/template_add_user_group_path.html",
ADD_USER_GROUP_LIST: "./template/template_add_user_group_list.html",
ADD_USER_GROUP_LIST_IN_COLLABORATION:
"./template/template_add_user_group_list_in_collaboration.html",
ADD_USER_GROUP_USER_LIST: "./template/template_add_user_group_user_list.html",
ADD_USER_GROUP_USER_LIST_IN_COLLABORATION:
"./template/template_add_user_group_user_list_in_collaboration.html",
ADD_USER_GROUP_PATH_IN_COLLABORATION:
"./template/template_add_user_group_path_in_collaboration.html",
};
// 名前空間 // 名前空間
var CONTACT = {}; var CONTACT = {};
document.addEventListener('DOMContentLoaded', function() { document.addEventListener("DOMContentLoaded", function () {
// メンバー検索 // メンバー検索
$('#contact .search_form input[type="search"]').keyup(function (e) { bindMemeberSearch();
var keyword = $('#contact .search_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { // iOSキーボード変換検知用
if (keyword != "" && keyword.length != 0) { bindiOSKeyBoardEvent();
$('#contact .search_form input[type="search"]').blur(); });
// ユーザー検索
CONTACT.searchUser = function (keyword) {
const overlayMessage = $(".overlay_src_msg");
const isAllGroup = $("#tabAllGroup").is(":checked");
let hasNoData = false;
overlayMessage.empty();
//全グループ検索画面
if (isAllGroup) {
//グループデータ検索
const groupList = CHAT_DB.getGroupByName(keyword);
groupDataSearch(groupList);
//ユーザデータ検索
const userList = CHAT_DB.getAllGroupShopMemberByName(keyword);
userDataSearch(userList);
hasNoData = userList.length == 0 && groupList.length == 0;
//連絡先画面
} else {
const userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
userDataSearch(userList);
hasNoData = userList.length == 0;
}
if (hasNoData) {
const noResultMsg = getNoResultMessage();
overlayMessage.append(noResultMsg);
}
};
/** UTILS */
var bindiOSKeyBoardEvent = function () {
const searchInput = $('#contact .search_form input[type="search"]');
searchInput.on("compositionend", function () {
if (CHAT_UTIL.isIOS()) {
var keyword = searchInput.val();
CONTACT.searchUser(keyword);
}
});
};
var bindMemeberSearch = function () {
const searchInput = $('#contact .search_form input[type="search"]');
searchInput.keyup(function (e) {
const keyword = searchInput.val();
const enterKeyPressed = e.key == "Enter" || e.KeyCode == 13;
const keywordEmpty = keyword == "" || keyword.length < 2;
const keywordNotEmpty = keyword != "" && keyword.length != 0;
if (enterKeyPressed) {
if (keywordNotEmpty) {
searchInput.blur();
return; return;
} }
} else if (keyword == "" || keyword.length < 2) { } else if (keywordEmpty) {
$(".overlay_src_msg").empty(); $(".overlay_src_msg").empty();
return; return;
} }
CONTACT.searchUser(keyword); CONTACT.searchUser(keyword);
if (e.key == "Enter" || e.KeyCode == 13) { if (enterKeyPressed) {
$('#contact .search_form input[type="search"]').blur(); searchInput.blur();
return; return;
} }
}); });
// iOSキーボード変換検知用 };
$('#contact .search_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) {
var keyword = $('#contact .search_form input[type="search"]').val();
CONTACT.searchUser(keyword);
}
}
);
});
// ユーザー検索 var groupDataSearch = function (groupList) {
CONTACT.searchUser = function (keyword) { const groupTemplate = getTemplate(TemplateURL.GROUP_LIST);
var groupList;
$(".overlay_src_msg").empty();
var isAllGroup = $("#tabAllGroup").is(":checked");
//全グループ検索画面 groupList.forEach(function (group) {
if (isAllGroup) { let html = renderGroupList(
//グループデータ検索 groupTemplate,
groupList = CHAT_DB.getGroupByName(keyword); group.groupName,
var groupTemplate; group.groupId,
$.get( group.isFavorite
{ url: "./template/template_group_list.html", async: false },
function (text) {
groupTemplate = text;
}
); );
groupList.forEach(function (group) {
let html = Mustache.render(groupTemplate, {
name: group.groupName,
id: group.groupId,
isFavorite: group.isFavorite,
});
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj); $(".overlay_src_msg").append(obj);
}); });
};
//ユーザデータ検索 var renderGroupList = function (url, groupName, groupID, isFavorite) {
var userList = CHAT_DB.getAllGroupShopMemberByName(keyword); return Mustache.render(url, {
var userTemplate; name: groupName,
$.get( id: groupID,
{ url: "./template/template_user_list.html", async: false }, isFavorite: isFavorite,
function (text) { });
userTemplate = text; };
}
); var userDataSearch = function (userList) {
userList.forEach(function (user) { userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
}); });
let html = Mustache.render(userTemplate, { var userTemplate = getTemplate(TemplateURL.USER_LIST);
userList: userList, let html = renderUserList(userTemplate, userList);
});
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj); $(".overlay_src_msg").append(obj);
if (userList.length == 0 && groupList.length == 0) { };
const noResultMsg = $("<div/>", {
width: "auto", var renderUserList = function (url, userList) {
style: "text-align: center", return Mustache.render(url, {
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
}
//連絡先画面
} else {
var userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
var userTemplate;
$.get(
{ url: "./template/template_user_list.html", async: false },
function (text) {
userTemplate = text;
}
);
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
});
let html = Mustache.render(userTemplate, {
userList: userList, userList: userList,
}); });
let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj);
if (userList.length == 0) {
const noResultMsg = $("<div/>", {
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
}
}
}; };
\ No newline at end of file
...@@ -9,7 +9,7 @@ let timeInterval = null; ...@@ -9,7 +9,7 @@ let timeInterval = null;
var backgroundFileName; var backgroundFileName;
var isIos; var isIos;
document.addEventListener('DOMContentLoaded', function() { document.addEventListener("DOMContentLoaded", function () {
var coviewApiActive = coview_api.Init({ var coviewApiActive = coview_api.Init({
testSTRParam: "param1", testSTRParam: "param1",
testNUMParam: 77, testNUMParam: 77,
...@@ -723,9 +723,7 @@ function applyForHostChange() { ...@@ -723,9 +723,7 @@ function applyForHostChange() {
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.setHostRequestFlg(HostRequestFlag.DOING); android.setHostRequestFlg(HostRequestFlag.DOING);
} else { } else {
webkit.messageHandlers.setHostRequestFlg.postMessage( webkit.messageHandlers.setHostRequestFlg.postMessage(HostRequestFlag.DOING);
HostRequestFlag.DOING
);
} }
fw.sendToMsg("others", "CHANGE_HOST_APPLY", { fw.sendToMsg("others", "CHANGE_HOST_APPLY", {
hostId: CHAT.globalLoginParameter.loginId, hostId: CHAT.globalLoginParameter.loginId,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment