Commit 00c4c2ac by Kim Peace

Added chat-db

parent 25a58f71
......@@ -262,8 +262,8 @@ CHAT_DB.searchMessages = function (keyword, userList) {
if (CHAT_UTIL.isIOS()) {
return JSON.parse(
callNativeApp(NATIVE_KEY_IOS.searchMessages, {
keyWord: keyword,
userList: userList,
"keyWord": keyword,
"userList": userList,
})
);
} else if (CHAT_UTIL.isAndroid()) {
......
// 名前空間
var CHAT = {};
// test comment
//招待するメンバーを保存する変数
CHAT.globalSelectedUserList = new Array();
CHAT.globalIsInvite = false;
......@@ -20,8 +20,8 @@ CHAT.saveRoomInfo = function (roomId, roomName) {
CHAT.globalLoginParameter.roomName = roomName;
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.roomInfosaveMessageHandlerId.postMessage({
roomId: roomId,
roomName: roomName,
"roomId": roomId,
"roomName": roomName,
});
} else if (CHAT_UTIL.isAndroid()) {
if (roomId == undefined && roomName == undefined) {
......@@ -376,6 +376,7 @@ getLoginParameter = function (
CHAT_UI.dismissLoadingIndicator();
};
// for android native call
CHAT.leaveRoom = function () {
socket.emit("leaveRoom", function () {});
};
......@@ -575,15 +576,9 @@ document.addEventListener("DOMContentLoaded", function () {
let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val();
$(".overlay_src_msg").empty();
var checkedUserList = [];
$(".img_wrap.filter").each(function (user) {
var selectedUser = $(".img_wrap.filter")[user];
checkedUserList.push($(selectedUser).data("user-id"));
});
if (keyword.length == 1) {
return;
}
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
let checkedUserList = getCheckedUserList();
if (keyword.length == 1) { return; }
const messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
var userMessageTemplate = getTemplate(TemplateURL.USER_MESSAGE);
var myMessageTemplate = getTemplate(TemplateURL.MY_MESSAGE);
......@@ -631,66 +626,94 @@ 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) {
$(".overlay_src_msg").empty();
const overlayMessage = $(".overlay_src_msg");
overlayMessage.empty();
rooms = CHAT_DB.getRoomList(ChatRoomType.ALL, keyword);
let roomListTitle = getLocalizedString("room_search_placeholder");
$("#chatTitle").text(roomListTitle);
var template = getTemplate(TemplateURL.ROOM_LIST);
rooms.forEach(function (room) {
room.profileImagePath = ASSET_PATH + "images/user-profile.png";
if (room.message) {
room.message = room.message.toString();
const roomMessage = getRoomMessage(room.message);
const displayMessage = getDisplayMessage(room.messageType, roomMessage);
let html = renderRoom(template, room, displayMessage);
// Click event
let obj = jQuery.parseHTML(html);
overlayMessage.append(obj);
});
if (rooms.length == 0) {
const noResultMsg = getNoResultMessage();
overlayMessage.append(noResultMsg);
}
};
var getRoomMessage = function (message) {
if (message) {
return message.toString();
} else {
room.message = getLocalizedString("noMessages");
return getLocalizedString("noMessages");
}
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 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);
});
var thumbnailCount =
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(", ");
}
let html = Mustache.render(template, {
return 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
: "",
lastMessage: displayMessage,
time: time,
unreadMsgCnt: room.unreadCount == 0 ? "" : room.unreadCount,
userCnt: room.attendUsers.length + 1,
attendUsers: room.attendUsers,
});
// Click event
let obj = jQuery.parseHTML(html);
$(".overlay_src_msg").append(obj);
});
if (rooms.length == 0) {
const noResultMsg = getNoResultMessage();
$(".overlay_src_msg").append(noResultMsg);
}
};
// メッセージ検索
......@@ -698,7 +721,7 @@ CHAT.searchMessage = function (keyword, workVal) {
$(".overlay_src_msg").empty();
var checkedUserList = [];
$(".img_wrap.filter").each(function (user) {
var selectedUser = $(".img_wrap.filter")[user];
const selectedUser = $(".img_wrap.filter")[user];
checkedUserList.push($(selectedUser).data("user-id"));
});
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
......
......@@ -154,8 +154,8 @@ document.addEventListener("DOMContentLoaded", function () {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinChangedCollaboration.postMessage({
joinCollaborationType: joinCollaborationType,
meetingId: data.payload.newMeetingId,
"joinCollaborationType": joinCollaborationType,
"meetingId": data.payload.newMeetingId,
});
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
webkit.messageHandlers.joinMeetingRoom.postMessage(
......@@ -539,8 +539,8 @@ function changeCollaboration(changeCollaborationType) {
penOff();
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.changeCollaboration.postMessage({
changeCollaborationType: changeCollaborationType,
meetingId: newMeetingId,
"changeCollaborationType": changeCollaborationType,
"meetingId": newMeetingId,
});
} else if (CHAT_UTIL.isAndroid()) {
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