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 }, resolve(text);
function (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 = searchInput.val();
var keyword = $('#archive .search_form input[type="search"]').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,20 +24,18 @@ CHAT_ADD_USER.searchUser = function (keyword) { ...@@ -23,20 +24,18 @@ 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) { }
const noResultMessage = getNoResultMessage(); // Set NoResult
overlayMessage.append(noResultMessage); if (hasNoData) {
} const noResultMessage = getNoResultMessage();
overlayMessage.append(noResultMessage);
} }
}; };
...@@ -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 = {};
......
...@@ -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) {
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,
});
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj); overlayMessage.append(obj);
if (groupList.length == 0 && userList.length == 0) { hasNoData = groupList.length == 0 && userList.length == 0;
const noResultMsg = $("<div/>", { //連絡先画面
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} //連絡先画面
} else { } else {
var userList = CHAT_DB.getMyGroupShopMemberByName(keyword); const userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
var userTemplate; searchUserData();
$.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) {
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,
});
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj); $(".overlay_src_msg").html(obj);
if (userList.length == 0) {
const noResultMsg = $("<div/>", { hasNoData = userList.length == 0;
width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
}
} }
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) { ...@@ -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) {
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;
}
});
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#contact .search_form input[type="search"]').on( bindiOSKeyBoardEvent();
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) {
var keyword = $('#contact .search_form input[type="search"]').val();
CONTACT.searchUser(keyword);
}
}
);
}); });
// ユーザー検索 // ユーザー検索
CONTACT.searchUser = function (keyword) { CONTACT.searchUser = function (keyword) {
var groupList; const overlayMessage = $(".overlay_src_msg");
$(".overlay_src_msg").empty(); const isAllGroup = $("#tabAllGroup").is(":checked");
var isAllGroup = $("#tabAllGroup").is(":checked"); let hasNoData = false;
overlayMessage.empty();
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
//グループデータ検索 //グループデータ検索
groupList = CHAT_DB.getGroupByName(keyword); const groupList = CHAT_DB.getGroupByName(keyword);
var groupTemplate; groupDataSearch(groupList);
$.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);
});
//ユーザデータ検索 //ユーザデータ検索
var userList = CHAT_DB.getAllGroupShopMemberByName(keyword); const userList = CHAT_DB.getAllGroupShopMemberByName(keyword);
var userTemplate; userDataSearch(userList);
$.get(
{ url: "./template/template_user_list.html", async: false }, hasNoData = userList.length == 0 && groupList.length == 0;
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);
}
//連絡先画面 //連絡先画面
} else { } else {
var userList = CHAT_DB.getMyGroupShopMemberByName(keyword); const userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
var userTemplate; userDataSearch(userList);
$.get(
{ url: "./template/template_user_list.html", async: false }, hasNoData = userList.length == 0;
function (text) { }
userTemplate = text;
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); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").html(obj); $(".overlay_src_msg").append(obj);
if (userList.length == 0) { });
const noResultMsg = $("<div/>", { };
width: "auto",
style: "text-align: center", var renderGroupList = function (url, groupName, groupID, isFavorite) {
}); return Mustache.render(url, {
noResultMsg.append(getLocalizedString("noResult")); name: groupName,
$(".overlay_src_msg").append(noResultMsg); 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; ...@@ -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