share.js 4.61 KB
Newer Older
Lee Munkyeong committed
1 2 3 4
/* --------------------------------------------------- */
/* Functions                                           */
/* --------------------------------------------------- */
let coview_api = new CoviewApi();
Lee Munkyeong committed
5
var isBoard = false;
6
let timeInterval = null;
Lee Munkyeong committed
7
var backgroundFileName;
8

Kim Peace committed
9
document.addEventListener("DOMContentLoaded", function () {
Kim Peace committed
10
  coview_api.Init({
Kim Peace committed
11
    coview_api_srv_addr: BIZ_TASK_YELL_URL,
12 13 14 15
    coview_wrap_id: "coviewShare",
    coview_api_key: "8dda7092c5820d663",
  });

Kim Peace committed
16
  CoviewBridge.bindReadyEvent();
17

Kim Peace committed
18
  CoviewBridge.bindStartEvent();
19

Kim Peace committed
20
  CoviewBridge.bindAllByeEvent();
Kim Peace committed
21

Kim Peace committed
22
  CoviewBridge.bindGuestByeEvent();
Kim Peace committed
23

Kim Peace committed
24
  CoviewBridge.bindDestroyEvent();
25

Kim Peace committed
26
  CoviewBridge.bindMessageEvent();
Lee Munkyeong committed
27 28
});

Kim Peace committed
29
// call from collaboration_overlay_menu.html and collaboration.html
Kim Peace committed
30
function changeCollaboration(collaborationType) {
31
  recordStop(function () {
Kim Peace committed
32
    var newMeetingID = 0;
33
    if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) {
34
      NativeBridgeDelegate.exitMeetingRoom();
35
    }
36
    NativeBridgeDelegate.setJoinCollaborationType(collaborationType);
37

38
    globalUserInfo.collaborationType = collaborationType;
Kim Peace committed
39 40
    CollaborationUI.updateScreen(collaborationType);

Kim Peace committed
41
    switch (collaborationType) {
42 43 44 45 46 47 48 49 50 51 52 53
      case COLLABORATION_TYPE.AUDIO:
        coview_api.ChangeCollaboration("audio");
        break;
      case COLLABORATION_TYPE.CAMERA:
        removeOldLocalVideo(g_localStream);
        coview_api.ChangeCollaboration("image");
        break;
      case COLLABORATION_TYPE.VIDEO:
        coview_api.ChangeCollaboration("video");
        break;
      case COLLABORATION_TYPE.DOCUMENT:
        coview_api.ChangeCollaboration("audio");
Kim Peace committed
54
        newMeetingID = NativeBridgeDataSource.createContentView();
55 56 57 58
        if (newMeetingID == "-1") { //会議室作成失敗
            CoviewBridge.finishCollaboration();
            return;
        }
59 60 61 62 63
        break;
      case COLLABORATION_TYPE.BOARD:
        coview_api.ChangeCollaboration("audio");
        break;
    }
Kim Peace committed
64

65 66 67 68 69
    if ($("#micBtn .voice").hasClass("disable")) {
      micOff();
    } else {
      micOn();
    }
Kim Peace committed
70

Kim Peace committed
71
    globalUserInfo.meetingID = newMeetingID;
Kim Peace committed
72

Kim Peace committed
73 74
    NativeBridgeDelegate.changeCollaboration(collaborationType, newMeetingID);
    FermiWebSocketBridge.changeCollaboration(collaborationType, newMeetingID);
Kim Peace committed
75
  });
76 77
}

Kim Peace committed
78
CollaborationUI.updateScreen = async function (collaborationType) {
Kim Peace committed
79 80 81
  $("#coviewEraserCtrBtn").click();
  if ($(".user_btn").hasClass("hide")) {
    $(".user_btn").click();
82
  }
Kim Peace committed
83
  if ($(".menu_btn").hasClass("hide")) {
84 85
    $(".menu_btn").click();
  }
Kim Peace committed
86

87
  CollaborationUI.displayAddUserButtonIfNeeded();
88

89
  $("link[href='./css/collaboration_board.css']").remove();
Kim Peace committed
90

Kim Peace committed
91 92
  $(".collaboration_contents").addClass("none");

Kim Peace committed
93
  switch (collaborationType) {
94
    case COLLABORATION_TYPE.AUDIO:
Kim Peace committed
95
      $(".voice_contents").removeClass("none");
96
      break;
97
    case COLLABORATION_TYPE.CAMERA:
Kim Peace committed
98
      $(".picture_contents").removeClass("none");
99
      break;
100
    case COLLABORATION_TYPE.VIDEO:
Kim Peace committed
101
      $(".video_contents").removeClass("none");
102
      break;
103
    case COLLABORATION_TYPE.DOCUMENT:
Kim Peace committed
104
      $(".document_contents").removeClass("none");
105
      break;
106
    case COLLABORATION_TYPE.BOARD:
Kim Peace committed
107 108 109 110
      $(".board_contents").removeClass("none");
      $("head").append(
        '<link rel="stylesheet" href="./css/collaboration_board.css">'
      );
111 112
      break;
  }
113 114
  await waitMillisecond(1000);
  $(".before_loading_indicator").addClass("none");
Kim Peace committed
115
};
116

Kim Peace committed
117
// call from modal_collabo_host_request.html
118
function applyForHostChange() {
Kim Peace committed
119
  if (
120
    globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT &&
121
    deviceInfo.androidVersion < ANDROID_SDK_VERSION.O &&
122
    deviceInfo.isAndroid()
Kim Peace committed
123 124
  ) {
    alert(getLocalizedString("not_support_version"));
125 126
    return;
  }
127
  const hostRequestFlg = NativeBridgeDataSource.getHostRequestFlg();
Kim Peace committed
128
  if (hostRequestFlg == HostRequestFlag.DOING) {
Kim Peace committed
129
    alert(getLocalizedString("already_processing_host_request"));
130 131
    return;
  }
132 133

  NativeBridgeDelegate.setHostRequestFlg(HostRequestFlag.DOING);
Kim Peace committed
134
  FermiWebSocketBridge.changeHostApply();
135 136 137
}

function getFermiLoginId(loginId) {
Kim Peace committed
138
  return globalUserInfo.shopName + "_" + loginId;
139 140
}

141
function screenLock() {
142
  // ロック用のdivを生成
143
  const element = document.createElement("div");
144
  element.id = "screenLock";
145 146

  // ロック用のスタイル
147 148 149 150 151 152 153 154
  element.style.height = "100%";
  element.style.left = "0px";
  element.style.position = "fixed";
  element.style.top = "0px";
  element.style.width = "100%";
  element.style.zIndex = "9999";
  element.style.opacity = "0";

Kim Peace committed
155
  document.getElementsByTagName("body").item(0).appendChild(element);
156 157
}

158
async function waitMillisecond(millesecond) {
159
  await new Promise((done) => setTimeout(() => done(), millesecond));
160
}