Commit 1a39aefa by Kim Peace

Adopt js lint

parent d1e0e0f0
// 名前空間 // 名前空間
var ARCHIVE_UI = {}; var ARCHIVE_UI = {};
$(function() { $(function () {
// アーカイブ検索 // アーカイブ検索
$('#archive .search_form input[type="search"]').keyup(function(e) { $('#archive .search_form input[type="search"]').keyup(function (e) {
var keyword = $('#archive .search_form input[type="search"]').val(); var keyword = $('#archive .search_form input[type="search"]').val();
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
if (keyword.length != 0 && keyword != '') { if (keyword.length != 0 && keyword != "") {
$('#archive .search_form input[type="search"]').blur(); $('#archive .search_form input[type="search"]').blur();
return; return;
} }
} else if (keyword == '' || keyword.length < 2) { } else if (keyword == "" || keyword.length < 2) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
return; return;
} }
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
ARCHIVE_UI.refreshSearchScreen(keyword); ARCHIVE_UI.refreshSearchScreen(keyword);
...@@ -25,26 +25,31 @@ $(function() { ...@@ -25,26 +25,31 @@ $(function() {
// 検索結果を表示 // 検索結果を表示
}); });
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#archive .search_form input[type="search"]').on('compositionend', function() { $('#archive .search_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var keyword = $('#archive .search_form input[type="search"]').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);
} }
}); }
);
}); });
ARCHIVE_UI.refreshSearchScreen = function(keyword) { ARCHIVE_UI.refreshSearchScreen = function (keyword) {
var archiveList = CHAT_DB.getArchiveByName(keyword); var archiveList = CHAT_DB.getArchiveByName(keyword);
var archiveTemplate; var archiveTemplate;
$.get({ url: "./template/template_archive_list.html", async: false } $.get(
, function(text) { { url: "./template/template_archive_list.html", async: false },
function (text) {
archiveTemplate = text; archiveTemplate = text;
}); }
);
archiveList.forEach(function(archive) { archiveList.forEach(function (archive) {
var typeImage = ""; var typeImage = "";
switch(archive.archiveType) { switch (archive.archiveType) {
case 0: // 画像 case 0: // 画像
typeImage = "icon/icon_collabo_picture.png"; typeImage = "icon/icon_collabo_picture.png";
break; break;
...@@ -57,7 +62,8 @@ ARCHIVE_UI.refreshSearchScreen = function(keyword) { ...@@ -57,7 +62,8 @@ ARCHIVE_UI.refreshSearchScreen = function(keyword) {
case 3: // 文書 case 3: // 文書
typeImage = "icon/icon_collabo_document.png"; typeImage = "icon/icon_collabo_document.png";
break; break;
default: // その他 default:
// その他
typeImage = ""; typeImage = "";
} }
...@@ -65,10 +71,10 @@ ARCHIVE_UI.refreshSearchScreen = function(keyword) { ...@@ -65,10 +71,10 @@ ARCHIVE_UI.refreshSearchScreen = function(keyword) {
archiveId: archive.archiveId, archiveId: archive.archiveId,
fileName: archive.archiveName, fileName: archive.archiveName,
insertDate: archive.archiveDate, insertDate: archive.archiveDate,
typeImage: typeImage typeImage: typeImage,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
}); });
}; };
// 名前空間 // 名前空間
var CHAT_ADD_USER = {}; var CHAT_ADD_USER = {};
$(function() { $(function () {
// メンバー検索 // メンバー検索
$('#chat_add_user .search_form input[type="search"]').click(function(e){ $('#chat_add_user .search_form input[type="search"]').click(function (e) {
//画面タイトル設定 //画面タイトル設定
let contactListTitle = getLocalizedString("userSearch"); let contactListTitle = getLocalizedString("userSearch");
$('#addUserTitle').text(contactListTitle); $("#addUserTitle").text(contactListTitle);
}) });
$('#chat_add_user .search_form input[type="search"]').keyup(function(e){ $('#chat_add_user .search_form input[type="search"]').keyup(function (e) {
var keyword = $('#chat_add_user .search_form input[type="search"]').val(); var keyword = $('#chat_add_user .search_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
if (keyword != '' && keyword.length != 0) { if (keyword != "" && keyword.length != 0) {
$('#chat_add_user .search_form input[type="search"]').blur(); $('#chat_add_user .search_form input[type="search"]').blur();
return false; return false;
} }
} else if (keyword == '' || keyword.length < 2) { } else if (keyword == "" || keyword.length < 2) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
return false; return false;
} }
CHAT_ADD_USER.searchUser(keyword); CHAT_ADD_USER.searchUser(keyword);
...@@ -27,91 +27,107 @@ $(function() { ...@@ -27,91 +27,107 @@ $(function() {
} }
}); });
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#chat_add_user .search_form input[type="search"]').on('compositionend', function() { $('#chat_add_user .search_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var keyword = $('#chat_add_user .search_form input[type="search"]').val(); var keyword = $(
'#chat_add_user .search_form input[type="search"]'
).val();
CHAT_ADD_USER.searchUser(keyword); CHAT_ADD_USER.searchUser(keyword);
} }
}); }
);
}); });
// ユーザー検索 // ユーザー検索
CHAT_ADD_USER.searchUser = function(keyword) { CHAT_ADD_USER.searchUser = function (keyword) {
var isAllGroup = $('#tabAllGroupOnAddUser').is(':checked'); var isAllGroup = $("#tabAllGroupOnAddUser").is(":checked");
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
//グループデータ検索 //グループデータ検索
var groupList = CHAT_DB.getGroupByName(keyword); var groupList = CHAT_DB.getGroupByName(keyword);
var groupTemplate; var groupTemplate;
$.get({ url: "./template/template_make_room_group_list.html", async: false } $.get(
, function(text) { { url: "./template/template_make_room_group_list.html", async: false },
function (text) {
groupTemplate = text; groupTemplate = text;
}); }
);
groupList.forEach(function(group) { groupList.forEach(function (group) {
let html = Mustache.render(groupTemplate, { let html = Mustache.render(groupTemplate, {
name: group.groupName, name: group.groupName,
id: group.groupId, id: group.groupId,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
}) });
//ユーザデータ検索 //ユーザデータ検索
var userList = CHAT_DB.getAllGroupShopMemberNotInRoomByName(keyword); var userList = CHAT_DB.getAllGroupShopMemberNotInRoomByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_make_room_user_list.html", async: false } $.get(
, function(text) { { url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text; userTemplate = text;
}); }
userList.forEach(function(user) { );
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function(shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == user.shopMemberId; return shopMemberId == user.shopMemberId;
}) });
if (findObj) { if (findObj) {
user.checked = 'checked'; user.checked = "checked";
} }
}); });
let html = Mustache.render(userTemplate, { let html = Mustache.render(userTemplate, {
userList: userList userList: userList,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
if (userList.length == 0 && groupList.length == 0) { if (userList.length == 0 && groupList.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
} });
  //連絡先画面 noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} //連絡先画面
} else { } else {
var userList = CHAT_DB.getMyGroupShopMemberNotInRoomByName(keyword); var userList = CHAT_DB.getMyGroupShopMemberNotInRoomByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_make_room_user_list.html", async: false } $.get(
, function(text) { { url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text; userTemplate = text;
}); }
userList.forEach(function(user) { );
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function(shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == user.shopMemberId; return shopMemberId == user.shopMemberId;
}) });
if (findObj) { if (findObj) {
user.checked = 'checked'; user.checked = "checked";
} }
}); });
let html = Mustache.render(userTemplate, { let html = Mustache.render(userTemplate, {
userList: userList 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) { if (userList.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} }
} }
}; };
...@@ -8,37 +8,39 @@ function callNativeApp(iosKey, jsonData) { ...@@ -8,37 +8,39 @@ function callNativeApp(iosKey, jsonData) {
try { try {
var key = iosKey; var key = iosKey;
var data = jsonData; var data = jsonData;
var payload = {key: key, data: data}; var payload = { key: key, data: data };
// payloadの形 {"type":"SJbridge","data":{"name":"abc","role":"dev"}} // payloadの形 {"type":"SJbridge","data":{"name":"abc","role":"dev"}}
// resにObjective-cからのレスポンスが返る // resにObjective-cからのレスポンスが返る
result = prompt(JSON.stringify (payload)); result = prompt(JSON.stringify(payload));
console.log(result); console.log(result);
} catch(err) { } catch (err) {
console.log('The native context does not exist yet'); console.log("The native context does not exist yet");
} }
return result; return result;
} }
//ロカールDBからルーム一覧情報を取得 //ロカールDBからルーム一覧情報を取得
CHAT_DB.getRoomList = function(roomType, keyWord) { CHAT_DB.getRoomList = function (roomType, keyWord) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getRoomList", {"roomType": roomType, "keyWord": keyWord})); return JSON.parse(
callNativeApp("getRoomList", { roomType: roomType, keyWord: keyWord })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getRoomList(roomType, keyWord)); return JSON.parse(android.getRoomList(roomType, keyWord));
} }
}; };
CHAT_DB.callGetRoomList = function(roomType) { CHAT_DB.callGetRoomList = function (roomType) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getRoomList", {"roomType": roomType})); return JSON.parse(callNativeApp("getRoomList", { roomType: roomType }));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getRoomList(roomType)); return JSON.parse(android.getRoomList(roomType));
} }
} };
//ロカールDBからログインしたユーザのデータを取得する。 //ロカールDBからログインしたユーザのデータを取得する。
CHAT_DB.getMyInfo = function() { CHAT_DB.getMyInfo = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyInfo", {})); return JSON.parse(callNativeApp("getMyInfo", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -47,16 +49,16 @@ CHAT_DB.getMyInfo = function() { ...@@ -47,16 +49,16 @@ CHAT_DB.getMyInfo = function() {
} }
}; };
CHAT_DB.getMessages = function(roomId) { CHAT_DB.getMessages = function (roomId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMessages", {"roomId": roomId})); return JSON.parse(callNativeApp("getMessages", { roomId: roomId }));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getMessageList(roomId)); return JSON.parse(android.getMessageList(roomId));
} }
}; };
CHAT_DB.getFavoriteUsersNotInRoom = function() { CHAT_DB.getFavoriteUsersNotInRoom = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getFavoriteUsersNotInRoom", {})); return JSON.parse(callNativeApp("getFavoriteUsersNotInRoom", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -65,7 +67,7 @@ CHAT_DB.getFavoriteUsersNotInRoom = function() { ...@@ -65,7 +67,7 @@ CHAT_DB.getFavoriteUsersNotInRoom = function() {
} }
}; };
CHAT_DB.getFavoriteUsers = function() { CHAT_DB.getFavoriteUsers = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getFavoriteUsers", {})); return JSON.parse(callNativeApp("getFavoriteUsers", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -74,7 +76,7 @@ CHAT_DB.getFavoriteUsers = function() { ...@@ -74,7 +76,7 @@ CHAT_DB.getFavoriteUsers = function() {
} }
}; };
CHAT_DB.getFavoriteGroups = function() { CHAT_DB.getFavoriteGroups = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getFavoriteGroups", {})); return JSON.parse(callNativeApp("getFavoriteGroups", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -83,7 +85,7 @@ CHAT_DB.getFavoriteGroups = function() { ...@@ -83,7 +85,7 @@ CHAT_DB.getFavoriteGroups = function() {
} }
}; };
CHAT_DB.getMyGroupUsers = function() { CHAT_DB.getMyGroupUsers = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyGroupUsers", {})); return JSON.parse(callNativeApp("getMyGroupUsers", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -92,25 +94,27 @@ CHAT_DB.getMyGroupUsers = function() { ...@@ -92,25 +94,27 @@ CHAT_DB.getMyGroupUsers = function() {
} }
}; };
CHAT_DB.getGroupInfo = function(groupId) { CHAT_DB.getGroupInfo = function (groupId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getGroupInfo", {"groupId": groupId})); return JSON.parse(callNativeApp("getGroupInfo", { groupId: groupId }));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getGroupInfo(groupId)); return JSON.parse(android.getGroupInfo(groupId));
} }
}; };
CHAT_DB.getGroupInfoForAddUser = function(groupId) { CHAT_DB.getGroupInfoForAddUser = function (groupId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getGroupInfoForAddUser", {"groupId": groupId})); return JSON.parse(
callNativeApp("getGroupInfoForAddUser", { groupId: groupId })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getGroupInfoForAddUser(groupId)); return JSON.parse(android.getGroupInfoForAddUser(groupId));
} }
}; };
CHAT_DB.loadSelectedUsers = function() { CHAT_DB.loadSelectedUsers = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getSelectedUserList", {})); return JSON.parse(callNativeApp("getSelectedUserList", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -118,72 +122,96 @@ CHAT_DB.loadSelectedUsers = function() { ...@@ -118,72 +122,96 @@ CHAT_DB.loadSelectedUsers = function() {
console.log(JSON.parse(android.getSelectedUserList())); console.log(JSON.parse(android.getSelectedUserList()));
return JSON.parse(android.getSelectedUserList()); return JSON.parse(android.getSelectedUserList());
} }
} };
CHAT_DB.getNameCardData = function(shopMemberId) { CHAT_DB.getNameCardData = function (shopMemberId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getNameCardData", {"shopMemberId": shopMemberId})); return JSON.parse(
callNativeApp("getNameCardData", { shopMemberId: shopMemberId })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getNameCardData(shopMemberId)); return JSON.parse(android.getNameCardData(shopMemberId));
} }
}; };
CHAT_DB.getMyGroupShopMemberByName = function(shopMemberName) { CHAT_DB.getMyGroupShopMemberByName = function (shopMemberName) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyGroupShopMemberByName", {"shopMemberName": shopMemberName})); return JSON.parse(
callNativeApp("getMyGroupShopMemberByName", {
shopMemberName: shopMemberName,
})
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getMyGroupShopMemberByName(shopMemberName)); return JSON.parse(android.getMyGroupShopMemberByName(shopMemberName));
} }
}; };
CHAT_DB.getMyGroupShopMemberNotInRoomByName = function(shopMemberName) { CHAT_DB.getMyGroupShopMemberNotInRoomByName = function (shopMemberName) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyGroupShopMemberNotInRoomByName", {"shopMemberName": shopMemberName})); return JSON.parse(
callNativeApp("getMyGroupShopMemberNotInRoomByName", {
shopMemberName: shopMemberName,
})
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getMyGroupShopMemberNotInRoomByName(shopMemberName)); return JSON.parse(
android.getMyGroupShopMemberNotInRoomByName(shopMemberName)
);
} }
}; };
CHAT_DB.getAllGroupShopMemberByName = function(shopMemberName) { CHAT_DB.getAllGroupShopMemberByName = function (shopMemberName) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getAllGroupShopMemberByName", {"shopMemberName": shopMemberName})); return JSON.parse(
callNativeApp("getAllGroupShopMemberByName", {
shopMemberName: shopMemberName,
})
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getAllGroupShopMemberByName(shopMemberName)); return JSON.parse(android.getAllGroupShopMemberByName(shopMemberName));
} }
}; };
CHAT_DB.getAllGroupShopMemberNotInRoomByName = function(shopMemberName) { CHAT_DB.getAllGroupShopMemberNotInRoomByName = function (shopMemberName) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getAllGroupShopMemberNotInRoomByName", {"shopMemberName": shopMemberName})); return JSON.parse(
callNativeApp("getAllGroupShopMemberNotInRoomByName", {
shopMemberName: shopMemberName,
})
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getAllGroupShopMemberNotInRoomByName(shopMemberName)); return JSON.parse(
android.getAllGroupShopMemberNotInRoomByName(shopMemberName)
);
} }
}; };
CHAT_DB.getGroupByName = function(groupName) { CHAT_DB.getGroupByName = function (groupName) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getGroupByName", {"groupName": groupName})); return JSON.parse(
callNativeApp("getGroupByName", { groupName: groupName })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getGroupByName(groupName)); return JSON.parse(android.getGroupByName(groupName));
} }
}; };
CHAT_DB.getUsersInRoom = function(roomId) { CHAT_DB.getUsersInRoom = function (roomId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getUsersInRoom", {"roomId": roomId})); return JSON.parse(callNativeApp("getUsersInRoom", { roomId: roomId }));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getUsersInRoom(roomId)); return JSON.parse(android.getUsersInRoom(roomId));
} }
} };
// アーカイブ一覧 // アーカイブ一覧
CHAT_DB.getArchiveList = function() { CHAT_DB.getArchiveList = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getArchiveList", {})); return JSON.parse(callNativeApp("getArchiveList", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -191,7 +219,7 @@ CHAT_DB.getArchiveList = function() { ...@@ -191,7 +219,7 @@ CHAT_DB.getArchiveList = function() {
} }
}; };
CHAT_DB.updateArchiveList = function() { CHAT_DB.updateArchiveList = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.updateArchiveList.postMessage({}); webkit.messageHandlers.updateArchiveList.postMessage({});
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -200,24 +228,28 @@ CHAT_DB.updateArchiveList = function() { ...@@ -200,24 +228,28 @@ CHAT_DB.updateArchiveList = function() {
}; };
// アーカイブ一覧検索 // アーカイブ一覧検索
CHAT_DB.getArchiveByName = function(archiveName) { CHAT_DB.getArchiveByName = function (archiveName) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getArchiveByName", {"archiveName": archiveName})); return JSON.parse(
callNativeApp("getArchiveByName", { archiveName: archiveName })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getArchiveListByName(archiveName)); return JSON.parse(android.getArchiveListByName(archiveName));
} }
}; };
// アーカイブ詳細 // アーカイブ詳細
CHAT_DB.getArchiveDetail = function(archiveId) { CHAT_DB.getArchiveDetail = function (archiveId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getArchiveDetail", {"archiveId": archiveId})); return JSON.parse(
callNativeApp("getArchiveDetail", { archiveId: archiveId })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getArchiveDetail(archiveId)); return JSON.parse(android.getArchiveDetail(archiveId));
} }
}; };
CHAT_DB.updateArchiveDetail = function(archiveId) { CHAT_DB.updateArchiveDetail = function (archiveId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.updateArchiveDetail.postMessage(archiveId); webkit.messageHandlers.updateArchiveDetail.postMessage(archiveId);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -225,15 +257,17 @@ CHAT_DB.updateArchiveDetail = function(archiveId) { ...@@ -225,15 +257,17 @@ CHAT_DB.updateArchiveDetail = function(archiveId) {
} }
}; };
CHAT_DB.searchMessages = function(keyword, userList) { CHAT_DB.searchMessages = function (keyword, userList) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("searchMessages", {"keyWord": keyword, "userList": userList})); return JSON.parse(
callNativeApp("searchMessages", { keyWord: keyword, userList: userList })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.searchMessages(keyword, userList)); return JSON.parse(android.searchMessages(keyword, userList));
} }
}; };
CHAT_DB.getMyGroupUsersNotInRoom = function() { CHAT_DB.getMyGroupUsersNotInRoom = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getMyGroupUsersNotInRoom", {})); return JSON.parse(callNativeApp("getMyGroupUsersNotInRoom", {}));
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -242,33 +276,37 @@ CHAT_DB.getMyGroupUsersNotInRoom = function() { ...@@ -242,33 +276,37 @@ CHAT_DB.getMyGroupUsersNotInRoom = function() {
} }
}; };
CHAT_DB.getUserInfo = function(shopMemberId) { CHAT_DB.getUserInfo = function (shopMemberId) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getUserInfo", {"shopMemberId": shopMemberId})); return JSON.parse(
callNativeApp("getUserInfo", { shopMemberId: shopMemberId })
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
//String形式をJsonに変更してReturn //String形式をJsonに変更してReturn
return JSON.parse(android.getUserInfo(shopMemberId)); return JSON.parse(android.getUserInfo(shopMemberId));
} }
}; };
CHAT_DB.getBeforeRoomType = function() { CHAT_DB.getBeforeRoomType = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return callNativeApp("getBeforeRoomType", {}); return callNativeApp("getBeforeRoomType", {});
} }
}; };
CHAT_DB.getRoomType = function() { CHAT_DB.getRoomType = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return parseInt(callNativeApp("getRoomType", {}), 10); return parseInt(callNativeApp("getRoomType", {}), 10);
} }
}; };
CHAT_DB.removeFavoriteUser = function(shopMemberId) { CHAT_DB.removeFavoriteUser = function (shopMemberId) {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var result = callNativeApp("removeFavoriteUser", {"shopMemberId": shopMemberId}); var result = callNativeApp("removeFavoriteUser", {
shopMemberId: shopMemberId,
});
if (result == "true") { if (result == "true") {
return true; return true;
} else { } else {
...@@ -277,10 +315,12 @@ CHAT_DB.removeFavoriteUser = function(shopMemberId) { ...@@ -277,10 +315,12 @@ CHAT_DB.removeFavoriteUser = function(shopMemberId) {
} }
}; };
CHAT_DB.addFavoriteUser = function(shopMemberId) { CHAT_DB.addFavoriteUser = function (shopMemberId) {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var result = callNativeApp("addFavoriteUser", {"shopMemberId": shopMemberId}); var result = callNativeApp("addFavoriteUser", {
shopMemberId: shopMemberId,
});
if (result == "true") { if (result == "true") {
return true; return true;
} else { } else {
...@@ -289,10 +329,10 @@ CHAT_DB.addFavoriteUser = function(shopMemberId) { ...@@ -289,10 +329,10 @@ CHAT_DB.addFavoriteUser = function(shopMemberId) {
} }
}; };
CHAT_DB.removeFavoriteGroup = function(groupId) { CHAT_DB.removeFavoriteGroup = function (groupId) {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var result = callNativeApp("removeFavoriteGroup", {"groupId": groupId}); var result = callNativeApp("removeFavoriteGroup", { groupId: groupId });
if (result == "true") { if (result == "true") {
return true; return true;
} else { } else {
...@@ -301,10 +341,10 @@ CHAT_DB.removeFavoriteGroup = function(groupId) { ...@@ -301,10 +341,10 @@ CHAT_DB.removeFavoriteGroup = function(groupId) {
} }
}; };
CHAT_DB.addFavoriteGroup = function(groupId) { CHAT_DB.addFavoriteGroup = function (groupId) {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var result = callNativeApp("addFavoriteGroup", {"groupId": groupId}); var result = callNativeApp("addFavoriteGroup", { groupId: groupId });
if (result == "true") { if (result == "true") {
return true; return true;
} else { } else {
...@@ -313,8 +353,7 @@ CHAT_DB.addFavoriteGroup = function(groupId) { ...@@ -313,8 +353,7 @@ CHAT_DB.addFavoriteGroup = function(groupId) {
} }
}; };
CHAT_DB.getContentList = function () {
CHAT_DB.getContentList = function() {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
//TODO ローカルDBからダウンロード済のコンテンツを取得 //TODO ローカルDBからダウンロード済のコンテンツを取得
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -322,51 +361,55 @@ CHAT_DB.getContentList = function() { ...@@ -322,51 +361,55 @@ CHAT_DB.getContentList = function() {
} }
}; };
CHAT_DB.getUserListByLoginId = function(loginIdList) { CHAT_DB.getUserListByLoginId = function (loginIdList) {
console.log(loginIdList); console.log(loginIdList);
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return JSON.parse(callNativeApp("getUserListByLoginId", {"loginIdList": loginIdList.join(",")})); return JSON.parse(
callNativeApp("getUserListByLoginId", {
loginIdList: loginIdList.join(","),
})
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
return JSON.parse(android.getUserListByLoginId(loginIdList.join(","))); return JSON.parse(android.getUserListByLoginId(loginIdList.join(",")));
} }
} };
CHAT_DB.getCollaborationJoinFlg = function() { CHAT_DB.getCollaborationJoinFlg = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return callNativeApp("getCollaborationJoinFlg", {}); return callNativeApp("getCollaborationJoinFlg", {});
} }
}; };
CHAT_DB.getUserInfoList = function(shopMemberId) { CHAT_DB.getUserInfoList = function (shopMemberId) {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return callNativeApp("getUserInfoList", {"shopMemberId": shopMemberId}); return callNativeApp("getUserInfoList", { shopMemberId: shopMemberId });
} }
}; };
CHAT_DB.createContentView = function() { CHAT_DB.createContentView = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return parseInt(callNativeApp("createContentView", {})); return parseInt(callNativeApp("createContentView", {}));
} }
}; };
CHAT_DB.getToMoveGroupId = function() { CHAT_DB.getToMoveGroupId = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return callNativeApp("getToMoveGroupId", {}); return callNativeApp("getToMoveGroupId", {});
} }
}; };
CHAT_DB.getJoinCollaborationType = function() { CHAT_DB.getJoinCollaborationType = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return parseInt(callNativeApp("getJoinCollaborationType", {}), 10); return parseInt(callNativeApp("getJoinCollaborationType", {}), 10);
} }
}; };
CHAT_DB.getHostRequestFlg = function() { CHAT_DB.getHostRequestFlg = function () {
// Androidは実装不要 // Androidは実装不要
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
return parseInt(callNativeApp("getHostRequestFlg", {}), 10); return parseInt(callNativeApp("getHostRequestFlg", {}), 10);
......
jQuery('#homeButton').on('click', function() { jQuery("#homeButton").on("click", function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.goHome.postMessage({}); webkit.messageHandlers.goHome.postMessage({});
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
...@@ -6,7 +6,7 @@ jQuery('#homeButton').on('click', function() { ...@@ -6,7 +6,7 @@ jQuery('#homeButton').on('click', function() {
} }
}); });
jQuery('#reloadButton').on('click', function() { jQuery("#reloadButton").on("click", function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
//TODO IOS処理追加必要。 //TODO IOS処理追加必要。
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
......
var lastscrollvalue; var lastscrollvalue;
window.onscroll = function() { window.onscroll = function () {
beforeScroll = window.scrollY; beforeScroll = window.scrollY;
} };
$('#roomNameChangeBtn').click(function() { $("#roomNameChangeBtn").click(function () {
var changeRoomName = $('#roomNameInput').val(); var changeRoomName = $("#roomNameInput").val();
var trimmedRoomName = $('#roomNameInput').val().trim(); var trimmedRoomName = $("#roomNameInput").val().trim();
if (trimmedRoomName.length == 0) { if (trimmedRoomName.length == 0) {
alert(getLocalizedString("error_empty_room_name")); alert(getLocalizedString("error_empty_room_name"));
return; return;
...@@ -15,7 +15,7 @@ $('#roomNameChangeBtn').click(function() { ...@@ -15,7 +15,7 @@ $('#roomNameChangeBtn').click(function() {
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
android.changeRoomName(changeRoomName); android.changeRoomName(changeRoomName);
} }
}) });
/* /*
$('#messages').scroll(function() { $('#messages').scroll(function() {
......
// 名前空間 // 名前空間
var CHAT_UTIL = {}; var CHAT_UTIL = {};
CHAT_UTIL.isAndroid = function() { CHAT_UTIL.isAndroid = function () {
return PLATFORM == 'android'; return PLATFORM == "android";
}; };
CHAT_UTIL.isIOS = function() { CHAT_UTIL.isIOS = function () {
return PLATFORM == 'ios'; return PLATFORM == "ios";
}; };
CHAT_UTIL.isMobile = function() { CHAT_UTIL.isMobile = function () {
return IS_MOBILE == 'true'; return IS_MOBILE == "true";
}; };
CHAT_UTIL.formatDate = function(date) { CHAT_UTIL.formatDate = function (date) {
const REFERENCE = moment(); const REFERENCE = moment();
const TODAY = REFERENCE.clone().startOf('day'); const TODAY = REFERENCE.clone().startOf("day");
let createdAt = moment(date); let createdAt = moment(date);
if (date.length == 14) { if (date.length == 14) {
createdAt = moment(date,'YYYYMMDDhhmmss'); createdAt = moment(date, "YYYYMMDDhhmmss");
} else { } else {
createdAt = moment(date); createdAt = moment(date);
} }
// #36171 // #36171
const createdAtDay = createdAt.format('MMM Do'); const createdAtDay = createdAt.format("MMM Do");
const createdAtTime = createdAt.format('HH:mm'); const createdAtTime = createdAt.format("HH:mm");
if (createdAt.isSame(TODAY, 'd')) { if (createdAt.isSame(TODAY, "d")) {
createdAt = createdAtTime; createdAt = createdAtTime;
} else { } else {
createdAt = createdAtDay; createdAt = createdAtDay;
...@@ -36,59 +36,62 @@ CHAT_UTIL.formatDate = function(date) { ...@@ -36,59 +36,62 @@ CHAT_UTIL.formatDate = function(date) {
rntDate.createdAtTime = createdAtTime; rntDate.createdAtTime = createdAtTime;
rntDate.createdAt = createdAt; rntDate.createdAt = createdAt;
return rntDate; return rntDate;
} };
CHAT_UTIL.htmlDecode = function(input) { CHAT_UTIL.htmlDecode = function (input) {
var e = document.createElement('textarea'); var e = document.createElement("textarea");
e.innerHTML = input; e.innerHTML = input;
// handle case of empty input // handle case of empty input
return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue; return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
} };
//generates a unique id, not obligator a UUID //generates a unique id, not obligator a UUID
CHAT_UTIL.generateUUID = function() { CHAT_UTIL.generateUUID = function () {
var d = new Date().getTime(); var d = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
var r = (d + Math.random()*16)%16 | 0; /[xy]/g,
d = Math.floor(d/16); function (c) {
return (c=='x' ? r : (r&0x3|0x8)).toString(16); var r = (d + Math.random() * 16) % 16 | 0;
}); d = Math.floor(d / 16);
return (c == "x" ? r : (r & 0x3) | 0x8).toString(16);
}
);
return uuid; return uuid;
}; };
CHAT_UTIL.systemDay = function(date) { CHAT_UTIL.systemDay = function (date) {
let createdAt = moment(date); let createdAt = moment(date);
createdAt = moment(date,'YYYYMMDDhhmmss'); createdAt = moment(date, "YYYYMMDDhhmmss");
const createdAtDow = createdAt.format('YYYY-MM-DD'); const createdAtDow = createdAt.format("YYYY-MM-DD");
let systemDay = new Object(); let systemDay = new Object();
systemDay.year = createdAt.format('YYYY'); systemDay.year = createdAt.format("YYYY");
systemDay.month = createdAt.format('MM'); systemDay.month = createdAt.format("MM");
systemDay.day = createdAt.format('DD'); systemDay.day = createdAt.format("DD");
systemDay.dow = moment(createdAtDow).day(); systemDay.dow = moment(createdAtDow).day();
return systemDay; return systemDay;
} };
CHAT_UTIL.findDow = function(data) { CHAT_UTIL.findDow = function (data) {
let dow = ""; let dow = "";
if (data == 0) { if (data == 0) {
dow = getLocalizedString('sunday'); dow = getLocalizedString("sunday");
} else if (data == 1) { } else if (data == 1) {
dow = getLocalizedString('monday'); dow = getLocalizedString("monday");
} else if (data == 2) { } else if (data == 2) {
dow = getLocalizedString('thusday'); dow = getLocalizedString("thusday");
} else if (data == 3) { } else if (data == 3) {
dow = getLocalizedString('wednesday'); dow = getLocalizedString("wednesday");
} else if (data == 4) { } else if (data == 4) {
dow = getLocalizedString('thursday'); dow = getLocalizedString("thursday");
} else if (data == 5) { } else if (data == 5) {
dow = getLocalizedString('friday'); dow = getLocalizedString("friday");
} else if (data == 6) { } else if (data == 6) {
dow = getLocalizedString('sunday'); dow = getLocalizedString("sunday");
} }
return dow; return dow;
} };
function msToTime(s) { function msToTime(s) {
var ms = s % 1000; var ms = s % 1000;
...@@ -98,27 +101,27 @@ function msToTime(s) { ...@@ -98,27 +101,27 @@ function msToTime(s) {
var mins = s % 60; var mins = s % 60;
var hrs = (s - mins) / 60; var hrs = (s - mins) / 60;
return hrs + ':' + mins + ':' + secs; return hrs + ":" + mins + ":" + secs;
} }
function updateDuration() { function updateDuration() {
var now = new Date(); var now = new Date();
$('.collaboration_duration').each(function(index, item) { $(".collaboration_duration").each(function (index, item) {
var insertDateString = $(item).data('insertdate'); var insertDateString = $(item).data("insertdate");
insertDateString = insertDateString.toString(); insertDateString = insertDateString.toString();
var year = insertDateString.substring(0,4); var year = insertDateString.substring(0, 4);
var month = insertDateString.substring(4,6); var month = insertDateString.substring(4, 6);
var day = insertDateString.substring(6,8); var day = insertDateString.substring(6, 8);
var hour = insertDateString.substring(8,10); var hour = insertDateString.substring(8, 10);
var min = insertDateString.substring(10,12); var min = insertDateString.substring(10, 12);
var sec = insertDateString.substring(12,14); var sec = insertDateString.substring(12, 14);
var insertDate = new Date(year, month-1 , day, hour, min, sec); var insertDate = new Date(year, month - 1, day, hour, min, sec);
$(item).html(msToTime(now - insertDate)); $(item).html(msToTime(now - insertDate));
}); });
} }
CHAT_UTIL.getCollaborationType = function(key) { CHAT_UTIL.getCollaborationType = function (key) {
switch(key) { switch (key) {
case collaborationTypeKey.AUDIO: case collaborationTypeKey.AUDIO:
return COLLABORATION_TYPE.AUDIO; return COLLABORATION_TYPE.AUDIO;
case collaborationTypeKey.CAMERA: case collaborationTypeKey.CAMERA:
...@@ -130,10 +133,12 @@ CHAT_UTIL.getCollaborationType = function(key) { ...@@ -130,10 +133,12 @@ CHAT_UTIL.getCollaborationType = function(key) {
default: default:
return 0; return 0;
} }
} };
CHAT_UTIL.getCoviewTypeFromCollaborationType = function(joinCollaborationType) { CHAT_UTIL.getCoviewTypeFromCollaborationType = function (
switch(joinCollaborationType) { joinCollaborationType
) {
switch (joinCollaborationType) {
case COLLABORATION_TYPE.AUDIO: case COLLABORATION_TYPE.AUDIO:
console.log(collaborationTypeKey.AUDIO); console.log(collaborationTypeKey.AUDIO);
return collaborationTypeKey.AUDIO; return collaborationTypeKey.AUDIO;
...@@ -149,4 +154,4 @@ CHAT_UTIL.getCoviewTypeFromCollaborationType = function(joinCollaborationType) { ...@@ -149,4 +154,4 @@ CHAT_UTIL.getCoviewTypeFromCollaborationType = function(joinCollaborationType) {
default: default:
return 0; return 0;
} }
} };
\ No newline at end of file
...@@ -3,16 +3,14 @@ var socket; ...@@ -3,16 +3,14 @@ var socket;
// 名前空間 // 名前空間
var CHAT_SOCKET = {}; var CHAT_SOCKET = {};
CHAT_SOCKET.socketCheck = function () { CHAT_SOCKET.socketCheck = function () {
if(socket == null || socket.disconnected) { if (socket == null || socket.disconnected) {
window.location.reload(); window.location.reload();
} }
} };
CHAT_SOCKET.connectSocket = function () { CHAT_SOCKET.connectSocket = function () {
if (IS_ONLINE == 'true') { if (IS_ONLINE == "true") {
socket = io(CHAT_SERVER_URL); socket = io(CHAT_SERVER_URL);
setSocketAction(); setSocketAction();
} else { } else {
...@@ -20,7 +18,6 @@ CHAT_SOCKET.connectSocket = function () { ...@@ -20,7 +18,6 @@ CHAT_SOCKET.connectSocket = function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
//TODO IOSの場合 //TODO IOSの場合
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
} }
} }
}; };
...@@ -28,10 +25,10 @@ CHAT_SOCKET.connectSocket = function () { ...@@ -28,10 +25,10 @@ CHAT_SOCKET.connectSocket = function () {
/* --------------------------------------------------- /* ---------------------------------------------------
* Socket Connect/Disconnectc * Socket Connect/Disconnectc
* --------------------------------------------------- */ * --------------------------------------------------- */
function setSocketAction () { function setSocketAction() {
socket.on('connect', function() { socket.on("connect", function () {
// socketが接続されたらチャット画面で画面を更新する // socketが接続されたらチャット画面で画面を更新する
$('.overlay').removeClass('active undismissable'); $(".overlay").removeClass("active undismissable");
// loadingIndicatorを表示 // loadingIndicatorを表示
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
// チャットルームに入場する際、sid, loginId, shopName, roomId, roomNameの情報を取得しNodeJsに渡す // チャットルームに入場する際、sid, loginId, shopName, roomId, roomNameの情報を取得しNodeJsに渡す
...@@ -43,14 +40,14 @@ function setSocketAction () { ...@@ -43,14 +40,14 @@ function setSocketAction () {
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}); });
socket.on('disconnect', function() { socket.on("disconnect", function () {
//socketが切断されたら黒画面で画面を更新する //socketが切断されたら黒画面で画面を更新する
$('.overlay').addClass('active undismissable'); $(".overlay").addClass("active undismissable");
//alert('Disconnected from the server'); //alert('Disconnected from the server');
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}); });
socket.on('connect_error', function() { socket.on("connect_error", function () {
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}); });
...@@ -167,28 +164,39 @@ function setSocketAction () { ...@@ -167,28 +164,39 @@ function setSocketAction () {
// New Message // New Message
// #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;
$.get({ url: "./template/template_user_message.html", async: false } $.get(
, function(text) { { url: "./template/template_user_message.html", async: false },
function (text) {
userMessageTemplate = text; userMessageTemplate = text;
}); }
);
var myMessageTemplate; var myMessageTemplate;
$.get({ url: "./template/template_my_message.html", async: false } $.get(
, function(text) { { url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text; myMessageTemplate = text;
}); }
);
var systemMessageTemplate; var systemMessageTemplate;
$.get({ url: "./template/template_system_message.html", async: false } $.get(
, function(text) { { url: "./template/template_system_message.html", async: false },
function (text) {
systemMessageTemplate = text; systemMessageTemplate = text;
}); }
);
var openCollaborationMessageTemplate; var openCollaborationMessageTemplate;
$.get({ url: "./template/template_open_collaboration_message.html", async: false } $.get(
, function(text) { {
url: "./template/template_open_collaboration_message.html",
async: false,
},
function (text) {
openCollaborationMessageTemplate = text; openCollaborationMessageTemplate = text;
}); }
);
let template = userMessageTemplate; let template = userMessageTemplate;
if (message.id === socket.id) { if (message.id === socket.id) {
...@@ -196,33 +204,43 @@ function setSocketAction () { ...@@ -196,33 +204,43 @@ function setSocketAction () {
template = myMessageTemplate; template = myMessageTemplate;
} }
let messageTime = CHAT_UTIL.formatDate(message.createdAt); let messageTime = CHAT_UTIL.formatDate(message.createdAt);
message.profileImagePath = CHAT.getProfileImgUrl(message.profileImagePath) message.profileImagePath = CHAT.getProfileImgUrl(message.profileImagePath);
try { try {
message.text = decodeURIComponent(message.text) message.text = decodeURIComponent(message.text);
} catch(e) { } catch (e) {
message.text = message.text message.text = message.text;
} }
let type; let type;
let collaborationType; let collaborationType;
if ( message.text.includes(messageSeperator) ) { if (message.text.includes(messageSeperator)) {
let text = message.text.split(messageSeperator); let text = message.text.split(messageSeperator);
message.text = text[0]; message.text = text[0];
type = text[1]; type = text[1];
if (type == messageType.COMMUNICATIONSTART || type == messageType.COMMUNICATIONEND) { if (
type == messageType.COMMUNICATIONSTART ||
type == messageType.COMMUNICATIONEND
) {
collaborationType = text[2]; collaborationType = text[2];
var meetingId = 0; var meetingId = 0;
if (collaborationType == CHAT_UTIL.getCollaborationType(collaborationTypeKey.DOCUMENT)) { if (
collaborationType ==
CHAT_UTIL.getCollaborationType(collaborationTypeKey.DOCUMENT)
) {
meetingId = text[3]; meetingId = text[3];
} }
var userInCollaboration; var userInCollaboration;
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
userInCollaboration = JSON.parse(CHAT_DB.getUserInfoList(message.userId)); userInCollaboration = JSON.parse(
CHAT_DB.getUserInfoList(message.userId)
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
userInCollaboration = JSON.parse(android.getUserInfoList(message.userId)); userInCollaboration = JSON.parse(
android.getUserInfoList(message.userId)
);
} }
userInCollaboration.forEach(function(user) { userInCollaboration.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
}) });
template = openCollaborationMessageTemplate; template = openCollaborationMessageTemplate;
let html = Mustache.render(template, { let html = Mustache.render(template, {
roomName: roomName, roomName: roomName,
...@@ -234,12 +252,15 @@ function setSocketAction () { ...@@ -234,12 +252,15 @@ function setSocketAction () {
meetingId: meetingId, meetingId: meetingId,
createdAtDay: messageTime.createdAtDay, createdAtDay: messageTime.createdAtDay,
createdAtTime: messageTime.createdAtTime, createdAtTime: messageTime.createdAtTime,
isOtherYear: false isOtherYear: false,
}); });
$('#messages').append(html); $("#messages").append(html);
} else { } else {
var replacePath = message.text; var replacePath = message.text;
replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName='); replacePath = replacePath.replaceAll(
"?fileName=",
"?sid=" + CHAT.globalLoginParameter.sid + "&fileName="
);
message.text = replacePath; message.text = replacePath;
var messageSender; var messageSender;
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
...@@ -254,11 +275,15 @@ function setSocketAction () { ...@@ -254,11 +275,15 @@ function setSocketAction () {
shopMemberId: message.userId, shopMemberId: message.userId,
createdAtDay: messageTime.createdAtDay, createdAtDay: messageTime.createdAtDay,
createdAtTime: messageTime.createdAtTime, createdAtTime: messageTime.createdAtTime,
isToday: true isToday: true,
}); });
// イメージの場合、img tagを追加する // イメージの場合、img tagを追加する
html = message.text.includes('attachedImages') || message.text.includes('attachedVideos') ? CHAT_UTIL.htmlDecode(html) : html; html =
$('#messages').append(html); message.text.includes("attachedImages") ||
message.text.includes("attachedVideos")
? CHAT_UTIL.htmlDecode(html)
: html;
$("#messages").append(html);
} }
} }
...@@ -269,83 +294,89 @@ function setSocketAction () { ...@@ -269,83 +294,89 @@ function setSocketAction () {
}); });
// Notification // Notification
socket.on('newNotification', function(keyword, event) { socket.on("newNotification", function (keyword, event) {
var notificationString = getLocalizedString(event, keyword) var notificationString = getLocalizedString(event, keyword);
$('#messageNotification').finish().text(notificationString).delay(500).slideDown().delay(1500).slideUp(); $("#messageNotification")
.finish()
.text(notificationString)
.delay(500)
.slideDown()
.delay(1500)
.slideUp();
}); });
// 新しいメッセージを受信する場合の処理 // 新しいメッセージを受信する場合の処理
// #36170 // #36170
// socket.on('loadMessages', function(messages, shopMemberId, users, roomId, roomName){ // socket.on('loadMessages', function(messages, shopMemberId, users, roomId, roomName){
// let jQueryMessages = $('#messages'); // let jQueryMessages = $('#messages');
// // スクロールの変化を防ぐため以前画面の高さを保存する // // スクロールの変化を防ぐため以前画面の高さを保存する
// let beforeHeight = jQueryMessages.prop('scrollHeight'); // let beforeHeight = jQueryMessages.prop('scrollHeight');
// // メッセージ文字列の生成 // // メッセージ文字列の生成
// let workVal = ""; // let workVal = "";
// messages.forEach(function(message) { // messages.forEach(function(message) {
// let template = $('#message-template').html(); // let template = $('#message-template').html();
// if (message.shopMemberId == shopMemberId) { // if (message.shopMemberId == shopMemberId) {
// template = $('#message-template-me').html(); // template = $('#message-template-me').html();
// } // }
// let messageTime = CHAT_UTIL.formatDate(message.time.time); // let messageTime = CHAT_UTIL.formatDate(message.time.time);
// //
// if (users != undefined) { // if (users != undefined) {
// let user = users.find((user) => user.loginId == message.loginId) // let user = users.find((user) => user.loginId == message.loginId)
// //
// // userProfilePathが使えるpathかをcheckして使えないpathの場合、default画像の経路に変更 // // userProfilePathが使えるpathかをcheckして使えないpathの場合、default画像の経路に変更
// if (user) { // if (user) {
// message.profileImagePath = CHAT.getProfileImgUrl(user.profileImagePath) // message.profileImagePath = CHAT.getProfileImgUrl(user.profileImagePath)
// } else { // } else {
// message.profileImagePath = CHAT.getProfileImgUrl("") // message.profileImagePath = CHAT.getProfileImgUrl("")
// } // }
// } else { // } else {
// message.profileImagePath = CHAT.getProfileImgUrl(message.profileImagePath) // message.profileImagePath = CHAT.getProfileImgUrl(message.profileImagePath)
// } // }
// //
// // #36147 // // #36147
// message.message = message.message.toString(); // message.message = message.message.toString();
// var replacePath = message.message; // var replacePath = message.message;
// replacePath = replacePath.replaceAll('/acms',CHAT_SERVER_URL+'/acms'); // replacePath = replacePath.replaceAll('/acms',CHAT_SERVER_URL+'/acms');
// message.message = replacePath; // message.message = replacePath;
// let html = Mustache.render(template, { // let html = Mustache.render(template, {
// text: message.message, // text: message.message,
// from: message.loginId, // from: message.loginId,
// profileImage: message.profileImagePath, // profileImage: message.profileImagePath,
// createdAtDay: messageTime.createdAtDay, // createdAtDay: messageTime.createdAtDay,
// createdAtTime: messageTime.createdAtTime // createdAtTime: messageTime.createdAtTime
// }); // });
// html = message.message.includes('attachedImages') || message.message.includes('attachedVideos') ? CHAT_UTIL.htmlDecode(html) : html; // html = message.message.includes('attachedImages') || message.message.includes('attachedVideos') ? CHAT_UTIL.htmlDecode(html) : html;
// workVal = html + workVal; // workVal = html + workVal;
// }) // })
// //
// // メッセージの画面描画 // // メッセージの画面描画
// jQueryMessages.prepend(workVal); // jQueryMessages.prepend(workVal);
// if (beforeHeight !== 0) { // if (beforeHeight !== 0) {
// // 追加のメッセージ読み込み時は読み込み前のスクロール位置を維持 // // 追加のメッセージ読み込み時は読み込み前のスクロール位置を維持
// setTimeout(function () { // setTimeout(function () {
// jQueryMessages.scrollTop(jQueryMessages.prop('scrollHeight') - beforeHeight); // jQueryMessages.scrollTop(jQueryMessages.prop('scrollHeight') - beforeHeight);
// }, 400); // }, 400);
// } else { // } else {
// // 新規に入室の場合は最下部へスクロール // // 新規に入室の場合は最下部へスクロール
// CHAT_UI.waitForLoadingImage(jQueryMessages, CHAT_UI.scrollToBottom); // CHAT_UI.waitForLoadingImage(jQueryMessages, CHAT_UI.scrollToBottom);
// // タブレット等、画面サイズが大きい場合、スクロール出来なくならないよう追加で10件メッセージを取得 // // タブレット等、画面サイズが大きい場合、スクロール出来なくならないよう追加で10件メッセージを取得
// if ($(window).height() > jQueryMessages.height()) { // if ($(window).height() > jQueryMessages.height()) {
// $('#messages').scroll(); // $('#messages').scroll();
// } // }
// } // }
// //
// // ユーザ削除ボタン表示しない // // ユーザ削除ボタン表示しない
// $("#userSelectionDeleteBtn").hide(); // $("#userSelectionDeleteBtn").hide();
// //
// CHAT_UI.dismissLoadingIndicator();// add some... // CHAT_UI.dismissLoadingIndicator();// add some...
// //
// // チャットに遷移する // // チャットに遷移する
// $('#pills-chat-tab').tab('show'); // $('#pills-chat-tab').tab('show');
// }); // });
// Update User List In Room // Update User List In Room
// サイドバーのユーザーリストアップデート。 // サイドバーのユーザーリストアップデート。
/* socket.on('updateUserList', function(users, onlineUsers) { /* socket.on('updateUserList', function(users, onlineUsers) {
console.log(users); console.log(users);
console.log(onlineUsers); console.log(onlineUsers);
...@@ -389,26 +420,30 @@ function setSocketAction () { ...@@ -389,26 +420,30 @@ function setSocketAction () {
});*/ });*/
// Update Group List(Invite) // Update Group List(Invite)
socket.on('refreshGroupList', function(groups, isInvite) { socket.on("refreshGroupList", function (groups, isInvite) {
$('#group_list').html(''); $("#group_list").html("");
const template = $('#group-template').html(); const template = $("#group-template").html();
if (groups.length === 0) { if (groups.length === 0) {
$('#group_list').append('<center class="text-secondary">'+ getLocalizedString(everyoneIsHere) +'</center>'); $("#group_list").append(
'<center class="text-secondary">' +
getLocalizedString(everyoneIsHere) +
"</center>"
);
} }
// グループ名と人数を表記する。 // グループ名と人数を表記する。
groups.forEach(function(group) { groups.forEach(function (group) {
let html = Mustache.render(template, { let html = Mustache.render(template, {
name: group.groupName, name: group.groupName,
info: group.memberCnt + getLocalizedString("people") info: group.memberCnt + getLocalizedString("people"),
}); });
// グループをクリックすると、該当グループのユーザーリストを読み込むようにイベントを与える // グループをクリックすると、該当グループのユーザーリストを読み込むようにイベントを与える
let obj = $(jQuery.parseHTML(html)).on('click', function() { let obj = $(jQuery.parseHTML(html)).on("click", function () {
// loadingIndicatorを表示 // loadingIndicatorを表示
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
socket.emit('getUserListInGroup', group.groupId, isInvite); socket.emit("getUserListInGroup", group.groupId, isInvite);
$('#groupName').text(group.groupName); $("#groupName").text(group.groupName);
}); });
$('#group_list').append(obj); $("#group_list").append(obj);
}); });
// Rotate // Rotate
...@@ -417,41 +452,47 @@ function setSocketAction () { ...@@ -417,41 +452,47 @@ function setSocketAction () {
} }
// Set Title // Set Title
let memberSelectTitle = getLocalizedString("groupSearch") let memberSelectTitle = getLocalizedString("groupSearch");
$('#pills-group-tab').tab('show'); $("#pills-group-tab").tab("show");
$('#backButton').show(); $("#backButton").show();
if (isInvite) { if (isInvite) {
$('.titleRoomName').text(memberSelectTitle); $(".titleRoomName").text(memberSelectTitle);
$('#newRoomName, .roomListIcon, .chatRoomIcon').hide(); $("#newRoomName, .roomListIcon, .chatRoomIcon").hide();
$('#userSelectionConfirmBtn').show(); $("#userSelectionConfirmBtn").show();
$("#userSelectionConfirmBtn").off().on('click', function() { $("#userSelectionConfirmBtn")
.off()
.on("click", function () {
CHAT_UI.setConfirmButtonEvent(isInvite); CHAT_UI.setConfirmButtonEvent(isInvite);
}); });
} else { } else {
$('.titleRoomName').text(memberSelectTitle); $(".titleRoomName").text(memberSelectTitle);
$('.roomListIcon, .chatRoomIcon, #newRoomName').hide(); $(".roomListIcon, .chatRoomIcon, #newRoomName").hide();
$('#userSelectionConfirmBtn').show(); $("#userSelectionConfirmBtn").show();
$("#userSelectionConfirmBtn").off().on('click', function() { $("#userSelectionConfirmBtn")
.off()
.on("click", function () {
CHAT_UI.setConfirmButtonEvent(isInvite); CHAT_UI.setConfirmButtonEvent(isInvite);
}); });
} }
if (CHAT.globalSelectedUserList.length > 0) { if (CHAT.globalSelectedUserList.length > 0) {
$('#userSelectionLength').text(CHAT.globalSelectedUserList.length); $("#userSelectionLength").text(CHAT.globalSelectedUserList.length);
} else { } else {
$('#userSelectionLength').text(''); $("#userSelectionLength").text("");
} }
$('#backButton').off().on('click', function() { $("#backButton")
.off()
.on("click", function () {
// loadingIndicatorを表示 // loadingIndicatorを表示
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
if (isInvite) { if (isInvite) {
$('#pills-chat-tab').tab('show'); $("#pills-chat-tab").tab("show");
} else { } else {
if (IS_ONLINE == 'true') { if (IS_ONLINE == "true") {
android.updateRoomList(); android.updateRoomList();
CHAT_UI.refreshRoomList(chatRoomType.DM); CHAT_UI.refreshRoomList(chatRoomType.DM);
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
...@@ -462,57 +503,63 @@ function setSocketAction () { ...@@ -462,57 +503,63 @@ function setSocketAction () {
// Update User List(Invite) // Update User List(Invite)
// #36170 // #36170
socket.on('refreshUserListInGroup', function(users, groupId, isInvite) { socket.on("refreshUserListInGroup", function (users, groupId, isInvite) {
$('#user_list').html(''); $("#user_list").html("");
const template = $('#user-template').html(); const template = $("#user-template").html();
// Set Title // Set Title
let memberSelectTitle = getLocalizedString("userSearch") let memberSelectTitle = getLocalizedString("userSearch");
$('.titleRoomName').text(memberSelectTitle); $(".titleRoomName").text(memberSelectTitle);
users.forEach( function(user) { users.forEach(function (user) {
// loadingIndicatorを表示 // loadingIndicatorを表示
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
user.profileImagePath = CHAT.getProfileImgUrl(user.profileImagePath) user.profileImagePath = CHAT.getProfileImgUrl(user.profileImagePath);
let html = Mustache.render(template, { let html = Mustache.render(template, {
id: user.shopMemberId, id: user.shopMemberId,
profileImage: user.profileImagePath, profileImage: user.profileImagePath,
name: user.loginId name: user.loginId,
}); });
// クリックするとactive クラスを与え、チェック表示を出させる。 // クリックするとactive クラスを与え、チェック表示を出させる。
let obj = $(jQuery.parseHTML(html)).on('click',function() { let obj = $(jQuery.parseHTML(html)).on("click", function () {
if ($(this).find('.userCheckBox.active').length > 0) { if ($(this).find(".userCheckBox.active").length > 0) {
// remove // remove
CHAT.globalSelectedUserList = CHAT.globalSelectedUserList.filter(function(element) { CHAT.globalSelectedUserList = CHAT.globalSelectedUserList.filter(
function (element) {
return user.loginId != element.loginId; return user.loginId != element.loginId;
}); }
);
} else { } else {
// add // add
CHAT.globalSelectedUserList.push({loginId:user.loginId, shopMemberId : user.shopMemberId, profileImagePath: user.profileImagePath}); CHAT.globalSelectedUserList.push({
loginId: user.loginId,
shopMemberId: user.shopMemberId,
profileImagePath: user.profileImagePath,
});
} }
$(this).find('.userCheckBox').toggleClass('active'); $(this).find(".userCheckBox").toggleClass("active");
if (CHAT.globalSelectedUserList.length > 0) { if (CHAT.globalSelectedUserList.length > 0) {
$('#userSelectionLength').text(CHAT.globalSelectedUserList.length); $("#userSelectionLength").text(CHAT.globalSelectedUserList.length);
} else { } else {
$('#userSelectionLength').text(''); $("#userSelectionLength").text("");
} }
}); });
let findObj = CHAT.globalSelectedUserList.find(function(selectedUser) { let findObj = CHAT.globalSelectedUserList.find(function (selectedUser) {
return selectedUser.loginId == user.loginId; return selectedUser.loginId == user.loginId;
}) });
if (findObj) { if (findObj) {
$(obj).find('.userCheckBox').toggleClass('active'); $(obj).find(".userCheckBox").toggleClass("active");
} }
$('#user_list').append(obj); $("#user_list").append(obj);
}) });
$('.userCheckBox').show(); $(".userCheckBox").show();
// Rotate // Rotate
if (CHAT_UI.isLandscapeMode()) { if (CHAT_UI.isLandscapeMode()) {
...@@ -520,53 +567,57 @@ function setSocketAction () { ...@@ -520,53 +567,57 @@ function setSocketAction () {
$(".squareBoxContent span").addClass("landscape_span"); $(".squareBoxContent span").addClass("landscape_span");
} }
$('#backButton').off().on('click', function() { $("#backButton")
.off()
.on("click", function () {
// loadingIndicatorを表示 // loadingIndicatorを表示
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
socket.emit('getGroupList', isInvite) socket.emit("getGroupList", isInvite);
}); });
$("#userSelectionConfirmBtn").off().on('click', function() { $("#userSelectionConfirmBtn")
.off()
.on("click", function () {
// loadingIndicatorを表示 // loadingIndicatorを表示
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
CHAT_UI.setConfirmButtonEvent(isInvite); CHAT_UI.setConfirmButtonEvent(isInvite);
}); });
$('#backButton').show(); $("#backButton").show();
$('.roomListIcon, .chatRoomIcon').hide(); $(".roomListIcon, .chatRoomIcon").hide();
$('#userSelectionConfirmBtn').show(); $("#userSelectionConfirmBtn").show();
$('.userCheckBox').show(); $(".userCheckBox").show();
$('#pills-user-tab').tab('show'); $("#pills-user-tab").tab("show");
}); });
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* Show Error Log */ /* Show Error Log */
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
socket.on('showServerError', function(message) { socket.on("showServerError", function (message) {
// #36174 // #36174
// #36215 // #36215
if (message.includes("SC_FORBIDDEN")) if (message.includes("SC_FORBIDDEN")) {
{ alert("SC_FORBIDDEN");
alert('SC_FORBIDDEN');
return; return;
} }
if (message == 'server error Ocurred') { if (message == "server error Ocurred") {
message = getLocalizedString("serverErrorOccured"); message = getLocalizedString("serverErrorOccured");
} else if (message == 'Room not found') { } else if (message == "Room not found") {
message = getLocalizedString("errorRoomNotFound"); message = getLocalizedString("errorRoomNotFound");
} }
$("#customAlertTitle").text(message); $("#customAlertTitle").text(message);
$("#customAlertOk").text(getLocalizedString("yesTitle")); $("#customAlertOk").text(getLocalizedString("yesTitle"));
$('#customAlert').appendTo("body").modal({ $("#customAlert")
backdrop: 'static', .appendTo("body")
keyboard: false .modal({
backdrop: "static",
keyboard: false,
}) })
.on('click', '#customAlertOk', function(e) { .on("click", "#customAlertOk", function (e) {});
});
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
if (message == "Room not found") { if (message == "Room not found") {
...@@ -586,31 +637,34 @@ function setSocketAction () { ...@@ -586,31 +637,34 @@ function setSocketAction () {
// androidでの場合 // androidでの場合
android.getLoginParameter(); android.getLoginParameter();
} else { } else {
CHAT_UI.htmlElementTextInitialize("ko") CHAT_UI.htmlElementTextInitialize("ko");
// webでのsocket connect // webでのsocket connect
socket.emit('join', params, function(err) { socket.emit("join", params, function (err) {
if (err) { if (err) {
// #36174 // #36174
$("#customAlertTitle").text(err); $("#customAlertTitle").text(err);
$("#customAlertOk").text(getLocalizedString("yesTitle")); $("#customAlertOk").text(getLocalizedString("yesTitle"));
$('#customAlert').appendTo("body").modal({ $("#customAlert")
backdrop: 'static', .appendTo("body")
keyboard: false .modal({
backdrop: "static",
keyboard: false,
}) })
.on('click', '#customAlertOk', function(e) { .on("click", "#customAlertOk", function (e) {});
});
} else { } else {
if (params.roomName != undefined) { if (params.roomName != undefined) {
$('.titleRoomName').text(params.roomName).data('roomName', params.roomName); $(".titleRoomName")
.text(params.roomName)
.data("roomName", params.roomName);
} else { } else {
let roomListTitle = getLocalizedString("roomListTitle") let roomListTitle = getLocalizedString("roomListTitle");
$('.titleRoomName').text(roomListTitle) $(".titleRoomName").text(roomListTitle);
} }
} }
// loadingIndicatorを表示しない // loadingIndicatorを表示しない
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}); });
} }
}) });
} }
...@@ -15,78 +15,96 @@ var beforeHeight = window.innerHeight; ...@@ -15,78 +15,96 @@ var beforeHeight = window.innerHeight;
var beforeWidth = window.innerWidth; var beforeWidth = window.innerWidth;
var beforeScroll; var beforeScroll;
CHAT.saveRoomInfo = function(roomId, roomName) { CHAT.saveRoomInfo = function (roomId, roomName) {
CHAT.globalLoginParameter.roomId = roomId; CHAT.globalLoginParameter.roomId = roomId;
CHAT.globalLoginParameter.roomName = roomName; CHAT.globalLoginParameter.roomName = roomName;
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.roomInfosaveMessageHandlerId.postMessage({"roomId":roomId, "roomName":roomName}); webkit.messageHandlers.roomInfosaveMessageHandlerId.postMessage({
roomId: roomId,
roomName: roomName,
});
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
if (roomId == undefined && roomName == undefined) { if (roomId == undefined && roomName == undefined) {
android.saveVisitRoomInfo('', ''); android.saveVisitRoomInfo("", "");
} else { } else {
android.saveVisitRoomInfo(roomId, roomName); android.saveVisitRoomInfo(roomId, roomName);
} }
} }
} };
// #36170 画像パスが存在しない場合はデフォルトの画像を返す // #36170 画像パスが存在しない場合はデフォルトの画像を返す
// 存在する場合はプロフィール画像取得用APIのURLを生成して返す // 存在する場合はプロフィール画像取得用APIのURLを生成して返す
CHAT.getProfileImgUrl = function(path) { CHAT.getProfileImgUrl = function (path) {
if (path == undefined || path == "") { if (path == undefined || path == "") {
return ASSET_PATH + 'img/noImage.png'; return ASSET_PATH + "img/noImage.png";
} else { } else {
if (path.includes('/mnt')) { if (path.includes("/mnt")) {
var userInfo = path.split("/").reverse(); var userInfo = path.split("/").reverse();
return CMS_SERVER_URL + '/chatapi/user?profileFileName=' + userInfo[0] + '&profileGetLoginId=' + userInfo[1] + '&sid=' + CHAT.globalLoginParameter.sid + '&cmd=12'; return (
CMS_SERVER_URL +
"/chatapi/user?profileFileName=" +
userInfo[0] +
"&profileGetLoginId=" +
userInfo[1] +
"&sid=" +
CHAT.globalLoginParameter.sid +
"&cmd=12"
);
} else { } else {
return path; return path;
} }
} }
} };
// Video のサムネイルファイル生成する // Video のサムネイルファイル生成する
CHAT.createVideoThumbnailAndUpload = function(sourceImage, callback) { CHAT.createVideoThumbnailAndUpload = function (sourceImage, callback) {
var fileReader = new FileReader(); var fileReader = new FileReader();
fileReader.onload = function() { fileReader.onload = function () {
var blob = new Blob([fileReader.result], {type: sourceImage.type}); var blob = new Blob([fileReader.result], { type: sourceImage.type });
var url = URL.createObjectURL(blob); var url = URL.createObjectURL(blob);
var video = document.createElement('video'); var video = document.createElement("video");
var timeupdate = function() { var timeupdate = function () {
if (snapImage()) { if (snapImage()) {
video.removeEventListener('timeupdate', timeupdate); video.removeEventListener("timeupdate", timeupdate);
video.pause(); video.pause();
} }
}; };
video.addEventListener('loadeddata', function() { video.addEventListener("loadeddata", function () {
if (snapImage()) { if (snapImage()) {
video.removeEventListener('timeupdate', timeupdate); video.removeEventListener("timeupdate", timeupdate);
} }
}); });
var snapImage = function() { var snapImage = function () {
var canvas = document.createElement('canvas'); var canvas = document.createElement("canvas");
canvas.width = video.videoWidth; canvas.width = video.videoWidth;
canvas.height = video.videoHeight; canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height); canvas
.getContext("2d")
.drawImage(video, 0, 0, canvas.width, canvas.height);
fetch(canvas.toDataURL("image/jpeg")) fetch(canvas.toDataURL("image/jpeg"))
.then(function(res) { .then(function (res) {
return res.arrayBuffer(); return res.arrayBuffer();
}) })
.then(function(buf) { .then(function (buf) {
// 回転された画像をFormDataに保存 // 回転された画像をFormDataに保存
const newFile = new File([buf], sourceImage.name, {type:"image/jpeg"}); const newFile = new File([buf], sourceImage.name, {
type: "image/jpeg",
});
callback(newFile, true); callback(newFile, true);
// ajax End // ajax End
}).catch((error) => { // fetch Error catch Block })
.catch((error) => {
// fetch Error catch Block
if (error) { if (error) {
console.log(error) console.log(error);
} }
}); });
return true; return true;
}; };
video.addEventListener('timeupdate', timeupdate); video.addEventListener("timeupdate", timeupdate);
video.preload = 'metadata'; video.preload = "metadata";
video.src = url; video.src = url;
// Load video in Safari / IE11 // Load video in Safari / IE11
video.muted = true; video.muted = true;
...@@ -94,15 +112,16 @@ CHAT.createVideoThumbnailAndUpload = function(sourceImage, callback) { ...@@ -94,15 +112,16 @@ CHAT.createVideoThumbnailAndUpload = function(sourceImage, callback) {
video.pause(); video.pause();
}; };
fileReader.readAsArrayBuffer(sourceImage); fileReader.readAsArrayBuffer(sourceImage);
} };
// Ajaxでイメージをアップロードする // Ajaxでイメージをアップロードする
CHAT.uploadImage = function(formData) { CHAT.uploadImage = function (formData) {
formData.append('roomId', CHAT.globalLoginParameter.roomId); formData.append("roomId", CHAT.globalLoginParameter.roomId);
formData.append('sid', CHAT.globalLoginParameter.sid); formData.append("sid", CHAT.globalLoginParameter.sid);
jQuery.ajax({ jQuery
.ajax({
async: true, async: true,
url: CMS_SERVER_URL+"/chatapi/file/upload", url: CMS_SERVER_URL + "/chatapi/file/upload",
type: "post", type: "post",
data: formData, data: formData,
contentType: false, contentType: false,
...@@ -110,136 +129,228 @@ CHAT.uploadImage = function(formData) { ...@@ -110,136 +129,228 @@ CHAT.uploadImage = function(formData) {
error: function () { error: function () {
alert("読み込み失敗"); alert("読み込み失敗");
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
} },
}).done(function(res) { })
var imgPath = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.fileName + '&roomId=' + CHAT.globalLoginParameter.roomId; .done(function (res) {
var imageName = res.fileName var imgPath =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.fileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
var imageName = res.fileName;
// uploadFileの判断 // uploadFileの判断
var extension = imageName.substr(imageName.lastIndexOf('.') + 1).toLowerCase(); var extension = imageName
.substr(imageName.lastIndexOf(".") + 1)
.toLowerCase();
// 画像の処理 // 画像の処理
if (res.fileType == "jpeg" || res.fileType == "jpg" || res.fileType == "png") { if (
res.fileType == "jpeg" ||
res.fileType == "jpg" ||
res.fileType == "png"
) {
if (res.thumbnailPath && res.thumbnailPath.length > 0) { if (res.thumbnailPath && res.thumbnailPath.length > 0) {
imgPath = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.thumbImageFileName + '&roomId=' + CHAT.globalLoginParameter.roomId; imgPath =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.thumbImageFileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
imageName = res.thumbImageFileName; imageName = res.thumbImageFileName;
} }
let downloadPath = CMS_SERVER_URL + '/chatapi/file/download?fileName=' + imageName + '&roomId=' + CHAT.globalLoginParameter.roomId; let downloadPath =
CMS_SERVER_URL +
"/chatapi/file/download?fileName=" +
imageName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
// アップロードが終了した後ローディング画面から離れてメッセージをメッセージを転送する // アップロードが終了した後ローディング画面から離れてメッセージをメッセージを転送する
const lightbox = $('<a/>', {'data-lightbox':'attachedImages', 'data-title':imageName}); const lightbox = $("<a/>", {
const image = $('<img/>', {src:imgPath, width:'auto', style:'max-width:100%', 'data-toggle':'modal', onclick:'imageModal(this);'}); "data-lightbox": "attachedImages",
const downloadIcon = $('<a/>', {href:downloadPath, class:'fa fa-download', download:res.fileName}); "data-title": imageName,
});
const image = $("<img/>", {
src: imgPath,
width: "auto",
style: "max-width:100%",
"data-toggle": "modal",
onclick: "imageModal(this);",
});
const downloadIcon = $("<a/>", {
href: downloadPath,
class: "fa fa-download",
download: res.fileName,
});
lightbox.append(image); lightbox.append(image);
lightbox.append(downloadIcon); lightbox.append(downloadIcon);
let text = lightbox.prop('outerHTML') let text = lightbox.prop("outerHTML");
let encodedText let encodedText;
try { try {
encodedText = encodeURIComponent(text) encodedText = encodeURIComponent(text);
} catch(e) { } catch (e) {
encodedText = text; encodedText = text;
} }
socket.emit('createMessage', { socket.emit(
text: encodedText + messageSeperator + messageType.IMAGE "createMessage",
}, 1); {
text: encodedText + messageSeperator + messageType.IMAGE,
} else { // 動画の処理 },
1
);
} else {
// 動画の処理
if (res.thumbnailPath && res.thumbnailPath.length > 0) { if (res.thumbnailPath && res.thumbnailPath.length > 0) {
imgPath = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.thumbImageFileName + '&roomId=' + CHAT.globalLoginParameter.roomId; imgPath =
} CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
let downloadPath = CMS_SERVER_URL + '/chatapi/file/download?fileName=' + imageName + '&roomId=' + CHAT.globalLoginParameter.roomId; res.thumbImageFileName +
"&roomId=" +
var videoSrc = CMS_SERVER_URL + '/chatapi/file/getImage?fileName=' + res.fileName + '&roomId=' + CHAT.globalLoginParameter.roomId; CHAT.globalLoginParameter.roomId;
const totalDiv = $('<div/>', {id:"attachedImages"}); }
const videoTag = $('<video/>', {controls:"true", width:'auto', style:'max-width:100%'});
const source = $('<source/>', {src:videoSrc}); let downloadPath =
const downloadIcon = $('<a/>',{href:downloadPath, class:'fa fa-download', download:res.fileName}); CMS_SERVER_URL +
"/chatapi/file/download?fileName=" +
imageName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
var videoSrc =
CMS_SERVER_URL +
"/chatapi/file/getImage?fileName=" +
res.fileName +
"&roomId=" +
CHAT.globalLoginParameter.roomId;
const totalDiv = $("<div/>", { id: "attachedImages" });
const videoTag = $("<video/>", {
controls: "true",
width: "auto",
style: "max-width:100%",
});
const source = $("<source/>", { src: videoSrc });
const downloadIcon = $("<a/>", {
href: downloadPath,
class: "fa fa-download",
download: res.fileName,
});
videoTag.append(source); videoTag.append(source);
totalDiv.append(videoTag); totalDiv.append(videoTag);
totalDiv.append(downloadIcon); totalDiv.append(downloadIcon);
let text = totalDiv.prop('outerHTML'); let text = totalDiv.prop("outerHTML");
let encodedText let encodedText;
try { try {
encodedText = encodeURIComponent(text) encodedText = encodeURIComponent(text);
} catch(e) { } catch (e) {
encodedText = text; encodedText = text;
} }
socket.emit('createMessage', { socket.emit(
text: encodedText + messageSeperator + messageType.VIDEO "createMessage",
}, 1); {
text: encodedText + messageSeperator + messageType.VIDEO,
},
1
);
} }
$('.overlay').removeClass('active undismissable'); $(".overlay").removeClass("active undismissable");
$('.loader').removeClass('active'); $(".loader").removeClass("active");
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
}) });
} };
CHAT.createGetDataUrl = function(fileName, roomId) { CHAT.createGetDataUrl = function (fileName, roomId) {
var filePath = CMS_SERVER_URL + '/chatapi/file/getImage?sid=' + CHAT.globalLoginParameter.sid + '&fileName=' + fileName + '&roomId=' + roomId; var filePath =
CMS_SERVER_URL +
"/chatapi/file/getImage?sid=" +
CHAT.globalLoginParameter.sid +
"&fileName=" +
fileName +
"&roomId=" +
roomId;
return filePath; return filePath;
} };
// Thumbnailのファイルを生成する。 // Thumbnailのファイルを生成する。
CHAT.createThumbnailAndUpload = function(sourceImage, callback) { CHAT.createThumbnailAndUpload = function (sourceImage, callback) {
const fileReader = new FileReader(); const fileReader = new FileReader();
const img = new Image(); const img = new Image();
fileReader.onloadend = function() { fileReader.onloadend = function () {
img.src = fileReader.result img.src = fileReader.result;
} };
img.onload = function() { img.onload = function () {
const elem = document.createElement('canvas'); const elem = document.createElement("canvas");
var rate var rate;
var width = img.width var width = img.width;
var height = img.height var height = img.height;
if ((img.width <= 500) && (img.height <= 500)) if (img.width <= 500 && img.height <= 500) {
{ callback(undefined, false);
callback(undefined, false) return;
return
} }
if (img.width > img.height) if (img.width > img.height) {
{ rate = 500 / img.width;
rate = 500/img.width
} else { } else {
rate = 500/img.height rate = 500 / img.height;
} }
elem.width = width * rate; elem.width = width * rate;
elem.height = height * rate; elem.height = height * rate;
const ctx = elem.getContext('2d') const ctx = elem.getContext("2d");
ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, elem.width, elem.height); ctx.drawImage(
img,
0,
0,
img.width,
img.height,
0,
0,
elem.width,
elem.height
);
// ctx.drawImage(img, 0, 0, width, height); // ctx.drawImage(img, 0, 0, width, height);
fetch(elem.toDataURL("image/jpeg")) fetch(elem.toDataURL("image/jpeg"))
.then(function(res) { .then(function (res) {
return res.arrayBuffer(); return res.arrayBuffer();
}) })
.then(function(buf) { .then(function (buf) {
const newFile = new File([buf], sourceImage.name, {type:"image/jpeg"}); const newFile = new File([buf], sourceImage.name, {
type: "image/jpeg",
callback(newFile, true) });
}).catch((error) => { // fetch Error catch Block callback(newFile, true);
})
.catch((error) => {
// fetch Error catch Block
if (error) { if (error) {
console.log(error) console.log(error);
} }
}); });
} };
fileReader.readAsDataURL(sourceImage); fileReader.readAsDataURL(sourceImage);
} };
// 該当チャットルームに参加するためログイン情報をサーバに渡す // 該当チャットルームに参加するためログイン情報をサーバに渡す
getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomName = undefined, languageCode, shopMemberId) { getLoginParameter = function (
var loginParam = new Object() sid,
loginId,
shopName,
roomId = undefined,
roomName = undefined,
languageCode,
shopMemberId
) {
var loginParam = new Object();
loginParam.sid = sid; loginParam.sid = sid;
loginParam.loginId = loginId; loginParam.loginId = loginId;
loginParam.shopName = shopName; loginParam.shopName = shopName;
...@@ -250,12 +361,12 @@ getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomNam ...@@ -250,12 +361,12 @@ getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomNam
CHAT.globalLoginParameter = loginParam; CHAT.globalLoginParameter = loginParam;
if (!languageCode) { if (!languageCode) {
languageCode = "en" languageCode = "en";
} }
// fermi coview share // fermi coview share
globalUserInfo.sid = sid; globalUserInfo.sid = sid;
globalUserInfo.loginId = shopName + '_' + loginId; globalUserInfo.loginId = shopName + "_" + loginId;
globalUserInfo.shopName = shopName; globalUserInfo.shopName = shopName;
globalUserInfo.roomId = roomId; globalUserInfo.roomId = roomId;
globalUserInfo.roomName = roomName; globalUserInfo.roomName = roomName;
...@@ -263,209 +374,231 @@ getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomNam ...@@ -263,209 +374,231 @@ getLoginParameter = function(sid, loginId, shopName, roomId = undefined, roomNam
CHAT_UI.htmlElementTextInitialize(languageCode); CHAT_UI.htmlElementTextInitialize(languageCode);
CHAT_UI.dismissLoadingIndicator(); CHAT_UI.dismissLoadingIndicator();
} };
CHAT.leaveRoom = function() { CHAT.leaveRoom = function () {
socket.emit('leaveRoom', function() { socket.emit("leaveRoom", function () {});
}); };
}
$(function() { $(function () {
// ルーム名変更イベント // ルーム名変更イベント
$('.change_room_name_btn button').click(function(){ $(".change_room_name_btn button").click(function () {
$('form').submit(); $("form").submit();
}); });
// 検索アイコン押下イベント // 検索アイコン押下イベント
$('.nav_item_wrap .search_menu').click(function(){ $(".nav_item_wrap .search_menu").click(function () {
$('.nav_item_wrap').addClass('none'); $(".nav_item_wrap").addClass("none");
$('.footer-wrap').addClass('none'); $(".footer-wrap").addClass("none");
$('.chat_room_src_form').removeClass('none'); $(".chat_room_src_form").removeClass("none");
$('.room_container').addClass('none'); $(".room_container").addClass("none");
$('.overlay_src_msg').removeClass('none'); $(".overlay_src_msg").removeClass("none");
// フィルタ表示 // フィルタ表示
$('#filter').removeClass('none'); $("#filter").removeClass("none");
$('#user_list').addClass('none'); $("#user_list").addClass("none");
$('.chat_room_src_form input[type="search"]').focus(); $('.chat_room_src_form input[type="search"]').focus();
$('#searchMessage').addClass('onfocus'); $("#searchMessage").addClass("onfocus");
$('.chat_list').removeClass('none'); $(".chat_list").removeClass("none");
}); });
$('.chat_room_src_form .cancel').click(function(){ $(".chat_room_src_form .cancel").click(function () {
$('.nav_item_wrap').removeClass('none'); $(".nav_item_wrap").removeClass("none");
$('.footer-wrap').removeClass('none'); $(".footer-wrap").removeClass("none");
$('.chat_room_src_form').addClass('none'); $(".chat_room_src_form").addClass("none");
$('.chat_room_src_form input').val(''); $(".chat_room_src_form input").val("");
$('.room_container').removeClass('none'); $(".room_container").removeClass("none");
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
// ユーザーリスト表示 // ユーザーリスト表示
$('#filter').addClass('none'); $("#filter").addClass("none");
$('#user_list').removeClass('none'); $("#user_list").removeClass("none");
$('.chat_room_src_form input[type="search"]').blur(); $('.chat_room_src_form input[type="search"]').blur();
$('#searchMessage').removeClass('onfocus'); $("#searchMessage").removeClass("onfocus");
$('.chat_list').addClass('none'); $(".chat_list").addClass("none");
CHAT_UI.scrollToBottom(); CHAT_UI.scrollToBottom();
}); });
$('.chat_room_src_form input[type="search"]').click(function() { $('.chat_room_src_form input[type="search"]').click(function () {
if($('#searchMessage').hasClass('onfocus')) { if ($("#searchMessage").hasClass("onfocus")) {
$('#searchMessage').removeClass('onfocus'); $("#searchMessage").removeClass("onfocus");
$('#searchMessage').blur(); $("#searchMessage").blur();
} else { } else {
$('#searchMessage').addClass('onfocus'); $("#searchMessage").addClass("onfocus");
$('#searchMessage').focus(); $("#searchMessage").focus();
} }
}) });
$('#searchMessage').blur(function() { $("#searchMessage").blur(function () {
$('#searchMessage').removeClass('onfocus'); $("#searchMessage").removeClass("onfocus");
}) });
// フィルタ選択イベント // フィルタ選択イベント
$(document).on('click', '#filter .img_wrap', function(event) { $(document).on("click", "#filter .img_wrap", function (event) {
// チェックアイコン追加 // チェックアイコン追加
$(this).toggleClass("filter"); $(this).toggleClass("filter");
}); });
$('#chat .search_form input[type="search"]').click(function(){ $('#chat .search_form input[type="search"]').click(function () {
let roomListTitle = getLocalizedString("room_search_placeholder"); let roomListTitle = getLocalizedString("room_search_placeholder");
$('#chatTitle').text(roomListTitle); $("#chatTitle").text(roomListTitle);
}); });
$('#chat .search_form .cancel').click(function(){ $("#chat .search_form .cancel").click(function () {
let roomListTitle = getLocalizedString("roomListTitle"); let roomListTitle = getLocalizedString("roomListTitle");
$('#chatTitle').text(roomListTitle); $("#chatTitle").text(roomListTitle);
}); });
$('#chat_add_user .search_form .cancel').click(function() { $("#chat_add_user .search_form .cancel").click(function () {
let roomListTitle = getLocalizedString("inviteUsersSubtitle"); let roomListTitle = getLocalizedString("inviteUsersSubtitle");
$('#addUserTitle').text(roomListTitle); $("#addUserTitle").text(roomListTitle);
}); });
$('#chatMakeRoom .search_form .cancel').click(function() { $("#chatMakeRoom .search_form .cancel").click(function () {
let roomListTitle = getLocalizedString("createRoomTitle"); let roomListTitle = getLocalizedString("createRoomTitle");
$('#makeRoomTitle').text(roomListTitle); $("#makeRoomTitle").text(roomListTitle);
}); });
// チャットメンバー検索 // チャットメンバー検索
$('#chat .search_form input[type="search"]').keyup(function(e){ $('#chat .search_form input[type="search"]').keyup(function (e) {
var rooms; var rooms;
var keyword = $('#chat .search_form input[type="search"]').val(); var keyword = $('#chat .search_form input[type="search"]').val();
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
if (keyword.length != 0 && keyword != '') { if (keyword.length != 0 && keyword != "") {
$('#chat .search_form input[type="search"]').blur(); $('#chat .search_form input[type="search"]').blur();
return; return;
} }
} else if (keyword == '' || keyword.length < 2) { } else if (keyword == "" || keyword.length < 2) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
return; return;
} }
CHAT.searchRoom(keyword, rooms); CHAT.searchRoom(keyword, rooms);
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
$('#chat .search_form input[type="search"]').blur(); $('#chat .search_form input[type="search"]').blur();
return ; return;
} }
}); });
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#chat .search_form input[type="search"]').on('compositionend', function(){ $('#chat .search_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var rooms; var rooms;
var keyword = $('#chat .search_form input[type="search"]').val(); var keyword = $('#chat .search_form input[type="search"]').val();
CHAT.searchRoom(keyword, rooms); CHAT.searchRoom(keyword, rooms);
} }
}); }
);
var footerHeight = $('.footer-wrap').height(); var footerHeight = $(".footer-wrap").height();
window.addEventListener("resize", function() { window.addEventListener("resize", function () {
var afterHeight = window.innerHeight; var afterHeight = window.innerHeight;
var afterWidth = window.innerWidth; var afterWidth = window.innerWidth;
var moreScroll = beforeHeight - afterHeight; var moreScroll = beforeHeight - afterHeight;
if (beforeHeight > afterHeight && (beforeHeight - afterHeight) > 50) { if (beforeHeight > afterHeight && beforeHeight - afterHeight > 50) {
if (beforeWidth == afterWidth) { if (beforeWidth == afterWidth) {
//キーボード表示時 //キーボード表示時
$('.room_container').css('margin-bottom', 0); $(".room_container").css("margin-bottom", 0);
window.scrollTo(0, beforeScroll + moreScroll - $('.footer_content_b').height()); window.scrollTo(
0,
beforeScroll + moreScroll - $(".footer_content_b").height()
);
} else { } else {
//画面回転時 //画面回転時
window.scrollTo(0, beforeScroll + (moreScroll * 2) - $('.footer_content_b').height()); window.scrollTo(
0,
beforeScroll + moreScroll * 2 - $(".footer_content_b").height()
);
} }
} else if (beforeHeight < afterHeight) { } else if (beforeHeight < afterHeight) {
$('.room_container').css('margin-bottom', footerHeight); $(".room_container").css("margin-bottom", footerHeight);
if (beforeWidth == afterWidth) { if (beforeWidth == afterWidth) {
//キーボード非表示 //キーボード非表示
window.scrollTo(0, beforeScroll + moreScroll + $('.footer_content_b').height()); window.scrollTo(
0,
beforeScroll + moreScroll + $(".footer_content_b").height()
);
} else { } else {
//画面回転時 //画面回転時
window.scrollTo(0, beforeScroll + (moreScroll * 2) + $('.footer_content_b').height()); window.scrollTo(
0,
beforeScroll + moreScroll * 2 + $(".footer_content_b").height()
);
} }
} }
beforeHeight = window.innerHeight; beforeHeight = window.innerHeight;
beforeWidth = window.innerWidth; beforeWidth = window.innerWidth;
}); });
$('#messageInput').focusin(function(e) { $("#messageInput").focusin(function (e) {
beforeHeight = window.innerHeight; beforeHeight = window.innerHeight;
beforeWidth = window.innerWidth; beforeWidth = window.innerWidth;
beforeScroll = window.scrollY; beforeScroll = window.scrollY;
}) });
// チャットルーム // チャットルーム
// メッセージ検索イベント // メッセージ検索イベント
$('.chat_room_src_form input[type="search"]').keyup(function(e){ $('.chat_room_src_form input[type="search"]').keyup(function (e) {
let workVal = ""; let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val(); var keyword = $('.chat_room_src_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
if (keyword != '' && keyword.length != 0) { if (keyword != "" && keyword.length != 0) {
$('.chat_room_src_form input[type="search"]').blur(); $('.chat_room_src_form input[type="search"]').blur();
return; return;
} }
} else if (keyword == '' || keyword.length < 2) { } else if (keyword == "" || keyword.length < 2) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
return; return;
} }
CHAT.searchMessage(keyword, workVal); CHAT.searchMessage(keyword, workVal);
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
$('#searchMessage').removeClass('onfocus'); $("#searchMessage").removeClass("onfocus");
$('.chat_room_src_form input[type="search"]').blur(); $('.chat_room_src_form input[type="search"]').blur();
return; return;
} }
}); });
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('.chat_room_src_form input[type="search"]').on('compositionend', function(){ $('.chat_room_src_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
let workVal = ""; let workVal = "";
var keyword = $('.chat_room_src_form input[type="search"]').val(); var keyword = $('.chat_room_src_form input[type="search"]').val();
CHAT.searchMessage(keyword, workVal); CHAT.searchMessage(keyword, workVal);
} }
}); }
);
$(document).on('click', '.filter_img', function(event) { $(document).on("click", ".filter_img", function (event) {
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 = []; var checkedUserList = [];
$('.img_wrap.filter').each(function(user) { $(".img_wrap.filter").each(function (user) {
var selectedUser = $('.img_wrap.filter')[user]; var selectedUser = $(".img_wrap.filter")[user];
checkedUserList.push($(selectedUser).data('user-id')); checkedUserList.push($(selectedUser).data("user-id"));
}) });
if (keyword.length == 1) { return; } if (keyword.length == 1) {
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(',')); return;
}
var messages = CHAT_DB.searchMessages(keyword, checkedUserList.join(","));
var userMessageTemplate; var userMessageTemplate;
$.get({ url: "./template/template_user_message.html", async: false } $.get(
, function(text) { { url: "./template/template_user_message.html", async: false },
function (text) {
userMessageTemplate = text; userMessageTemplate = text;
}); }
);
var myMessageTemplate; var myMessageTemplate;
$.get({ url: "./template/template_my_message.html", async: false } $.get(
, function(text) { { url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text; myMessageTemplate = text;
}); }
);
let jQueryMessages = $('.overlay_src_msg'); let jQueryMessages = $(".overlay_src_msg");
messages.forEach(function(message) { messages.forEach(function (message) {
let template = userMessageTemplate; let template = userMessageTemplate;
if (message.shopMemberId == CHAT.globalLoginParameter.shopMemberId) { if (message.shopMemberId == CHAT.globalLoginParameter.shopMemberId) {
template = myMessageTemplate; template = myMessageTemplate;
...@@ -477,13 +610,16 @@ $(function() { ...@@ -477,13 +610,16 @@ $(function() {
// ユーザの様式を読み込む // ユーザの様式を読み込む
if (message.profileUrl) { if (message.profileUrl) {
message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl) message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl);
} else { } else {
message.profileUrl = CHAT.getProfileImgUrl("") message.profileUrl = CHAT.getProfileImgUrl("");
} }
message.message = message.message.toString(); message.message = message.message.toString();
var replacePath = message.message; var replacePath = message.message;
replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName='); replacePath = replacePath.replaceAll(
"?fileName=",
"?sid=" + CHAT.globalLoginParameter.sid + "&fileName="
);
message.message = replacePath; message.message = replacePath;
let html = Mustache.render(template, { let html = Mustache.render(template, {
...@@ -492,93 +628,117 @@ $(function() { ...@@ -492,93 +628,117 @@ $(function() {
shopMemberId: message.shopMemberId, shopMemberId: message.shopMemberId,
profileImage: message.profileUrl, profileImage: message.profileUrl,
createdAtDay: messageTime.createdAtDay, createdAtDay: messageTime.createdAtDay,
createdAtTime: messageTime.createdAtTime createdAtTime: messageTime.createdAtTime,
}); });
html = message.message.includes('attachedImages') || message.message.includes('attachedVideos') ? CHAT_UTIL.htmlDecode(html) : html; html =
message.message.includes("attachedImages") ||
message.message.includes("attachedVideos")
? CHAT_UTIL.htmlDecode(html)
: html;
workVal = html + workVal; workVal = html + workVal;
}) });
jQueryMessages.prepend(workVal); jQueryMessages.prepend(workVal);
}); });
}); });
// チャットルーム検索 // チャットルーム検索
CHAT.searchRoom = function(keyword, rooms) { CHAT.searchRoom = function (keyword, rooms) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").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; var template;
$.get({ url: "./template/template_room_list.html", async: false } $.get(
, function(text) { { url: "./template/template_room_list.html", async: false },
function (text) {
template = text; template = text;
}); }
rooms.forEach(function(room) { );
room.profileImagePath = ASSET_PATH + 'images/user-profile.png' rooms.forEach(function (room) {
room.profileImagePath = ASSET_PATH + "images/user-profile.png";
if (room.message) { if (room.message) {
room.message = room.message.toString() room.message = room.message.toString();
} else { } else {
room.message = getLocalizedString("noMessages") room.message = getLocalizedString("noMessages");
} }
var displayMsg; var displayMsg;
if (room.messageType == messageType.TEXT || room.messageType == messageType.SYSTEM) displayMsg = room.message; if (
if (room.messageType == messageType.IMAGE) displayMsg = getLocalizedString("image"); room.messageType == messageType.TEXT ||
if (room.messageType == messageType.VIDEO) displayMsg = getLocalizedString("video"); 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.TEXT) displayMsg = room.message;
if (room.messageType == messageType.COMMUNICATIONSTART) displayMsg = getLocalizedString("collaboration_start"); if (room.messageType == messageType.COMMUNICATIONSTART)
if (room.messageType == messageType.COMMUNICATIONEND) displayMsg = getLocalizedString("collaboration_end"); displayMsg = getLocalizedString("collaboration_start");
if (room.messageType == messageType.COMMUNICATIONEND)
displayMsg = getLocalizedString("collaboration_end");
var attendUserName = []; var attendUserName = [];
room.attendUsers.forEach(function(user) { room.attendUsers.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
attendUserName.push(user.shopMemberName); attendUserName.push(user.shopMemberName);
}); });
var thumbnailCount = room.attendUsers.length > 4 ? 4 : room.attendUsers.length; var thumbnailCount =
room.attendUsers.length > 4 ? 4 : room.attendUsers.length;
if (room.chatRoomName == "") { if (room.chatRoomName == "") {
room.chatRoomName = attendUserName.join(', '); room.chatRoomName = attendUserName.join(", ");
} }
let html = Mustache.render(template, { let html = Mustache.render(template, {
thumbnailCount: thumbnailCount, thumbnailCount: thumbnailCount,
roomName: room.chatRoomName, roomName: room.chatRoomName,
roomId: room.chatRoomId, roomId: room.chatRoomId,
profileImage: room.profileImagePath, profileImage: room.profileImagePath,
lastMessage: displayMsg , lastMessage: displayMsg,
time: room.insertDate ? CHAT_UTIL.formatDate(room.insertDate).createdAt : '', time: room.insertDate
unreadMsgCnt: room.unreadCount == 0 ? '' : room.unreadCount, ? CHAT_UTIL.formatDate(room.insertDate).createdAt
: "",
unreadMsgCnt: room.unreadCount == 0 ? "" : room.unreadCount,
userCnt: room.attendUsers.length + 1, userCnt: room.attendUsers.length + 1,
attendUsers: room.attendUsers attendUsers: room.attendUsers,
}); });
// Click event // Click event
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
}); });
if (rooms.length == 0) { if (rooms.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} }
}; };
// メッセージ検索 // メッセージ検索
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]; var 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(","));
var userMessageTemplate; var userMessageTemplate;
$.get({ url: "./template/template_user_message.html", async: false } $.get(
, function(text) { { url: "./template/template_user_message.html", async: false },
function (text) {
userMessageTemplate = text; userMessageTemplate = text;
}); }
);
var myMessageTemplate; var myMessageTemplate;
$.get({ url: "./template/template_my_message.html", async: false } $.get(
, function(text) { { url: "./template/template_my_message.html", async: false },
function (text) {
myMessageTemplate = text; myMessageTemplate = text;
}); }
);
let jQueryMessages = $('.overlay_src_msg'); let jQueryMessages = $(".overlay_src_msg");
messages.forEach(function(message) { messages.forEach(function (message) {
let template = userMessageTemplate; let template = userMessageTemplate;
if (message.shopMemberId == CHAT.globalLoginParameter.shopMemberId) { if (message.shopMemberId == CHAT.globalLoginParameter.shopMemberId) {
template = myMessageTemplate; template = myMessageTemplate;
...@@ -588,13 +748,16 @@ CHAT.searchMessage = function(keyword, workVal) { ...@@ -588,13 +748,16 @@ CHAT.searchMessage = function(keyword, workVal) {
} }
let messageTime = CHAT_UTIL.formatDate(message.insertDate); let messageTime = CHAT_UTIL.formatDate(message.insertDate);
if (message.profileUrl) { if (message.profileUrl) {
message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl) message.profileUrl = CHAT.getProfileImgUrl(message.profileUrl);
} else { } else {
message.profileUrl = CHAT.getProfileImgUrl("") message.profileUrl = CHAT.getProfileImgUrl("");
} }
message.message = message.message.toString(); message.message = message.message.toString();
var replacePath = message.message; var replacePath = message.message;
replacePath = replacePath.replaceAll('?fileName=', '?sid=' + CHAT.globalLoginParameter.sid + '&fileName='); replacePath = replacePath.replaceAll(
"?fileName=",
"?sid=" + CHAT.globalLoginParameter.sid + "&fileName="
);
message.message = replacePath; message.message = replacePath;
let html = Mustache.render(template, { let html = Mustache.render(template, {
text: message.message, text: message.message,
...@@ -602,15 +765,22 @@ CHAT.searchMessage = function(keyword, workVal) { ...@@ -602,15 +765,22 @@ CHAT.searchMessage = function(keyword, workVal) {
shopMemberId: message.shopMemberId, shopMemberId: message.shopMemberId,
profileImage: message.profileUrl, profileImage: message.profileUrl,
createdAtDay: messageTime.createdAtDay, createdAtDay: messageTime.createdAtDay,
createdAtTime: messageTime.createdAtTime createdAtTime: messageTime.createdAtTime,
}); });
html = message.message.includes('attachedImages') || message.message.includes('attachedVideos') ? CHAT_UTIL.htmlDecode(html) : html; html =
message.message.includes("attachedImages") ||
message.message.includes("attachedVideos")
? CHAT_UTIL.htmlDecode(html)
: html;
workVal = html + workVal; workVal = html + workVal;
}) });
jQueryMessages.prepend(workVal); jQueryMessages.prepend(workVal);
if (messages.length == 0) { if (messages.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
jQueryMessages.append(noResultMsg); jQueryMessages.append(noResultMsg);
} }
}; };
// 名前空間 // 名前空間
var CHAT_MAKE_ROOM = {}; var CHAT_MAKE_ROOM = {};
$(function() { $(function () {
// メンバー検索 // メンバー検索
$('#chatMakeRoom .search_form input[type="search"]').click(function(e) { $('#chatMakeRoom .search_form input[type="search"]').click(function (e) {
let contactListTitle = getLocalizedString("userSearch"); let contactListTitle = getLocalizedString("userSearch");
$('#makeRoomTitle').text(contactListTitle); $("#makeRoomTitle").text(contactListTitle);
}); });
$('#chatMakeRoom .search_form input[type="search"]').keyup(function(e) { $('#chatMakeRoom .search_form input[type="search"]').keyup(function (e) {
//画面タイトル設定 //画面タイトル設定
var keyword = $('#chatMakeRoom .search_form input[type="search"]').val(); var keyword = $('#chatMakeRoom .search_form input[type="search"]').val();
if (e.KeyCode == 13 || e.key == "Enter") { if (e.KeyCode == 13 || e.key == "Enter") {
if (keyword != '' && keyword.length != 0) { if (keyword != "" && keyword.length != 0) {
$('#chatMakeRoom .search_form input[type="search"]').blur(); $('#chatMakeRoom .search_form input[type="search"]').blur();
return false; return false;
} }
} else if (keyword == '' || keyword.length < 2) { } else if (keyword == "" || keyword.length < 2) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
return false; return false;
} }
CHAT_MAKE_ROOM.searchUser(keyword); CHAT_MAKE_ROOM.searchUser(keyword);
...@@ -26,91 +26,107 @@ $(function() { ...@@ -26,91 +26,107 @@ $(function() {
} }
}); });
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#chatMakeRoom .search_form input[type="search"]').on('compositionend', function() { $('#chatMakeRoom .search_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var keyword = $('#chatMakeRoom .search_form input[type="search"]').val(); var keyword = $(
'#chatMakeRoom .search_form input[type="search"]'
).val();
CHAT_MAKE_ROOM.searchUser(keyword); CHAT_MAKE_ROOM.searchUser(keyword);
} }
}); }
);
}); });
// メンバー検索 // メンバー検索
CHAT_MAKE_ROOM.searchUser = function(keyword) { CHAT_MAKE_ROOM.searchUser = function (keyword) {
var isAllGroup = $('#tabAllGroupOnMakeRoom').is(':checked'); var isAllGroup = $("#tabAllGroupOnMakeRoom").is(":checked");
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
//グループデータ検索 //グループデータ検索
var groupList = CHAT_DB.getGroupByName(keyword); var groupList = CHAT_DB.getGroupByName(keyword);
var groupTemplate; var groupTemplate;
$.get({ url: "./template/template_make_room_group_list.html", async: false } $.get(
, function(text) { { url: "./template/template_make_room_group_list.html", async: false },
function (text) {
groupTemplate = text; groupTemplate = text;
}); }
);
groupList.forEach(function(group) { groupList.forEach(function (group) {
let html = Mustache.render(groupTemplate, { let html = Mustache.render(groupTemplate, {
name: group.groupName, name: group.groupName,
id: group.groupId, id: group.groupId,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
}) });
//ユーザデータ検索 //ユーザデータ検索
var userList = CHAT_DB.getAllGroupShopMemberByName(keyword); var userList = CHAT_DB.getAllGroupShopMemberByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_make_room_user_list.html", async: false } $.get(
, function(text) { { url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text; userTemplate = text;
}); }
userList.forEach(function(user) { );
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function(shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == user.shopMemberId; return shopMemberId == user.shopMemberId;
}) });
if (findObj) { if (findObj) {
user.checked = 'checked'; user.checked = "checked";
} }
}); });
let html = Mustache.render(userTemplate, { let html = Mustache.render(userTemplate, {
userList: userList userList: userList,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
if (groupList.length == 0 && userList.length == 0) { if (groupList.length == 0 && userList.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
} });
  //連絡先画面 noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} //連絡先画面
} else { } else {
var userList = CHAT_DB.getMyGroupShopMemberByName(keyword); var userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_make_room_user_list.html", async: false } $.get(
, function(text) { { url: "./template/template_make_room_user_list.html", async: false },
function (text) {
userTemplate = text; userTemplate = text;
}); }
userList.forEach(function(user) { );
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
let findObj = CHAT.globalSelectedUserList.find(function(shopMemberId) { let findObj = CHAT.globalSelectedUserList.find(function (shopMemberId) {
return shopMemberId == user.shopMemberId; return shopMemberId == user.shopMemberId;
}) });
if (findObj) { if (findObj) {
user.checked = 'checked'; user.checked = "checked";
} }
}); });
let html = Mustache.render(userTemplate, { let html = Mustache.render(userTemplate, {
userList: userList 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) { if (userList.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} }
} }
} };
function recordStart() { function recordStart() {
MainManRecord('on'); MainManRecord("on");
$('#recordBtn').removeClass('bg_gray'); $("#recordBtn").removeClass("bg_gray");
$('#recordBtn').addClass('bg_red'); $("#recordBtn").addClass("bg_red");
} }
function recordStop(callback) { function recordStop(callback) {
...@@ -9,62 +9,66 @@ function recordStop(callback) { ...@@ -9,62 +9,66 @@ function recordStop(callback) {
screenLock(); screenLock();
// アーカイブ保存処理 // アーカイブ保存処理
MainManRecordWithCollaboration('stop', CMS_SERVER_URL + '/chatapi/file/uploadArchive', callback); MainManRecordWithCollaboration(
"stop",
CMS_SERVER_URL + "/chatapi/file/uploadArchive",
callback
);
} }
function MainManRecordWithCollaboration(action, url, callback) { function MainManRecordWithCollaboration(action, url, callback) {
mediaRecorder.stop(); mediaRecorder.stop();
console.log('Recorded Blobs: ', recordedBlobs); console.log("Recorded Blobs: ", recordedBlobs);
setTimeout(function() { setTimeout(function () {
console.log("Recoding File upload.."); console.log("Recoding File upload..");
const blob = new Blob(recordedBlobs, {type: 'video/webm'}); const blob = new Blob(recordedBlobs, { type: "video/webm" });
console.log(blob) console.log(blob);
var uploadFileName = "record_" + g_webroom + "_" + g_shareCount + ".webm"; var uploadFileName = "record_" + g_webroom + "_" + g_shareCount + ".webm";
g_shareCount++; g_shareCount++;
var formData = new FormData(); var formData = new FormData();
formData.append("fileData",blob,uploadFileName); formData.append("fileData", blob, uploadFileName);
formData.append('sid', globalUserInfo.sid); formData.append("sid", globalUserInfo.sid);
formData.append('roomId', globalUserInfo.roomId); formData.append("roomId", globalUserInfo.roomId);
if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) { if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) {
formData.append('archiveType', 1); formData.append("archiveType", 1);
} else { } else {
formData.append('archiveType', 2); formData.append("archiveType", 2);
} }
console.log(uploadFileName) console.log(uploadFileName);
$.ajax({ $.ajax({
type :'post', type: "post",
url, url,
data : formData, data: formData,
contentType: false, contentType: false,
processData: false, processData: false,
success : function(res) { success: function (res) {
recordFinished(); recordFinished();
callback(); callback();
console.log(res) console.log(res);
} },
,error : function(err){ error: function (err) {
recordFinished(); recordFinished();
callback(); callback();
console.log(err); console.log(err);
} },
}); });
}, 1000); }, 1000);
} }
function screenLock(){ function screenLock() {
// ロック用のdivを生成 // ロック用のdivを生成
var element = document.createElement('div'); var element = document.createElement("div");
element.id = "screenLock"; element.id = "screenLock";
// ロック用のスタイル // ロック用のスタイル
element.style.height = '100%'; element.style.height = "100%";
element.style.left = '0px'; element.style.left = "0px";
element.style.position = 'fixed'; element.style.position = "fixed";
element.style.top = '0px'; element.style.top = "0px";
element.style.width = '100%'; element.style.width = "100%";
element.style.zIndex = '9999'; element.style.zIndex = "9999";
element.style.opacity = '0'; element.style.opacity = "0";
var objBody = document.getElementsByTagName("body").item(0); var objBody = document.getElementsByTagName("body").item(0);
objBody.appendChild(element); objBody.appendChild(element);
...@@ -78,10 +82,10 @@ function delete_dom_obj(id_name) { ...@@ -78,10 +82,10 @@ function delete_dom_obj(id_name) {
} }
function recordFinished() { function recordFinished() {
$('#recordBtn').addClass('bg_gray'); $("#recordBtn").addClass("bg_gray");
$('#recordBtn').removeClass('bg_red'); $("#recordBtn").removeClass("bg_red");
// ロック画面の削除 // ロック画面の削除
delete_dom_obj('screenLock'); delete_dom_obj("screenLock");
} }
$(function () { $(function () {
...@@ -94,7 +98,6 @@ $(function () { ...@@ -94,7 +98,6 @@ $(function () {
.toggleClass("slidein") .toggleClass("slidein")
.css({ transform: "translateX(" & -w & ")" }); .css({ transform: "translateX(" & -w & ")" });
$("#collabo_main").toggleClass("noscroll"); $("#collabo_main").toggleClass("noscroll");
}); });
// ユーザーリストオーバーレイ表示 // ユーザーリストオーバーレイ表示
...@@ -107,7 +110,6 @@ $(function () { ...@@ -107,7 +110,6 @@ $(function () {
.css({ transform: "translateX(" & -w & ")" }); .css({ transform: "translateX(" & -w & ")" });
$("#collabo_main").toggleClass("noscroll"); $("#collabo_main").toggleClass("noscroll");
if ($("#overlay_user_list.overlay").hasClass("noscroll")) { if ($("#overlay_user_list.overlay").hasClass("noscroll")) {
$("#overlay_user_list.overlay").removeClass("noscroll"); $("#overlay_user_list.overlay").removeClass("noscroll");
} else { } else {
...@@ -159,86 +161,92 @@ $(function () { ...@@ -159,86 +161,92 @@ $(function () {
CHAT_UI.showLoadingIndicator(); CHAT_UI.showLoadingIndicator();
CHAT.globalSelectedUserList = []; CHAT.globalSelectedUserList = [];
CHAT_UI.refreshMyGroupForAddUserInCollaboration(); CHAT_UI.refreshMyGroupForAddUserInCollaboration();
$('#addUserConfirmBtnInCollaboration').off().on('click', function() { $("#addUserConfirmBtnInCollaboration")
$('#addUserInCollaboration').modal('hide'); .off()
if (typeof(android) != "undefined") { .on("click", function () {
$("#addUserInCollaboration").modal("hide");
if (typeof android != "undefined") {
android.saveSelectedUserList(CHAT.globalSelectedUserList.join(",")); android.saveSelectedUserList(CHAT.globalSelectedUserList.join(","));
} else { } else {
webkit.messageHandlers.saveSelectedUserList.postMessage(CHAT.globalSelectedUserList.join(",")); webkit.messageHandlers.saveSelectedUserList.postMessage(
CHAT.globalSelectedUserList.join(",")
);
} }
CHAT_UI.confirmInviteUserListInCollaboration(); CHAT_UI.confirmInviteUserListInCollaboration();
}); });
}); });
$('#penBtn').click(function () { $("#penBtn").click(function () {
$('#coviewPenCtrBtn').click(); $("#coviewPenCtrBtn").click();
if ($('#penBtn').hasClass('bg_red')) { if ($("#penBtn").hasClass("bg_red")) {
$('#penBtn').removeClass('bg_red'); $("#penBtn").removeClass("bg_red");
$('#penBtn').addClass('bg_blue'); $("#penBtn").addClass("bg_blue");
} else { } else {
$('#penBtn').addClass('bg_red'); $("#penBtn").addClass("bg_red");
$('#penBtn').removeClass('bg_blue'); $("#penBtn").removeClass("bg_blue");
} }
}) });
$('#photo_open_place_holder').click(function () { $("#photo_open_place_holder").click(function () {
$("#open_file_upload").trigger("click"); $("#open_file_upload").trigger("click");
}) });
$('#eraserBtn').click(function () { $("#eraserBtn").click(function () {
$('#coviewEraserCtrBtn').click(); $("#coviewEraserCtrBtn").click();
}) });
$('#micBtn').click(function () { $("#micBtn").click(function () {
$('#coviewMicCtrBtn').click(); $("#coviewMicCtrBtn").click();
if ($('#micBtn').hasClass('bg_red')) { if ($("#micBtn").hasClass("bg_red")) {
micOn(); micOn();
} else { } else {
micOff(); micOff();
} }
}) });
$('#captureBtn').click(function () { $("#captureBtn").click(function () {
if ($('#recordBtn').hasClass('bg_red')) { if ($("#recordBtn").hasClass("bg_red")) {
screenLock(); screenLock();
recordStop(function() { recordStop(function () {
$('#screenLock').remove(); $("#screenLock").remove();
coview_api.Capture(CMS_SERVER_URL + '/chatapi/file/uploadArchive'); coview_api.Capture(CMS_SERVER_URL + "/chatapi/file/uploadArchive");
}); });
} else { } else {
coview_api.Capture(CMS_SERVER_URL + '/chatapi/file/uploadArchive'); coview_api.Capture(CMS_SERVER_URL + "/chatapi/file/uploadArchive");
} }
}) });
$('#captureRequestBtn').click(function () { $("#captureRequestBtn").click(function () {
fw.sendToMsg('others', 'CAPTURE_REQUEST', {"name": CHAT.globalLoginParameter.loginId}); fw.sendToMsg("others", "CAPTURE_REQUEST", {
}) name: CHAT.globalLoginParameter.loginId,
});
});
$('#recordBtn').click(function () { $("#recordBtn").click(function () {
if ($('#recordBtn').hasClass('bg_gray')) { if ($("#recordBtn").hasClass("bg_gray")) {
recordStart(); recordStart();
} else { } else {
recordStop(null); recordStop(null);
} }
}) });
}); });
function penOff() { function penOff() {
if ($('#penBtn').hasClass('bg_blue')) { if ($("#penBtn").hasClass("bg_blue")) {
$('#coviewPenCtrBtn').click(); $("#coviewPenCtrBtn").click();
$('#penBtn').addClass('bg_red'); $("#penBtn").addClass("bg_red");
$('#penBtn').removeClass('bg_blue'); $("#penBtn").removeClass("bg_blue");
} }
}; }
function micOn() { function micOn() {
coview_api.MicMuteControl('off'); coview_api.MicMuteControl("off");
$('#micBtn').addClass('bg_blue'); $("#micBtn").addClass("bg_blue");
$('#micBtn').removeClass('bg_red'); $("#micBtn").removeClass("bg_red");
}; }
function micOff() { function micOff() {
coview_api.MicMuteControl('on'); coview_api.MicMuteControl("on");
$('#micBtn').removeClass('bg_blue'); $("#micBtn").removeClass("bg_blue");
$('#micBtn').addClass('bg_red'); $("#micBtn").addClass("bg_red");
}; }
// アコーディオン // アコーディオン
$('.category').on('click', function() { $(".category").on("click", function () {
$(this).toggleClass("open"); $(this).toggleClass("open");
$(this).next().slideToggle(); $(this).next().slideToggle();
}); });
$('.home_btn').on('click', function() { $(".home_btn").on("click", function () {
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.goHome(); android.goHome();
} else if (CHAT_UTIL.isIOS()) { } else if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.goHome.postMessage({}); webkit.messageHandlers.goHome.postMessage({});
} }
}); });
$(function() { $(function () {
var h = $(window).height(); //画面の高さを取得 var h = $(window).height(); //画面の高さを取得
// ローディング表示 // ローディング表示
...@@ -29,41 +29,40 @@ $(function() { ...@@ -29,41 +29,40 @@ $(function() {
$('.search_form input[type="search"]').click(function () { $('.search_form input[type="search"]').click(function () {
$(this).addClass("focus"); $(this).addClass("focus");
// キャンセルボタン表示 // キャンセルボタン表示
$('.cancel').removeClass('none'); $(".cancel").removeClass("none");
$('.search_form form').addClass('d-flex flex-row h-100 align-items-center'); $(".search_form form").addClass("d-flex flex-row h-100 align-items-center");
$('.content').addClass('none'); $(".content").addClass("none");
$('.craeteRoomButton').addClass('none'); $(".craeteRoomButton").addClass("none");
}); });
// 共通検索フォーム キャンセルボタン押下イベント // 共通検索フォーム キャンセルボタン押下イベント
$('.search_form .cancel').click(function(){ $(".search_form .cancel").click(function () {
$(this).addClass('none'); $(this).addClass("none");
$('.search_form input').removeClass('focus'); $(".search_form input").removeClass("focus");
$('.search_form input').val(''); $(".search_form input").val("");
$('.search_form form').removeClass(); $(".search_form form").removeClass();
$('.content').removeClass('none'); $(".content").removeClass("none");
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
$('.craeteRoomButton').removeClass('none'); $(".craeteRoomButton").removeClass("none");
}); });
$('.message_input_form').on('focus',function(e){ $(".message_input_form").on("focus", function (e) {
setTimeout(function() { setTimeout(function () {
$('.message_input_send').removeClass('none'); $(".message_input_send").removeClass("none");
$('.attach_file').addClass('none'); $(".attach_file").addClass("none");
$('.footer_content_b').addClass('none'); $(".footer_content_b").addClass("none");
}, 10); }, 10);
}); });
$('.message_input_form').on('focusout',function(e){ $(".message_input_form").on("focusout", function (e) {
setTimeout(function() { setTimeout(function () {
if($(e.relatedTarget).hasClass('message_input_send')){ if ($(e.relatedTarget).hasClass("message_input_send")) {
CHAT_UI.sendMessage(); CHAT_UI.sendMessage();
} else { } else {
$('.message_input_send').addClass('none'); $(".message_input_send").addClass("none");
$('.attach_file').removeClass('none'); $(".attach_file").removeClass("none");
$('.footer_content_b').removeClass('none'); $(".footer_content_b").removeClass("none");
} }
}, 10); }, 10);
}); });
}); });
...@@ -10,62 +10,62 @@ const readyState = { ...@@ -10,62 +10,62 @@ const readyState = {
}; };
const messageType = { const messageType = {
TEXT : 0 , TEXT: 0,
IMAGE : 1 , IMAGE: 1,
VIDEO : 2 , VIDEO: 2,
SYSTEM : 3 , SYSTEM: 3,
COMMUNICATIONSTART : 4, COMMUNICATIONSTART: 4,
COMMUNICATIONEND : 5 COMMUNICATIONEND: 5,
} };
const userAPICmd = { const userAPICmd = {
MYINFO : 9 MYINFO: 9,
} };
const chatRoomType = { const chatRoomType = {
DM : "1", DM: "1",
GROUP : "0", GROUP: "0",
ALL : "2" ALL: "2",
} };
const groupSearchFlg = { const groupSearchFlg = {
ROOT : "0" ROOT: "0",
} };
const nameCardAreaId = { const nameCardAreaId = {
MY : "myNamecard", MY: "myNamecard",
USER : "userNamecard" USER: "userNamecard",
} };
const collaborationTypeKey = { const collaborationTypeKey = {
AUDIO : "audio", AUDIO: "audio",
CAMERA : "camera", CAMERA: "camera",
VIDEO : "video" , VIDEO: "video",
DOCUMENT : "document", DOCUMENT: "document",
BOARD : "board" BOARD: "board",
} };
const COLLABORATION_TYPE = { const COLLABORATION_TYPE = {
AUDIO : 0, AUDIO: 0,
CAMERA : 2, CAMERA: 2,
VIDEO : 3, VIDEO: 3,
DOCUMENT : 4, DOCUMENT: 4,
BOARD : 5 BOARD: 5,
} };
const makeRoomFlg = { const makeRoomFlg = {
NAME_CARD : 0, NAME_CARD: 0,
MAKE_ROOM : 1 MAKE_ROOM: 1,
} };
const ANDROID_SDK_VERSION = { const ANDROID_SDK_VERSION = {
O : 26 O: 26,
} };
const HOST_REQUEST_FLG = { const HOST_REQUEST_FLG = {
DONE : 0, DONE: 0,
DOING : 1 DOING: 1,
} };
const messageSeperator = "<::split>"; const messageSeperator = "<::split>";
const dataMessageScheme = "::NOT_MESSAGE"; const dataMessageScheme = "::NOT_MESSAGE";
...@@ -3,15 +3,15 @@ var CONTACT = {}; ...@@ -3,15 +3,15 @@ var CONTACT = {};
$(function () { $(function () {
// メンバー検索 // メンバー検索
$('#contact .search_form input[type="search"]').keyup(function(e) { $('#contact .search_form input[type="search"]').keyup(function (e) {
var keyword = $('#contact .search_form input[type="search"]').val(); var keyword = $('#contact .search_form input[type="search"]').val();
if (e.key == "Enter" || e.KeyCode == 13) { if (e.key == "Enter" || e.KeyCode == 13) {
if (keyword != '' && keyword.length != 0) { if (keyword != "" && keyword.length != 0) {
$('#contact .search_form input[type="search"]').blur(); $('#contact .search_form input[type="search"]').blur();
return; return;
} }
} else if (keyword == '' || keyword.length < 2) { } else if (keyword == "" || keyword.length < 2) {
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
return; return;
} }
CONTACT.searchUser(keyword); CONTACT.searchUser(keyword);
...@@ -21,80 +21,95 @@ $(function () { ...@@ -21,80 +21,95 @@ $(function () {
} }
}); });
// iOSキーボード変換検知用 // iOSキーボード変換検知用
$('#contact .search_form input[type="search"]').on('compositionend', function() { $('#contact .search_form input[type="search"]').on(
"compositionend",
function () {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
var keyword = $('#contact .search_form input[type="search"]').val(); var keyword = $('#contact .search_form input[type="search"]').val();
CONTACT.searchUser(keyword); CONTACT.searchUser(keyword);
} }
}); }
);
}); });
// ユーザー検索 // ユーザー検索
CONTACT.searchUser = function(keyword) { CONTACT.searchUser = function (keyword) {
var groupList; var groupList;
$('.overlay_src_msg').empty(); $(".overlay_src_msg").empty();
var isAllGroup = $('#tabAllGroup').is(':checked'); var isAllGroup = $("#tabAllGroup").is(":checked");
//全グループ検索画面 //全グループ検索画面
if (isAllGroup) { if (isAllGroup) {
//グループデータ検索 //グループデータ検索
groupList = CHAT_DB.getGroupByName(keyword); groupList = CHAT_DB.getGroupByName(keyword);
var groupTemplate; var groupTemplate;
$.get({ url: "./template/template_group_list.html", async: false } $.get(
, function(text) { { url: "./template/template_group_list.html", async: false },
function (text) {
groupTemplate = text; groupTemplate = text;
}); }
);
groupList.forEach(function(group) { groupList.forEach(function (group) {
let html = Mustache.render(groupTemplate, { let html = Mustache.render(groupTemplate, {
name: group.groupName, name: group.groupName,
id: group.groupId, id: group.groupId,
isFavorite: group.isFavorite isFavorite: group.isFavorite,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
}) });
//ユーザデータ検索 //ユーザデータ検索
var userList = CHAT_DB.getAllGroupShopMemberByName(keyword); var userList = CHAT_DB.getAllGroupShopMemberByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_user_list.html", async: false } $.get(
, function(text) { { url: "./template/template_user_list.html", async: false },
function (text) {
userTemplate = text; userTemplate = text;
}); }
userList.forEach(function(user) { );
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
}); });
let html = Mustache.render(userTemplate, { let html = Mustache.render(userTemplate, {
userList: userList userList: userList,
}); });
let obj = jQuery.parseHTML(html); let obj = jQuery.parseHTML(html);
$('.overlay_src_msg').append(obj); $(".overlay_src_msg").append(obj);
if (userList.length == 0 && groupList.length == 0) { if (userList.length == 0 && groupList.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} }
//連絡先画面 //連絡先画面
} else { } else {
var userList = CHAT_DB.getMyGroupShopMemberByName(keyword); var userList = CHAT_DB.getMyGroupShopMemberByName(keyword);
var userTemplate; var userTemplate;
$.get({ url: "./template/template_user_list.html", async: false } $.get(
, function(text) { { url: "./template/template_user_list.html", async: false },
function (text) {
userTemplate = text; userTemplate = text;
}); }
userList.forEach(function(user) { );
userList.forEach(function (user) {
user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl); user.profileUrl = CHAT.getProfileImgUrl(user.profileUrl);
}); });
let html = Mustache.render(userTemplate, { let html = Mustache.render(userTemplate, {
userList: userList 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) { if (userList.length == 0) {
const noResultMsg = $('<div/>',{width:'auto', style:'text-align: center'}); const noResultMsg = $("<div/>", {
noResultMsg.append(getLocalizedString("noResult")) width: "auto",
$('.overlay_src_msg').append(noResultMsg); style: "text-align: center",
});
noResultMsg.append(getLocalizedString("noResult"));
$(".overlay_src_msg").append(noResultMsg);
} }
} }
}; };
$(window).on('load',function () { //読み込み完了したら実行する $(window).on("load", function () {
$('#loader-bg').delay(900).fadeOut(800);//ローディングを隠す //読み込み完了したら実行する
$('#loader').delay(600).fadeOut(300); $("#loader-bg").delay(900).fadeOut(800); //ローディングを隠す
$("#loader").delay(600).fadeOut(300);
}); });
$(function () { $(function () {
......
...@@ -119,10 +119,10 @@ $(function () { ...@@ -119,10 +119,10 @@ $(function () {
console.log("=============> READY : ready for coview api"); console.log("=============> READY : ready for coview api");
Coview_addLoginId(globalUserInfo.loginId); Coview_addLoginId(globalUserInfo.loginId);
coview_api.Login(globalUserInfo.loginId); coview_api.Login(globalUserInfo.loginId);
initCollaborationUI(joinCollaborationType) initCollaborationUI(joinCollaborationType);
fw.socket.on('message', async function(data) { fw.socket.on("message", async function (data) {
console.log('====> message::data: ', data); console.log("====> message::data: ", data);
if (data.type ==="CHANGE_COLLABORATION") { if (data.type === "CHANGE_COLLABORATION") {
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) { if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.exitMeetingRoom.postMessage({}); webkit.messageHandlers.exitMeetingRoom.postMessage({});
...@@ -131,8 +131,12 @@ $(function () { ...@@ -131,8 +131,12 @@ $(function () {
} }
} }
if (CHAT_UTIL.isAndroid() && data.payload.collaborationType == COLLABORATION_TYPE.DOCUMENT && androidVersion < ANDROID_SDK_VERSION.O) { if (
alert(getLocalizedString('not_support_version')); CHAT_UTIL.isAndroid() &&
data.payload.collaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
joinCollaborationType = COLLABORATION_TYPE.CAMERA; joinCollaborationType = COLLABORATION_TYPE.CAMERA;
} else { } else {
joinCollaborationType = data.payload.collaborationType; joinCollaborationType = data.payload.collaborationType;
...@@ -141,53 +145,80 @@ $(function () { ...@@ -141,53 +145,80 @@ $(function () {
initCollaborationUI(joinCollaborationType); initCollaborationUI(joinCollaborationType);
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinChangedCollaboration.postMessage({"joinCollaborationType": joinCollaborationType, "meetingId": data.payload.newMeetingId}); webkit.messageHandlers.joinChangedCollaboration.postMessage({
joinCollaborationType: joinCollaborationType,
meetingId: data.payload.newMeetingId,
});
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) { if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
webkit.messageHandlers.joinMeetingRoom.postMessage(data.payload.newMeetingId); webkit.messageHandlers.joinMeetingRoom.postMessage(
data.payload.newMeetingId
);
} }
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
android.joinChangedCollaboration(joinCollaborationType, data.payload.newMeetingId); android.joinChangedCollaboration(
joinCollaborationType,
data.payload.newMeetingId
);
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) { if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
android.joinMeetingRoom(data.payload.newMeetingId); android.joinMeetingRoom(data.payload.newMeetingId);
} }
} }
} else if (data.type ==="SHARE_FILE") { } else if (data.type === "SHARE_FILE") {
if (joinCollaborationType != COLLABORATION_TYPE.CAMERA) { if (joinCollaborationType != COLLABORATION_TYPE.CAMERA) {
initCollaborationUI(COLLABORATION_TYPE.CAMERA); initCollaborationUI(COLLABORATION_TYPE.CAMERA);
joinCollaborationType = COLLABORATION_TYPE.CAMERA; joinCollaborationType = COLLABORATION_TYPE.CAMERA;
fw.sendToMsg('others', 'SHARE_FILE_HOST', {"collaborationType": COLLABORATION_TYPE.CAMERA}); fw.sendToMsg("others", "SHARE_FILE_HOST", {
collaborationType: COLLABORATION_TYPE.CAMERA,
});
} }
} else if (data.type ==="SHARE_FILE_HOST") { } else if (data.type === "SHARE_FILE_HOST") {
if (joinCollaborationType != COLLABORATION_TYPE.CAMERA && g_isMainMan) { if (joinCollaborationType != COLLABORATION_TYPE.CAMERA && g_isMainMan) {
initCollaborationUI(COLLABORATION_TYPE.CAMERA); initCollaborationUI(COLLABORATION_TYPE.CAMERA);
joinCollaborationType = COLLABORATION_TYPE.CAMERA; joinCollaborationType = COLLABORATION_TYPE.CAMERA;
} }
} else if (data.type === "CAPTURE_REQUEST" && g_isMainMan) { } else if (data.type === "CAPTURE_REQUEST" && g_isMainMan) {
if (confirm(data.payload.name + getLocalizedString("request_capture"))) { if (
if ($('#recordBtn').hasClass('bg_red')) { confirm(data.payload.name + getLocalizedString("request_capture"))
) {
if ($("#recordBtn").hasClass("bg_red")) {
screenLock(); screenLock();
recordStop(function() { recordStop(function () {
$('#screenLock').remove(); $("#screenLock").remove();
captureAndShareImage(CMS_SERVER_URL + '/chatapi/file/uploadArchive', data.payload.name); captureAndShareImage(
CMS_SERVER_URL + "/chatapi/file/uploadArchive",
data.payload.name
);
}); });
} else { } else {
captureAndShareImage(CMS_SERVER_URL + '/chatapi/file/uploadArchive', data.payload.name); captureAndShareImage(
CMS_SERVER_URL + "/chatapi/file/uploadArchive",
data.payload.name
);
} }
} }
} else if (data.type === "HOST_CHANGE_REQUEST") { } else if (data.type === "HOST_CHANGE_REQUEST") {
if (data.payload.loginId == globalUserInfo.loginId) { if (data.payload.loginId == globalUserInfo.loginId) {
fw.sendToMsg('others', 'HOST_CHANGE_RESPONSE', {"isAndroid": CHAT_UTIL.isAndroid(), "isAble" : androidVersion >= ANDROID_SDK_VERSION.O, "loginId": CHAT.globalLoginParameter.loginId}); fw.sendToMsg("others", "HOST_CHANGE_RESPONSE", {
isAndroid: CHAT_UTIL.isAndroid(),
isAble: androidVersion >= ANDROID_SDK_VERSION.O,
loginId: CHAT.globalLoginParameter.loginId,
});
} }
} else if (data.type === "HOST_CHANGE_RESPONSE") { } else if (data.type === "HOST_CHANGE_RESPONSE") {
var isAndroid = data.payload.isAndroid; var isAndroid = data.payload.isAndroid;
var isAble = data.payload.isAble var isAble = data.payload.isAble;
if (g_isMainMan && isAndroid && !isAble && joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) { if (
alert(getLocalizedString('err_target_android_version_not_support')); g_isMainMan &&
} else if (g_isMainMan){ isAndroid &&
!isAble &&
joinCollaborationType == COLLABORATION_TYPE.DOCUMENT
) {
alert(getLocalizedString("err_target_android_version_not_support"));
} else if (g_isMainMan) {
Coview_changeHost(getFermiLoginId(data.payload.loginId)); Coview_changeHost(getFermiLoginId(data.payload.loginId));
} }
} else if (data.type === "API_SEND_OWNER_CHANGE_COMPLETE") { } else if (data.type === "API_SEND_OWNER_CHANGE_COMPLETE") {
if ($('#recordBtn').hasClass('bg_red')) { if ($("#recordBtn").hasClass("bg_red")) {
recordStop(penOff); recordStop(penOff);
} else { } else {
penOff(); penOff();
...@@ -196,35 +227,54 @@ $(function () { ...@@ -196,35 +227,54 @@ $(function () {
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.setHostRequestFlg(HOST_REQUEST_FLG.DOING); android.setHostRequestFlg(HOST_REQUEST_FLG.DOING);
} else { } else {
webkit.messageHandlers.setHostRequestFlg.postMessage(HOST_REQUEST_FLG.DOING); webkit.messageHandlers.setHostRequestFlg.postMessage(
HOST_REQUEST_FLG.DOING
);
} }
if (g_isMainMan) { if (g_isMainMan) {
if(confirm(getLocalizedString('norify_request_host_change', data.payload.hostId))) { if (
confirm(
getLocalizedString(
"norify_request_host_change",
data.payload.hostId
)
)
) {
Coview_changeHost(getFermiLoginId(data.payload.hostId)); Coview_changeHost(getFermiLoginId(data.payload.hostId));
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.setHostRequestFlg(HOST_REQUEST_FLG.DONE); android.setHostRequestFlg(HOST_REQUEST_FLG.DONE);
} else { } else {
webkit.messageHandlers.setHostRequestFlg.postMessage(HOST_REQUEST_FLG.DONE); webkit.messageHandlers.setHostRequestFlg.postMessage(
HOST_REQUEST_FLG.DONE
);
} }
} else { } else {
fw.sendToMsg('others', 'HOST_REQUEST_REJECT', {"hostId": data.payload.hostId}); fw.sendToMsg("others", "HOST_REQUEST_REJECT", {
hostId: data.payload.hostId,
});
} }
fw.sendToMsg('others', 'HOST_REQUEST_DONE', {"hostId": data.payload.hostId}); fw.sendToMsg("others", "HOST_REQUEST_DONE", {
hostId: data.payload.hostId,
});
} }
} else if (data.type === "HOST_REQUEST_DONE") { } else if (data.type === "HOST_REQUEST_DONE") {
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.setHostRequestFlg(HOST_REQUEST_FLG.DONE); android.setHostRequestFlg(HOST_REQUEST_FLG.DONE);
} else { } else {
webkit.messageHandlers.setHostRequestFlg.postMessage(HOST_REQUEST_FLG.DONE); webkit.messageHandlers.setHostRequestFlg.postMessage(
HOST_REQUEST_FLG.DONE
);
} }
} else if (data.type === "HOST_REQUEST_REJECT") { } else if (data.type === "HOST_REQUEST_REJECT") {
if (data.payload.hostId == CHAT.globalLoginParameter.loginId) { if (data.payload.hostId == CHAT.globalLoginParameter.loginId) {
alert('REJECT for owner user'); alert("REJECT for owner user");
} }
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.setHostRequestFlg(HOST_REQUEST_FLG.DONE); android.setHostRequestFlg(HOST_REQUEST_FLG.DONE);
} else { } else {
webkit.messageHandlers.setHostRequestFlg.postMessage(HOST_REQUEST_FLG.DONE); webkit.messageHandlers.setHostRequestFlg.postMessage(
HOST_REQUEST_FLG.DONE
);
} }
} }
}); });
...@@ -386,14 +436,19 @@ $(function () { ...@@ -386,14 +436,19 @@ $(function () {
console.log("consoleLog", json); console.log("consoleLog", json);
break; break;
case "fileChange": case "fileChange":
if (joinCollaborationType != COLLABORATION_TYPE.CAMERA) { break; } if (joinCollaborationType != COLLABORATION_TYPE.CAMERA) {
break;
}
LoadMobileShareFile(json.fileName); LoadMobileShareFile(json.fileName);
backgroundFileName = json.fileName; backgroundFileName = json.fileName;
console.log("fileChange", json); console.log("fileChange", json);
break; break;
case "ReceiveMediaResponse": case "ReceiveMediaResponse":
if (isBoard && g_isMainMan) { if (isBoard && g_isMainMan) {
wc_api.dispatchEvent (new Event ("message"), {"api":"fileChange","fileName":backgroundFileName}); wc_api.dispatchEvent(new Event("message"), {
api: "fileChange",
fileName: backgroundFileName,
});
} }
break; break;
default: default:
...@@ -424,101 +479,115 @@ function changeCollaboration(changeCollaborationType) { ...@@ -424,101 +479,115 @@ function changeCollaboration(changeCollaborationType) {
} }
} }
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.setJoinCollaborationType.postMessage(changeCollaborationType); webkit.messageHandlers.setJoinCollaborationType.postMessage(
changeCollaborationType
);
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
if (changeCollaborationType == COLLABORATION_TYPE.DOCUMENT && androidVersion < ANDROID_SDK_VERSION.O) { if (
alert(getLocalizedString('not_support_version')); changeCollaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
return; return;
} }
android.setJoinCollaborationType(changeCollaborationType); android.setJoinCollaborationType(changeCollaborationType);
} }
joinCollaborationType = changeCollaborationType; joinCollaborationType = changeCollaborationType;
if ($('#recordBtn').hasClass('bg_red')) { if ($("#recordBtn").hasClass("bg_red")) {
recordStop(null); recordStop(null);
} }
initCollaborationUI(changeCollaborationType); initCollaborationUI(changeCollaborationType);
switch (changeCollaborationType) { switch (changeCollaborationType) {
case COLLABORATION_TYPE.AUDIO: case COLLABORATION_TYPE.AUDIO:
coview_api.ChangeCollaboration('audio'); coview_api.ChangeCollaboration("audio");
break; break;
case COLLABORATION_TYPE.CAMERA: case COLLABORATION_TYPE.CAMERA:
coview_api.ChangeCollaboration('image'); coview_api.ChangeCollaboration("image");
break; break;
case COLLABORATION_TYPE.VIDEO: case COLLABORATION_TYPE.VIDEO:
coview_api.ChangeCollaboration('video'); coview_api.ChangeCollaboration("video");
break; break;
case COLLABORATION_TYPE.DOCUMENT: case COLLABORATION_TYPE.DOCUMENT:
coview_api.ChangeCollaboration('audio'); coview_api.ChangeCollaboration("audio");
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
newMeetingId = CHAT_DB.createContentView(); newMeetingId = CHAT_DB.createContentView();
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
newMeetingId = android.createContentView(); newMeetingId = android.createContentView();
console.log('newMeetingId = ' + newMeetingId); console.log("newMeetingId = " + newMeetingId);
} }
break; break;
case COLLABORATION_TYPE.BOARD: case COLLABORATION_TYPE.BOARD:
coview_api.ChangeCollaboration('audio'); coview_api.ChangeCollaboration("audio");
break; break;
} }
if ($('#micBtn').hasClass('bg_red')) { if ($("#micBtn").hasClass("bg_red")) {
micOff(); micOff();
} else { } else {
micOn(); micOn();
} }
penOff(); penOff();
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.changeCollaboration.postMessage({"changeCollaborationType": changeCollaborationType, "meetingId": newMeetingId}); webkit.messageHandlers.changeCollaboration.postMessage({
changeCollaborationType: changeCollaborationType,
meetingId: newMeetingId,
});
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
android.changeCollaboration(changeCollaborationType, newMeetingId); android.changeCollaboration(changeCollaborationType, newMeetingId);
} }
fw.sendToMsg('others', 'CHANGE_COLLABORATION', {"collaborationType": changeCollaborationType, "newMeetingId": newMeetingId}); fw.sendToMsg("others", "CHANGE_COLLABORATION", {
collaborationType: changeCollaborationType,
newMeetingId: newMeetingId,
});
} }
var scrollLock = function (e) { var scrollLock = function (e) {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
if ($(e.target).closest('.add_user_modal').length > 0 if (
|| $(e.target).closest('#overlay_user_list').length > 0 $(e.target).closest(".add_user_modal").length > 0 ||
|| $(e.target).closest('.pip_indicator').length > 0) $(e.target).closest("#overlay_user_list").length > 0 ||
{ $(e.target).closest(".pip_indicator").length > 0
) {
e.stopPropagation(); e.stopPropagation();
} else { } else {
e.preventDefault(); e.preventDefault();
} }
} }
} };
let collaboScreen = document.getElementById('collabo_main'); let collaboScreen = document.getElementById("collabo_main");
function scrollLockON() { function scrollLockON() {
collaboScreen.addEventListener('touchmove', scrollLock, {passive: false}); collaboScreen.addEventListener("touchmove", scrollLock, { passive: false });
} }
function scrollLockOFF() { function scrollLockOFF() {
collaboScreen.removeEventListener('touchmove', scrollLock, {passive: false}); collaboScreen.removeEventListener("touchmove", scrollLock, {
passive: false,
});
} }
function initCollaborationUI(changeCollaborationType){ function initCollaborationUI(changeCollaborationType) {
$('#coviewEraserCtrBtn').click(); $("#coviewEraserCtrBtn").click();
if ($('.user_btn').hasClass("hide")) { if ($(".user_btn").hasClass("hide")) {
$('.user_btn').click(); $(".user_btn").click();
} }
if ($('.menu_btn').hasClass("hide")) { if ($(".menu_btn").hasClass("hide")) {
$(".menu_btn").click(); $(".menu_btn").click();
} }
if (CHAT_UTIL.isIOS) { if (CHAT_UTIL.isIOS) {
roomType = CHAT_DB.getRoomType(); roomType = CHAT_DB.getRoomType();
if (roomType == chatRoomType.DM) { if (roomType == chatRoomType.DM) {
$('.add_user_btn').removeClass('none'); $(".add_user_btn").removeClass("none");
} }
} }
$("link[href='./css/collaboration_board.css']").remove(); $("link[href='./css/collaboration_board.css']").remove();
penOff(); penOff();
switch (changeCollaborationType) { switch (changeCollaborationType) {
case COLLABORATION_TYPE.AUDIO: case COLLABORATION_TYPE.AUDIO:
$('.collaboration_contents').addClass('none'); $(".collaboration_contents").addClass("none");
$('.voice_contents').removeClass('none'); $(".voice_contents").removeClass("none");
var w = $('.user_btn').width(); var w = $(".user_btn").width();
$('.user_btn').toggleClass("hide"); $(".user_btn").toggleClass("hide");
$("#overlay_user_list.overlay") $("#overlay_user_list.overlay")
.toggleClass("slidein") .toggleClass("slidein")
.css({ transform: "translateX(" & -w & ")" }); .css({ transform: "translateX(" & -w & ")" });
...@@ -531,20 +600,20 @@ function initCollaborationUI(changeCollaborationType){ ...@@ -531,20 +600,20 @@ function initCollaborationUI(changeCollaborationType){
break; break;
case COLLABORATION_TYPE.CAMERA: case COLLABORATION_TYPE.CAMERA:
$('.collaboration_contents').addClass('none'); $(".collaboration_contents").addClass("none");
$('.picture_contents').removeClass('none'); $(".picture_contents").removeClass("none");
break; break;
case COLLABORATION_TYPE.VIDEO: case COLLABORATION_TYPE.VIDEO:
$('.collaboration_contents').addClass('none'); $(".collaboration_contents").addClass("none");
$('.video_contents').removeClass('none'); $(".video_contents").removeClass("none");
break; break;
case COLLABORATION_TYPE.DOCUMENT: case COLLABORATION_TYPE.DOCUMENT:
$('.collaboration_contents').addClass('none'); $(".collaboration_contents").addClass("none");
$('.document_contents').removeClass('none'); $(".document_contents").removeClass("none");
var w = $('.user_btn').width(); var w = $(".user_btn").width();
$('.user_btn').toggleClass("hide"); $(".user_btn").toggleClass("hide");
$("#overlay_user_list.overlay") $("#overlay_user_list.overlay")
.toggleClass("slidein") .toggleClass("slidein")
.css({ transform: "translateX(" & -w & ")" }); .css({ transform: "translateX(" & -w & ")" });
...@@ -557,9 +626,11 @@ function initCollaborationUI(changeCollaborationType){ ...@@ -557,9 +626,11 @@ function initCollaborationUI(changeCollaborationType){
break; break;
case COLLABORATION_TYPE.BOARD: case COLLABORATION_TYPE.BOARD:
$('.collaboration_contents').addClass('none'); $(".collaboration_contents").addClass("none");
$('.board_contents').removeClass('none'); $(".board_contents").removeClass("none");
$('head').append('<link rel="stylesheet" href="./css/collaboration_board.css">'); $("head").append(
'<link rel="stylesheet" href="./css/collaboration_board.css">'
);
break; break;
} }
} }
...@@ -573,7 +644,7 @@ function Coview_exitCollaboration(isDocument = false) { ...@@ -573,7 +644,7 @@ function Coview_exitCollaboration(isDocument = false) {
android.exitMeetingRoom(); android.exitMeetingRoom();
} }
} }
if ($('#recordBtn').hasClass('bg_red')) { if ($("#recordBtn").hasClass("bg_red")) {
recordStop(Coview_finishCollaboration); recordStop(Coview_finishCollaboration);
} else { } else {
Coview_finishCollaboration(); Coview_finishCollaboration();
...@@ -587,11 +658,11 @@ function Coview_finishCollaboration() { ...@@ -587,11 +658,11 @@ function Coview_finishCollaboration() {
if (CHAT_UTIL.isIOS()) { if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.finishCollaboration.postMessage({}); webkit.messageHandlers.finishCollaboration.postMessage({});
} else if (CHAT_UTIL.isAndroid()) { } else if (CHAT_UTIL.isAndroid()) {
android.finishCollaboration() android.finishCollaboration();
}
} }
};
isLeaved = true; isLeaved = true;
if (collaborationJoinFlg != '2') { if (collaborationJoinFlg != "2") {
CHAT_UI.joinRoom( CHAT_UI.joinRoom(
CHAT.globalLoginParameter.roomId, CHAT.globalLoginParameter.roomId,
CHAT.globalLoginParameter.name CHAT.globalLoginParameter.name
...@@ -614,26 +685,29 @@ function Coview_addLoginId(loginId) { ...@@ -614,26 +685,29 @@ function Coview_addLoginId(loginId) {
console.log("addUser loginId = " + loginId); console.log("addUser loginId = " + loginId);
var url = "https://biztaskyell.abookcloud.com/auth/getuser"; var url = "https://biztaskyell.abookcloud.com/auth/getuser";
$.ajax({ $.ajax({
url : url, url: url,
method : 'post', method: "post",
data : { data: {
id : loginId id: loginId,
}, },
success : function (result) { success: function (result) {
console.log("result", result); console.log("result", result);
if (result.statusCode != 200) { if (result.statusCode != 200) {
coview_api.addUser(loginId); coview_api.addUser(loginId);
} }
}, },
error : function (err) { error: function (err) {
console.log(err.toString()); console.log(err.toString());
} },
}); });
} }
function applyForHostChange() { function applyForHostChange() {
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT && androidVersion < ANDROID_SDK_VERSION.O) { if (
alert(getLocalizedString('not_support_version')); joinCollaborationType == COLLABORATION_TYPE.DOCUMENT &&
androidVersion < ANDROID_SDK_VERSION.O
) {
alert(getLocalizedString("not_support_version"));
return; return;
} }
var hostRequestFlg = 0; var hostRequestFlg = 0;
...@@ -643,16 +717,20 @@ function applyForHostChange() { ...@@ -643,16 +717,20 @@ function applyForHostChange() {
hostRequestFlg = CHAT_DB.getHostRequestFlg(); hostRequestFlg = CHAT_DB.getHostRequestFlg();
} }
if (hostRequestFlg == HOST_REQUEST_FLG.DOING) { if (hostRequestFlg == HOST_REQUEST_FLG.DOING) {
alert(getLocalizedString('already_processing_host_request')); alert(getLocalizedString("already_processing_host_request"));
return; return;
} }
if (CHAT_UTIL.isAndroid()) { if (CHAT_UTIL.isAndroid()) {
android.setHostRequestFlg(HOST_REQUEST_FLG.DOING); android.setHostRequestFlg(HOST_REQUEST_FLG.DOING);
} else { } else {
webkit.messageHandlers.setHostRequestFlg.postMessage(HOST_REQUEST_FLG.DOING); webkit.messageHandlers.setHostRequestFlg.postMessage(
HOST_REQUEST_FLG.DOING
);
} }
fw.sendToMsg('others', 'CHANGE_HOST_APPLY', {"hostId": CHAT.globalLoginParameter.loginId}); fw.sendToMsg("others", "CHANGE_HOST_APPLY", {
}; hostId: CHAT.globalLoginParameter.loginId,
});
}
function Coview_connect_audio_collaboration() { function Coview_connect_audio_collaboration() {
globalUserInfo.coWorkType = collaborationTypeKey.AUDIO; globalUserInfo.coWorkType = collaborationTypeKey.AUDIO;
...@@ -666,43 +744,63 @@ function hostSearchInterval() { ...@@ -666,43 +744,63 @@ function hostSearchInterval() {
let hostName = ""; let hostName = "";
function hostSearch() { function hostSearch() {
if (g_isMainMan) { if (g_isMainMan) {
$("#collaboration_user_" + CHAT.globalLoginParameter.loginId).addClass("host"); $("#collaboration_user_" + CHAT.globalLoginParameter.loginId).addClass(
$('.host_contents').removeClass('none'); "host"
);
$(".host_contents").removeClass("none");
if (joinCollaborationType == COLLABORATION_TYPE.CAMERA) { if (joinCollaborationType == COLLABORATION_TYPE.CAMERA) {
$('.photo_select_button').removeClass('none'); $(".photo_select_button").removeClass("none");
} }
if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) { if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) {
$('.video_contents_host').removeClass('none'); $(".video_contents_host").removeClass("none");
$('.video_contents_user').addClass('none'); $(".video_contents_user").addClass("none");
} }
if (CHAT_UTIL.isIOS()) isIos = true; if (CHAT_UTIL.isIOS()) isIos = true;
} else { } else {
$("#collaboration_user_" + CHAT.globalLoginParameter.loginId).removeClass("host"); $("#collaboration_user_" + CHAT.globalLoginParameter.loginId).removeClass(
$('.host_contents').addClass('none'); "host"
);
$(".host_contents").addClass("none");
if (joinCollaborationType == COLLABORATION_TYPE.CAMERA) { if (joinCollaborationType == COLLABORATION_TYPE.CAMERA) {
$('.photo_select_button').addClass('none'); $(".photo_select_button").addClass("none");
} }
if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) { if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) {
$('.video_contents_user').removeClass('none'); $(".video_contents_user").removeClass("none");
$('.video_contents_host').addClass('none'); $(".video_contents_host").addClass("none");
} }
} }
if (hostName != g_isMainManUsername) { if (hostName != g_isMainManUsername) {
if (hostName != "") { if (hostName != "") {
$("#collaboration_user_" + getReplacedLoginId(hostName)).removeClass("host"); $("#collaboration_user_" + getReplacedLoginId(hostName)).removeClass(
"host"
);
} }
$("#collaboration_user_" + getReplacedLoginId(g_isMainManUsername)).addClass("host"); $(
"#collaboration_user_" + getReplacedLoginId(g_isMainManUsername)
).addClass("host");
hostName = g_isMainManUsername; hostName = g_isMainManUsername;
} else { } else {
if (hostName == "") { if (hostName == "") {
if (!$("#collaboration_user_" + CHAT.globalLoginParameter.loginId).hasClass("host") && coview_api.getRoomUsers()) { if (
$("#collaboration_user_" + CHAT.globalLoginParameter.loginId).addClass("host"); !$(
"#collaboration_user_" + CHAT.globalLoginParameter.loginId
).hasClass("host") &&
coview_api.getRoomUsers()
) {
$(
"#collaboration_user_" + CHAT.globalLoginParameter.loginId
).addClass("host");
} }
} else { } else {
if (!$("#collaboration_user_" + getReplacedLoginId(hostName)).hasClass('host')) { if (
$("#collaboration_user_" + getReplacedLoginId(hostName)).addClass("host"); !$("#collaboration_user_" + getReplacedLoginId(hostName)).hasClass(
"host"
)
) {
$("#collaboration_user_" + getReplacedLoginId(hostName)).addClass(
"host"
);
} }
} }
} }
} }
...@@ -710,23 +808,25 @@ function hostSearchInterval() { ...@@ -710,23 +808,25 @@ function hostSearchInterval() {
} }
function hostChangeRequest(loginId) { function hostChangeRequest(loginId) {
fw.sendToMsg('others', 'HOST_CHANGE_REQUEST', {"loginId": getFermiLoginId(loginId)}); fw.sendToMsg("others", "HOST_CHANGE_REQUEST", {
loginId: getFermiLoginId(loginId),
});
} }
function getFermiLoginId(loginId) { function getFermiLoginId(loginId) {
return globalUserInfo.shopName + '_' + loginId; return globalUserInfo.shopName + "_" + loginId;
} }
function getReplacedLoginId(loginId) { function getReplacedLoginId(loginId) {
return loginId.replaceAll(globalUserInfo.shopName + '_', ''); return loginId.replaceAll(globalUserInfo.shopName + "_", "");
} }
function captureAndShareImage(urls, changeHostName) { function captureAndShareImage(urls, changeHostName) {
addCaptureEffect(); addCaptureEffect();
$(this).removeClass("on"); $(this).removeClass("on");
var w,h; var w, h;
var video = document.getElementById("localVideo"); var video = document.getElementById("localVideo");
var canvas = document.createElement('canvas'); var canvas = document.createElement("canvas");
if (clientOrientaionState == 1) { if (clientOrientaionState == 1) {
canvas.width = w = 680; canvas.width = w = 680;
canvas.height = h = 515; canvas.height = h = 515;
...@@ -735,32 +835,44 @@ function captureAndShareImage(urls, changeHostName) { ...@@ -735,32 +835,44 @@ function captureAndShareImage(urls, changeHostName) {
canvas.height = h = 515; canvas.height = h = 515;
} }
if (canvas.getContext) { if (canvas.getContext) {
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext("2d");
ctx.drawImage(video, 0, 0, w, h); ctx.drawImage(video, 0, 0, w, h);
ctx.drawImage(document.getElementById("canvasRemote"), 0, 0, w, h); ctx.drawImage(document.getElementById("canvasRemote"), 0, 0, w, h);
} }
canvas.toBlob(function(blob) { canvas.toBlob(function (blob) {
var newImg = document.createElement('img') var newImg = document.createElement("img");
var url = URL.createObjectURL(blob); var url = URL.createObjectURL(blob);
canvasRemote.style.backgroundImage = "url('"+ URL.createObjectURL(blob) + "')"; canvasRemote.style.backgroundImage =
"url('" + URL.createObjectURL(blob) + "')";
canvasRemote.style.backgroundSize = "contain"; canvasRemote.style.backgroundSize = "contain";
$(canvasRemote).attr("height", $(snapshots[cpatureViewIndex]).attr("height")); $(canvasRemote).attr(
"height",
$(snapshots[cpatureViewIndex]).attr("height")
);
$(canvasRemote).attr("width", $(snapshots[cpatureViewIndex]).attr("width")); $(canvasRemote).attr("width", $(snapshots[cpatureViewIndex]).attr("width"));
console.log ('url', URL.createObjectURL(blob)); console.log("url", URL.createObjectURL(blob));
if ($(".canvas_wrap").css("width").replace("px","") / $(".canvas_wrap").css("height").replace("px","") < $(canvas).attr("width") / $(canvas).attr("height")) { if (
var h = $(".canvas_wrap").css("width").replace("px","") * ($(canvas).attr("height") / $(canvas).attr("width")); $(".canvas_wrap").css("width").replace("px", "") /
var w = $(".canvas_wrap").css("width").replace("px",""); $(".canvas_wrap").css("height").replace("px", "") <
$(canvas).attr("width") / $(canvas).attr("height")
) {
var h =
$(".canvas_wrap").css("width").replace("px", "") *
($(canvas).attr("height") / $(canvas).attr("width"));
var w = $(".canvas_wrap").css("width").replace("px", "");
$(canvasRemote).css("height", h); $(canvasRemote).css("height", h);
$(canvasRemote).css("width", w); $(canvasRemote).css("width", w);
$(canvasRemote).css("margin-top", (-h/2)); $(canvasRemote).css("margin-top", -h / 2);
$(canvasRemote).css("margin-left", (-w/2)); $(canvasRemote).css("margin-left", -w / 2);
} else { } else {
var h = $(".canvas_wrap").css("height").replace("px",""); var h = $(".canvas_wrap").css("height").replace("px", "");
var w = $(".canvas_wrap").css("height").replace("px","") / ($(canvas).attr("height") / $(canvas).attr("width")); var w =
$(".canvas_wrap").css("height").replace("px", "") /
($(canvas).attr("height") / $(canvas).attr("width"));
$(canvasRemote).css("height", h); $(canvasRemote).css("height", h);
$(canvasRemote).css("width", w); $(canvasRemote).css("width", w);
$(canvasRemote).css("margin-top", (-h/2)); $(canvasRemote).css("margin-top", -h / 2);
$(canvasRemote).css("margin-left", (-w/2)); $(canvasRemote).css("margin-left", -w / 2);
} }
$(".canvas_wrap").css("background-color", "#000"); $(".canvas_wrap").css("background-color", "#000");
$(".clear_img").show(); $(".clear_img").show();
...@@ -769,34 +881,42 @@ function captureAndShareImage(urls, changeHostName) { ...@@ -769,34 +881,42 @@ function captureAndShareImage(urls, changeHostName) {
//Fermi側にイメージ保存。 //Fermi側にイメージ保存。
var formData = new FormData(); var formData = new FormData();
var uploadFileName = "capture_share_" + g_webroom + "_" + g_shareCount + ".png" var uploadFileName =
"capture_share_" + g_webroom + "_" + g_shareCount + ".png";
g_shareCount++; g_shareCount++;
formData.append("imgFile", blob, uploadFileName); formData.append("imgFile", blob, uploadFileName);
var uploadUrl = location.protocol + "//" + location.hostname + ":" + location.port + "/upload/create"; var uploadUrl =
location.protocol +
"//" +
location.hostname +
":" +
location.port +
"/upload/create";
if (!location.port) { if (!location.port) {
uploadUrl = location.protocol + "//" + location.hostname + "/upload/create"; uploadUrl =
location.protocol + "//" + location.hostname + "/upload/create";
} }
$.ajax({ $.ajax({
type: 'post', type: "post",
url: g_coviewapiserverADDR + "/upload/create", url: g_coviewapiserverADDR + "/upload/create",
data: formData, data: formData,
processData: false, processData: false,
contentType: false, contentType: false,
success: function(res) { success: function (res) {
setTimeout(function() { setTimeout(function () {
SendFileShare(uploadFileName); SendFileShare(uploadFileName);
$("#coviewCaptureCtrBtn").hide(); $("#coviewCaptureCtrBtn").hide();
$("#coviewRecCtrBtn").hide(); $("#coviewRecCtrBtn").hide();
$(".coview_share_title_name").text("LIVE(CAPTURE IMAGE)"); $(".coview_share_title_name").text("LIVE(CAPTURE IMAGE)");
$(".coview_on_media_btn_back").show(); $(".coview_on_media_btn_back").show();
//アーカイブ保存。 //アーカイブ保存。
ArchiveFileManage(blob,uploadFileName,urls); ArchiveFileManage(blob, uploadFileName, urls);
}, 1500); }, 1500);
}, },
error: function(err) { error: function (err) {
console.log(err); console.log(err);
} },
}); });
}); });
} }
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