Commit 52e466d4 by Kim Peace

Fixed for collaboration

parent a6846c4b
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
</a> </a>
</div> </div>
<div class="footer_item mx-md-3"> <div class="footer_item mx-md-3">
<a href="javascript:CoviewBridge.exitCollaboration(isDocument);"> <a href="javascript:CoviewBridge.exitCollaboration();">
<div class="img_wrap bg_red mx-1"> <div class="img_wrap bg_red mx-1">
<img src="icon/icon_close_white.png" alt="閉じる"> <img src="icon/icon_close_white.png" alt="閉じる">
</div> </div>
......
...@@ -38,9 +38,9 @@ var CoviewUserInfo = class { ...@@ -38,9 +38,9 @@ var CoviewUserInfo = class {
case COLLABORATION_TYPE.VIDEO: case COLLABORATION_TYPE.VIDEO:
return COLLABORATION_TYPE.VIDEO; return COLLABORATION_TYPE.VIDEO;
case COLLABORATION_TYPE.DOCUMENT: case COLLABORATION_TYPE.DOCUMENT:
return COLLABORATION_TYPE.DOCUMENT; return COLLABORATION_TYPE.AUDIO;
case COLLABORATION_TYPE.BOARD: case COLLABORATION_TYPE.BOARD:
return COLLABORATION_TYPE.BOARD; return COLLABORATION_TYPE.AUDIO;
} }
} }
......
...@@ -33,3 +33,6 @@ var DeviceInfo = class { ...@@ -33,3 +33,6 @@ var DeviceInfo = class {
}; };
var deviceInfo = new DeviceInfo(NativeBridgeDataSource.getDeviceInfo()); var deviceInfo = new DeviceInfo(NativeBridgeDataSource.getDeviceInfo());
// WARN:: this variable is only for use in coview. and should request not to use this.
var isIos = deviceInfo.isiOS();
...@@ -212,10 +212,11 @@ NativeBridgeDelegate.changeRoomName = function (newRoomName) { ...@@ -212,10 +212,11 @@ NativeBridgeDelegate.changeRoomName = function (newRoomName) {
}; };
NativeBridgeDelegate.startCollaboration = function (type) { NativeBridgeDelegate.startCollaboration = function (type) {
const collaborationNumber = CHAT_UTIL.getCollaborationTypeNumber(type);
if (deviceInfo.isiOS()) { if (deviceInfo.isiOS()) {
webkit.messageHandlers.startCollaboration.postMessage(type); webkit.messageHandlers.startCollaboration.postMessage(collaborationNumber);
} else if (deviceInfo.isAndroid()) { } else if (deviceInfo.isAndroid()) {
android.startCollaboration(type); android.startCollaboration(collaborationNumber);
} }
}; };
...@@ -347,14 +348,19 @@ NativeBridgeDelegate.startContentView = function () { ...@@ -347,14 +348,19 @@ NativeBridgeDelegate.startContentView = function () {
} }
}; };
NativeBridgeDelegate.changeCollaboration = function (type, meetingID) { NativeBridgeDelegate.changeCollaboration = function (
collaborationType,
meetingID
) {
const collaborationNumber =
CHAT_UTIL.getCollaborationTypeNumber(collaborationType);
if (deviceInfo.isiOS()) { if (deviceInfo.isiOS()) {
webkit.messageHandlers.changeCollaboration.postMessage({ webkit.messageHandlers.changeCollaboration.postMessage({
changeCollaborationType: type, changeCollaborationType: collaborationNumber,
meetingId: meetingID, meetingId: meetingID,
}); });
} else if (deviceInfo.isAndroid()) { } else if (deviceInfo.isAndroid()) {
android.changeCollaboration(type, meetingID); android.changeCollaboration(collaborationNumber, meetingID);
} }
}; };
......
...@@ -29,8 +29,6 @@ document.addEventListener("DOMContentLoaded", function () { ...@@ -29,8 +29,6 @@ document.addEventListener("DOMContentLoaded", function () {
********************************/ ********************************/
CollaborationUI.bindMenuButton = function () { CollaborationUI.bindMenuButton = function () {
$(".menu_btn").click(function () { $(".menu_btn").click(function () {
var w = $(this).width();
$(this).toggleClass("hide"); $(this).toggleClass("hide");
$("#overlay_menu .item").toggleClass("hide"); $("#overlay_menu .item").toggleClass("hide");
}); });
......
...@@ -3,7 +3,7 @@ var CollaborationFeature = {}; ...@@ -3,7 +3,7 @@ var CollaborationFeature = {};
CoviewBridge.bindReadyEvent = function () { CoviewBridge.bindReadyEvent = function () {
coview_api.addEventListener("ready", function () { coview_api.addEventListener("ready", function () {
CoviewBridge.addLoginId(globalUserInfo.loginId); CoviewBridge.addLoginID(globalUserInfo.loginId);
coview_api.Login(globalUserInfo.loginId); coview_api.Login(globalUserInfo.loginId);
updateCollaborationUI(globalUserInfo.collaborationType); updateCollaborationUI(globalUserInfo.collaborationType);
NativeBridgeDelegate.setHostRequestFlg(HostRequestFlag.DONE); NativeBridgeDelegate.setHostRequestFlg(HostRequestFlag.DONE);
...@@ -18,6 +18,9 @@ CoviewBridge.bindStartEvent = function () { ...@@ -18,6 +18,9 @@ CoviewBridge.bindStartEvent = function () {
}); });
}; };
/**************
* Scroll Lock
**************/
CollaborationFeature.scrollLock = function (e) { CollaborationFeature.scrollLock = function (e) {
if (deviceInfo.isiOS()) { if (deviceInfo.isiOS()) {
if ( if (
...@@ -87,124 +90,38 @@ CoviewBridge.bindDestroyEvent = function () { ...@@ -87,124 +90,38 @@ CoviewBridge.bindDestroyEvent = function () {
}; };
CoviewBridge.bindMessageEvent = function () { CoviewBridge.bindMessageEvent = function () {
let meetingId;
coview_api.addEventListener("message", async function (event, json) { coview_api.addEventListener("message", async function (event, json) {
if (globalUserInfo.isLeaved) { if (globalUserInfo.isLeaved) {
return; return;
} }
let loginIdList = new Array(); let loginIDList = new Array();
switch (json.api) { switch (json.api) {
case "LoginResponse": case "LoginResponse":
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) { CollaborationFeature.didReceiveLoginResponseMessage();
isDocument = true;
globalUserInfo.collaborationType = COLLABORATION_TYPE.AUDIO;
}
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.BOARD) {
isBoard = true;
globalUserInfo.collaborationType = COLLABORATION_TYPE.AUDIO;
}
hostSearchInterval();
switch (globalUserInfo.joinType) {
case COLLABORATION_JOIN_TYPE.ATTENDEE:
coview_api.JoinRoom(
globalUserInfo.roomId,
globalUserInfo.coWorkType
);
if (isDocument) {
NativeBridgeDelegate.startContentView();
}
break;
case COLLABORATION_JOIN_TYPE.HOST:
let deleteRoomResult = JSON.parse(
await deleteRoomApi(globalUserInfo.roomId)
);
if (deleteRoomResult.resultCode == 200) {
waitMillisecond(3000);
}
coview_api.CreateRoom(
globalUserInfo.roomId,
globalUserInfo.coWorkType
);
if (isDocument) {
meetingId = NativeBridgeDataSource.createContentView();
globalUserInfo.meetingID = meetingId;
}
break;
case COLLABORATION_JOIN_TYPE.INVITED:
coview_api.JoinRoom(
globalUserInfo.roomId,
globalUserInfo.coWorkType
);
break;
default:
break;
}
moveToVideoShareArea();
break; break;
case "CreateRoomResponse": case "CreateRoomResponse":
if (json.resultCode == 200) { if (json.resultCode == 200) {
var coviewInviteMessage; CollaborationFeature.didReceiveCreateRoomResponseMessage();
if (isDocument) {
coviewInviteMessage =
"" +
messageSeperator +
MessageType.COMMUNICATIONSTART +
messageSeperator +
CHAT_UTIL.getCollaborationTypeNumber(
COLLABORATION_TYPE.DOCUMENT
) +
messageSeperator +
meetingId;
} else if (isBoard) {
coviewInviteMessage =
"" +
messageSeperator +
MessageType.COMMUNICATIONSTART +
messageSeperator +
COLLABORATION_TYPE.BOARD;
} else {
coviewInviteMessage =
"" +
messageSeperator +
MessageType.COMMUNICATIONSTART +
messageSeperator +
CHAT_UTIL.getCollaborationTypeNumber(
globalUserInfo.collaborationType
);
}
CHAT_SOCKET.emitCreateMessage(coviewInviteMessage, 0);
} }
break; break;
case "joinRoomInfoResponse": case "joinRoomInfoResponse":
if (json.resultCode == 200) { if (json.resultCode != 200) {
} else { CollaborationFeature.didReceivedJoinRoomInfoResponseMessage();
alert(getLocalizedString("not_exist_sharing_call"));
coview_api.LeaveRoom();
$(".coview_share_area").hide();
CollaborationUI.hideLoadingIndicator();
NativeBridgeDelegate.joinRoom(roomInfo.roomID, roomInfo.roomName);
} }
break; break;
case "JoinRoomResponse": case "JoinRoomResponse":
if (json.resultCode == 200) { if (json.resultCode != 200) {
hostSearchInterval(); break;
for (let key in g_participants) {
loginIdList.push(key);
}
CollaborationUI.refreshJoinedCollaboration(loginIdList);
} }
break; CollaborationFeature.searchHostIntervally();
// fall through
case "RoomMemberJoinedEvent": case "RoomMemberJoinedEvent":
for (let key in g_participants) { // fall through
loginIdList.push(key);
}
CollaborationUI.refreshJoinedCollaboration(loginIdList);
break;
case "RoomMemberLeavedEvent": case "RoomMemberLeavedEvent":
for (let key in g_participants) { for (let key in g_participants) {
loginIdList.push(key); loginIDList.push(key);
} }
CollaborationUI.refreshJoinedCollaboration(loginIdList); CollaborationUI.refreshJoinedCollaboration(loginIDList);
break; break;
case "HostRequest": case "HostRequest":
// to be called by // to be called by
...@@ -232,12 +149,74 @@ CoviewBridge.bindMessageEvent = function () { ...@@ -232,12 +149,74 @@ CoviewBridge.bindMessageEvent = function () {
}); });
}; };
CollaborationFeature.didReceiveLoginResponseMessage = async function () {
CollaborationFeature.searchHostIntervally();
switch (globalUserInfo.joinType) {
case COLLABORATION_JOIN_TYPE.INVITED:
// fall through
case COLLABORATION_JOIN_TYPE.ATTENDEE:
coview_api.JoinRoom(globalUserInfo.roomId, globalUserInfo.coWorkType);
break;
case COLLABORATION_JOIN_TYPE.HOST:
let deleteRoomResult = JSON.parse(
await deleteRoom(globalUserInfo.roomId)
);
if (deleteRoomResult.resultCode == 200) {
waitMillisecond(3000);
}
coview_api.CreateRoom(globalUserInfo.roomId, globalUserInfo.coWorkType);
break;
default:
break;
}
const isDocument =
globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT;
const isAttendee =
globalUserInfo.joinType == COLLABORATION_JOIN_TYPE.ATTENDEE;
const isHost = globalUserInfo.joinType == COLLABORATION_JOIN_TYPE.HOST;
if (isDocument) {
if (isAttendee) {
NativeBridgeDelegate.startContentView();
} else if (isHost) {
globalUserInfo.meetingID = NativeBridgeDataSource.createContentView();
}
}
CollaborationUI.moveToVideoShareArea();
};
CollaborationFeature.didReceiveCreateRoomResponseMessage = function () {
let coviewInviteMessage =
"" +
messageSeperator +
MessageType.COMMUNICATIONSTART +
messageSeperator +
CHAT_UTIL.getCollaborationTypeNumber(globalUserInfo.collaborationType);
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) {
coviewInviteMessage += messageSeperator + globalUserInfo.meetingID;
}
CHAT_SOCKET.emitCreateMessage(coviewInviteMessage, 0);
};
CollaborationFeature.didReceivedJoinRoomInfoResponseMessage = function () {
alert(getLocalizedString("not_exist_sharing_call"));
coview_api.LeaveRoom();
$(".coview_share_area").hide();
CollaborationUI.hideLoadingIndicator();
NativeBridgeDelegate.joinRoom(roomInfo.roomID, roomInfo.roomName);
};
CoviewBridge.changeHost = function (userID) { CoviewBridge.changeHost = function (userID) {
// call in agent_app.js // call in agent_app.js
changeOwnerSend(userID); changeOwnerSend(userID);
}; };
CoviewBridge.addLoginId = function (loginID) { CoviewBridge.addLoginID = function (loginID) {
const url = "https://biztaskyell.abookcloud.com/auth/getuser"; const url = "https://biztaskyell.abookcloud.com/auth/getuser";
$.ajax({ $.ajax({
url: url, url: url,
...@@ -256,66 +235,75 @@ CoviewBridge.addLoginId = function (loginID) { ...@@ -256,66 +235,75 @@ CoviewBridge.addLoginId = function (loginID) {
}); });
}; };
function hostSearchInterval() { CollaborationFeature.searchHostIntervally = function () {
let hostName = ""; let hostName = "";
function hostSearch() { function searchHost() {
if (g_isMainMan) { if (g_isMainMan) {
$("#collaboration_user_" + currentUserInfo.loginID).addClass("host"); CollaborationUI.showHostButtons();
$(".host_contents").removeClass("none");
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.CAMERA) {
$(".photo_select_button").removeClass("none");
}
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.VIDEO) {
$(".video_contents_host").removeClass("none");
$(".video_contents_user").addClass("none");
}
if (deviceInfo.isiOS()) isIos = true;
} else { } else {
$("#collaboration_user_" + currentUserInfo.loginID).removeClass("host"); CollaborationUI.hideHostButtons();
$(".host_contents").addClass("none");
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.CAMERA) {
$(".photo_select_button").addClass("none");
}
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.VIDEO) {
$(".video_contents_user").removeClass("none");
$(".video_contents_host").addClass("none");
}
} }
CollaborationUI.showHostMark(hostName);
if (hostName != g_isMainManUsername) { if (hostName != g_isMainManUsername) {
if (hostName != "") {
$("#collaboration_user_" + getReplacedLoginId(hostName)).removeClass(
"host"
);
}
$(
"#collaboration_user_" + getReplacedLoginId(g_isMainManUsername)
).addClass("host");
hostName = g_isMainManUsername; hostName = g_isMainManUsername;
} else {
if (hostName == "") {
if (
!$("#collaboration_user_" + currentUserInfo.loginID).hasClass(
"host"
) &&
coview_api.getRoomUsers()
) {
$("#collaboration_user_" + currentUserInfo.loginID).addClass("host");
}
} else {
if (
!$("#collaboration_user_" + getReplacedLoginId(hostName)).hasClass(
"host"
)
) {
$("#collaboration_user_" + getReplacedLoginId(hostName)).addClass(
"host"
);
}
}
} }
} }
timeInterval = setInterval(hostSearch, 2000); timeInterval = setInterval(searchHost, 2000);
} };
CollaborationUI.showHostButtons = function () {
$("#collaboration_user_" + currentUserInfo.loginID).addClass("host");
$(".host_contents").removeClass("none");
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.CAMERA) {
$(".photo_select_button").removeClass("none");
}
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.VIDEO) {
$(".video_contents_host").removeClass("none");
$(".video_contents_user").addClass("none");
}
};
CollaborationUI.hideHostButtons = function () {
$("#collaboration_user_" + currentUserInfo.loginID).removeClass("host");
$(".host_contents").addClass("none");
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.CAMERA) {
$(".photo_select_button").addClass("none");
}
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.VIDEO) {
$(".video_contents_user").removeClass("none");
$(".video_contents_host").addClass("none");
}
};
CollaborationUI.showHostMark = function (hostName) {
const currentUserLoginIDDiv = $(
"#collaboration_user_" + currentUserInfo.loginID
);
const replaceHostIDDiv = $(
"#collaboration_user_" + getReplacedLoginId(hostName)
);
const replacedMainManUserID = $(
"#collaboration_user_" + getReplacedLoginId(g_isMainManUsername)
);
if (hostName != g_isMainManUsername) {
if (hostName != "") {
replaceHostIDDiv.removeClass("host");
}
replacedMainManUserID.addClass("host");
return;
}
if (hostName == "") {
if (!currentUserLoginIDDiv.hasClass("host") && coview_api.getRoomUsers()) {
currentUserLoginIDDiv.addClass("host");
}
} else {
if (!replaceHostIDDiv.hasClass("host")) {
replaceHostIDDiv.addClass("host");
}
}
};
function captureAndShareImage(urls, changeHostName) { function captureAndShareImage(urls, changeHostName) {
addCaptureEffect(); addCaptureEffect();
...@@ -337,62 +325,32 @@ function captureAndShareImage(urls, changeHostName) { ...@@ -337,62 +325,32 @@ function captureAndShareImage(urls, changeHostName) {
} }
canvas.toBlob(function (blob) { canvas.toBlob(function (blob) {
var newImg = document.createElement("img");
var url = URL.createObjectURL(blob);
canvasRemote.style.backgroundImage = canvasRemote.style.backgroundImage =
"url('" + URL.createObjectURL(blob) + "')"; "url('" + URL.createObjectURL(blob) + "')";
canvasRemote.style.backgroundSize = "contain"; canvasRemote.style.backgroundSize = "contain";
$(canvasRemote).attr( $(canvasRemote).attr(
"height", "height",
$(snapshots[cpatureViewIndex]).attr("height") $(snapshots[cpatureViewIndex]).attr("height")
); );
$(canvasRemote).attr("width", $(snapshots[cpatureViewIndex]).attr("width")); $(canvasRemote).attr("width", $(snapshots[cpatureViewIndex]).attr("width"));
if (
$(".canvas_wrap").css("width").replace("px", "") / CollaborationUI.configureCanvasSize($(canvas));
$(".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("width", w);
$(canvasRemote).css("margin-top", -h / 2);
$(canvasRemote).css("margin-left", -w / 2);
} else {
var h = $(".canvas_wrap").css("height").replace("px", "");
var w =
$(".canvas_wrap").css("height").replace("px", "") /
($(canvas).attr("height") / $(canvas).attr("width"));
$(canvasRemote).css("height", h);
$(canvasRemote).css("width", w);
$(canvasRemote).css("margin-top", -h / 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();
SetShareMenuState("on"); SetShareMenuState("on");
WithImageShareBtnState("on"); WithImageShareBtnState("on");
//Fermi側にイメージ保存。 //Fermi側にイメージ保存。
var formData = new FormData(); let formData = new FormData();
var uploadFileName = const uploadFileName =
"capture_share_" + g_webroom + "_" + g_shareCount + ".png"; "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";
if (!location.port) {
uploadUrl =
location.protocol + "//" + location.hostname + "/upload/create";
}
$.ajax({ $.ajax({
type: "post", type: "post",
url: g_coviewapiserverADDR + "/upload/create", url: g_coviewapiserverADDR + "/upload/create",
...@@ -416,6 +374,29 @@ function captureAndShareImage(urls, changeHostName) { ...@@ -416,6 +374,29 @@ function captureAndShareImage(urls, changeHostName) {
}); });
} }
CollaborationUI.configureCanvasSize = function (canvas) {
const canvasWrap = $(".canvas_wrap");
const canvasWidth = $(canvas).attr("width");
const canvasHeight = $(canvas).attr("height");
const canvasRatio = canvasWidth / canvasHeight;
const reversedCanvasRatio = canvasHeight / canvasWidth;
const canvasWidthValue = canvasWrap.css("width").replace("px", "");
const canvasHeightValue = canvasWrap.css("height").replace("px", "");
let h;
let w;
if (canvasWidthValue / canvasHeightValue < canvasRatio) {
h = canvasWidthValue * reversedCanvasRatio;
w = canvasWidthValue;
} else {
h = canvasHeightValue;
w = canvasHeightValue / reversedCanvasRatio;
}
$(canvasRemote).css("height", h);
$(canvasRemote).css("width", w);
$(canvasRemote).css("margin-top", -h / 2);
$(canvasRemote).css("margin-left", -w / 2);
};
function getReplacedLoginId(loginId) { function getReplacedLoginId(loginId) {
return loginId.replaceAll(globalUserInfo.shopName + "_", ""); return loginId.replaceAll(globalUserInfo.shopName + "_", "");
} }
...@@ -495,8 +476,8 @@ CollaborationUI.refreshJoinedCollaboration = function (loginIDList) { ...@@ -495,8 +476,8 @@ CollaborationUI.refreshJoinedCollaboration = function (loginIDList) {
Common.dismissLoadingIndicator(); Common.dismissLoadingIndicator();
}; };
function moveToVideoShareArea() { CollaborationUI.moveToVideoShareArea = function () {
CollaborationUI.showLoadingIndicator(); CollaborationUI.showLoadingIndicator();
$(".coview_share_area").show(); $(".coview_share_area").show();
$("#collabo_main").removeClass("none"); $("#collabo_main").removeClass("none");
} };
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
/* Functions */ /* Functions */
/* --------------------------------------------------- */ /* --------------------------------------------------- */
let coview_api = new CoviewApi(); let coview_api = new CoviewApi();
var isDocument = false;
var isBoard = false; var isBoard = false;
let timeInterval = null; let timeInterval = null;
var backgroundFileName; var backgroundFileName;
var isIos;
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
coview_api.Init({ coview_api.Init({
...@@ -153,8 +151,7 @@ function screenLock() { ...@@ -153,8 +151,7 @@ function screenLock() {
element.style.zIndex = "9999"; element.style.zIndex = "9999";
element.style.opacity = "0"; element.style.opacity = "0";
const objBody = document.getElementsByTagName("body").item(0); document.getElementsByTagName("body").item(0).appendChild(element);
objBody.appendChild(element);
} }
async function waitMillisecond(millesecond) { async function waitMillisecond(millesecond) {
......
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