Commit 00c4c2ac by Kim Peace

Added chat-db

parent 25a58f71
...@@ -262,8 +262,8 @@ CHAT_DB.searchMessages = function (keyword, userList) { ...@@ -262,8 +262,8 @@ CHAT_DB.searchMessages = function (keyword, userList) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse( return JSON.parse(
callNativeApp(NATIVE_KEY_IOS.searchMessages, { callNativeApp(NATIVE_KEY_IOS.searchMessages, {
keyWord: keyword, "keyWord": keyword,
userList: userList, "userList": userList,
}) })
); );
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
......
// 名前空間 // 名前空間
var CHAT = {}; var CHAT = {};
// test comment
//招待するメンバーを保存する変数 //招待するメンバーを保存する変数
CHAT.globalSelectedUserList = new Array(); CHAT.globalSelectedUserList = new Array();
CHAT.globalIsInvite = false; CHAT.globalIsInvite = false;
...@@ -20,8 +20,8 @@ CHAT.saveRoomInfo = function (roomId, roomName) { ...@@ -20,8 +20,8 @@ CHAT.saveRoomInfo = function (roomId, roomName) {
CHAT.globalLoginParameter.roomName = roomName; CHAT.globalLoginParameter.roomName = roomName;
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.roomInfosaveMessageHandlerId.postMessage({ webkit.messageHandlers.roomInfosaveMessageHandlerId.postMessage({
roomId: roomId, "roomId": roomId,
roomName: roomName, "roomName": roomName,
}); });
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
if (roomId == undefined && roomName == undefined) { if (roomId == undefined && roomName == undefined) {
...@@ -376,6 +376,7 @@ getLoginParameter = function ( ...@@ -376,6 +376,7 @@ getLoginParameter = function (
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}; };
// for android native call
CHAT.leaveRoom = function () { CHAT.leaveRoom = function () {
socket.emit("leaveRoom", function () {}); socket.emit("leaveRoom", function () {});
}; };
...@@ -575,15 +576,9 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -575,15 +576,9 @@ document.addEventListener("DOMContentLoaded", function () {
let workVal = ""; let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val(); var keyword = $('.chat_room_src_form input[type="search"]').val();
$(".overlay_src_msg").empty(); $(".overlay_src_msg").empty();
var checkedUserList = []; let checkedUserList = getCheckedUserList();
$(".img_wrap.filter").each(function (user) { if (keyword.length == 1) { return; }
var selectedUser = $(".img_wrap.filter")[user]; const messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
checkedUserList.push($(selectedUser).data("user-id"));
});
if (keyword.length == 1) {
return;
}
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE); var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE); var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
...@@ -631,74 +626,102 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -631,74 +626,102 @@ document.addEventListener("DOMContentLoaded", function () {
}); });
}); });
var getCheckedUserList = function () {
let checkedUserList = [];
$(".img_wrap.filter").each(function (user) {
const selectedUser = $(".img_wrap.filter")[user];
checkedUserList.push($(selectedUser).data("user-id"));
});
return checkedUserList;
};
// チャットルーム検索 // チャットルーム検索
CHAT.searchRoom = function (keyword, rooms) { CHAT.searchRoom = function (keyword, rooms) {
$(".overlay_src_msg").empty(); const overlayMessage = $(".overlay_src_msg");
overlayMessage.empty();
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 = getTemplate(TemplateURL.ROOM_LIST); var template = getTemplate(TemplateURL.ROOM_LIST);
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) { const roomMessage = getRoomMessage(room.message);
room.message = room.message.toString(); const displayMessage = getDisplayMessage(room.messageType, roomMessage);
} else {
room.message = getLocalizedString("noMessages"); let html = renderRoom(template, room, displayMessage);
}
var displayMsg;
if (
room.messageType == MessageType.TEXT ||
room.messageType == MessageType.SYSTEM
)
displayMsg = room.message;
if (room.messageType == MessageType.IMAGE)
displayMsg = getLocalizedString("image");
if (room.messageType == MessageType.VIDEO)
displayMsg = getLocalizedString("video");
if (room.messageType == MessageType.TEXT) displayMsg = room.message;
if (room.messageType == MessageType.COMMUNICATIONSTART)
displayMsg = getLocalizedString("collaboration_start");
if (room.messageType == MessageType.COMMUNICATIONEND)
displayMsg = getLocalizedString("collaboration_end");
var attendUserName = [];
room.attendUsers.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
attendUserName.push(user.shopMemberName);
});
var thumbnailCount =
room.attendUsers.length > 4 ? 4 : room.attendUsers.length;
if (room.chatRoomName == "") {
room.chatRoomName = attendUserName.join(", ");
}
let html = Mustache.render(template, {
thumbnailCount: thumbnailCount,
roomName: room.chatRoomName,
roomId: room.chatRoomId,
profileImage: room.profileImagePath,
lastMessage: displayMsg,
time: room.insertDate
? CHAT_UTIL.formatDate(room.insertDate).createdAt
: "",
unreadMsgCnt: room.unreadCount == 0 ? "" : room.unreadCount,
userCnt: room.attendUsers.length + 1,
attendUsers: room.attendUsers,
});
// Click event // Click event
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj); overlayMessage.append(obj);
}); });
if (rooms.length == 0) { if (rooms.length == 0) {
const noResultMsg = getNoResultMessage(); const noResultMsg = getNoResultMessage();
$(".overlay_src_msg").append(noResultMsg); overlayMessage.append(noResultMsg);
}
};
var getRoomMessage = function (message) {
if (message) {
return message.toString();
} else {
return getLocalizedString("noMessages");
} }
}; };
var getDisplayMessage = function (messageType, roomMessage) {
switch (messageType) {
case MessageType.TEXT:
return roomMessage;
case MessageType.SYSTEM:
return roomMessage;
case MessageType.IMAGE:
return getLocalizedString("image");
case MessageType.VIDEO:
return getLocalizedString("video");
case MessageType.COMMUNICATIONSTART:
return getLocalizedString("collaboration_start");
case MessageType.COMMUNICATIONEND:
return getLocalizedString("collaboration_end");
default:
return "";
}
};
var renderRoom = function (template, room, displayMessage) {
var attendUserName = [];
room.attendUsers.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
attendUserName.push(user.shopMemberName);
});
const thumbnailCount =
room.attendUsers.length > 4 ? 4 : room.attendUsers.length;
const time = room.insertDate
? CHAT_UTIL.formatDate(room.insertDate).createdAt
: "";
if (room.chatRoomName == "") {
room.chatRoomName = attendUserName.join(", ");
}
return Mustache.render(template, {
thumbnailCount: thumbnailCount,
roomName: room.chatRoomName,
roomId: room.chatRoomId,
profileImage: room.profileImagePath,
lastMessage: displayMessage,
time: time,
unreadMsgCnt: room.unreadCount == 0 ? "" : room.unreadCount,
userCnt: room.attendUsers.length + 1,
attendUsers: room.attendUsers,
});
};
// メッセージ検索 // メッセージ検索
CHAT.searchMessage = function (keyword, workVal) { CHAT.searchMessage = function (keyword, workVal) {
$(".overlay_src_msg").empty(); $(".overlay_src_msg").empty();
var checkedUserList = []; var checkedUserList = [];
$(".img_wrap.filter").each(function (user) { $(".img_wrap.filter").each(function (user) {
var selectedUser = $(".img_wrap.filter")[user]; const selectedUser = $(".img_wrap.filter")[user];
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(","));
......
...@@ -154,8 +154,8 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -154,8 +154,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinChangedCollaboration.postMessage({ webkit.messageHandlers.joinChangedCollaboration.postMessage({
joinCollaborationType: joinCollaborationType, "joinCollaborationType": joinCollaborationType,
meetingId: data.payload.newMeetingId, "meetingId": data.payload.newMeetingId,
}); });
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) { if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
webkit.messageHandlers.joinMeetingRoom.postMessage( webkit.messageHandlers.joinMeetingRoom.postMessage(
...@@ -539,8 +539,8 @@ function changeCollaboration(changeCollaborationType) { ...@@ -539,8 +539,8 @@ function changeCollaboration(changeCollaborationType) {
penOff(); penOff();
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.changeCollaboration.postMessage({ webkit.messageHandlers.changeCollaboration.postMessage({
changeCollaborationType: changeCollaborationType, "changeCollaborationType": changeCollaborationType,
meetingId: newMeetingId, "meetingId": newMeetingId,
}); });
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
android.changeCollaboration(changeCollaborationType, newMeetingId); android.changeCollaboration(changeCollaborationType, newMeetingId);
......
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