Commit 0c53021f by Kang Donghun

テストコミット

parent bc873f6b
......@@ -7,13 +7,14 @@ var isBoard = false;
let isLeaved = false;
let timeInterval = null;
var backgroundFileName;
var isIos;
$(function () {
var coviewApiActive = coview_api.Init({
testSTRParam: "param1",
testNUMParam: 77,
testBOOLParam: false,
coview_api_srv_addr: "https://livetaskyell.abookcloud.com",
coview_api_srv_addr: "https://biztaskyell.abookcloud.com",
coview_wrap_id: "coviewShare",
coview_api_key: "8dda7092c5820d663",
});
......@@ -118,6 +119,70 @@ $(function () {
console.log("=============> READY : ready for coview api");
Coview_addLoginId(globalUserInfo.loginId);
coview_api.Login(globalUserInfo.loginId);
initCollaborationUI(joinCollaborationType)
fw.socket.on('message', async function(data) {
console.log('====> message::data: ', data);
if (data.type ==="CHANGE_COLLABORATION") {
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.exitMeetingRoom.postMessage({});
} else if (CHAT_UTIL.isAndroid()) {
android.exitMeetingRoom();
}
}
if (CHAT_UTIL.isAndroid() && data.payload.collaborationType == COLLABORATION_TYPE.DOCUMENT && androidVersion < ANDROID_SDK_VERSION.O) {
alert(getLocalizedString('not_support_version'));
joinCollaborationType = COLLABORATION_TYPE.CAMERA;
} else {
joinCollaborationType = data.payload.collaborationType;
}
joinMeetingId = data.payload.newMeetingId;
initCollaborationUI(joinCollaborationType);
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.joinChangedCollaboration.postMessage({"joinCollaborationType": joinCollaborationType, "meetingId": data.payload.newMeetingId});
webkit.messageHandlers.joinMeetingRoom.postMessage(data.payload.newMeetingId);
} else if (CHAT_UTIL.isAndroid()) {
android.joinChangedCollaboration(joinCollaborationType, data.payload.newMeetingId);
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
android.joinMeetingRoom(data.payload.newMeetingId);
}
}
} else if (data.type ==="SHARE_FILE") {
if (joinCollaborationType != COLLABORATION_TYPE.CAMERA) {
initCollaborationUI(COLLABORATION_TYPE.CAMERA);
joinCollaborationType = COLLABORATION_TYPE.CAMERA;
fw.sendToMsg('others', 'SHARE_FILE_HOST', {"collaborationType": COLLABORATION_TYPE.CAMERA});
}
} else if (data.type ==="SHARE_FILE_HOST") {
if (joinCollaborationType != COLLABORATION_TYPE.CAMERA && g_isMainMan) {
initCollaborationUI(COLLABORATION_TYPE.CAMERA);
joinCollaborationType = COLLABORATION_TYPE.CAMERA;
}
} else if (data.type === "CAPTURE_REQUEST" && g_isMainMan) {
if (confirm(data.payload.name + getLocalizedString("request_capture"))) {
captureAndShareImage(CMS_SERVER_URL + '/chatapi/file/uploadArchive', data.payload.name);
}
} else if (data.type === "HOST_CHANGE_REQUEST") {
if (data.payload.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") {
var isAndroid = data.payload.isAndroid;
var isAble = data.payload.isAble
if (g_isMainMan && isAndroid && !isAble && joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
alert(getLocalizedString('err_target_android_version_not_support'));
} else {
Coview_changeHost(data.payload.loginId);
}
} else if (data.type === "API_SEND_OWNER_CHANGE_COMPLETE") {
if ($('#recordBtn').hasClass('bg_red')) {
recordStop();
}
penOff();
}
});
});
coview_api.addEventListener("start", function () {
......@@ -158,9 +223,6 @@ $(function () {
let loginIdList = new Array();
switch (json.api) {
case "LoginResponse":
console.log("------------------------------");
console.log(globalUserInfo.coWorkType);
console.log(collaborationJoinFlg);
if (globalUserInfo.coWorkType == collaborationTypeKey.DOCUMENT) {
isDocument = true;
globalUserInfo.coWorkType = collaborationTypeKey.AUDIO;
......@@ -169,6 +231,7 @@ $(function () {
isBoard = true;
globalUserInfo.coWorkType = collaborationTypeKey.CAMERA;
}
hostSearchInterval();
if (collaborationJoinFlg == "1") {
coview_api.JoinRoom(globalUserInfo.roomId, globalUserInfo.coWorkType);
if (isDocument) {
......@@ -213,7 +276,7 @@ $(function () {
messageSeperator +
messageType.COMMUNICATIONSTART +
messageSeperator +
collaborationType.BOARD;
COLLABORATION_TYPE.BOARD;
} else {
coviewInviteMessage =
"" +
......@@ -252,6 +315,7 @@ $(function () {
break;
case "JoinRoomResponse":
if (json.resultCode == 200) {
hostSearchInterval();
for (let key in g_participants) {
loginIdList.push(key);
}
......@@ -310,6 +374,121 @@ function Coview_moveToVideoShareArea() {
$("#collabo_main").removeClass("none");
}
function changeCollaboration(changeCollaborationType) {
var newMeetingId = 0;
if (joinCollaborationType == COLLABORATION_TYPE.DOCUMENT) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.exitMeetingRoom.postMessage({});
} else if (CHAT_UTIL.isAndroid()) {
android.exitMeetingRoom();
}
}
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.setJoinCollaborationType.postMessage(changeCollaborationType);
} else if (CHAT_UTIL.isAndroid()) {
if (changeCollaborationType == COLLABORATION_TYPE.DOCUMENT && androidVersion < ANDROID_SDK_VERSION.O) {
alert(getLocalizedString('not_support_version'));
return;
}
android.setJoinCollaborationType(changeCollaborationType);
}
joinCollaborationType = changeCollaborationType;
if ($('#recordBtn').hasClass('bg_red')) {
recordStop();
}
initCollaborationUI(changeCollaborationType);
switch (changeCollaborationType) {
case COLLABORATION_TYPE.AUDIO:
coview_api.ChangeCollaboration('audio');
break;
case COLLABORATION_TYPE.CAMERA:
coview_api.ChangeCollaboration('image');
break;
case COLLABORATION_TYPE.VIDEO:
coview_api.ChangeCollaboration('video');
break;
case COLLABORATION_TYPE.DOCUMENT:
coview_api.ChangeCollaboration('audio');
if (CHAT_UTIL.isIOS()) {
newMeetingId = CHAT_DB.createContentView();
} else if (CHAT_UTIL.isAndroid()) {
newMeetingId = android.createContentView();
console.log('newMeetingId = ' + newMeetingId);
}
break;
case COLLABORATION_TYPE.BOARD:
coview_api.ChangeCollaboration('audio');
break;
}
penOff();
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.changeCollaboration.postMessage({"changeCollaborationType": changeCollaborationType, "meetingId": newMeetingId});
} else if (CHAT_UTIL.isAndroid()) {
android.changeCollaboration(changeCollaborationType, newMeetingId);
}
fw.sendToMsg('others', 'CHANGE_COLLABORATION', {"collaborationType": changeCollaborationType, "newMeetingId": newMeetingId});
}
function initCollaborationUI(changeCollaborationType){
if ($('.user_btn').hasClass("hide")) {
$('.user_btn').click();
}
if ($('.menu_btn').hasClass("hide")) {
$(".menu_btn").click();
}
$("link[href='./css/collaboration_board.css']").remove();
penOff();
switch (changeCollaborationType) {
case COLLABORATION_TYPE.AUDIO:
$('.collaboration_contents').addClass('none');
$('.voice_contents').removeClass('none');
var w = $('.user_btn').width();
$('.user_btn').toggleClass("hide");
$("#overlay_user_list.overlay")
.toggleClass("slidein")
.css({ transform: "translateX(" & -w & ")" });
$("#collabo_main").toggleClass("noscroll");
if ($("#overlay_user_list.overlay").hasClass("noscroll")) {
$("#overlay_user_list.overlay").removeClass("noscroll");
} else {
$("#overlay_user_list.overlay").addClass("noscroll");
}
break;
case COLLABORATION_TYPE.CAMERA:
$('.collaboration_contents').addClass('none');
$('.picture_contents').removeClass('none');
break;
case COLLABORATION_TYPE.VIDEO:
$('.collaboration_contents').addClass('none');
$('.video_contents').removeClass('none');
break;
case COLLABORATION_TYPE.DOCUMENT:
$('.collaboration_contents').addClass('none');
$('.document_contents').removeClass('none');
var w = $('.user_btn').width();
$('.user_btn').toggleClass("hide");
$("#overlay_user_list.overlay")
.toggleClass("slidein")
.css({ transform: "translateX(" & -w & ")" });
$("#collabo_main").toggleClass("noscroll");
if ($("#overlay_user_list.overlay").hasClass("noscroll")) {
$("#overlay_user_list.overlay").removeClass("noscroll");
} else {
$("#overlay_user_list.overlay").addClass("noscroll");
}
break;
case COLLABORATION_TYPE.BOARD:
$('.collaboration_contents').addClass('none');
$('.board_contents').removeClass('none');
$('head').append('<link rel="stylesheet" href="./css/collaboration_board.css">');
break;
}
}
function Coview_exitCollaboration(isDocument = false) {
if (isDocument) {
if (CHAT_UTIL.isIOS()) {
......@@ -318,9 +497,18 @@ function Coview_exitCollaboration(isDocument = false) {
android.exitMeetingRoom();
}
}
if ($('#recordBtn').hasClass('bg_red')) {
recordStop();
}
clearInterval(timeInterval);
coview_api.LeaveRoom();
if (coview_api.getRoomUsers()) { android.finishCollaboration() };
if (coview_api.getRoomUsers()) {
if (CHAT_UTIL.isIOS()) {
webkit.messageHandlers.finishCollaboration.postMessage({});
} else if (CHAT_UTIL.isAndroid()) {
android.finishCollaboration()
}
};
isLeaved = true;
if (collaborationJoinFlg != '2') {
CHAT_UI.joinRoom(
......@@ -343,7 +531,7 @@ function Coview_changeHost(userId) {
function Coview_addLoginId(loginId) {
console.log("addUser loginId = " + loginId);
var url = "https://livetaskyell.abookcloud.com/auth/getuser";
var url = "https://biztaskyell.abookcloud.com/auth/getuser";
$.ajax({
url : url,
method : 'post',
......@@ -373,6 +561,26 @@ function Coview_connect_audio_collaboration() {
function hostSearchInterval() {
let hostName = "";
function hostSearch() {
if (g_isMainMan) {
$('.host_contents').removeClass('none');
if (joinCollaborationType == COLLABORATION_TYPE.CAMERA) {
$('.photo_select_button').removeClass('none');
}
if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) {
$('.video_contents_host').removeClass('none');
$('.video_contents_user').addClass('none');
}
if (CHAT_UTIL.isIOS()) isIos = true;
} else {
$('.host_contents').addClass('none');
if (joinCollaborationType == COLLABORATION_TYPE.CAMERA) {
$('.photo_select_button').addClass('none');
}
if (joinCollaborationType == COLLABORATION_TYPE.VIDEO) {
$('.video_contents_user').removeClass('none');
$('.video_contents_host').addClass('none');
}
}
if (hostName != g_isMainManUsername) {
if (hostName != "") {
$("#collaboration_user_" + hostName).removeClass("host");
......@@ -388,12 +596,98 @@ function hostSearchInterval() {
if (!$("#collaboration_user_" + hostName).hasClass('host')) {
$("#collaboration_user_" + hostName).addClass("host");
}
}
}
}
timeInterval = setInterval(hostSearch, 2000);
}
function hostChangeRequest(loginId) {
fw.sendToMsg('others', 'HOST_CHANGE_REQUEST', {"loginId": loginId});
}
function captureAndShareImage(urls, changeHostName) {
addCaptureEffect();
$(this).removeClass("on");
var w,h;
var video = document.getElementById("localVideo");
var canvas = document.createElement('canvas');
if (clientOrientaionState == 1) {
canvas.width = w = 680;
canvas.height = h = 515;
} else {
canvas.width = w = 386;
canvas.height = h = 515;
}
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
ctx.drawImage(video, 0, 0, w, h);
ctx.drawImage(document.getElementById("canvasRemote"), 0, 0, w, h);
}
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"));
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")) {
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");
$(".clear_img").show();
SetShareMenuState("on");
WithImageShareBtnState("on");
//Fermi側にイメージ保存。
var formData = new FormData();
var 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",
data: formData,
processData: false,
contentType: false,
success: function(res) {
setTimeout(function() {
SendFileShare(uploadFileName);
$("#coviewCaptureCtrBtn").hide();
$("#coviewRecCtrBtn").hide();
$(".coview_share_title_name").text("LIVE(CAPTURE IMAGE)");
$(".coview_on_media_btn_back").show();
//アーカイブ保存。
ArchiveFileManage(blob,uploadFileName,urls);
}, 1500);
},
error: function(err) {
console.log(err);
}
});
});
}
function applyForHostChange() {
// coview_api.addEventProcess({"api": "HostRequest", "hostId": CHAT.globalLoginParameter.loginId});
wc_api.dispatchEvent (new Event ("message"), {"api":"HostRequest", "hostId": CHAT.globalLoginParameter.loginId});
......
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