Commit c886b040 by Kim Peace

Unified common js logics

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