Commit 52e466d4 by Kim Peace

Fixed for collaboration

parent a6846c4b
......@@ -59,7 +59,7 @@
</a>
</div>
<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">
<img src="icon/icon_close_white.png" alt="閉じる">
</div>
......
......@@ -38,9 +38,9 @@ var CoviewUserInfo = class {
case COLLABORATION_TYPE.VIDEO:
return COLLABORATION_TYPE.VIDEO;
case COLLABORATION_TYPE.DOCUMENT:
return COLLABORATION_TYPE.DOCUMENT;
return COLLABORATION_TYPE.AUDIO;
case COLLABORATION_TYPE.BOARD:
return COLLABORATION_TYPE.BOARD;
return COLLABORATION_TYPE.AUDIO;
}
}
......
......@@ -33,3 +33,6 @@ var DeviceInfo = class {
};
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) {
};
NativeBridgeDelegate.startCollaboration = function (type) {
const collaborationNumber = CHAT_UTIL.getCollaborationTypeNumber(type);
if (deviceInfo.isiOS()) {
webkit.messageHandlers.startCollaboration.postMessage(type);
webkit.messageHandlers.startCollaboration.postMessage(collaborationNumber);
} else if (deviceInfo.isAndroid()) {
android.startCollaboration(type);
android.startCollaboration(collaborationNumber);
}
};
......@@ -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()) {
webkit.messageHandlers.changeCollaboration.postMessage({
changeCollaborationType: type,
changeCollaborationType: collaborationNumber,
meetingId: meetingID,
});
} else if (deviceInfo.isAndroid()) {
android.changeCollaboration(type, meetingID);
android.changeCollaboration(collaborationNumber, meetingID);
}
};
......
......@@ -29,8 +29,6 @@ document.addEventListener("DOMContentLoaded", function () {
********************************/
CollaborationUI.bindMenuButton = function () {
$(".menu_btn").click(function () {
var w = $(this).width();
$(this).toggleClass("hide");
$("#overlay_menu .item").toggleClass("hide");
});
......
......@@ -3,7 +3,7 @@ var CollaborationFeature = {};
CoviewBridge.bindReadyEvent = function () {
coview_api.addEventListener("ready", function () {
CoviewBridge.addLoginId(globalUserInfo.loginId);
CoviewBridge.addLoginID(globalUserInfo.loginId);
coview_api.Login(globalUserInfo.loginId);
updateCollaborationUI(globalUserInfo.collaborationType);
NativeBridgeDelegate.setHostRequestFlg(HostRequestFlag.DONE);
......@@ -18,6 +18,9 @@ CoviewBridge.bindStartEvent = function () {
});
};
/**************
* Scroll Lock
**************/
CollaborationFeature.scrollLock = function (e) {
if (deviceInfo.isiOS()) {
if (
......@@ -87,124 +90,38 @@ CoviewBridge.bindDestroyEvent = function () {
};
CoviewBridge.bindMessageEvent = function () {
let meetingId;
coview_api.addEventListener("message", async function (event, json) {
if (globalUserInfo.isLeaved) {
return;
}
let loginIdList = new Array();
let loginIDList = new Array();
switch (json.api) {
case "LoginResponse":
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) {
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();
CollaborationFeature.didReceiveLoginResponseMessage();
break;
case "CreateRoomResponse":
if (json.resultCode == 200) {
var coviewInviteMessage;
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);
CollaborationFeature.didReceiveCreateRoomResponseMessage();
}
break;
case "joinRoomInfoResponse":
if (json.resultCode == 200) {
} else {
alert(getLocalizedString("not_exist_sharing_call"));
coview_api.LeaveRoom();
$(".coview_share_area").hide();
CollaborationUI.hideLoadingIndicator();
NativeBridgeDelegate.joinRoom(roomInfo.roomID, roomInfo.roomName);
if (json.resultCode != 200) {
CollaborationFeature.didReceivedJoinRoomInfoResponseMessage();
}
break;
case "JoinRoomResponse":
if (json.resultCode == 200) {
hostSearchInterval();
for (let key in g_participants) {
loginIdList.push(key);
}
CollaborationUI.refreshJoinedCollaboration(loginIdList);
}
if (json.resultCode != 200) {
break;
case "RoomMemberJoinedEvent":
for (let key in g_participants) {
loginIdList.push(key);
}
CollaborationUI.refreshJoinedCollaboration(loginIdList);
break;
CollaborationFeature.searchHostIntervally();
// fall through
case "RoomMemberJoinedEvent":
// fall through
case "RoomMemberLeavedEvent":
for (let key in g_participants) {
loginIdList.push(key);
loginIDList.push(key);
}
CollaborationUI.refreshJoinedCollaboration(loginIdList);
CollaborationUI.refreshJoinedCollaboration(loginIDList);
break;
case "HostRequest":
// to be called by
......@@ -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) {
// call in agent_app.js
changeOwnerSend(userID);
};
CoviewBridge.addLoginId = function (loginID) {
CoviewBridge.addLoginID = function (loginID) {
const url = "https://biztaskyell.abookcloud.com/auth/getuser";
$.ajax({
url: url,
......@@ -256,10 +235,25 @@ CoviewBridge.addLoginId = function (loginID) {
});
};
function hostSearchInterval() {
CollaborationFeature.searchHostIntervally = function () {
let hostName = "";
function hostSearch() {
function searchHost() {
if (g_isMainMan) {
CollaborationUI.showHostButtons();
} else {
CollaborationUI.hideHostButtons();
}
CollaborationUI.showHostMark(hostName);
if (hostName != g_isMainManUsername) {
hostName = g_isMainManUsername;
}
}
timeInterval = setInterval(searchHost, 2000);
};
CollaborationUI.showHostButtons = function () {
$("#collaboration_user_" + currentUserInfo.loginID).addClass("host");
$(".host_contents").removeClass("none");
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.CAMERA) {
......@@ -269,8 +263,9 @@ function hostSearchInterval() {
$(".video_contents_host").removeClass("none");
$(".video_contents_user").addClass("none");
}
if (deviceInfo.isiOS()) isIos = true;
} else {
};
CollaborationUI.hideHostButtons = function () {
$("#collaboration_user_" + currentUserInfo.loginID).removeClass("host");
$(".host_contents").addClass("none");
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.CAMERA) {
......@@ -280,42 +275,35 @@ function hostSearchInterval() {
$(".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 != "") {
$("#collaboration_user_" + getReplacedLoginId(hostName)).removeClass(
"host"
);
replaceHostIDDiv.removeClass("host");
}
replacedMainManUserID.addClass("host");
return;
}
$(
"#collaboration_user_" + getReplacedLoginId(g_isMainManUsername)
).addClass("host");
hostName = g_isMainManUsername;
} else {
if (hostName == "") {
if (
!$("#collaboration_user_" + currentUserInfo.loginID).hasClass(
"host"
) &&
coview_api.getRoomUsers()
) {
$("#collaboration_user_" + currentUserInfo.loginID).addClass("host");
if (!currentUserLoginIDDiv.hasClass("host") && coview_api.getRoomUsers()) {
currentUserLoginIDDiv.addClass("host");
}
} else {
if (
!$("#collaboration_user_" + getReplacedLoginId(hostName)).hasClass(
"host"
)
) {
$("#collaboration_user_" + getReplacedLoginId(hostName)).addClass(
"host"
);
}
}
if (!replaceHostIDDiv.hasClass("host")) {
replaceHostIDDiv.addClass("host");
}
}
timeInterval = setInterval(hostSearch, 2000);
}
};
function captureAndShareImage(urls, changeHostName) {
addCaptureEffect();
......@@ -337,62 +325,32 @@ function captureAndShareImage(urls, changeHostName) {
}
canvas.toBlob(function (blob) {
var newImg = document.createElement("img");
var url = URL.createObjectURL(blob);
canvasRemote.style.backgroundImage =
"url('" + URL.createObjectURL(blob) + "')";
canvasRemote.style.backgroundSize = "contain";
$(canvasRemote).attr(
"height",
$(snapshots[cpatureViewIndex]).attr("height")
);
$(canvasRemote).attr("width", $(snapshots[cpatureViewIndex]).attr("width"));
if (
$(".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("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);
}
CollaborationUI.configureCanvasSize($(canvas));
$(".canvas_wrap").css("background-color", "#000");
$(".clear_img").show();
SetShareMenuState("on");
WithImageShareBtnState("on");
//Fermi側にイメージ保存。
var formData = new FormData();
var uploadFileName =
let formData = new FormData();
const uploadFileName =
"capture_share_" + g_webroom + "_" + g_shareCount + ".png";
g_shareCount++;
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({
type: "post",
url: g_coviewapiserverADDR + "/upload/create",
......@@ -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) {
return loginId.replaceAll(globalUserInfo.shopName + "_", "");
}
......@@ -495,8 +476,8 @@ CollaborationUI.refreshJoinedCollaboration = function (loginIDList) {
Common.dismissLoadingIndicator();
};
function moveToVideoShareArea() {
CollaborationUI.moveToVideoShareArea = function () {
CollaborationUI.showLoadingIndicator();
$(".coview_share_area").show();
$("#collabo_main").removeClass("none");
}
};
......@@ -2,11 +2,9 @@
/* Functions */
/* --------------------------------------------------- */
let coview_api = new CoviewApi();
var isDocument = false;
var isBoard = false;
let timeInterval = null;
var backgroundFileName;
var isIos;
document.addEventListener("DOMContentLoaded", function () {
coview_api.Init({
......@@ -153,8 +151,7 @@ function screenLock() {
element.style.zIndex = "9999";
element.style.opacity = "0";
const objBody = document.getElementsByTagName("body").item(0);
objBody.appendChild(element);
document.getElementsByTagName("body").item(0).appendChild(element);
}
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