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()) {
......
// New Room
// チャットルーム生成ボタン処理
$("#createChatRoom").on("click", function () {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let isInvite = false;
CHAT.globalIsInvite = isInvite;
socket.emit("getGroupList", isInvite);
});
// Room Delete
// チャットルーム削除ボタン処理
$("#roomDeleteButton").on("click", function (e) {
if ($(".deleteBox").is(":visible")) {
// チャットルーム削除アイコンが表示されている時、ブラインド処理を行う
$(".deleteBox")
.finish()
.show()
.fadeTo("slow", 0, function () {
$(this).hide();
});
// チャットリストについてクリックイベントを与える
$(".chat_list").off("click");
$(".chat_list:not(.active_chat)").on("click", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let roomId = $(this).data("roomId");
let roomName = $(this).data("roomname");
socket.emit("joinRoom", roomId, roomName, function () {
$("#messages").html("");
$(".titleRoomName").text(roomName).data("roomName", roomName);
$("#pills-chat-tab").tab("show");
$("#message-search").attr(
"placeholder",
getLocalizedString("chat_search_placeholder")
);
});
});
let roomListTitle = getLocalizedString("roomListTitle");
$(".titleRoomName").text(roomListTitle);
$(".chat_list.active_chat").on("click", function (e) {
$("#pills-chat-tab").tab("show");
});
} else {
// チャットルーム削除アイコンが表示されていない場合、表示する
$(".deleteBox").finish().hide().fadeTo("slow", 1).show();
// #36129に対応
let deleteRoomTitle = getLocalizedString("deleteRoomTitle");
$(".titleRoomName").text(deleteRoomTitle);
// 重複処理を防ぐためにチャットリストのクリックイベントを消す
$(".chat_list").off("click");
// チャットルームの削除アイコンにクリックイベントを与える
$(".deleteBox").off("click");
$(".deleteBox").on("click", function (e) {
// #36174
let roomId = $(this).data("roomId");
let activeRoom = $(this).data("activeRoom");
$("#roomDeleteTitle").text(getLocalizedString("roomDeleteTitle"));
$("#roomDelete").text(getLocalizedString("roomDelete"));
$("#cancelTitle").text(getLocalizedString("cancelTitle"));
// #36128
$("#roomDeleteConfirm")
.appendTo("body")
.modal({
backdrop: "static",
keyboard: false,
})
.on("click", "#roomDelete", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// 現在接続されているチャットルームを離れるとメッセージテップを初期化する
if (activeRoom) {
$("#messages").html("");
CHAT.saveRoomInfo("", "");
}
// チャットルームから退場する
socket.emit("exitRoom", roomId);
// #36129に対応
let roomListTitle = getLocalizedString("roomListTitle");
$(".titleRoomName").text(roomListTitle);
});
});
}
});
$("#room-search").on("input", function (event) {
if ($("#room-search").val().length > 0) {
// 検索結果が有る場合、結果を表示する
socket.emit("roomSearch", encodeURIComponent($("#room-search").val()));
} else {
if (IS_ONLINE == "true") {
if (typeof android != "undefined") {
android.updateRoomList();
} else {
webkit.messageHandlers.updateRoomList.postMessage({});
}
CHAT_UI.refreshRoomList(ChatRoomType.DM);
CHAT_UI.dismissLoadingIndicator();
}
}
});
//メッセージ送信
$("#messageInput").on("keypress", function (event) {
if (event.which == 13) {
// Enterキーの処理
$("#messageSend").click();
}
});
// 写真アップロード
$("#imageInputButton").on("click", function () {
$("#imageInputTag").click();
});
// 動画アップロード
$("#videoUploadButton").on("click", function () {
$("#videoInputTag").click();
});
$("#imageInputTag").on("change", function () {
$("#image-form").submit();
// reset the value of form
$("#imageInputTag").val("");
});
$("#videoInputTag").on("change", function () {
$("#video-form").submit();
// reset the value of form
$("#videoInputTag").val("");
});
$("#image-form").on("submit", function (e) {
e.preventDefault();
const imageInputTag = $("#imageInputTag");
const file = imageInputTag.prop("files")[0];
if (file) {
$(".overlay").addClass("active undismissable");
$(".loader").addClass("active");
CHAT_UI.showLoadingIndicator();
var fd = new FormData($(this)[0]);
console.log($(this)[0]);
//画像の大きさが500pixelより大きかったら、thumbnailを生成
CHAT.createThumbnailAndUpload(
file,
function (resizeFile, thumbnailCreated) {
if (resizeFile && thumbnailCreated) {
//ただ、画像の大きさが500pixel以下の場合はthumbnailは生成されない
fd.append("thumb", resizeFile);
}
// イメージをアップロード
CHAT.uploadImage(fd);
}
);
}
});
$("#video-form").on("submit", function (e) {
e.preventDefault();
const videoInputTag = $("#videoInputTag");
const file = videoInputTag.prop("files")[0];
if (file) {
$(".overlay").addClass("active undismissable");
$(".loader").addClass("active");
CHAT_UI.showLoadingIndicator();
var fd = new FormData($(this)[0]);
if (!file.type.includes("image")) {
// video 保存
// CHAT.createVideoThumbnailAndUpload(file, function(resizeFile, thumbnailCreated) {
// if(resizeFile && thumbnailCreated) {
// //ただ、画像の大きさが500pixel以下の場合はthumbnailは生成されない
// fd.append('thumb', resizeFile)
// }
// CHAT.uploadImage(fd);
// })
CHAT.uploadImage(fd);
return;
}
}
});
$("#message-search").on("input", function (event) {
// チャットキーワードを入力するとページ内にある単語をハイライトする。(mark.js 使用)
if ($(this).val()) {
$(".message_content").unmark();
$(".message_content").mark($(this).val());
if ($("[data-markjs=true]").length > 0) {
// マーキングされている単語があった場合、最後の単語にスクロールを移動する。
CHAT_UI.scrollToLastMarkedUnseen($(this).val());
} else {
// マーキングされている単語がない場合、下段にスクロールする。
CHAT_UI.scrollToBottom();
}
} else {
// チャットキーワードが空欄になるとマーキングを解除し、下段にスクロールする。
$(".message_content").unmark();
CHAT_UI.scrollToBottom();
}
});
//次のマーキングされた単語にスクロールを移動する。
$("#pre-search").on("click", function (event) {
CHAT_UI.scrollToLastMarkedUnseen(jQuery("#message-search").val());
});
// Exit Room
$("#exitRoom").on("click", function (event) {
// 36174
$("#exitRoomTitle").text(getLocalizedString("exitRoomTitle"));
$("#exitRoomOk").text(getLocalizedString("yesTitle"));
$("#noExit").text(getLocalizedString("cancelTitle"));
$("#exitRoomConfirm")
.appendTo("body")
.modal({
backdrop: "static",
keyboard: false,
})
.on("click", "#exitRoomOk", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// チャットルームから退場する
socket.emit("exitRoom");
$("#dismiss").click();
CHAT.saveRoomInfo("", "");
});
});
// Side Bar
$("#sidebarCollapse").on("click", function () {
// open sidebar
$("#sidebar").addClass("active");
// fade in the overlay
$(".overlay").addClass("active");
$(".collapse.in").toggleClass("in");
$("a[aria-expanded=true]").attr("aria-expanded", "false");
});
$("#dismiss, .overlay").on("click", function () {
// hide sidebar
$("#sidebar").removeClass("active");
// hide overlay if dismissable
$(".overlay:not(.undismissable)").removeClass("active");
});
//Invite User
//招待ボタンを押すとグループリストを持ってくる。(ボタンを動的に追加して微動作中)
$("#addUser").on("click", function (event) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let isInvite = true;
CHAT.globalIsInvite = isInvite;
socket.emit("getGroupList", isInvite);
});
//グループ画面での検索
$("#groupListKeyword").on("input", function (event) {
// data-name値で当該キーワードが入っているグループのみを表示する。
if ($(this).val()) {
$('.group_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.group_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".group_list").show();
}
});
$("#userListKeyword").on("input", function (event) {
// data-name値で当該キーワードが入っているユーザーのみを表示する。
if ($(this).val()) {
$('.user_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.user_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".user_list").show();
}
});
$("#selectListKeyword").on("input", function (event) {
if ($(this).val()) {
$('.select_user_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.select_user_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".select_user_list").show();
}
});
$("#contactButton").on("click", function (event) {
CHAT_UI.refreshContactScreen();
});
$("#chatButton").on("click", function (event) {
CHAT_UI.refreshRoomList(ChatRoomType.DM);
});
$("#tabDM").on("click", function (e) {
CHAT_UI.refreshRoomList(ChatRoomType.DM);
});
$("#tabGroup").on("click", function (e) {
CHAT_UI.refreshRoomList(ChatRoomType.GROUP);
});
$("#tabAllGroup").on("click", function (e) {
CHAT_UI.refreshAllGroupSearch("0");
});
$("#tabMyGroup").on("click", function (e) {
$("#contactSearch").attr("placeholder", getLocalizedString("userSearch"));
CHAT_UI.refreshContactScreen();
});
$("#tabMyGroupOnMakeRoom").on("click", function (e) {
CHAT_UI.refreshMyGroupForMakeRoom();
});
$("#tabAllGroupOnMakeRoom").on("click", function (e) {
CHAT_UI.refreshAllGroupForMakeRoom("0");
});
$("#tabMyGroupOnAddUser").on("click", function (e) {
CHAT_UI.refreshMyGroupForAddUser();
});
$("#tabAllGroupOnAddUser").on("click", function (e) {
CHAT_UI.refreshAllGroupForAddUser("0");
});
$("#tabMyGroupOnAddUserInCollaboration").on("click", function (e) {
CHAT_UI.refreshMyGroupForAddUserInCollaboration();
});
$("#tabAllGroupOnAddUserInCollaboration").on("click", function (e) {
CHAT_UI.refreshAllGroupForAddUserInCollaboration("0");
});
$("#makeRoomConfirmBtn").on("click", function (e) {
if (typeof android != "undefined") {
android.saveSelectedUserList(CHAT.globalSelectedUserList.join(","));
} else {
webkit.messageHandlers.saveSelectedUserList.postMessage(
CHAT.globalSelectedUserList.join(",")
);
}
$("#makeRoomForm").submit();
});
$("#addUserConfirmBtn").on("click", function (e) {
if (typeof android != "undefined") {
android.saveSelectedUserList(CHAT.globalSelectedUserList.join(","));
} else {
webkit.messageHandlers.saveSelectedUserList.postMessage(
CHAT.globalSelectedUserList.join(",")
);
}
$("#addUserForm").submit();
});
CHAT_UI.joinCollaboration = function (collaborationType, meetingId = 0) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinCollaboration.postMessage({
"collaborationType": collaborationType,
"meetingId": meetingId,
});
} else if (CHAT_UTIL.isAndroid()) {
if (
collaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
return;
}
android.joinCollaboration(collaborationType, meetingId);
}
};
CHAT_UI.startCollaboration = function (collaborationType) {
if (CHAT_UTIL.isAndroid()) {
if (
collaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
return;
}
}
if ($(".collabo_area.start").length != 0) {
if (!confirm(getLocalizedString("already_exist_collaboration"))) {
CHAT_UI.dismissLoadingIndicator();
return;
}
socket.emit(
"createMessage",
{
text: DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL,
},
0
);
if (CHAT_UTIL.isIOS()) {
//TODO ルーム全協業終了API
} else if (CHAT_UTIL.isAndroid()) {
android.finishAllCollaboration();
}
}
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.startCollaboration.postMessage(collaborationType);
} else if (CHAT_UTIL.isAndroid()) {
android.startCollaboration(collaborationType);
}
};
CHAT_UI.refreshJoinedCollaboration = function (loginIdList) {
for (var count = 0; count < loginIdList.length; count++) {
loginIdList[count] = loginIdList[count].replaceAll(
globalUserInfo.shopName + "_",
""
);
}
CHAT_UI.showLoadingIndicator();
$("#collaboration_overlay_user_list").html("");
var joinedUserListTemplate;
$.get(
{ url: "./collaboration_overlay_user_list.html", async: false },
function (text) {
joinedUserListTemplate = text;
}
);
var joinedUserList = CHAT_DB.getUserListByLoginId(loginIdList);
var sortedUserList = new Array();
loginIdList.forEach(function (userId) {
joinedUserList.forEach(function (user) {
if (userId == user.loginId) {
sortedUserList.push(user);
}
});
});
sortedUserList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
});
let html = Mustache.render(joinedUserListTemplate, {
joinedUserList: sortedUserList,
});
let obj = jQuery.parseHTML(html);
$("#collaboration_overlay_user_list").append(obj);
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.refreshMyGroupForAddUserInCollaboration = function () {
if (CHAT.globalSelectedUserList.length > 0) {
$(".select_member_num").text(CHAT.globalSelectedUserList.length);
} else {
$(".select_member_num").text("0");
}
$("#favoriteListForAddUserInCollaboration").html("");
$("#myGroupListForAddUserInCollaboration").html("");
$("#tabMyGroupOnAddUserInCollaboration").prop("checked", true);
// グループの様式を読み込む
var groupTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_LIST_IN_COLLABORATION
);
// ユーザの様式を読み込む
var userTemplate = getTemplate(
TemplateURL.ADD_USER_USER_LIST_IN_COLLABORATION
);
var groupUserTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_USER_LIST_IN_COLLABORATION
);
if (IS_ONLINE == "true") {
if (typeof android != "undefined") {
android.updateGroupInfo("0");
android.updateMyInfo();
android.updateGroupUser();
android.updateFavorite();
} else {
webkit.messageHandlers.updateGroupInfo.postMessage("0");
webkit.messageHandlers.updateMyInfo.postMessage({});
webkit.messageHandlers.updateGroupUser.postMessage({});
webkit.messageHandlers.updateFavorite.postMessage({});
}
}
//お気に入りグループ取得。
var favoriteGroupList = CHAT_DB.getFavoriteGroups();
favoriteGroupList.forEach(function (favoriteGroup) {
let html = Mustache.render(groupTemplate, {
name: favoriteGroup.groupName,
id: favoriteGroup.groupId,
});
let obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#favoriteListForAddUserInCollaboration").append(obj);
});
//お気に入りユーザ取得。
var favoriteUserList = CHAT_DB.getFavoriteUsersNotInRoom();
favoriteUserList.forEach(function (favoriteUser) {
favoriteUser.profileUrl = CHAT.getProfileImgUrl(favoriteUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == favoriteUser.shopMemberId;
});
if (findObj) {
favoriteUser.checked = "checked";
}
});
let html = Mustache.render(userTemplate, {
userList: favoriteUserList,
});
let obj = jQuery.parseHTML(html);
$("#favoriteListForAddUserInCollaboration").append(obj);
var myGroupList = CHAT_DB.getMyGroupUsersNotInRoom();
myGroupList.forEach(function (myGroup) {
myGroup.groupUserList.forEach(function (groupUser) {
groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == groupUser.shopMemberId;
});
if (findObj) {
groupUser.checked = "checked";
}
});
let html = Mustache.render(groupUserTemplate, {
groupName: myGroup.groupName,
groupUserList: myGroup.groupUserList,
});
let obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#myGroupListForAddUserInCollaboration").append(obj);
});
$("#addUserInCollaboration").modal("show");
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) {
var groupId = paramGroupId;
$(".content").removeClass("none");
$("#tabAllGroupOnAddUserInCollaboration").prop("checked", true);
//オンライン状態であればサーバから情報更新。
if (IS_ONLINE == "true") {
if (typeof android != "undefined") {
android.updateGroupInfo(groupId);
} else {
webkit.messageHandlers.updateGroupInfo.postMessage(groupId);
}
}
//画面エリアを初期化。
$("#parentGroupBtnForAddUserInCollaboration").off();
$("#rootGroupBtnForAddUserInCollaboration").off();
$("#childGroupListAreaForAddUserInCollaboration").html("");
$("#userInGroupListForAddUserInCollaboration").html("");
$("#groupPathAreaForAddUserInCollaboration").html("");
//DBからグループ情報を取得。
var result = CHAT_DB.getGroupInfoForAddUser(groupId);
//上位グループ、トップグループ遷移ボタンのイベント追加。
if (typeof result.parentGroupId !== "undefined") {
$("#parentGroupBtnForAddUserInCollaboration").on("click", function () {
CHAT_UI.refreshAllGroupForAddUserInCollaboration(result.parentGroupId);
});
}
if (typeof result.rootGroupId !== "undefined") {
if (paramGroupId == 0) {
groupId = result.rootGroupId;
}
$("#rootGroupBtnForAddUserInCollaboration").on("click", function () {
CHAT_UI.refreshAllGroupForAddUserInCollaboration(result.rootGroupId);
});
}
if (groupId == result.rootGroupId || paramGroupId == "0") {
$("#rootGroupAreaInCollaboration").addClass("none");
$("#parentGroupAreaInCollaboration").addClass("none");
} else {
$("#rootGroupAreaInCollaboration").removeClass("none");
$("#parentGroupAreaInCollaboration").removeClass("none");
}
//該当グループのパースを表示。
var groupPathTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_PATH_IN_COLLABORATION
);
var groupPathCount = 0;
result.groupPathList.forEach(function (groupPath) {
if (!(groupPathCount < result.groupPathList.length - 3)) {
let html = Mustache.render(groupPathTemplate, {
name: groupPath.groupName,
id: groupPath.groupId,
});
let obj = jQuery.parseHTML(html);
$("#groupPathAreaForAddUserInCollaboration").append(obj);
}
groupPathCount++;
});
//該当グループの下位グループ表示。
var groupTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_LIST_IN_COLLABORATION
);
result.childGroupList.forEach(function (childGroup) {
let html = Mustache.render(groupTemplate, {
name: childGroup.groupName,
id: childGroup.groupId,
});
let obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#childGroupListAreaForAddUserInCollaboration").append(obj);
});
//該当グループの所属ユーザを表示。
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) {
return shopMemberId == groupUser.shopMemberId;
});
if (findObj) {
groupUser.checked = "checked";
}
});
let html = Mustache.render(userTemplate, {
userList: result.groupUserList,
});
let obj = jQuery.parseHTML(html);
$("#userInGroupListForAddUserInCollaboration").append(obj);
};
CHAT_UI.makeNameCardInCollaboration = function (shopMemberId) {
if (CHAT.globalLoginParameter.shopMemberId == shopMemberId) {
return;
}
var nameCardInfo = CHAT_DB.getNameCardData(shopMemberId);
var namecardTemplate;
var changeHostTemplate;
$.get({ url: "./modal_collabo_profile.html", async: false }, function (text) {
namecardTemplate = text;
});
let isCollaborationHost = coview_api.getRoomUsers();
nameCardInfo.profileUrl = CHAT.getProfileImgUrl(nameCardInfo.profileUrl);
let whosHost = $("#collaboration_user_" + nameCardInfo.loginId).hasClass(
"host"
);
let namecardHtml = Mustache.render(namecardTemplate, {
shopMemberId: nameCardInfo.shopMemberId,
profileUrl: nameCardInfo.profileUrl,
loginId: nameCardInfo.loginId,
name: nameCardInfo.shopMemberName,
groupPathList: nameCardInfo.groupPathList,
isFavorite: nameCardInfo.isFavorite,
isHost: isCollaborationHost,
whosHost: whosHost,
});
let namecardObj = $(jQuery.parseHTML(namecardHtml)).on(
"click",
function () {}
);
$("#userProfileModalInCollaboration").html(namecardObj);
$("#userNameCardInCollaboration").modal("show");
};
CHAT_UI.removeFavoriteUserInCollaboration = function (shopMemberId) {
CHAT_UI.showLoadingIndicator();
$("#userNameCardInCollaboration").modal("hide");
var result;
if (typeof android != "undefined") {
result = android.removeFavoriteUser(shopMemberId);
} else {
result = CHAT_DB.removeFavoriteUser(shopMemberId);
}
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.insertFavoriteUserInCollaboration = function (shopMemberId) {
$("#userNameCardInCollaboration").modal("hide");
var result;
if (typeof android != "undefined") {
result = android.addFavoriteUser(shopMemberId);
} else {
result = CHAT_DB.addFavoriteUser(shopMemberId);
}
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.confirmInviteUserListInCollaboration = function () {
var selectedUsers = CHAT_DB.loadSelectedUsers();
if (selectedUsers != "") {
$("#selectedUserListinCollaboration").html("");
var selectedUserList = CHAT_DB.loadSelectedUsers();
selectedUserList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
});
var modalTemplate;
$.get(
{ url: "./modal_add_user_confirm.html", async: false },
function (text) {
modalTemplate = text;
}
);
let html = Mustache.render(modalTemplate, {
userList: selectedUserList,
});
let obj = jQuery.parseHTML(html);
$("#modal_add_user_confirm").html(obj);
$("#modalAddUserConfirm").modal("show");
} else {
}
$("#cancelAddUserBtn")
.off()
.on("click", function () {
console.log("cancelClick");
$("#modalAddUserConfirm").modal("hide");
$("#addUserInCollaboration").modal("show");
});
$("#addUserBtn")
.off()
.on("click", function () {
CHAT_UI.showLoadingIndicator();
let userIdList = new Array();
selectedUserList.forEach(function (user) {
userIdList.push(user.shopMemberId);
});
if (typeof android != "undefined") {
android.inviteCollaboration(
userIdList.join(","),
CHAT_UTIL.getCollaborationType(globalUserInfo.coWorkType)
);
} else {
webkit.messageHandlers.inviteCollaboration.postMessage({
"userIdList": userIdList.join(","),
"collaborationType": CHAT_UTIL.getCollaborationType(
globalUserInfo.coWorkType
),
});
}
$("#modalAddUserConfirm").modal("hide");
});
};
// 名前空間
var CHAT_UI = {};
includeJs("./js/chat-ui-clickEvents.js");
includeJs("./js/chat-ui-collaboration.js");
// Rotate
$(window).on("resize", function () {
if (CHAT_UTIL.isMobile()) {
......@@ -19,114 +22,6 @@ $(window).on("resize", function () {
}
});
// New Room
// チャットルーム生成ボタン処理
$("#createChatRoom").on("click", function () {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let isInvite = false;
CHAT.globalIsInvite = isInvite;
socket.emit("getGroupList", isInvite);
});
// Room Delete
// チャットルーム削除ボタン処理
$("#roomDeleteButton").on("click", function (e) {
if ($(".deleteBox").is(":visible")) {
// チャットルーム削除アイコンが表示されている時、ブラインド処理を行う
$(".deleteBox")
.finish()
.show()
.fadeTo("slow", 0, function () {
$(this).hide();
});
// チャットリストについてクリックイベントを与える
$(".chat_list").off("click");
$(".chat_list:not(.active_chat)").on("click", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let roomId = $(this).data("roomId");
let roomName = $(this).data("roomname");
socket.emit("joinRoom", roomId, roomName, function () {
$("#messages").html("");
$(".titleRoomName").text(roomName).data("roomName", roomName);
$("#pills-chat-tab").tab("show");
$("#message-search").attr(
"placeholder",
getLocalizedString("chat_search_placeholder")
);
});
});
let roomListTitle = getLocalizedString("roomListTitle");
$(".titleRoomName").text(roomListTitle);
$(".chat_list.active_chat").on("click", function (e) {
$("#pills-chat-tab").tab("show");
});
} else {
// チャットルーム削除アイコンが表示されていない場合、表示する
$(".deleteBox").finish().hide().fadeTo("slow", 1).show();
// #36129に対応
let deleteRoomTitle = getLocalizedString("deleteRoomTitle");
$(".titleRoomName").text(deleteRoomTitle);
// 重複処理を防ぐためにチャットリストのクリックイベントを消す
$(".chat_list").off("click");
// チャットルームの削除アイコンにクリックイベントを与える
$(".deleteBox").off("click");
$(".deleteBox").on("click", function (e) {
// #36174
let roomId = $(this).data("roomId");
let activeRoom = $(this).data("activeRoom");
$("#roomDeleteTitle").text(getLocalizedString("roomDeleteTitle"));
$("#roomDelete").text(getLocalizedString("roomDelete"));
$("#cancelTitle").text(getLocalizedString("cancelTitle"));
// #36128
$("#roomDeleteConfirm")
.appendTo("body")
.modal({
backdrop: "static",
keyboard: false,
})
.on("click", "#roomDelete", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// 現在接続されているチャットルームを離れるとメッセージテップを初期化する
if (activeRoom) {
$("#messages").html("");
CHAT.saveRoomInfo("", "");
}
// チャットルームから退場する
socket.emit("exitRoom", roomId);
// #36129に対応
let roomListTitle = getLocalizedString("roomListTitle");
$(".titleRoomName").text(roomListTitle);
});
});
}
});
$("#room-search").on("input", function (event) {
if ($("#room-search").val().length > 0) {
// 検索結果が有る場合、結果を表示する
socket.emit("roomSearch", encodeURIComponent($("#room-search").val()));
} else {
if (IS_ONLINE == "true") {
if (typeof android != "undefined") {
android.updateRoomList();
} else {
webkit.messageHandlers.updateRoomList.postMessage({});
}
CHAT_UI.refreshRoomList(ChatRoomType.DM);
CHAT_UI.dismissLoadingIndicator();
}
}
});
//上にスクロールすると新しいメッセージを呼ぶ処理。
$("#messages").scroll(function () {
if ($(this).scrollTop() === 0) {
......@@ -207,195 +102,6 @@ CHAT_UI.sendMessage = function (e) {
}
$(".message_input_form").focus();
};
//メッセージ送信
$("#messageInput").on("keypress", function (event) {
if (event.which == 13) {
// Enterキーの処理
$("#messageSend").click();
}
});
// 写真アップロード
$("#imageInputButton").on("click", function () {
$("#imageInputTag").click();
});
// 動画アップロード
$("#videoUploadButton").on("click", function () {
$("#videoInputTag").click();
});
$("#imageInputTag").on("change", function () {
$("#image-form").submit();
// reset the value of form
$("#imageInputTag").val("");
});
$("#videoInputTag").on("change", function () {
$("#video-form").submit();
// reset the value of form
$("#videoInputTag").val("");
});
$("#image-form").on("submit", function (e) {
e.preventDefault();
const imageInputTag = $("#imageInputTag");
const file = imageInputTag.prop("files")[0];
if (file) {
$(".overlay").addClass("active undismissable");
$(".loader").addClass("active");
CHAT_UI.showLoadingIndicator();
var fd = new FormData($(this)[0]);
console.log($(this)[0]);
//画像の大きさが500pixelより大きかったら、thumbnailを生成
CHAT.createThumbnailAndUpload(
file,
function (resizeFile, thumbnailCreated) {
if (resizeFile && thumbnailCreated) {
//ただ、画像の大きさが500pixel以下の場合はthumbnailは生成されない
fd.append("thumb", resizeFile);
}
// イメージをアップロード
CHAT.uploadImage(fd);
}
);
}
});
$("#video-form").on("submit", function (e) {
e.preventDefault();
const videoInputTag = $("#videoInputTag");
const file = videoInputTag.prop("files")[0];
if (file) {
$(".overlay").addClass("active undismissable");
$(".loader").addClass("active");
CHAT_UI.showLoadingIndicator();
var fd = new FormData($(this)[0]);
if (!file.type.includes("image")) {
// video 保存
// CHAT.createVideoThumbnailAndUpload(file, function(resizeFile, thumbnailCreated) {
// if(resizeFile && thumbnailCreated) {
// //ただ、画像の大きさが500pixel以下の場合はthumbnailは生成されない
// fd.append('thumb', resizeFile)
// }
// CHAT.uploadImage(fd);
// })
CHAT.uploadImage(fd);
return;
}
}
});
/* --------------------------------------------------- */
/* Nav Bar Functions */
/* --------------------------------------------------- */
$("#message-search").on("input", function (event) {
// チャットキーワードを入力するとページ内にある単語をハイライトする。(mark.js 使用)
if ($(this).val()) {
$(".message_content").unmark();
$(".message_content").mark($(this).val());
if ($("[data-markjs=true]").length > 0) {
// マーキングされている単語があった場合、最後の単語にスクロールを移動する。
CHAT_UI.scrollToLastMarkedUnseen($(this).val());
} else {
// マーキングされている単語がない場合、下段にスクロールする。
CHAT_UI.scrollToBottom();
}
} else {
// チャットキーワードが空欄になるとマーキングを解除し、下段にスクロールする。
$(".message_content").unmark();
CHAT_UI.scrollToBottom();
}
});
//次のマーキングされた単語にスクロールを移動する。
$("#pre-search").on("click", function (event) {
CHAT_UI.scrollToLastMarkedUnseen(jQuery("#message-search").val());
});
// Exit Room
$("#exitRoom").on("click", function (event) {
// 36174
$("#exitRoomTitle").text(getLocalizedString("exitRoomTitle"));
$("#exitRoomOk").text(getLocalizedString("yesTitle"));
$("#noExit").text(getLocalizedString("cancelTitle"));
$("#exitRoomConfirm")
.appendTo("body")
.modal({
backdrop: "static",
keyboard: false,
})
.on("click", "#exitRoomOk", function (e) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
// チャットルームから退場する
socket.emit("exitRoom");
$("#dismiss").click();
CHAT.saveRoomInfo("", "");
});
});
// Side Bar
$("#sidebarCollapse").on("click", function () {
// open sidebar
$("#sidebar").addClass("active");
// fade in the overlay
$(".overlay").addClass("active");
$(".collapse.in").toggleClass("in");
$("a[aria-expanded=true]").attr("aria-expanded", "false");
});
$("#dismiss, .overlay").on("click", function () {
// hide sidebar
$("#sidebar").removeClass("active");
// hide overlay if dismissable
$(".overlay:not(.undismissable)").removeClass("active");
});
//Invite User
//招待ボタンを押すとグループリストを持ってくる。(ボタンを動的に追加して微動作中)
$("#addUser").on("click", function (event) {
//loadingIndicatorを表示
CHAT_UI.showLoadingIndicator();
let isInvite = true;
CHAT.globalIsInvite = isInvite;
socket.emit("getGroupList", isInvite);
});
//グループ画面での検索
$("#groupListKeyword").on("input", function (event) {
// data-name値で当該キーワードが入っているグループのみを表示する。
if ($(this).val()) {
$('.group_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.group_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".group_list").show();
}
});
$("#userListKeyword").on("input", function (event) {
// data-name値で当該キーワードが入っているユーザーのみを表示する。
if ($(this).val()) {
$('.user_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.user_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".user_list").show();
}
});
$("#selectListKeyword").on("input", function (event) {
if ($(this).val()) {
$('.select_user_list:not([data-name*="' + $(this).val() + '" i])').hide();
$('.select_user_list[data-name*="' + $(this).val() + '" i]').show();
} else {
$(".select_user_list").show();
}
});
/* ---------------------------------------------------------------------- */
/* */
......@@ -437,7 +143,7 @@ $('a[data-toggle="pill"]').on("show.bs.tab", function (e) {
android.updateRoomList();
} else {
webkit.messageHandlers.updateRoomList.postMessage({
groupId: "0",
"groupId": "0",
});
}
});
......@@ -749,11 +455,11 @@ CHAT_UI.showConfirmView = function (isInvite) {
);
} else {
webkit.messageHandlers.createChatRoom.postMessage({
roomType: "1",
userIdList: userIdList.join(","),
roomName: newRoomName,
screenFlg: MakeRoomFlag.MAKE_ROOM,
isVoice: false,
"roomType": "1",
"userIdList": userIdList.join(","),
"roomName": newRoomName,
"screenFlg": MakeRoomFlag.MAKE_ROOM,
"isVoice": false,
});
}
......@@ -878,11 +584,11 @@ CHAT_UI.showConfirmView = function (isInvite) {
);
} else {
webkit.messageHandlers.createChatRoom.postMessage({
roomType: "1",
userIdList: userIdList.join(","),
roomName: newRoomName,
screenFlg: MakeRoomFlag.MAKE_ROOM,
isVoice: false,
"roomType": "1",
"userIdList": userIdList.join(","),
"roomName": newRoomName,
"screenFlg": MakeRoomFlag.MAKE_ROOM,
"isVoice": false,
});
}
}
......@@ -1154,13 +860,6 @@ CHAT_UI.waitForLoadingImage = function (div, callback) {
}
});
};
$("#contactButton").on("click", function (event) {
CHAT_UI.refreshContactScreen();
});
$("#chatButton").on("click", function (event) {
CHAT_UI.refreshRoomList(ChatRoomType.DM);
});
CHAT_UI.refreshContactScreen = function () {
CHAT_UI.showLoadingIndicator();
......@@ -1396,8 +1095,8 @@ CHAT_UI.joinRoom = function (roomId, roomName) {
}
} else {
webkit.messageHandlers.joinRoom.postMessage({
roomId: roomId,
roomName: roomName,
"roomId": roomId,
"roomName": roomName,
});
}
};
......@@ -1600,69 +1299,6 @@ CHAT_UI.loadMessages = function (roomId, roomName) {
$("#userSelectionDeleteBtn").hide();
};
$("#tabDM").on("click", function (e) {
CHAT_UI.refreshRoomList(ChatRoomType.DM);
});
$("#tabGroup").on("click", function (e) {
CHAT_UI.refreshRoomList(ChatRoomType.GROUP);
});
$("#tabAllGroup").on("click", function (e) {
CHAT_UI.refreshAllGroupSearch("0");
});
$("#tabMyGroup").on("click", function (e) {
$("#contactSearch").attr("placeholder", getLocalizedString("userSearch"));
CHAT_UI.refreshContactScreen();
});
$("#tabMyGroupOnMakeRoom").on("click", function (e) {
CHAT_UI.refreshMyGroupForMakeRoom();
});
$("#tabAllGroupOnMakeRoom").on("click", function (e) {
CHAT_UI.refreshAllGroupForMakeRoom("0");
});
$("#tabMyGroupOnAddUser").on("click", function (e) {
CHAT_UI.refreshMyGroupForAddUser();
});
$("#tabAllGroupOnAddUser").on("click", function (e) {
CHAT_UI.refreshAllGroupForAddUser("0");
});
$("#tabMyGroupOnAddUserInCollaboration").on("click", function (e) {
CHAT_UI.refreshMyGroupForAddUserInCollaboration();
});
$("#tabAllGroupOnAddUserInCollaboration").on("click", function (e) {
CHAT_UI.refreshAllGroupForAddUserInCollaboration("0");
});
$("#makeRoomConfirmBtn").on("click", function (e) {
if (typeof android != "undefined") {
android.saveSelectedUserList(CHAT.globalSelectedUserList.join(","));
} else {
webkit.messageHandlers.saveSelectedUserList.postMessage(
CHAT.globalSelectedUserList.join(",")
);
}
$("#makeRoomForm").submit();
});
$("#addUserConfirmBtn").on("click", function (e) {
if (typeof android != "undefined") {
android.saveSelectedUserList(CHAT.globalSelectedUserList.join(","));
} else {
webkit.messageHandlers.saveSelectedUserList.postMessage(
CHAT.globalSelectedUserList.join(",")
);
}
$("#addUserForm").submit();
});
CHAT_UI.roomDisplayOff = function () {
if (typeof android != "undefined") {
android.roomDisplayOff();
......@@ -1886,11 +1522,11 @@ CHAT_UI.startChat = function (userShopMemberId, userName) {
);
} else {
webkit.messageHandlers.createChatRoom.postMessage({
roomType: "1",
userIdList: userIdList.join(","),
roomName: newRoomName,
screenFlg: MakeRoomFlag.NAME_CARD,
isVoice: false,
"roomType": "1",
"userIdList": userIdList.join(","),
"roomName": newRoomName,
"screenFlg": MakeRoomFlag.NAME_CARD,
"isVoice": false,
});
}
};
......@@ -1912,11 +1548,11 @@ CHAT_UI.startVoice = function (userShopMemberId, userName) {
);
} else {
webkit.messageHandlers.createChatRoom.postMessage({
roomType: "1",
userIdList: userIdList.join(","),
roomName: newRoomName,
screenFlg: MakeRoomFlag.NAME_CARD,
isVoice: true,
"roomType": "1",
"userIdList": userIdList.join(","),
"roomName": newRoomName,
"screenFlg": MakeRoomFlag.NAME_CARD,
"isVoice": true,
});
}
CHAT_UI.startCollaboration(COLLABORATION_TYPE.AUDIO);
......@@ -2414,11 +2050,11 @@ CHAT_UI.showMakeRoomConfirmView = function () {
);
} else {
webkit.messageHandlers.createChatRoom.postMessage({
roomType: "1",
userIdList: userIdList.join(","),
roomName: newRoomName,
screenFlg: MakeRoomFlag.MAKE_ROOM,
isVoice: false,
"roomType": "1",
"userIdList": userIdList.join(","),
"roomName": newRoomName,
"screenFlg": MakeRoomFlag.MAKE_ROOM,
"isVoice": false,
});
}
} else if (
......@@ -2498,11 +2134,11 @@ CHAT_UI.showMakeRoomConfirmView = function () {
);
} else {
webkit.messageHandlers.createChatRoom.postMessage({
roomType: "1",
userIdList: userIdList.join(","),
roomName: trimmedRoomName,
screenFlg: MakeRoomFlag.MAKE_ROOM,
isVoice: false,
"roomType": "1",
"userIdList": userIdList.join(","),
"roomName": trimmedRoomName,
"screenFlg": MakeRoomFlag.MAKE_ROOM,
"isVoice": false,
});
}
}
......@@ -2537,7 +2173,7 @@ CHAT_UI.showAddUserConfirmView = function () {
android.inviteUsers(userIdList.join(","), false);
} else {
webkit.messageHandlers.inviteUsers.postMessage({
userIdList: userIdList.join(","),
"userIdList": userIdList.join(","),
});
}
});
......@@ -2783,416 +2419,10 @@ CHAT_UI.offlineHandler = function (e) {
CHAT_UI.displayExistRoom = function (roomId) {
if (confirm("error_already_exist_same_user")) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinRoom.postMessage({ roomId: roomId });
webkit.messageHandlers.joinRoom.postMessage({ "roomId": roomId });
} else if (CHAT_UTIL.isAndroid()) {
android.joinRoom(roomId, "");
}
}
return;
};
CHAT_UI.joinCollaboration = function (collaborationType, meetingId = 0) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinCollaboration.postMessage({
collaborationType: collaborationType,
meetingId: meetingId,
});
} else if (CHAT_UTIL.isAndroid()) {
if (
collaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
return;
}
android.joinCollaboration(collaborationType, meetingId);
}
};
CHAT_UI.startCollaboration = function (collaborationType) {
if (CHAT_UTIL.isAndroid()) {
if (
collaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
return;
}
}
if ($(".collabo_area.start").length != 0) {
if (!confirm(getLocalizedString("already_exist_collaboration"))) {
CHAT_UI.dismissLoadingIndicator();
return;
}
socket.emit(
"createMessage",
{
text: DATA_MESSAGE_SCHEME + FINISH_ALL_COLLABORATION_SIGNAL,
},
0
);
if (CHAT_UTIL.isIOS()) {
//TODO ルーム全協業終了API
} else if (CHAT_UTIL.isAndroid()) {
android.finishAllCollaboration();
}
}
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.startCollaboration.postMessage(collaborationType);
} else if (CHAT_UTIL.isAndroid()) {
android.startCollaboration(collaborationType);
}
};
CHAT_UI.refreshJoinedCollaboration = function (loginIdList) {
for (var count = 0; count < loginIdList.length; count++) {
loginIdList[count] = loginIdList[count].replaceAll(
globalUserInfo.shopName + "_",
""
);
}
CHAT_UI.showLoadingIndicator();
$("#collaboration_overlay_user_list").html("");
var joinedUserListTemplate;
$.get(
{ url: "./collaboration_overlay_user_list.html", async: false },
function (text) {
joinedUserListTemplate = text;
}
);
var joinedUserList = CHAT_DB.getUserListByLoginId(loginIdList);
var sortedUserList = new Array();
loginIdList.forEach(function (userId) {
joinedUserList.forEach(function (user) {
if (userId == user.loginId) {
sortedUserList.push(user);
}
});
});
sortedUserList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
});
let html = Mustache.render(joinedUserListTemplate, {
joinedUserList: sortedUserList,
});
let obj = jQuery.parseHTML(html);
$("#collaboration_overlay_user_list").append(obj);
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.refreshMyGroupForAddUserInCollaboration = function () {
if (CHAT.globalSelectedUserList.length > 0) {
$(".select_member_num").text(CHAT.globalSelectedUserList.length);
} else {
$(".select_member_num").text("0");
}
$("#favoriteListForAddUserInCollaboration").html("");
$("#myGroupListForAddUserInCollaboration").html("");
$("#tabMyGroupOnAddUserInCollaboration").prop("checked", true);
// グループの様式を読み込む
var groupTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_LIST_IN_COLLABORATION
);
// ユーザの様式を読み込む
var userTemplate = getTemplate(
TemplateURL.ADD_USER_USER_LIST_IN_COLLABORATION
);
var groupUserTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_USER_LIST_IN_COLLABORATION
);
if (IS_ONLINE == "true") {
if (typeof android != "undefined") {
android.updateGroupInfo("0");
android.updateMyInfo();
android.updateGroupUser();
android.updateFavorite();
} else {
webkit.messageHandlers.updateGroupInfo.postMessage("0");
webkit.messageHandlers.updateMyInfo.postMessage({});
webkit.messageHandlers.updateGroupUser.postMessage({});
webkit.messageHandlers.updateFavorite.postMessage({});
}
}
//お気に入りグループ取得。
var favoriteGroupList = CHAT_DB.getFavoriteGroups();
favoriteGroupList.forEach(function (favoriteGroup) {
let html = Mustache.render(groupTemplate, {
name: favoriteGroup.groupName,
id: favoriteGroup.groupId,
});
let obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#favoriteListForAddUserInCollaboration").append(obj);
});
//お気に入りユーザ取得。
var favoriteUserList = CHAT_DB.getFavoriteUsersNotInRoom();
favoriteUserList.forEach(function (favoriteUser) {
favoriteUser.profileUrl = CHAT.getProfileImgUrl(favoriteUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == favoriteUser.shopMemberId;
});
if (findObj) {
favoriteUser.checked = "checked";
}
});
let html = Mustache.render(userTemplate, {
userList: favoriteUserList,
});
let obj = jQuery.parseHTML(html);
$("#favoriteListForAddUserInCollaboration").append(obj);
var myGroupList = CHAT_DB.getMyGroupUsersNotInRoom();
myGroupList.forEach(function (myGroup) {
myGroup.groupUserList.forEach(function (groupUser) {
groupUser.profileUrl = CHAT.getProfileImgUrl(groupUser.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == groupUser.shopMemberId;
});
if (findObj) {
groupUser.checked = "checked";
}
});
let html = Mustache.render(groupUserTemplate, {
groupName: myGroup.groupName,
groupUserList: myGroup.groupUserList,
});
let obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#myGroupListForAddUserInCollaboration").append(obj);
});
$("#addUserInCollaboration").modal("show");
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.refreshAllGroupForAddUserInCollaboration = function (paramGroupId) {
var groupId = paramGroupId;
$(".content").removeClass("none");
$("#tabAllGroupOnAddUserInCollaboration").prop("checked", true);
//オンライン状態であればサーバから情報更新。
if (IS_ONLINE == "true") {
if (typeof android != "undefined") {
android.updateGroupInfo(groupId);
} else {
webkit.messageHandlers.updateGroupInfo.postMessage(groupId);
}
}
//画面エリアを初期化。
$("#parentGroupBtnForAddUserInCollaboration").off();
$("#rootGroupBtnForAddUserInCollaboration").off();
$("#childGroupListAreaForAddUserInCollaboration").html("");
$("#userInGroupListForAddUserInCollaboration").html("");
$("#groupPathAreaForAddUserInCollaboration").html("");
//DBからグループ情報を取得。
var result = CHAT_DB.getGroupInfoForAddUser(groupId);
//上位グループ、トップグループ遷移ボタンのイベント追加。
if (typeof result.parentGroupId !== "undefined") {
$("#parentGroupBtnForAddUserInCollaboration").on("click", function () {
CHAT_UI.refreshAllGroupForAddUserInCollaboration(result.parentGroupId);
});
}
if (typeof result.rootGroupId !== "undefined") {
if (paramGroupId == 0) {
groupId = result.rootGroupId;
}
$("#rootGroupBtnForAddUserInCollaboration").on("click", function () {
CHAT_UI.refreshAllGroupForAddUserInCollaboration(result.rootGroupId);
});
}
if (groupId == result.rootGroupId || paramGroupId == "0") {
$("#rootGroupAreaInCollaboration").addClass("none");
$("#parentGroupAreaInCollaboration").addClass("none");
} else {
$("#rootGroupAreaInCollaboration").removeClass("none");
$("#parentGroupAreaInCollaboration").removeClass("none");
}
//該当グループのパースを表示。
var groupPathTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_PATH_IN_COLLABORATION
);
var groupPathCount = 0;
result.groupPathList.forEach(function (groupPath) {
if (!(groupPathCount < result.groupPathList.length - 3)) {
let html = Mustache.render(groupPathTemplate, {
name: groupPath.groupName,
id: groupPath.groupId,
});
let obj = jQuery.parseHTML(html);
$("#groupPathAreaForAddUserInCollaboration").append(obj);
}
groupPathCount++;
});
//該当グループの下位グループ表示。
var groupTemplate = getTemplate(
TemplateURL.ADD_USER_GROUP_LIST_IN_COLLABORATION
);
result.childGroupList.forEach(function (childGroup) {
let html = Mustache.render(groupTemplate, {
name: childGroup.groupName,
id: childGroup.groupId,
});
let obj = $(jQuery.parseHTML(html)).on("click", function () {});
$("#childGroupListAreaForAddUserInCollaboration").append(obj);
});
//該当グループの所属ユーザを表示。
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) {
return shopMemberId == groupUser.shopMemberId;
});
if (findObj) {
groupUser.checked = "checked";
}
});
let html = Mustache.render(userTemplate, {
userList: result.groupUserList,
});
let obj = jQuery.parseHTML(html);
$("#userInGroupListForAddUserInCollaboration").append(obj);
};
CHAT_UI.makeNameCardInCollaboration = function (shopMemberId) {
if (CHAT.globalLoginParameter.shopMemberId == shopMemberId) {
return;
}
var nameCardInfo = CHAT_DB.getNameCardData(shopMemberId);
var namecardTemplate;
var changeHostTemplate;
$.get({ url: "./modal_collabo_profile.html", async: false }, function (text) {
namecardTemplate = text;
});
let isCollaborationHost = coview_api.getRoomUsers();
nameCardInfo.profileUrl = CHAT.getProfileImgUrl(nameCardInfo.profileUrl);
let whosHost = $("#collaboration_user_" + nameCardInfo.loginId).hasClass(
"host"
);
let namecardHtml = Mustache.render(namecardTemplate, {
shopMemberId: nameCardInfo.shopMemberId,
profileUrl: nameCardInfo.profileUrl,
loginId: nameCardInfo.loginId,
name: nameCardInfo.shopMemberName,
groupPathList: nameCardInfo.groupPathList,
isFavorite: nameCardInfo.isFavorite,
isHost: isCollaborationHost,
whosHost: whosHost,
});
let namecardObj = $(jQuery.parseHTML(namecardHtml)).on(
"click",
function () {}
);
$("#userProfileModalInCollaboration").html(namecardObj);
$("#userNameCardInCollaboration").modal("show");
};
CHAT_UI.removeFavoriteUserInCollaboration = function (shopMemberId) {
CHAT_UI.showLoadingIndicator();
$("#userNameCardInCollaboration").modal("hide");
var result;
if (typeof android != "undefined") {
result = android.removeFavoriteUser(shopMemberId);
} else {
result = CHAT_DB.removeFavoriteUser(shopMemberId);
}
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.insertFavoriteUserInCollaboration = function (shopMemberId) {
$("#userNameCardInCollaboration").modal("hide");
var result;
if (typeof android != "undefined") {
result = android.addFavoriteUser(shopMemberId);
} else {
result = CHAT_DB.addFavoriteUser(shopMemberId);
}
CHAT_UI.dismissLoadingIndicator();
};
CHAT_UI.confirmInviteUserListInCollaboration = function () {
var selectedUsers = CHAT_DB.loadSelectedUsers();
if (selectedUsers != "") {
$("#selectedUserListinCollaboration").html("");
var selectedUserList = CHAT_DB.loadSelectedUsers();
selectedUserList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
});
var modalTemplate;
$.get(
{ url: "./modal_add_user_confirm.html", async: false },
function (text) {
modalTemplate = text;
}
);
let html = Mustache.render(modalTemplate, {
userList: selectedUserList,
});
let obj = jQuery.parseHTML(html);
$("#modal_add_user_confirm").html(obj);
$("#modalAddUserConfirm").modal("show");
} else {
}
$("#cancelAddUserBtn")
.off()
.on("click", function () {
console.log("cancelClick");
$("#modalAddUserConfirm").modal("hide");
$("#addUserInCollaboration").modal("show");
});
$("#addUserBtn")
.off()
.on("click", function () {
CHAT_UI.showLoadingIndicator();
let userIdList = new Array();
selectedUserList.forEach(function (user) {
userIdList.push(user.shopMemberId);
});
if (typeof android != "undefined") {
android.inviteCollaboration(
userIdList.join(","),
CHAT_UTIL.getCollaborationType(globalUserInfo.coWorkType)
);
} else {
webkit.messageHandlers.inviteCollaboration.postMessage({
userIdList: userIdList.join(","),
collaborationType: CHAT_UTIL.getCollaborationType(
globalUserInfo.coWorkType
),
});
}
$("#modalAddUserConfirm").modal("hide");
});
};
// 名前空間
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