Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- // All these three events are to stop any thing to be dropped on extention
- $("body").on("dragover", function (event) {
- event.preventDefault();
- event.stopPropagation();
- });
- $("body").on("dragleave", function (event) {
- event.preventDefault();
- event.stopPropagation();
- });
- $("body").on("drop", function (event) {
- event.preventDefault();
- event.stopPropagation();
- });
- var isPresentor = false;
- var joinReceived = false;
- var peerId = "";
- var pendingPresentId = "";
- var shareStream = null;
- var videoStream = null;
- var shareFlowing = false;
- var videoFlowing = false;
- var shareVideoActive = false;
- var shareVideo = null;
- var pauseFlag = false;
- var rtcInfo = {};
- var peerConns = {};
- var seltabid = null;
- var displayUserWaiting = [];
- var intervalidofvalidatenetwork = "";
- var reconnectInterval = 1000 * 10;
- var networkErrorCounter = 0;
- var isPresenting = "";
- var unReadMsgCounts = [];
- var screenShareSource = "";
- var mirrorRequestIpAdd = "";
- var mediaConstraints = {
- 'mandatory': {
- 'OfferToReceiveAudio': true,
- 'OfferToReceiveVideo': true
- }
- };
- $(".version").text(myApp.version);
- setInterval(function () {
- $.fn.hideDisplayAllowRequest();
- }, 5000);
- //connect();
- createstorage();
- document.onkeydown = function (e) {
- if (window.event.keyCode == 123 || e.button == 2)
- return false;
- }
- var autoUsername = "";
- if (myApp.loginMode == "" && myApp.chromeIpAddressKeyValue.length == 0) {
- $("#loginBtnTd").show();
- $("#loginBtnTd").css({"padding-top": "90px"});
- $("#myfooter").show();
- $("#myfooter").css({"padding-top": "30px"});
- }
- chrome.identity.getProfileUserInfo(function (autoUsername) {
- /* Use userInfo.email, or better (for privacy) userInfo.id
- They will be empty if user is not signed in in Chrome */
- var userlogin = autoUsername.email;
- var userinfo = userlogin.split('@');
- //$("#username").val(userinfo[0]);
- });
- // chrome.tabs.getSelected(null,function(tab){
- // captureTab();
- //})
- function networkvalidate()
- {
- var xmlHttp = new XMLHttpRequest();
- var url = "http://" + myApp.domain + "/validatenetwork.php";
- xmlHttp.onreadystatechange = function () {
- if (xmlHttp.readyState == 4) {
- if (xmlHttp.status >= 200) {
- var myArr = xmlHttp.responseText;
- //////////console.log("validatenetwork my arr -", myArr);
- } else {
- ////////console.log("error while calling validatenetwork.php");
- clearInterval(intervalidofvalidatenetwork);
- //showErrorState(1);
- setupUILogin(4);
- }
- }
- }
- xmlHttp.open("GET", url, true);
- xmlHttp.send();
- }
- function connect() {
- ////////console.log("Websocket Connected");
- $.fn.login();
- }
- function myNotifications(strMessage) {
- var opt = {
- type: "basic",
- title: "",
- message: strMessage,
- iconUrl: "icons/vianotification.png"
- };
- chrome.notifications.create("", opt, function (id) {
- if (chrome.runtime.lastError) {
- //console.error(chrome.runtime.lastError.message);
- }
- });
- }
- function onWebSocketMessage(evt) {
- var response = "";
- var data = evt.data;
- if ($.fn.isJson(data)) {
- response = JSON.parse(evt.data);
- console.log(response);
- if (response.request == "getRegisterDetailsAndRc") {
- //Gateway Version information
- if (response.version != undefined) {
- myApp.gatewayVersion = response.version;
- myApp.xmppExeReqKey = response.xmppExeReqKey;
- myApp.clientReqKey = response.clientReqKey;
- var dndChatPwdModInfo = response.dndChatPwdMod.split("#");
- myApp.modToggleDnd = dndChatPwdModInfo[0];
- myApp.modToggleChat = dndChatPwdModInfo[1];
- myApp.modPwdReq = dndChatPwdModInfo[2];
- myApp.currentLoginMode = response.moderation;
- //console.log(myApp.loginMode + "==" + response.moderation);
- myApp.roomCode = response.roomCode;
- if (response.isValidLogin == 1) {
- if (response.moderation != 0 || response.moderation == "") {
- if (myApp.loginMode == response.moderation) {
- if (response.roomCode != "" && response.roomCode == 0) {
- //myApp.roomCode = response.roomCode;
- $("#login").html("Login");
- $(".rc").show();
- $("#roomCode").focus();
- myApp.userValidityChk = "yes";
- if (response.moderation == "" || response.moderation == 3) {
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "25px"});
- } else if (response.moderation == 4 || response.moderation == 9) {
- $("#db_name,#db_pass").prop('disabled', true);
- $("#loginBtnTd").css({"padding": "20px"});
- $("#myfooter").css({"padding-top": "5px"});
- }
- } else {
- loginXmppUser.login();
- }
- } else {
- myApp.userValidityChk = "yes";
- if (response.moderation == "" || response.moderation == 3) {
- $("#db_pass").val("");
- if (response.roomCode != "" && response.roomCode == 0) {
- $("#login").html("Login");
- //myApp.roomCode = response.roomCode;
- $(".basic").show();
- $(".rc").show();
- $("#roomCode").focus();
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "25px"});
- } else {
- /*$(".db").hide();
- $(".basic").show();
- $("#login").html("Login");
- $("#loginBtnTd").css({"padding-top": "90px"});
- $("#myfooter").css({"padding-top": "30px"});*/
- loginXmppUser.login();
- //$("#loginBtnTd").css({"padding": "60px 10px 20px 20px"});
- //$("#myfooter").css({"padding-top": "60px"});
- }
- //$(".basic").show();
- $(".db").hide();
- } else {
- if (response.roomCode != "" && response.roomCode == 0) {
- //myApp.roomCode = response.roomCode;
- $(".rc").show();
- $("#roomCode").focus();
- $("#login").html("Login");
- $("#loginBtnTd").css({"padding": "20px"});
- $("#myfooter").css({"padding-top": "5px"});
- } else {
- loginXmppUser.login();
- }
- }
- }
- } else {
- myApp.userValidityChk = "yes";
- if (response.moderation == "0") {
- $("#username").val("");
- $("#db_name").focus();
- if ($("#db_pass").val() != "") {
- $("#db_name,#db_pass").prop('disabled', false);
- $("#db_pass").addClass("text_error");
- $("#db_pass").focus();
- }
- $(".db").show();
- $(".basic").hide();
- $("#login").html("Login");
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "10px"});
- }
- }
- } else if (response.isValidLogin == 0) {
- if (response.moderation == "0") {
- $("#username").val("");
- $("#db_name").focus();
- //if ($(".db").is(":visible") == true) {
- if ($("#db_pass").val() != "") {
- $("#db_name,#db_pass").prop('disabled', false);
- $("#db_pass").addClass("text_error");
- $("#db_pass").focus();
- }
- //}
- $(".db").show();
- $(".basic").hide();
- $("#loginBtnTd").css({"padding-top": "70px"});
- $("#myfooter").css({"padding-top": "10px"});
- } else if (response.moderation == "" || response.moderation == 3) {
- //if (response.moderation == 3) {
- myApp.userValidityChk = "yes";
- if (response.roomCode == 0 && response.roomCode != "") {
- $(".rc").show();
- $("#roomCode").focus();
- }
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "10px"});
- /*} else {
- myApp.userValidityChk = "yes";
- if (response.roomCode == 0) {
- $(".rc").show();
- $("#roomCode").focus();
- }
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "10px"});
- }*/
- $("#db_name,#db_pass").val("");
- $(".basic").show();
- $(".db").hide();
- } else if (response.moderation == 4 || response.moderation == 9) {
- myApp.userValidityChk = "yes";
- if (response.roomCode == 0) {
- $(".rc").show();
- $("#roomCode").focus();
- }
- $(".basic").hide();
- $(".db").show();
- $("#db_name,#db_pass").prop('disabled', true);
- $("#loginBtnTd").css({"padding-top": "30px"});
- $("#myfooter").css({"padding-top": "5px"});
- }
- $("#login").html("Login");
- } else if (response.isValidLogin == -2) {
- myApp.customNotification("Nick name already in use please try with another nick name.");
- $("#login").html("Login");
- $("#db_name,#db_pass,#username").prop('disabled', false);
- }
- } else {
- //this is the code for the version 2.1 or 0
- if (response.isValidLogin == 1 && (response.moderation != 0 || response.moderation == "")) {
- myApp.xmppExeReqKey = response.xmppExeReqKey;
- myApp.clientReqKey = response.clientReqKey;
- var dndChatPwdModInfo = response.dndChatPwdMod.split("#");
- myApp.modToggleDnd = dndChatPwdModInfo[0];
- myApp.modToggleChat = dndChatPwdModInfo[1];
- myApp.modPwdReq = dndChatPwdModInfo[2];
- myApp.currentLoginMode = response.moderation;
- myApp.roomCode = response.roomCode;
- //console.log(myApp.loginMode + "==" + response.moderation);
- if (myApp.loginMode == response.moderation) {
- if (response.roomCode != 0) {
- myApp.roomCode = response.roomCode;
- $("#login").html("Login");
- $(".rc").show();
- $("#roomCode").focus();
- myApp.userValidityChk = "yes";
- if (response.moderation == "" || response.moderation == 3) {
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "25px"});
- } else if (response.moderation == 4 || response.moderation == 9) {
- $("#loginBtnTd").css({"padding": "20px"});
- $("#myfooter").css({"padding-top": "5px"});
- }
- } else if (response.roomCode == 0) {
- loginXmppUser.login();
- }
- } else {
- myApp.userValidityChk = "yes";
- if (response.moderation == "" || response.moderation == 3) {
- $("#db_pass").val("");
- if (response.roomCode != 0) {
- $("#login").html("Login");
- myApp.roomCode = response.roomCode;
- $(".basic").show();
- $(".rc").show();
- $("#roomCode").focus();
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "25px"});
- } else {
- /*$(".db").hide();
- $(".basic").show();
- $("#login").html("Login");
- $("#loginBtnTd").css({"padding-top": "90px"});
- $("#myfooter").css({"padding-top": "30px"});*/
- loginXmppUser.login();
- //$("#loginBtnTd").css({"padding": "60px 10px 20px 20px"});
- //$("#myfooter").css({"padding-top": "60px"});
- }
- //$(".basic").show();
- $(".db").hide();
- } else {
- if (response.roomCode != 0) {
- myApp.roomCode = response.roomCode;
- $(".rc").show();
- $("#roomCode").focus();
- $("#login").html("Login");
- $("#loginBtnTd").css({"padding": "20px"});
- $("#myfooter").css({"padding-top": "5px"});
- } else {
- loginXmppUser.login();
- }
- }
- }
- } else if (response.moderation == 0 && response.isValidLogin == 1) {
- //console.log("Come");
- $("#db_pass").prop('disabled', false);
- $("#username").val("");
- $(".db").show();
- $(".basic").hide();
- $("#db_pass").addClass("text_error");
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "10px"});
- $("#login").html("Login");
- } else if (response.isValidLogin == 0) {
- $("#db_pass").val("");
- $(".basic").show();
- $(".db").hide();
- $("#login").html("Login");
- $("#loginBtnTd").css({"padding-top": "100px"});
- $("#myfooter").css({"padding-top": "20px"});
- } else if (response.isValidLogin == -2) {
- myApp.customNotification("Nick name already in use please try with another nick name.");
- $("#login").html("Login");
- }
- }
- } else if (response.request == "cancelDownload") {
- myApp.dataChannelObj.cancelDownloadViewFiles();
- } else if (response.request == "setFeatureAllow") {
- var gatewayFeature = response.message;
- myApp.featureListGateway = gatewayFeature.split("#");
- if (myApp.featureListGateway.indexOf("B2") < 0) {
- myApp.featureListChat = "no";
- $("#allparticipants").hide();
- $(".chat_start,.chat_selected").hide();
- $("#file_share_heading").css("margin-left", "60px");
- $("label[for =file-upload]").css("padding-left", "50px");
- $("#admin_fileshare").css("padding-left", "50px");
- }
- if (myApp.featureListGateway.indexOf("B3") < 0) {
- $("#cloud_transfer").hide();
- }
- if (myApp.featureListGateway.indexOf("B5") < 0) {
- $("#collaboration").hide();
- }
- if (myApp.featureListGateway.indexOf("B6") < 0) {
- myApp.FeatureListFileTransfer = "no";
- $("#file_share_heading,#file_transfer_td,.one_share").hide();
- }
- if (myApp.featureListGateway.indexOf("B20") < 0) {
- $("#thirdParyApps").hide();
- }
- if (myApp.featureListGateway.indexOf("B25") < 0) {
- $("#epoll").hide();
- }
- } else if (response.request == "setViewFIles") {
- $("#view_file,.file_action_button,.view_file_bar").show();
- $("#features_disp,.file_transfer_options").hide();
- parser = new DOMParser();
- xmlNodes = parser.parseFromString(response.data, "text/xml");
- var files = xmlNodes.getElementsByTagName("file");
- $("div.view_files").remove();
- $("div.view_files_hr").remove();
- for (i = 0; i < files.length; i++) {
- var nodes = files[i].childNodes;
- var fileName = nodes[0].innerHTML;
- if (fileName.length > 30) {
- fileName = fileName.slice(0, 30) + "..";
- }
- var len = nodes[2].innerHTML;
- //console.log(len);
- var fileSize = " ";
- if (len > 0) {
- var kb = len / 1024;
- fileSize = kb.toFixed(2) + "KB";
- if (kb >= 1) {
- var mb = kb / 1024;
- fileSize = mb.toFixed(2) + "MB";
- if (mb >= 1) {
- var gb = mb / 1024;
- if (gb >= 1) {
- fileSize = gb.toFixed(2) + "GB";
- }
- }
- }
- }
- var htmlData = '<div class="view_files">';
- htmlData += '<div style="float: left; width: 38%; padding-left: 10px;">' + fileName + '</div>'
- htmlData += '<div style="float: left; width: 15%; text-align: center;">' + nodes[1].innerHTML + '</div>';
- htmlData += '<div style="float: left; width: 15%; text-align: center;">' + fileSize + '</div>';
- htmlData += '<div style="float: left; width: 15%; text-align: center;">\n\
- <img data-filename = "' + nodes[0].innerHTML + '" data-filepath ="' + nodes[4].innerHTML + '" class="view_file_open" src="icons/fopen_17x11.png" style="vertical-align:middle">\n\
- </div>';
- //htmlData += '<div style="float: left; width: 15%; text-align: center;"><input data-filename = "' + nodes[0].innerHTML + '" data-filepath ="' + nodes[4].innerHTML + '" type="checkbox" class="file_check"></div>';
- if (nodes[1].innerHTML != "Folder") {
- htmlData += '<div style="float: left; width: 15%; text-align: center;">\n\
- <img data-filesize="' + nodes[2].innerHTML + '" data-filename = "' + nodes[0].innerHTML + '" data-filepath ="' + nodes[4].innerHTML + '" class="view_file_download" src="icons/download.png" style="vertical-align:middle">\n\
- </div>';
- }
- htmlData += '</div>';
- htmlData += '<div class="view_files_hr" style="padding-left: 10px; padding-right: 10px;padding-top: 20px;padding-bottom: 5px;"><hr></div>';
- //console.log(nodes[1].innerHTML);
- $("#view_files").append(htmlData);
- }
- if (myApp.osType == 1 || myApp.osType == 3) {
- $("#open_cloud_tab,.view_file_open").hide();
- }
- $("#view_file_info,#view_files").show();
- } else if (response.request == "fileTransferFormat") {
- if (response.message.charAt(response.message.length - 1) == '#') {
- var format = response.message.substr(0, response.message.length - 1);
- myApp.fileTransferFormatArray = format.split("#");
- } else {
- myApp.fileTransferFormatArray = response.message.split("#");
- }
- if (myApp.fileTransferFormatArray[0] != "All") {
- myApp.fileTransferFormatStr = myApp.fileTransferFormatArray.join(",.");
- myApp.fileTransferFormatStr = "." + myApp.fileTransferFormatStr;
- setTimeout(function () {
- $("#file-upload").attr("accept", myApp.fileTransferFormatStr);
- $("#file_open_via").attr("accept", myApp.fileTransferFormatStr);
- }, 1000);
- }
- } else if (response.request == "fileTransfer") {
- if ($("#file_download_info").is(":visible") == true) {
- $('.file_receive_prompt').css({"height": "372px"});
- }
- var isDuplicateFile = "No";
- if (myApp.dataChannel.readyState != "open") {
- myApp.startDataChannel();
- }
- var totalFileSize = response.fileSize;
- var ftTotLength = 0
- if (totalFileSize > 1024000) {
- ftTotLength = (totalFileSize / (1024 * 1024)).toFixed(2) + " MB";
- } else {
- ftTotLength = (totalFileSize / 1024).toFixed(2) + " KB";
- }
- if (myApp.trasferFileNames.indexOf(response.fileName) == -1) {
- fileRecTimeStamp = myApp.getCurrentTimeStamp();
- var senderName = response.from.split("@")[0];
- if (!(response.fileName in myApp.fileTransferReceived)) {
- myApp.fileTransferReceived[response.fileName] = fileRecTimeStamp;
- } else {
- // this varibale help to know whether user want to download the orignal file or the one that come later with same name treat as duplicate
- isDuplicateFile = "Yes";
- // in case if any user send the same file from one to one and share to all user
- myApp.fileTransferReceived[response.fileName + '|duplicate'] = fileRecTimeStamp;
- }
- //console.log(myApp.fileTransferReceived);
- window.resizeTo(585, 650);
- myApp.trasferFileNames[response.fileName] = response.fileSize;
- var htmlData = '<div style="padding-left: 10px;">';
- htmlData += '<div style="padding-top: 10px; padding-bottom: 15px;">From: ' + senderName + '</div>';
- htmlData += '<div style="padding-top: 10px; padding-bottom: 10px;" class="transfer_file_class">File Name: ' + response.fileName + '</div> ';
- htmlData += '<div style="color: #000000;" class="file_rec_basic">\n\
- <div style="color: #000000;" class="file_rec_color" id="rec_file_' + fileRecTimeStamp + '">0%</div></div>';
- htmlData += '<div class="sc_operation" id="save_cancel_' + fileRecTimeStamp + '">';
- htmlData += ' <input type="button" data-duplicate="' + isDuplicateFile + '" data-sendby="' + senderName + '" data-sendtype = "' + response.sendType + '" style="width:75px; height:25px; vertical-align: bottom;" class="logout save_transfer" value="save"/>';
- htmlData += ' <input type="button" data-sendtype = "' + response.sendType + '" style="width:75px; height:25px; vertical-align: bottom;" class="logout cancel_transfer" value="cancel"/>';
- htmlData += '</div>';
- htmlData += '<div class="open_operation" id="open_' + fileRecTimeStamp + '" style="display: none;">';
- htmlData += ' <input data-filename="' + response.fileName + '" type="button" style="width:75px; height:30px; vertical-align: bottom;" class="logout open_transfer" value="open"/>';
- htmlData += '</div>';
- htmlData += '<div style="padding-top: 10px; padding-bottom: 10px;" class="file_in_length">' + ftTotLength + ' <span style="padding-left:220px;" class="rec_file_length" id="rec_len_' + fileRecTimeStamp + '" ></span></div>';
- htmlData += '<div style="padding-right: 10px;"><hr></div>';
- htmlData += '</div>';
- $("#chat_user,#chat_window").hide()
- $("#features_disp,#coordinator_div,#mirror_users,#third_party_apps,#detail_grid,#choose_file,#touch_pad,.file_transfer_options,#view_file_info").hide();
- $(".file_receive_prompt").append(htmlData);
- $(".file_receive_prompt").show();
- }
- } else if (response.request == "kickOff") {
- disconnect();
- setTimeout(function () {
- window.resizeTo(440, 480);
- window.location.reload();
- }, 1000);
- } else if (response.request == "sessionReset") {
- disconnect();
- setTimeout(function () {
- myApp.customNotification("The session has ended or been reset.");
- window.resizeTo(440, 480);
- window.location.reload();
- }, 1000);
- } else if (response.request == "presentStopTwo") {
- if (myApp.presentOnMonitorId == 2) {
- if (isPresentor == true) {
- stopPresenting();
- }
- }
- } else if (response.request == "GDARequestState") {
- myApp.customNotification("You are already in requesting state.Please wait for your turn.");
- } else if (response.request == "pcConfig") {
- ////console.log(response.pcConfig["iceServers"]);
- myApp.pcConfig = response.pcConfig["iceServers"];
- } else if (response.request == "xmppClosed") {
- $.fn.reboot();
- } else if (response.request == "unAuthorisedUser") {
- myNotifications("Authentication failed. VIA unit may not be registered with authentication server or chrome service may not be enabled.");
- return;
- } else if (response.request == "roomNotExist") {
- myNotifications("Room not available to connect. VIA Gateway is not able to access the server, Please Contact Adminisrator.");
- //document.getElementById("strMsg-label").innerHTML="Room not available to connect.";
- roomnotavilable();
- } else if (response.request == "presence") {
- var fromName = response.from.split("@");
- if (response.presence == "online" || response.presence == "offline") {
- if (response.presence == "online") {
- if ($("#" + fromName[0]).length == 0 && $("." + fromName[0] + "_class").length == 0) {
- if (response.from != response.to) {
- $.fn.setPresence({"presence": response.presence, "from": response.from, "isPresenting": response.isPresenting, "isWaiting": response.isWaiting});
- //$.fn.setPresence(response.presence + "~" + response.from + "~" + response.isPresenting + "~" + response.isWaiting);
- }
- }
- //if (myApp.currentLoginMode == 4) {
- if (response.isWaiting == "No") {
- if ($("." + fromName[0] + "_allow").length > 0) {
- $("." + fromName[0] + "_allow").remove();
- if ($(".allow_present_screen .allow").length == 0) {
- $(".allow_present_screen").hide();
- }
- }
- }
- if (myApp.currentLoginMode != "") {
- if (response.presenceStatusMod == "Yes") {
- if (fromName[0] != "viaadmin") {
- if (myApp.currentLoginMode == 4) {
- if (myApp.moderatorNames.indexOf(response.from) == -1) {
- myApp.moderatorNames.push(response.from);
- }
- console.log(myApp.moderatorNames);
- } else {
- if (myApp.currentLoginMode == 3) {
- myApp.moderatorName = response.from;
- if (myApp.modToggleDnd == 1) {
- if (myApp.moderatorName == myApp.jid) {
- if (response.isPresenting == "Yes" && $("#btnfullscreen").is(":visible") == false) {
- $("#dnd_toggle").show();
- } else {
- $("#dnd_toggle").hide();
- }
- //$.fn.markPresenceForDndGateway("Yes");
- }
- }
- }
- }
- if (response.from != response.to) {
- // when any user become moderator
- $(".mod").hide();
- $("#moderator").html(fromName[0] + " is Moderator").prop('disabled', true);
- } else if (response.from == response.to) {
- if (myApp.osType != 3) {
- if (myApp.modToggleChat == 1) {
- $("#mod_chat_disp").show();
- //$("#moderation_chat").prop("checked", true);
- }
- }
- myApp.socketId.send(JSON.stringify({
- "request": "getMirroringList",
- "jid": myApp.jid,
- "type": "client",
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("#moderator").html("Leave Moderation");
- }
- }
- } else {
- // console.log(response.from + "-" + response.to + "-" + myApp.moderatorName);
- $("#mirror_band").hide();
- $("#mirror_users").hide();
- $("#mirror_listing").empty();
- myApp.isMirrorUsers = "No";
- if (response.from != response.to) {
- if (myApp.moderatorName == response.from) {
- $("#moderator").html("Become Moderator").prop('disabled', false);
- }
- }
- }
- }
- /*if (response.isPresenting == "Yes" && $('#btnfullscreen').is(':hidden') == true) {
- if (myApp.modToggleDnd == 1) {
- if (myApp.currentLoginMode == 3) {
- if (myApp.moderatorName == myApp.jid && response.from == myApp.jid) {
- $("#dnd_toggle").show();
- //$.fn.markPresenceForDndGateway();
- }
- } else if (myApp.currentLoginMode == "") {
- if (response.from == myApp.jid) {
- $("#dnd_toggle").show();
- //$.fn.markPresenceForDndGateway();
- }
- } else if (myApp.currentLoginMode == 4) {
- if (myApp.moderatorNames.indexOf(myApp.jid) != -1 && response.from == myApp.jid) {
- $("#dnd_toggle").show();
- //$.fn.markPresenceForDndGateway();
- }
- }
- }
- }*/
- if (response.isWaiting == "No") {
- if (isPresentor == false) {
- $("#presentmeimg").attr('src', 'icons/PRESENT-OFF.png');
- }
- }
- var displayUserId = fromName[0] + "_display";
- if (response.isWaiting == "Yes" && response.isPresenting == "No") {
- $("#" + displayUserId + ".display").children("img").attr('src', 'icons/display_waiting.png');
- } else if (response.isPresenting == "Yes" && response.isWaiting == "No") {
- $("#" + displayUserId + ".display").children("img").attr('src', 'icons/present_active.png');
- } else {
- $("#" + displayUserId + ".display").children("img").attr('src', 'icons/display.png');
- }
- if (response.from == response.to) {
- myApp.userIsPresenting = response.isPresenting;
- }
- } else if (response.presence == "offline") {
- if (response.from != response.to) {
- myApp.moderatorNames.splice(myApp.moderatorNames.indexOf(response.from), 1);
- $.fn.setPresence({"presence": response.presence, "from": response.from});
- }
- }
- }
- } else if (response.request == "duplicate") {
- myApp.customNotification("Nick name already in use please try with another nick name.");
- $("#login").html("Login");
- } else if (response.request == "inValidRc") {
- $("#login").html("Login");
- $("#roomCode").addClass("text_error");
- } else if (response.request == "loginError") {
- if (response.errorType == "Database Mode") {
- $(".db").show();
- $("#username").val("");
- $(".basic").hide();
- } else if (response.errorType == "Basic Mode") {
- $(".basic").show();
- $(".db").hide();
- }
- } else if (response.request == "loggedin") {
- if (response.valid == "success") {
- if (myApp.gatewayVersion == 0) {
- $(".participane_name").width("375px");
- $("#collaboration,#thirdParyApps,#file_transfer_td,#cloud_transfer,.feature_seperator,#file_share_heading").hide();
- }
- myApp.osType = response.osType;
- if (myApp.osType == 3) {
- $(".all_features,.all_exam,.chat_selected").hide();
- $(".all_participants").width("50%");
- $(".participane_name").width("400px");
- }
- if (myApp.osType == 1) {
- $(".open_on_via_td").hide();
- $("#thirdParyApps").hide();
- }
- chrome.runtime.sendMessage({
- "jid": myApp.jid,
- "xmppExeReqKey": myApp.xmppExeReqKey,
- "clientReqKey": myApp.clientReqKey,
- "socketId": myApp.socketId,
- "serverUrl": myApp.serverUrl,
- "serverPort": myApp.serverPort
- });
- if (response.moderation != "") {
- adddata();
- updateuserlastlogin(myApp.domain, '1', myApp.currentLoginMode);
- if (myApp.currentLoginMode == 3) {
- $("#moderator").show();
- } else {
- $("#moderator").hide();
- }
- }
- $.fn.screenAfterLogin();
- }
- } else if (response.request == "basicModeratorPwd") {
- if (response.data == "success") {
- /*myApp.socketId.send(JSON.stringify({
- "request": "getMirroringList",
- "jid": myApp.jid,
- "type": "client",
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));*/
- if (myApp.osType != 3) {
- if (myApp.modToggleChat == 1) {
- $("#mod_chat_disp").show();
- }
- }
- if (myApp.modToggleDnd == 1) {
- if (myApp.userIsPresenting == "Yes") {
- $("#dnd_toggle").show();
- }
- }
- $.fn.markPresenceForDndGateway("Yes");
- $("#moderator").html("Leave Moderation");
- $("#mod_pass").val("");
- $(".mod,#mod_error").hide();
- } else if (response.data == "fail") {
- $("#mod_error").show();
- }
- } else if (response.request == "cordinates") {
- //console.log("cordinates" + response.xAxis + " " + response.yAxis);
- myApp.serverXaxis = response.xAxis;
- myApp.serverYaxis = response.yAxis;
- } else if (response.request == "thirdPartyFromGateway") {
- var messageLen = response.data.length;
- if (response.totalBytes == messageLen) {
- //$("#third_party_apps").hide();
- myApp.setThirdPartyApps(response.data);
- }
- } else if (response.request == "chat") {
- var fromUser = response.from.split("@");
- var onlyUser = myApp.jid.split("@");
- if (response.message == "Exam Coordinator" && fromUser[0] == "viaadmin") {
- $("#coordinator_div").show();
- } else if (response.message == "ChatEnabled" & & response.subject == "Command" && fromUser[0] == "viaadmin") {
- myApp.isChatDisabled = false;
- $(".chat_start,#allparticipants").removeClass("inactiveLink");
- $("#moderation_chat").prop('disabled', false).prop('checked', true);
- } else if (response.message == "ChatDisabled" && response.subject == "Command" && fromUser[0] == "viaadmin") {
- myApp.isChatDisabled = true;
- $("#moderation_chat").prop('checked', false);
- $(".chat_start,#allparticipants").addClass("inactiveLink");
- } else if (response.message == "ExamStarted" && fromUser[0] == "viaadmin") {
- $(".all_features").hide();
- $("#exam_td,.all_exam").show();
- $("#detail_grid,.always-at-bottom").hide();
- $("#user_listing,.features,#presentmeimg,#moderator,#moderation_chat").addClass("inactiveLink");
- window.resizeTo(585, 145);
- $(".always-at-bottom,#myfooter,#touch_pad,#chat_user,#chat_window,.allow_present_screen,#users,#detail_grid,#features_disp,#third_party_apps,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- if (isPresentor == true) {
- stopPresenting();
- }
- } else if (response.message == "ExamStoped" && fromUser[0] == "viaadmin") {
- $("#coordinator_div").hide();
- $(".all_features,always-at-bottom").show();
- $("#exam_td,.all_exam").hide();
- $("#user_listing,.features,#presentmeimg,#moderator,#moderation_chat").removeClass("inactiveLink");
- $(".always-at-bottom,#myfooter,#touch_pad,#chat_user,#chat_window,.allow_present_screen,#users,#detail_grid,#features_disp,#third_party_apps,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- window.resizeTo(585, 130);
- } else if (response.message == "SetStaff" && fromUser[0] == "viaadmin") {
- myApp.socketId.send(JSON.stringify({
- "request": "basicModeratorIn", "isPresenting": isPresenting, "isPwdReq": 0, "password": mod_pass, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey, "clientReqKey": myApp.clientReqKey
- }));
- $.fn.markPresenceForDndGateway("Yes");
- } else if (response.message == "UnSetStaff" && fromUser[0] == "viaadmin") {
- $("#moderator").html("Become Moderator").prop('disabled', false);
- if ($("#mirror_users").is(":visible") == true) {
- $("#mirror_users").hide();
- $("#detail_grid,#users").show();
- }
- myApp.moderatorName = "";
- $.fn.sendLeaveModerationReq();
- $("#mirror_band").hide();
- } else if (response.message == "SetDNDAdmin" && fromUser[0] == "viaadmin") {
- $.fn.enableDnd();
- } else if (response.message == "UnSetDNDAdmin" && fromUser[0] == "viaadmin") {
- $.fn.disableDnd();
- } else if ((response.subject == "MirroringUpdated" || response.subject == "SetMirroringList") && fromUser[0] == "viaadmin") {
- $("#mirror_listing").empty();
- if (response.message == "UNAVAILABLE") {
- myApp.isMirrorUsers = "No";
- $("#mirror_band").hide();
- $("#mirror_users").hide();
- $("#mirror_listing").empty();
- if ($("#coordinator_div").is(":visible") == true) {
- window.resizeTo(585, 145);
- } else {
- window.resizeTo(585, 130);
- }
- $("#users,#detail_grid,.always-at-bottom").hide();
- } else {
- var mirr_users_arr = response.message.split("#");
- if (mirr_users_arr.length > 0) {
- myApp.isMirrorUsers = "Yes";
- }
- mirr_users_arr.forEach(function (element) {
- if (element != "") {
- var htmlData = '<div style="padding-top: 5px;width: 100%">';
- htmlData += '<div style="float: left; width: 16%; margin-left: 20px"><img src="icons/MediumSmiley.png" style="vertical-align:middle"></div>';
- htmlData += '<div style="float: left; width: 38%; padding-top: 8px;">' + element.split("_")[1] + '</div>'
- htmlData += '<div class="' + element + ' mirror_stop" style="float: left; width: 40%; text-align: center; padding-top: 5px;"><img src="icons/display_active.png" style="vertical-align:middle"></div>';
- if (mirr_users_arr.length > 1 && mirr_users_arr[2] != undefined) {
- htmlData += '<div style="width: 96%; float: left; padding-left: 20px;"><hr></hr></div>';
- }
- htmlData += '</div>';
- $("#mirror_listing").append(htmlData);
- }
- });
- if ($("#mirror_users").is(":visible") == false) {
- if ($("#touch_pad").is(":visible") == false) {
- $("#mirror_band").show();
- window.resizeTo(585, 650);
- }
- //$("#mirror_band").show();
- }
- }
- } else if (response.message == "PresentRequest" && fromUser[0] == "viaadmin") {
- var classNameAllow = fromUser[0] + '_present';
- if ($("." + classNameAllow).length == 0) {
- var htmlData = '<div class="' + classNameAllow + '" style="border: 1px solid; background-color: #FFFFFF; width: 283px; height: 185px; margin-right: auto; margin-left: auto;">';
- htmlData += '<table style="width:100%;">';
- htmlData += '<tr>';
- htmlData += '<td style="background-color: #FFC001; height: 30px;"></td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style=" font-size: 13px; padding-left:5px;padding-top:5px; color:#000000">You have been selected to present to the main dispaly.</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="padding-top:65px;">';
- htmlData += '<button class="logout" id="accept_present" style="width: 35%; height: 32px; font-size: 12px; margin-left: 5px;">Accept</button>';
- htmlData += '<button class="logout" id="reject_present" style="width: 35%; height: 32px; font-size: 12px; margin-left:10px;">Reject</button>';
- htmlData += '<img src="icons/logo_noname.png" style="outline:none; vertical-align:middle; padding-left:10px;" border=0>';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '</table>';
- htmlData += '</div>';
- $(".allow_present_screen").append(htmlData);
- $(".allow_present_screen").show();
- var d = new Date();
- var startTime = d.getTime();
- displayUserWaiting.push(classNameAllow + "~" + startTime);
- }
- } else if ((response.message == "PresentRequestOne" || response.message == "PresentRequestShare") && fromUser[0] == "viaadmin") {
- //PresentRejected comes when user rejected the moderator present request.
- var counter = 1;
- var timer = setInterval(function () {
- if (counter == 15 || $(".moderator_share_req").is(":visible") == false) {
- $(".moderator_share_req").hide();
- clearInterval(timer);
- }
- counter++;
- }, 1000)
- $(".moderator_share_req").show();
- $("#users,#detail_grid,.always-at-bottom").show();
- window.resizeTo(585, 650);
- $(document).on("click", ".moderator_share_reply", function () {
- var message = $(this).val();
- $(".moderator_share_req").hide();
- myApp.socketId.send(JSON.stringify({
- "request": "modAskShareReply", "totalDisp": myApp.totalDisplayRunning,
- "actionType": response.message, "action": message, "jid": myApp.jid,
- "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey, "clientReqKey": myApp.clientReqKey
- }));
- });
- } else if (response.subject == "GDARequestShareTwo" && fromUser[0] == "viaadmin") {
- window.resizeTo(585, 650);
- $("#touch_pad,#chat_user,#third_party_apps,#features_disp,.file_transfer_options,.file_receive_prompt,#chat_window").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- var requestFrom = response.message.split("@");
- var classNameAllow = requestFrom[0] + '_allow_dual';
- if ($("." + classNameAllow).length == 0) {
- var htmlData = '<div class="' + classNameAllow + ' allow_dual" style="border: 1px solid; background-color: #FFFFFF;">';
- htmlData += '<table style="width:100%; padding-top: 10px; padding-left:5px;" cellspacing="5" cellpadding="5">';
- htmlData += '<tr> ';
- htmlData += '<td align="center">'
- htmlData += '<img src="icons/logo_noname.png" style="outline:none;" border=0>';
- htmlData += '<img class="allow_dual_share_cross" src="icons/cross.png" border=0 style="outline:none;" align="right">';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="border: 1px solid blue; height: 50px; vertical-align: top;"><span>[' + requestFrom[0] + ']</span> has requested to present.</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="height: 50px; vertical-align: top;">';
- htmlData += '<button data-allowto="' + response.message + '" class="logout allow_dual_first" style="margin-left: 7px; width: 47%; height: 32px; font-size: 11px;">Allow full screen on first display</button>';
- htmlData += '<button data-allowto="' + response.message + '" class="logout allow_dual_second" style="margin-left: 7px; width: 47%; height: 32px; font-size: 11px;">Allow full screen on second display</button>';
- htmlData += '<button data-allowto="' + response.message + '" class="logout allow_dual_auto_position" style="margin-left: 7px; width: 47%;height: 32px; font-size: 11px;">Allow (Auto Position)</button>';
- htmlData += '<button data-denyto="' + response.message + '" class="logout deny_access_dual" style="margin-left: 7px; width: 47%; height: 32px; font-size: 11px;">Deny</button>';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '</table>';
- htmlData += '</div>';
- $(".allow_present_screen").append(htmlData);
- $(".allow_present_screen").show();
- }
- } else if ((response.subject == "GDARequestShare" || response.subject == "GDARequestFull") && fromUser[0] == "viaadmin") {
- window.resizeTo(585, 650);
- $("#touch_pad,#chat_user,#third_party_apps,#features_disp,.file_transfer_options,.file_receive_prompt,#chat_window").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- if (response.message.indexOf("IOSMIRRORNAME") < 5) {
- var requestFrom = response.message.split("@");
- var classNameAllow = requestFrom[0] + '_allow';
- if ($("." + classNameAllow).length == 0) {
- var htmlData = '<div class="' + classNameAllow + ' allow" style="border: 1px solid; background-color: #FFFFFF;">';
- htmlData += '<table style="width:100%; padding-top: 10px; padding-left:5px;" cellspacing="5" cellpadding="5">';
- htmlData += '<tr > ';
- htmlData += '<td align="center">'
- htmlData += '<img src="icons/logo_noname.png" style="outline:none;" border=0>';
- htmlData += '<img class="allow_share_cross" src="icons/cross.png" border=0 style="outline:none;" align="right">';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="border: 1px solid blue; height: 50px; vertical-align: top;"><span>[' + requestFrom[0] + ']</span> has requested to present.</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="height: 50px; vertical-align: top;">';
- htmlData += '<button class="logout allow_full_screen" style="width: 47%; height: 32px; font-size: 11px;">Allow full screen</button> ';
- if (response.subject == "GDARequestShare") {
- htmlData += '<button class="logout allow_auto_position" style="width: 47%;height: 32px; font-size: 11px;">Allow (Auto Position)</button>';
- }
- htmlData += '<button id="' + requestFrom[0] + '_deny" class="logout deny_access" style="width: 47%; height: 32px; font-size: 11px;">Deny</button>';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '</table>';
- htmlData += '</div>';
- $(".allow_present_screen").append(htmlData);
- $(".allow_present_screen").show();
- var d = new Date();
- var startTime = d.getTime();
- displayUserWaiting.push(classNameAllow + "~" + startTime);
- }
- } else if (response.message.indexOf("IOSMIRRORNAME") > 5) {
- // $("#touch_pad,#chat_user,#third_party_apps,#features_disp,.file_transfer_options,.file_receive_prompt,#chat_window").hide();
- var mirrorRequestFrom = response.message.split("@");
- mirrorRequestIpAdd = mirrorRequestFrom[1].split("_")[0];
- if (!(mirrorRequestIpAdd in myApp.mirrorUsers)) {
- myApp.mirrorUsers[mirrorRequestIpAdd] = {"onlyName": mirrorRequestFrom[0],
- "fullName": response.message,
- "time": myApp.getCurrentTimeStamp()
- };
- var allowMirrTimerClass = myApp.mirrorUsers[mirrorRequestIpAdd].time + "_timer";
- showMirroringTimer(30, mirrorRequestIpAdd);
- var htmlData = '<div class="' + myApp.mirrorUsers[mirrorRequestIpAdd].time + ' allow" style="border: 1px solid; background-color: #FFFFFF;">';
- htmlData += '<table style="width:100%; padding-top: 0px; padding-left:5px;" cellspacing="5" cellpadding="5">';
- htmlData += '<tr> ';
- htmlData += '<td colspan="2">'
- htmlData += '<img src="icons/logo_noname.png" style="outline:none;" border=0>';
- htmlData += '<img class="allow_share_cross" src="icons/cross.png" border=0 style="outline:none;" align="right">';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="height: 40px; vertical-align: top;"><span>[' + mirrorRequestFrom[0] + ']</span> has requested to present.</td>';
- htmlData += '<td align="right" style="vertical-align: top;"><span class="' + allowMirrTimerClass + '"> </span></td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td colspan="2" style="height: 50px; vertical-align: top;">';
- htmlData += '<button class="logout mirror_full_screen" data-from ="' + mirrorRequestIpAdd + '" style="width: 47%; height: 32px; font-size: 11px;">Allow full screen</button> ';
- if (response.subject == "GDARequestShare") {
- htmlData += '<button class="logout mirror_auto_position" data-from ="' + mirrorRequestIpAdd + '"style="width: 47%;height: 32px; font-size: 11px;">Allow (Auto Position)</button>';
- }
- htmlData += '<button class="logout deny_mirror" data-from ="' + mirrorRequestIpAdd + '" style="width: 47%; height: 32px; font-size: 11px;">Deny</button>';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '</table>';
- htmlData += '</div>';
- $(".allow_present_screen").append(htmlData);
- $(".allow_present_screen").show();
- }
- }
- } else if (response.subject == "GDAGrantShare" && fromUser[0] == "viaadmin") {
- var requestFrom = response.message.split("@");
- //myApp.presentRequestFrom = response.message;
- //////console.log(myApp.presentRequestFrom);
- $("#users,#detail_grid,.always-at-bottom").show();
- window.resizeTo(585, 650);
- var classNameAllow = requestFrom[0] + '_allow';
- if ($("." + classNameAllow).length == 0) {
- var htmlData = '<div class="' + classNameAllow + ' allow" style="border: 1px solid; background-color: #FFFFFF;">';
- htmlData += '<table style="width:100%; padding-top: 10px; padding-left:5px;" cellspacing="5" cellpadding="5">';
- htmlData += '<tr > ';
- htmlData += '<td align="center">'
- htmlData += '<img src="icons/logo_noname.png" style="outline:none;" border=0>';
- htmlData += '<img class="allow_share_cross" src="icons/cross.png" border=0 style="outline:none;" align="right">';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="border: 1px solid blue; height: 50px; vertical-align: top;"><span>[' + requestFrom[0] + ']</span> has requested to present.</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="height: 50px; vertical-align: top;">';
- htmlData += '<button class="logout allow_full_screen" style="width: 47%; height: 32px; font-size: 11px;">Allow full screen</button> ';
- htmlData += '<button class="logout allow_auto_position" style="width: 47%;height: 32px; font-size: 11px;">Allow (Auto Position)</button>';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '</table>';
- htmlData += '</div>';
- $(".allow_present_screen").append(htmlData);
- $(".allow_present_screen").show();
- }
- } else if (response.subject == "GDAGrantShareTwo" && fromUser[0] == "viaadmin") {
- window.resizeTo(585, 650);
- $("#users,#detail_grid,.always-at-bottom").show();
- var requestFrom = response.message.split("@");
- var classNameAllow = requestFrom[0] + '_allow_dual';
- if ($("." + classNameAllow).length == 0) {
- var htmlData = '<div class="' + classNameAllow + ' allow_dual" style="border: 1px solid; background-color: #FFFFFF;">';
- htmlData += '<table style="width:100%; padding-top: 10px; padding-left:5px;" cellspacing="5" cellpadding="5">';
- htmlData += '<tr > ';
- htmlData += '<td align="center">';
- htmlData += '<img src="icons/logo_noname.png" style="outline:none;" border=0>';
- htmlData += '<img class="allow_dual_share_cross" src="icons/cross.png" border=0 style="outline:none;" align="right">';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="border: 1px solid blue; height: 50px; text-align: center;vertical-align: top;">Selected User: <span>[' + requestFrom[0] + ']</span></td>';
- htmlData += '</tr>';
- htmlData += '<tr>';
- htmlData += '<td style="height: 50px; vertical-align: top;">';
- htmlData += '<button data-allowto="' + response.message + '" class="logout allow_dual_first" style="margin-left: 7px; width: 47%; height: 32px; font-size: 11px;">Allow full screen on first display</button>';
- htmlData += '<button data-allowto="' + response.message + '" class="logout allow_dual_second" style="margin-left: 7px; width: 47%; height: 32px; font-size: 11px;">Allow full screen on second display</button>';
- htmlData += '<button data-allowto="' + response.message + '" class="logout allow_dual_auto_position" style="margin-left: 7px; width: 47%;height: 32px; font-size: 11px;">Allow (Auto Position)</button>';
- htmlData += '</td>';
- htmlData += '</tr>';
- htmlData += '</table>';
- htmlData += '</div>';
- $(".allow_present_screen").append(htmlData);
- $(".allow_present_screen").show();
- }
- } else if (response.message == "PresentStopWaiting") {
- $("#presentmeimg").attr('src', 'icons/PRESENT-OFF.png');
- if (myApp.currentLoginMode == "") {
- var isModSending = "Yes";
- } else if (myApp.currentLoginMode == 3) {
- var isModSending = myApp.moderatorName == myApp.jid ? "Yes" : "No";
- } else if (myApp.currentLoginMode == 4 || myApp.currentLoginMode == 9) {
- var isModSending = myApp.moderatorNames.indexOf(myApp.jid) != -1 ? "Yes" : "No";
- }
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "stopPresentStatus",
- "isModerator": isModSending,
- "jid": myApp.jid,
- "type": "client",
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- return;
- } else if (response.message == "Present" && fromUser[0] == "viaadmin") {
- publishPresenting();
- } else if (response.message == "PresentUnStaff" && fromUser[0] == "viaadmin") {
- publishPresenting();
- } else if ((response.message == "PresentStopOne" || response.message == "PresentStop") && fromUser[0] == "viaadmin") {
- if (response.message == "PresentStopOne") {
- if (myApp.presentOnMonitorId == 1) {
- if (isPresentor == true) {
- stopPresenting();
- }
- }
- } else if (response.message == "PresentStop") {
- if (isPresentor == true) {
- stopPresenting();
- }
- }
- } else if (response.message == "PollStarted") {
- myApp.chromeButtonNotification("A new poll is available. Please participate.")
- $("#epoll").show();
- } else if (response.message == "PollStoped") {
- $("#epoll").hide();
- } else if (response.subject == "DNDEnabled") {
- if (onlyUser[0] != response.message) {
- if (isPresentor == true) {
- stopPresenting();
- }
- $("#coordinator_div").html("[" + response.message + "] has enabled DND.").show();
- $("#user_listing,.features,#presentmeimg").addClass("inactiveLink");
- //$("#presentmeimg").attr('src', 'icons/admin_dnd.png')
- window.resizeTo(585, 145);
- $(".always-at-bottom,#myfooter,#touch_pad,#chat_user,#chat_window,.allow_present_screen,#users,#detail_grid,#features_disp,#third_party_apps,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- }
- } else if (response.subject == "DNDDisabled") {
- $("#user_listing,.features,#presentmeimg,#presentmetext,.chat_start").removeClass("inactiveLink");
- if (onlyUser[0] != response.message) {
- if(myApp.isChatDisabled == true){
- $(".chat_start").addClass("inactiveLink");
- }
- $("#coordinator_div").hide();
- window.resizeTo(585, 130);
- $(".always-at-bottom,#myfooter,#touch_pad,#chat_user,#chat_window,.allow_present_screen,#users,#detail_grid,#features_disp,#third_party_apps,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- } else if (onlyUser[0] == response.message) {
- $("#moderator").removeClass("inactiveLink");
- if ($("#moderation_chat").is(":checked") == false) {
- $(".chat_start").addClass("inactiveLink");
- }
- }
- } else {
- if (response.subject == "Chat") {
- $("#mirror_users,#mirror_band").hide();
- //var sendData = "chat~" + response.to + "~" + response.from + "~" + response.message + "~" + response.subject;
- xmppChat.onMessage({"type": "chat", "to": response.to, "from": response.from, "message": response.message, "subject": response.subject});
- }
- }
- } else if (response.request == "boxPeerId") {
- peerId = response.boxPeerId;
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "showMe",
- "username": myApp.loginUserId,
- "extwidth": screen.width,
- "extheight": screen.height,
- "clientReqKey": myApp.clientReqKey,
- "type": "client"
- }));
- } else if (response.request == "startPresent") {
- $("#presentmeimg").attr("src", "icons/PRESENT-OFF.png");
- myApp.totalDisplayRunning = response.numDispRun;
- myApp.monitorId = response.monitorId;
- //console.log(myApp.totalDisplayRunning, myApp.monitorId);
- if (isAskingPermission == "No") {
- $('.present_type_radio').prop('checked', false);
- $(".prompt_present_screen").show();
- window.resizeTo(585, 650);
- $("#chat_window,#chat_user,#features_disp,#third_party_apps,#touch_pad,#myfooter,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- } else {
- isAskingPermission = "No";
- if (isPresentor && !joinReceived) {
- joinReceived = true;
- window.resizeTo(669, 490);
- if (screenShareSource == "screen") {
- pendingPresentId = chrome.desktopCapture.chooseDesktopMedia(
- ["screen"], onAccessApproved);
- } else if (screenShareSource == "window") {
- pendingPresentId = chrome.desktopCapture.chooseDesktopMedia(
- ["window", "audio"], onAccessApproved);
- } else if (screenShareSource == "tab") {
- pendingPresentId = chrome.desktopCapture.chooseDesktopMedia(
- ["tab", "audio"], onAccessApproved);
- }
- screenShareSource = "";
- }
- }
- //
- } else if (response.request == "iceCandidate" && shareFlowing) {
- //////console.log('Received ICE candidate...');
- var candidate = new RTCIceCandidate({
- sdpMLineIndex: response.candidate.sdpMLineIndex,
- sdpMid: response.candidate.sdpMid,
- candidate: response.candidate.candidate
- });
- ////////console.log(candidate);
- rtcInfo[peerId].addIceCandidate(candidate);
- } else if (response.request == "rccollaborationIceCandidate") {
- myApp.dataChannelObj.addDcIceCandidate(response);
- } else if (response.request == "answer" && shareFlowing) {
- //////console.log("recieved answer");
- var RTCSessionDescription = window.mozRTCSessionDescription || window.webkitRTCSessionDescription || window.RTCSessionDescription;
- rtcInfo[peerId].setRemoteDescription(new RTCSessionDescription(response.peerDescription));
- } else if (response.request == "collabanswer") {
- console.log(response.peerDescription);
- myApp.dataChannelObj.setDcRemoteDescription(response);
- } else if (response.request == "showFullScreenBtn") {
- myApp.presentOnMonitorId = response.monitorId;
- myApp.totalDisplayRunning = response.screenReserved;
- //console.log("shikha");
- if (isPresentor == true) {
- $("#btnfullscreen").show();
- }
- if (myApp.currentLoginMode == "") {
- $("#dnd_toggle").hide();
- $.fn.markPresenceForDndGateway("Yes");
- } else if (myApp.currentLoginMode == 3) {
- if (myApp.modToggleDnd == 1) {
- if (myApp.moderatorName == myApp.jid) {
- $("#dnd_toggle").hide();
- $.fn.markPresenceForDndGateway("Yes");
- } else {
- //$.fn.markPresenceForDndGateway("No");
- }
- }
- } else if (myApp.currentLoginMode == 4) {
- if (myApp.modToggleDnd == 1) {
- if (myApp.moderatorNames.indexOf(myApp.jid) != -1) {
- $("#dnd_toggle").hide();
- $.fn.markPresenceForDndGateway("Yes");
- } else {
- // $.fn.markPresenceForDndGateway("No");
- }
- }
- }
- } else if (response.request == "NOSPACE") {
- //////console.log("Space Not Available");
- myNotifications("Space Not Available to Show your Screen, Please try again after some time.");
- $("#login").html("Login");
- isPresentor = false;
- } else if (response.request == "hideFullScreenBtn") {
- myApp.presentOnMonitorId = response.monitorId;
- myApp.totalDisplayRunning = response.screenReserved;
- if (myApp.currentLoginMode == "") {
- if (myApp.modToggleDnd == 1) {
- $("#dnd_toggle").show();
- if ($("#btnfullscreen").is(":visible")) {
- $.fn.markPresenceForDndGateway("Yes");
- }
- }
- } else if (myApp.currentLoginMode == 3) {
- if (myApp.modToggleDnd == 1) {
- if (myApp.moderatorName == myApp.jid) {
- $("#dnd_toggle").show();
- if ($("#btnfullscreen").is(":visible")) {
- $.fn.markPresenceForDndGateway("Yes");
- }
- } else {
- if ($("#btnfullscreen").is(":visible")) {
- $.fn.markPresenceForDndGateway("No");
- }
- }
- }
- } else if (myApp.currentLoginMode == 4) {
- if (myApp.modToggleDnd == 1) {
- if (myApp.moderatorNames.indexOf(myApp.jid) != -1) {
- $("#dnd_toggle").show();
- if ($("#btnfullscreen").is(":visible")) {
- $.fn.markPresenceForDndGateway("Yes");
- }
- } else {
- if ($("#btnfullscreen").is(":visible")) {
- $.fn.markPresenceForDndGateway("No");
- }
- }
- }
- }
- $("#btnfullscreen").hide();
- } else if (response.request == "stopShareAll") {
- myNotifications("Another user has taken over the full screen or there is no additional space available to present.");
- stopPresenting();
- } else if (response.request == "mediaRunning") {
- myNotifications("Presentation is not allowed while media is playing on the main display. Please wait.");
- stopPresenting();
- } else if (response.request == "byeserver" && shareFlowing) {
- myNotifications("Room not available to present, Please try after some time.");
- roomnotavilable()
- stopPresenting();
- }
- }
- }
- $(document).on("click", ".mirror_stop", function (e) {
- var mirror_details = $(this).attr("class").split("_");
- var mirror_ip = mirror_details[0];
- myApp.socketId.send(JSON.stringify({
- "request": "stopMirroring",
- "mirrorIp": mirror_ip,
- "jid": myApp.jid,
- "type": "client",
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- })
- document.addEventListener("contextmenu", function (e) {
- e.preventDefault();
- });
- $("#open_on_via").on("click", function () {
- $("#file_open_on_via").trigger("click");
- });
- $(document).on("change", "#file_open_on_via", function () {
- console.log(myApp.sendFileOpenOnVia);
- if (myApp.sendFileOpenOnVia == true) {
- var file = this.files[0];
- fileChangeOpenVia(file);
- $(".file_transfer_options,#features_disp").hide();
- $(this).val("");
- } else {
- $("#open_on_via_div").show();
- $("#features_disp,#detail_grid,.file_transfer_options").hide();
- myApp.customNotification("File is uploading. Please wait for it's completion to send another one.");
- }
- })
- $("#mouse_pad").bind("contextmenu", function (e) {
- e.preventDefault();
- });
- var message_text = "";
- var allXmppUsers = [];
- $.fn.extend({
- screenAfterLogin: function () {
- if (myApp.gatewayVersion != 0) {
- /*setTimeout(function () {
- createCollaborationPeerConn();
- }, 1500);
- setTimeout(function () {
- peerConns[myApp.xmppExeReqKey].createOffer(setLocalPCOffer, errorCallback);
- }, 2500);
- setTimeout(function () {
- peerConns[myApp.xmppExeReqKey].createOffer(setLocalPCOffer, errorCallback);
- }, 2500); */
- }
- $("#allAction").show();
- $("#login_details").hide();
- $(myfooter).hide();
- $("#room_name").text(myApp.roomNameText);
- $("#login_user").text($.fn.getUserName(myApp.loginUserId));
- window.resizeTo(585, 130);
- },
- markPresenceForDndGateway: function (mod) {
- var isPresenting = isPresentor == true ? "Yes" : "No";
- myApp.socketId.send(JSON.stringify({
- "request": "markPresence", "isPresenting": isPresenting, "totalDisp": myApp.totalDisplayRunning, "isMod": mod, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey, "clientReqKey": myApp.clientReqKey
- }));
- },
- getUserName: function (username) {
- if (username.length > 15) {
- return username.substr(0, 15) + "...";
- } else {
- return username;
- }
- },
- screenAfterPresentation: function () {
- $("#touch_pad,#third_party_apps,#features_disp").hide();
- window.resizeTo(585, 650);
- if ($("#users").is(":visible") == false) {
- $("#users,#detail_grid,.always-at-bottom").show();
- }
- //$("#chat_user,#coordinator_div,#third_party_apps,#features_disp,#detail_grid,.allow_present_screen,#users,#chat_window,#touch_pad,#myfooter,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- },
- manageXmppUsePosition: function (user, html) {
- allXmppUsers.push(user);
- allXmppUsers.sort();
- //////console.log(allXmppUsers);
- if (allXmppUsers.length == 1) {
- $("#user_listing").append(html);
- } else if (allXmppUsers.length > 1) {
- var pos = allXmppUsers.indexOf(user);
- if (pos + 1 != allXmppUsers.length) {
- var pos_insert = pos + 1;
- var insert_before = "." + allXmppUsers[pos_insert] + "_class";
- $(html).insertBefore(insert_before);
- //////console.log(user, insert_before);
- } else if (pos + 1 == allXmppUsers.length) {
- var pos_insert = pos - 1;
- var insert_after = "." + allXmppUsers[pos_insert] + "_class";
- $(html).insertAfter(insert_after);
- }
- }
- },
- getOnlineUsersHtml: function (user, isPresenting, isWaiting) {
- if (myApp.gatewayVersion == 0) {
- var user_width = myApp.osType == 3 ? "400px" : "375px";
- } else {
- var user_width = myApp.osType == 3 ? "400px" : "320px";
- }
- var display_width = myApp.osType == 3 ? "90px" : "70px";
- var chat_width = myApp.osType == 3 ? "70px" : "50px";
- var fileshare_width = "40px";
- var displayImage = "";
- if (user != "") {
- html = '<div class="new_user ' + user + '_class">';
- html += '<div class="user" style="width:' + user_width + '"><img src="icons/MediumSmiley.png" style="vertical-align:middle"> ' + $.fn.getUserName(user) + '</div>';
- if (isPresenting == "Yes") {
- displayImage = "icons/display_active.png";
- } else if (isPresenting == "No") {
- if (isWaiting == "Yes") {
- displayImage = "icons/display_waiting.png";
- } else if (isWaiting == "No") {
- displayImage = "icons/display.png";
- }
- }
- if (user != "viaadmin") {
- html += '<div id="' + user + '_display" class="user display" style="width:' + display_width + '; text-align:center;"><img src="' + displayImage + '" style="vertical-align:middle"></div>';
- } else {
- html += '<div id="' + user + '_display" class="user" style="width:' + display_width + '; text-align:center;"><img src="' + displayImage + '" style="vertical-align:middle"></div>';
- }
- if (myApp.osType != 3) {
- console.log(myApp.featureListChat, );
- if (myApp.featureListChat == "yes") {
- html += '<div id="' + user + '" class="user chat_start" style="width:' + chat_width + ';cursor:pointer;margin-left:20px; text-align:center;"><img src="icons/chat.png" style="vertical-align:middle"></div>';
- }
- if (myApp.gatewayVersion != 0) {
- if (myApp.FeatureListFileTransfer == "yes") {
- html += '<div id="' + user + '_share" class="user one_share" style="width:' + fileshare_width + '; text-align:center;margin-left:20px;">';
- if (user != "viaadmin") {
- html += ' <label for="file-upload" style="padding-left:15px;"> <img src="icons/fileshare.png" style="vertical-align:middle"></label>';
- } else if (user == "viaadmin") {
- html += ' <label id="admin_fileshare" style="padding-left:15px;"> <img src="icons/fileshare.png" style="vertical-align:middle"></label>';
- }
- html += '</div>';
- }
- }
- }
- html += "<div><hr></hr></div>";
- html += "</div>";
- $.fn.manageXmppUsePosition(user, html);
- }
- //$("#user_listing").append(html);
- //$("#" + user + ".chat_start").find("img").attr('src', 'ix`cons/chat_active.png');
- },
- setPresence: function (obj) {
- var userInfo = obj.from.split("@");
- if (obj.presence == "online") {
- $.fn.getOnlineUsersHtml(userInfo[0], obj.isPresenting, obj.isWaiting);
- } else if (obj.presence == "offline") {
- //console.log(obj);
- myApp.manageChatUsers(userInfo[0], "remove");
- var indexDelete = allXmppUsers.indexOf(userInfo[0]);
- if (indexDelete > -1) {
- allXmppUsers.splice(indexDelete, 1);
- }
- // If the moderator user is getting offline without doing the leave moderation
- if (myApp.moderatorName == obj.from) {
- $("#moderator").html("Become Moderator").prop('disabled', false);
- }
- if ($("." + userInfo[0] + "_allow")) {
- $("." + userInfo[0] + "_allow").remove();
- if ($(".allow_present_screen .allow").length == 0) {
- $(".allow_present_screen").hide();
- }
- }
- if ($("#" + userInfo[0]).length == 0) {
- $("#" + userInfo[0] + "_display").parent().remove();
- } else {
- $("#" + userInfo[0]).parent().remove();
- }
- $("#" + myApp.getUserChatId(userInfo[0])).hide();
- $("#" + myApp.getUserChatBoxId(userInfo[0])).hide();
- if ($("#" + myApp.getUserChatId(userInfo[0])).hasClass("active_chat_user")) {
- if ($("#chat_user").children(".open_chat").is(":visible") == false) {
- $.fn.showParticipants("participants");
- }
- var setUserChatId = $('.open_chat:visible:first').attr("id");
- if (setUserChatId) {
- var setUserChatInfo = setUserChatId.split("_user");
- $("#" + myApp.getUserChatId(setUserChatInfo[0])).addClass("active_chat_user");
- $("#" + myApp.getUserChatBoxId(setUserChatInfo[0])).show();
- }
- }
- }
- },
- startChating: function (obj, callOn, messageText) {
- var user = obj.id;
- $("#" + user + ".chat_start").find("img").attr('src', 'icons/chat_active.png');
- myApp.manageChatUsers(user, "add");
- for (var i = 0; i < myApp.chatUsers.length; i++) {
- var id_user = myApp.getUserChatId(myApp.chatUsers[i]);
- var id_user_chat = myApp.getUserChatBoxId(myApp.chatUsers[i]);
- if ($("#" + id_user).length == 0 && $("#" + id_user_chat).length == 0) {
- $("#chat_user").append('<div id="' + id_user + '" class="open_chat"><img src="icons/SmallSmiley.png" style="vertical-align:middle; padding-right:10px;">' + $.fn.getUserName(myApp.chatUsers[i]) + '<span class="unseen_msg"></span></div>');
- $("#chats").append('<div id="' + id_user_chat + '" style="height:440px;display:none;overflow:auto;" class="user_chat_msg"></div>');
- }
- }
- if (callOn == "onMessage") {
- if (messageText) {
- messageText = messageText.replace(/\n/g, "<br />");
- if (messageText.length > 45) {
- var htmlAppend = '<div class="message_len rcorners2" style="text-align: left; margin: 15px 10px; 0 0">' + messageText + '</div>';
- } else {
- var htmlAppend = '<div class="message_len" style="text-align: left; margin-top: 15px;"><span class="rcorners2">' + messageText + '</span></div>';
- }
- if ($("#chat_user").is(":hidden") == true) {
- $(".open_chat").removeClass("active_chat_user");
- $(".user_chat_msg").hide();
- $("#" + myApp.getUserChatId(user)).addClass("active_chat_user").show();
- $("#" + myApp.getUserChatBoxId(user)).append(htmlAppend);
- $("#" + myApp.getUserChatBoxId(user)).show();
- $('.user_chat_msg').scrollTop(1000000);
- } else {
- var activeChatUser = $(".active_chat_user").closest("div").attr("id").split("_user");
- if (user == activeChatUser[0]) {
- $("#" + myApp.getUserChatBoxId(activeChatUser[0])).append(htmlAppend);
- $("#" + myApp.getUserChatId(activeChatUser[0])).show();
- $("#" + myApp.getUserChatBoxId(activeChatUser[0])).show();
- $('.user_chat_msg').scrollTop(1000000);
- } else {
- if (user in unReadMsgCounts) {
- var cnt = unReadMsgCounts[user];
- var newCount = cnt + 1;
- unReadMsgCounts[user] = newCount;
- $("#" + myApp.getUserChatId(user) + " span").text(newCount);
- } else {
- unReadMsgCounts[user] = 1;
- $("#" + myApp.getUserChatId(user) + " span").text("1");
- }
- $("#" + myApp.getUserChatBoxId(user)).append(htmlAppend);
- $('.user_chat_msg').scrollTop(1000000);
- $("#" + myApp.getUserChatId(activeChatUser[0])).show();
- }
- }
- }
- } else if (callOn = "sendMessage") {
- $(".user_chat_msg").hide();
- $("#" + myApp.getUserChatId(user)).show();
- $("#" + myApp.getUserChatBoxId(user)).show();
- $(".open_chat").removeClass("active_chat_user");
- $("#" + myApp.getUserChatId(user)).addClass("active_chat_user");
- $("#" + myApp.getUserChatId(user) + " span").text("");
- delete unReadMsgCounts[user];
- }
- $("#chat_window").show();
- $("#chat_user").show();
- $("#users").hide();
- $("#detail_grid").hide();
- },
- openChat: function (obj) {
- $("#msg").val("");
- $(".user_chat_msg").hide();
- var chat_user_id = obj.id + "_chat";
- $(".open_chat").removeClass("active_chat_user");
- $("#" + obj.id).addClass("active_chat_user");
- $("#" + obj.id + " span").text("");
- delete unReadMsgCounts[obj.id.split("_user")[0]];
- $("#" + chat_user_id).show();
- },
- showParticipants: function (id) {
- //$("#detail_grid").toggle();
- $(".file_transfer_options").hide();
- if (id == "participants") {
- if ($(window).height() > 160 && $("#users").is(":visible")) {
- $("#mirror_band").hide();
- if ($("#coordinator_div").is(":visible") == true) {
- window.resizeTo(585, 145);
- } else {
- window.resizeTo(585, 130);
- }
- $("#users,#detail_grid,.always-at-bottom").hide();
- } else {
- if (myApp.isMirrorUsers == "Yes") {
- $("#mirror_band").show();
- }
- window.resizeTo(585, 650);
- $("#mirror_users,#chat_window,#chat_user,#features_disp,#third_party_apps,#touch_pad,#myfooter,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info,#open_on_via_div").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- }
- } else if (id == "allparticipants") {
- if ($("#chat_user").parent().find('.active_chat_user').length == 1) {
- var current_user_id = $("#chat_user").parent().find('.active_chat_user').attr("id");
- var current_user_id = current_user_id.split("_user")
- $.fn.startChating({"id": current_user_id[0]});
- $("#features_disp").hide();
- } else {
- if (myApp.isMirrorUsers == "Yes") {
- $("#mirror_band").show();
- }
- $("#mirror_users,#chat_window,#chat_user,#features_disp,#third_party_apps,#touch_pad,#myfooter,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info,#open_on_via_div").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- }
- }
- },
- login: function () {
- if (myApp.userValidityChk == "yes") {
- //check for lower version 2.1 or 0
- if (myApp.gatewayVersion == 0) {
- if (myApp.roomCode != 0) {
- $("#login").html("Login");
- if (myApp.roomCode == $("#roomCode").val()) {
- $("#login").html("Logging In...");
- loginXmppUser.login();
- } else {
- $("#roomCode").addClass("text_error");
- myApp.userValidityChk = "no";
- $.fn.validateUser();
- }
- } else if (myApp.roomCode == 0) {
- loginXmppUser.login();
- }
- } else {
- loginXmppUser.login();
- }
- } else {
- //$("#login").html("Login");
- $.fn.validateUser();
- }
- //intervalidofvalidatenetwork = setInterval(networkvalidate, reconnectInterval);
- },
- validateUser: function () {
- var db_name = $("#db_name").val().toLowerCase().replace(/ /g, "_");
- var db_pass = $("#db_pass").val();
- var username = $("#username").val().toLowerCase().replace(/ /g, "_");
- var domain = $("#domain").val();
- myApp.loginUserId = username != "" ? username : db_name;
- myApp.domain = domain;
- myApp.roomNameText = domain;
- if ($.fn.validateSpecialCharacters(myApp.loginUserId) == true) {
- if (myApp.domain === "") {
- $("#domain").setAttribute("class", "server-box-after");
- return;
- }
- //////////////////////////////////////code to get id for gateway authorization with which you want to share/////////////////////////////////////
- var xmlHttp = new XMLHttpRequest();
- var url = "http://" + myApp.domain + "/id.php";
- var showError = false;
- xmlHttp.onreadystatechange = function () {
- if (xmlHttp.readyState == 4) {
- if (xmlHttp.status == 200) {
- parseOut = [];
- var response = xmlHttp.responseText;
- var parseResposne = JSON.parse(response);
- myApp.uniqueGatewayId = parseResposne['uniqueid'];
- myApp.serverUrl = parseResposne['serverIP'];
- myApp.serverPort = parseResposne['port'];
- myApp.jid = username != "" ? username + "@" + parseResposne['ipadd'] : db_name + "@" + parseResposne['ipadd'];
- myApp.domain = parseResposne['ipadd'];
- var ws = new WebSocket("wss://" + myApp.serverUrl + ":" + myApp.serverPort);
- myApp.socketId = ws;
- ws.onopen = function ()
- {
- ////////console.log("Websocket Connected");
- myApp.socketId.send(JSON.stringify({
- "request": "validateUser", "jid": myApp.jid, "db_pass": db_pass, "boxId": myApp.domain, "gatewayUniqueId": myApp.uniqueGatewayId, "version": "2.2", "type": "client"
- }));
- myApp.socketId.addEventListener("message", onWebSocketMessage, false);
- }
- } else {
- ////console.log(" ocing while calling id.php");
- if (showError == false) {
- myApp.customNotification("Login unsuccessful. Unable to reach chrome at this address");
- $("#login").html("Login");
- showError = true;
- }
- }
- }
- };
- xmlHttp.open("GET", url, true);
- xmlHttp.send();
- }
- },
- collaboration: function () {
- //shikha////////////////////
- $("#mouse_pad").width(myApp.touchPadWidth).height(myApp.touchPadHeight);
- var xmL = collaborationScreen.getXml("R", "1000", "0", "0", myApp.loginUserId);
- collaborationScreen.start(xmL);
- $("#touch_pad").show();
- $("#detail_grid,#features_disp,#third_party_apps,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info,.file_transfer_options").hide();
- },
- clearMessageBox: function () {
- $("#msg").blur();
- setTimeout(function () {
- $("#msg").focus();
- }, 100);
- },
- sendMessage: function () {
- if ($.trim(message_text).length != 0) {
- xmppChat.sendMessage();
- } else {
- $.fn.clearMessageBox();
- }
- message_text = "";
- },
- logout: function () {
- if (isPresentor == true) {
- stopPresenting();
- }
- $("#presentmeimg").attr("src", "icons/PRESENT-OFF.png");
- myApp.socketId.send(JSON.stringify({
- "request": "logout", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey, "clientReqKey": myApp.clientReqKey
- }));
- myApp.socketId.close();
- if (myApp.loginMode == 0) {
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "10px"});
- } else {
- $("#loginBtnTd").css({"padding-top": "90px"});
- $("#myfooter").css({"padding-top": "10px"});
- }
- window.resizeTo(440, 480);
- myApp.userValidityChk = "no";
- $("#moderator").html("Become Moderator");
- $("#roomCode").val("");
- $("#exam_td,#chat_user,#dnd_toggle,#allow_present_screen,#allAction,#chat_window,#features_disp,#third_party_apps,#touch_pad,#myfooter,#detail_grid,.always-at-bottom,#coordinator_div,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- $("#login_details,#myfooter").show();
- $("user_listing,.allow_present_screen").empty();
- $("#login").html("Login");
- $(".rc").hide();
- $("user_listing,.allow_present_screen").empty();
- myApp.loginMode = "";
- myApp.currentLoginMode = "";
- myApp.moderatorName = "";
- myApp.modToggleDnd = "";
- myApp.modToggleChat = "";
- myApp.modPwdReq = "";
- myApp.jid = "";
- window.location.reload();
- },
- reboot: function () {
- /*if (myApp.loginMode == 0 && myApp.loginMode != "" ) {
- $("#loginBtnTd").css({"padding-top": "60px"});
- $("#myfooter").css({"padding-top": "10px"});
- } else if (myApp.loginMode == "" || myApp.loginMode == 3) {
- $("#loginBtnTd").css({"padding-top": "90px"});
- $("#myfooter").css({"padding-top": "10px"});
- }*/
- if (isPresentor == true) {
- stopPresenting();
- }
- $("#presentmeimg").attr("src", "icons/PRESENT-OFF.png");
- $("#btnpause").hide();
- myApp.loginMode = "";
- myApp.currentLoginMode = "";
- myApp.moderatorName = "";
- myApp.modToggleDnd = "";
- myApp.modToggleChat = "";
- myApp.modPwdReq = "";
- // chrome.runtime.reload();
- $("#login").html("Login");
- $(".rc").hide();
- window.resizeTo(440, 480);
- myApp.socketId.close();
- myApp.userValidityChk = "no";
- $("#moderator").html("Become Moderator");
- $("#roomCode").val("");
- $("user_listing,.allow_present_screen").empty();
- $("#chat_user,#dnd_toggle,#allAction,#chat_window,#features_disp,#third_party_apps,#touch_pad,#myfooter,#detail_grid,.always-at-bottom,#coordinator_div,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info").hide();
- $("#login_details,#myfooter").show();
- window.location.reload();
- },
- isJson: function (str) {
- try {
- JSON.parse(str);
- } catch (e) {
- return false;
- }
- return true;
- },
- enableDnd: function () {
- $("#dnd_toggle").attr('src', 'icons/dnd_ena.png');
- $("#moderator").addClass("inactiveLink");
- $("#user_listing,.features,#presentmeimg").addClass("inactiveLink");
- myApp.socketId.send(JSON.stringify({
- "request": "dnd", "message": "SetDND", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- },
- disableDnd: function () {
- $("#dnd_toggle").attr('src', 'icons/dnd_dis.png');
- //$("#moderator").removeClass("inactiveLink");
- //$("#user_listing,.features,#presentmeimg").removeClass("inactiveLink");
- myApp.socketId.send(JSON.stringify({
- "request": "dnd", "message": "UnSetDND", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- },
- hideDisplayAllowRequest: function () {
- var d = new Date();
- var startTime = d.getTime();
- var endTime = startTime + 30000;
- if (displayUserWaiting.length > 0) {
- for (var i = 0; i <= displayUserWaiting.length - 1; i++) {
- //////console.log(displayUserWaiting[0]);
- //////console.log(i, displayUserWaiting[i]);
- var elemsArray = displayUserWaiting[i].split("~");
- //////console.log(elemsArray);
- if (d.getTime() > parseInt(elemsArray[1]) + 30000) {
- $("." + elemsArray[0]).remove();
- displayUserWaiting.splice(i, 1);
- //console.log(displayUserWaiting);
- if (displayUserWaiting.length == 0) {
- $(".allow_present_screen").hide();
- }
- }
- }
- }
- },
- authenticateModerator: function () {
- var mod_pass = $("#mod_pass").val();
- if (mod_pass != "") {
- $.fn.sendModeratorReq(mod_pass);
- } else {
- //$("#mod_error").show();
- }
- },
- validateSpecialCharacters: function (username) {
- var pattern = new RegExp(/[@^&,]/); //unacceptable chars
- if (pattern.test(username)) {
- $("#login").html("Login");
- $("#username").prop('disabled', false);
- myNotifications("Invalid Nick Name. Please enter a Nick Name that does not contain any special characters.");
- return false;
- }
- return true; //good user input
- },
- sendModeratorReq: function (mod_pass) {
- isPresenting = $("#presentmetext").text() == "Present" ? "No" : "Yes";
- ////console.log(isPresenting);
- myApp.socketId.send(JSON.stringify({
- "request": "basicModeratorIn", "totalDisp": myApp.totalDisplayRunning, "isPresenting": isPresenting, "isPwdReq": myApp.modPwdReq, "password": mod_pass, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey, "clientReqKey": myApp.clientReqKey
- }));
- },
- sendLeaveModerationReq: function () {
- $("#dnd_toggle,#mod_chat_disp").hide();
- isPresenting = $("#presentmetext").text() == "Present" ? "No" : "Yes";
- myApp.socketId.send(JSON.stringify({
- "request": "basicModeratorOut", "totalDisp": myApp.totalDisplayRunning, "isPresenting": isPresenting, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey, "clientReqKey": myApp.clientReqKey
- }));
- myApp.socketId.send(JSON.stringify({
- "request": "manageModChat", "message": "ChatEnabled", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("#user_listing,#allparticipants").removeClass("inactiveLink");
- },
- loginOnClick: function () {
- if ($("#domain").val() != "") {
- if ($("#username").is(":hidden") == false) {
- if ($("#username").val() != "") {
- $("#username").prop('disabled', true);
- $("#login").html("Logging In...");
- connect();
- } else {
- $("#username").addClass("text_error");
- }
- }
- if ($("#db_name").is(":hidden") == false) {
- if ($("#db_name").val() != "" && $("#db_pass").val() != "") {
- $("#login").html("Logging In...");
- $("#db_name,#db_pass").prop('disabled', true);
- connect();
- } else {
- if ($("#db_name").val() == "") {
- $("#db_name").addClass("text_error");
- }
- if ($("#db_pass").val() == "") {
- $("#db_pass").addClass("text_error");
- }
- }
- }
- if ($("#roomCode").is(":hidden") != false) {
- if ($("#roomCode").val() == "") {
- $("#roomCode").addClass("text_error");
- }
- }
- } else {
- $("#domain").addClass("text_error");
- }
- }
- });
- $(document).on("click", ".present_type_radio", function () {
- screenShareSource = this.id;
- if (isAskingPermission == "No") {
- if (isPresentor && !joinReceived) {
- joinReceived = true;
- window.resizeTo(669, 490);
- if (screenShareSource == "screen") {
- pendingPresentId = chrome.desktopCapture.chooseDesktopMedia(
- ["screen"], onAccessApproved);
- } else if (screenShareSource == "window") {
- pendingPresentId = chrome.desktopCapture.chooseDesktopMedia(
- ["window", "audio"], onAccessApproved);
- } else if (screenShareSource == "tab") {
- pendingPresentId = chrome.desktopCapture.chooseDesktopMedia(
- ["tab", "audio"], onAccessApproved);
- }
- screenShareSource = "";
- }
- } else {
- myApp.socketId.send(JSON.stringify({
- "request": "grantDisplayMe", "message": "GrantDisplayMe", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- }
- $(".prompt_present_screen").hide();
- });
- /* View Files code starts */
- $(document).on("click", "#call_view_files,#refresh_view_file", function () {
- myApp.socketId.send(JSON.stringify({
- "request": "viewFiles", "jid": myApp.jid, "type": "client", "clientReqKey": myApp.clientReqKey, "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- });
- $(document).on("click", ".file_check", function () {
- if (this.checked == true) {
- if ($('input.file_check:checked').length <= 1) {
- myApp.viewFileDownload.push({"filaname": $(this).attr('data-filename'), "filepath": $(this).attr('data-filepath')});
- } else {
- alert("You can select only one file.");
- $(this).prop('checked', false);
- }
- } else {
- var selectedFile = $(this).attr('data-filename');
- $.each(myApp.viewFileDownload, function (index, value) {
- $.each(value, function (key, val) {
- if (key == "filaname") {
- if (val == selectedFile) {
- delete myApp.viewFileDownload[index];
- }
- }
- });
- });
- }
- })
- $(document).on("click", ".view_file_open", function () {
- var viewFileOpen = $(this).attr('data-filename');
- var viewFileOpenPath = $(this).attr('data-filepath');
- myApp.socketId.send(JSON.stringify({
- "request": "openFileAtGateway",
- "jid": myApp.jid,
- "type": "client",
- "filePath": viewFileOpenPath,
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- })
- $(document).on("click", "#cloud_transfer", function () {
- if (myApp.dataChannel.readyState != "open") {
- myApp.startDataChannel();
- }
- })
- $(document).on("click", ".view_file_download", function () {
- if ($(".download_operation").length == 0) {
- downloadDataHtml();
- }
- var viewFileOpen = $(this).attr('data-filename');
- var viewFileOpenPath = $(this).attr('data-filepath');
- var viewFileSize = $(this).attr('data-filesize');
- $(".cancel_download").attr('data-filename', viewFileOpen);
- $(".cancel_download").attr('data-filepath', viewFileOpenPath);
- $(".cancel_download").attr('data-filesize', viewFileSize);
- myApp.socketId.send(JSON.stringify({
- "request": "sendDownloadFile", "action": "start", "fileSize": viewFileSize, "fileName": viewFileOpen.trim(), "filePath": viewFileOpenPath.trim(), "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- })
- /* View Files code ends */
- /* Tranfer of file action button */
- $(document).on("click", "#admin_fileshare", function () {
- $(".file_transfer_options").show();
- $(".download_from_via,.download_from_via_files").hide();
- })
- $(document).on("click", ".open_transfer", function () {
- chrome.downloads.open(myApp.deltaId[$(this).attr('data-filename').trim()]);
- });
- $(document).on("click", ".file_transfer", function () {
- var isReceived = $(".file_receive_prompt").find(".transfer_file_send,.transfer_file_class").length;
- if (isReceived > 0) {
- $("#features_disp").hide();
- $(".file_receive_prompt").show();
- } else {
- $.fn.showParticipants("participants");
- }
- })
- $(document).on("click", ".one_share", function () {
- if (myApp.dataChannel.readyState != "open") {
- myApp.startDataChannel();
- }
- if (this.id.split("_share")[0] != "viaadmin") {
- myApp.sendFileTo = this.id.split("_share")[0] + "@" + myApp.domain;
- myApp.shareFileWith = this.id.split("_share")[0];
- }
- })
- $(document).on("click", "#transfer_file_cross", function () {
- $(".file_transfer_options").hide();
- })
- $(document).on("click", "#save_transfer", function (event) {
- myApp.shareFileWith = "viaadmin";
- myApp.sendFileTo = "viaadmin@" + myApp.domain;
- })
- $(document).on("click", ".save_transfer", function (event) {
- if (myApp.isDownloadFileMode == "yes") {
- var divText = $(this).parents('div').eq(1).find(".transfer_file_class").text();
- var fileSendType = $(this).attr('data-sendtype');
- var fileSendBy = $(this).attr('data-sendby');
- var fileName = divText.split(":")[1];
- myApp.isDuplicateDownload = $(this).attr("data-duplicate");
- $(this).parents('div').eq(1).find(".my_bar_basic").html("");
- //$(".my_bar_basic").html("");
- myApp.socketId.send(JSON.stringify({
- "request": "sendTranferFile", "fileSendBy": fileSendBy, "action": "start", "fileSendType": fileSendType, "osType": myApp.osType, "fileName": fileName.trim(), "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- } else if (myApp.isDownloadFileMode == "no") {
- myApp.customNotification("Download in progress.");
- }
- });
- $(document).on("click", ".cancel_download", function () {
- //$(this).parents('div').eq(2).remove();
- /*if ($("#file_download_info > div .download_file_class").length == 0) {
- $.fn.showParticipants("participants");
- }*/
- var viewFileOpen = $(this).attr('data-filename');
- var viewFileOpenPath = $(this).attr('data-filepath');
- var viewFileSize = $(this).attr('data-filesize');
- myApp.socketId.send(JSON.stringify({
- "request": "sendDownloadFile", "action": "stop", "fileSize": viewFileSize, "fileName": viewFileOpen.trim(), "filePath": viewFileOpenPath.trim(), "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- });
- /* Tranfer of file action button */
- $(document).on("click", ".file_error_cross", function () {
- $("#media_support_err").hide();
- })
- $(document).on("click", ".present_type_cross", function () {
- $(".prompt_present_screen").hide();
- stopPresenting();
- })
- $(document).on("click", "#mirror_band", function () {
- $("#detail_grid,#third_party_apps,#touch_pad,.file_receive_prompt").hide();
- $("#mirror_users").show();
- $("#mirror_band").hide();
- })
- $(document).on("click", ".chat_start", function () {
- if (myApp.isCollaborationStarted == "Yes") {
- myApp.isCollaborationStarted = "No";
- collaborationScreen.stop();
- }
- $("#mirror_band").hide();
- $.fn.startChating(this, "sendMessage");
- });
- $(document).on("click", ".open_chat", function () {
- $.fn.openChat(this);
- });
- $(document).on("click", "#login", function () {
- $.fn.loginOnClick();
- intervalidofvalidatenetwork = setInterval(networkvalidate, reconnectInterval);
- });
- $(document).keypress(function (e) {
- if (e.which == 13) {
- if ($("#domain").is(':focus') || $("#username").is(':focus') || $("#db_name").is(':focus') || $("#db_pass").is(':focus') || $("#roomCode").is(':focus')) {
- $.fn.loginOnClick();
- intervalidofvalidatenetwork = setInterval(networkvalidate, reconnectInterval);
- }
- if ($("#mod_pass").focus()) {
- $.fn.authenticateModerator();
- }
- }
- });
- $(document).on("click", "#collaboration,.open_third_party", function () {
- //var checkDcTimer = myApp.isChromeOs == true ? 2000 : 1500;
- if (myApp.dataChannel.readyState != "open") {
- myApp.startDataChannel();
- myApp.isCollaborationStarted = "Yes";
- /*setTimeout(function () {
- console.log("Opened SetTimeOut.");
- myApp.isCollaborationStarted = "Yes";
- if (myApp.dataChannel.readyState == "open") {
- console.log("Opened.");
- $.fn.collaboration();
- }
- }, 2000);*/
- } else if (myApp.dataChannel.readyState == "open") {
- $.fn.collaboration();
- }
- });
- $(document).on("keypress", "#msg,#send", function (e) {
- message_text = $("#msg").val();
- if ($.trim(message_text).length != 0) {
- if (event.keyCode == 13) {
- xmppChat.sendMessage();
- $.fn.clearMessageBox();
- }
- } else {
- if (event.keyCode == 13) {
- $.fn.clearMessageBox();
- }
- }
- });
- $(document).on("click", "#logout", function () {
- $.fn.logout();
- });
- $(document).on("click", "#viewAllUsers", function () {
- client.getRoster();
- });
- $(document).on("click", "#send", function () {
- message_text = $("#msg").val();
- $.fn.sendMessage();
- });
- $(document).on("click", "#allparticipants", function () {
- $.fn.showParticipants(this.id);
- });
- $(document).on("click", ".participants", function () {
- $.fn.showParticipants("participants");
- });
- $(document).on("click", "#thirdParyApps", function () {
- $("#features_disp,#detail_grid,#users,#chat_user,#chat_window,#touch_pad,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info,.file_transfer_options").hide();
- $("#third_party_apps").show();
- myApp.getThirdPartyApps();
- })
- $(document).on("click", ".open_third_party", function () {
- var data = stringToArrayBuffer(this.id + "~" + myApp.jid + "~fromClient" + "~OpenThirdParty");
- myApp.socketId.send(JSON.stringify({
- "request": "openThirdParty", "id": this.id, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $.fn.collaboration();
- /*chrome.sockets.tcp.send(myApp.socketId, data, function (resultCode) {
- //////console.log("Send Third Party Request.");
- })*/
- })
- $(document).on("click", "#crossButton1", function () {
- $.fn.logout();
- chrome.app.window.current().close();
- })
- $(document).on("click", ".allow_share_cross", function () {
- if ($('.allow_share_cross').length <= 1) {
- $(".allow_present_screen").hide();
- }
- $(this).closest("div").remove();
- })
- $(document).on("click", ".allow_dual_share_cross", function () {
- if ($('.allow_dual_share_cross').length <= 1) {
- $(".allow_present_screen").hide();
- }
- $(this).closest("div").remove();
- })
- $(document).on("click", ".display", function () {
- var userDisplayId = this.id;
- var displayImg = $("#" + userDisplayId).find("img").attr("src").split("/");
- var allowUser = this.id.split("_display")[0] + "@" + myApp.domain;
- if (myApp.moderatorName != "" && myApp.currentLoginMode != "") {
- if (myApp.moderatorName == myApp.jid) {
- myApp.socketId.send(JSON.stringify({
- "request": "grantDisplay", "message": "GrantDisplay", "jid": myApp.jid, "presentReqFrom": allowUser, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- }
- } else if (myApp.moderatorNames.length > 0) {
- if (myApp.moderatorNames.indexOf(allowUser) == -1) {
- myApp.socketId.send(JSON.stringify({
- "request": "grantDisplay", "message": "GrantDisplay", "jid": myApp.jid, "presentReqFrom": allowUser, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- } else {
- myApp.customNotification("This user is a moderator. Starting their presentation is not allowed.");
- }
- }
- })
- $(document).on("click", "#minimizebutton", function () {
- chrome.app.window.current().minimize();
- })
- $(document).on("click", ".features", function () {
- /*if (!peerConns[myApp.xmppExeReqKey]) {
- createCollaborationPeerConn();
- }*/
- //peerConns[myApp.xmppExeReqKey].createOffer(setLocalPCOffer, errorCallback);
- if ($(window).height() > 200 && $("#features_disp").is(":visible")) {
- window.resizeTo(585, 130);
- $("#features_disp,.always-at-bottom,.file_transfer_options").hide();
- } else {
- window.resizeTo(585, 650);
- $("#features_disp,.always-at-bottom").show();
- $("#mirror_band,#mirror_users,#touch_pad,#detail_grid,#third_party_apps,#chat_window,#chat_user,#myFooter,.file_receive_prompt,#file_transfer_disp,#view_file_info,#file_download_info,.file_transfer_options,#open_on_via_div").hide();
- }
- })
- $(document).on("click", "#e_examimg,#eexamtext", function () {
- var role = myApp.moderatorName != "" ? "4" : "9";
- chrome.windows.create({'url': 'http://' + myApp.domain + '/pexam.php?uname=' + myApp.encodeUsernameForUrl(myApp.loginUserId) + '&role=' + role, 'type': 'popup', 'width': screen.width, 'height': screen.height}, function (window) {
- });
- })
- $(document).on("click", ".new_user", function () {
- //$(this).css("background", "#707070");
- })
- $(document).on("click", "#epoll", function () {
- chrome.windows.create({'url': 'http://' + myApp.domain + '/polling/index.php?uname=' + myApp.encodeUsernameForUrl(myApp.loginUserId), 'type': 'popup', 'width': 800, 'height': 600}, function (window) {
- });
- })
- $(document).on("click", "#moderator", function () {
- var modText = $(this).html();
- $("#mod_pass").val("");
- if (modText == "Become Moderator") {
- if (myApp.modPwdReq == 1) {
- $(".mod").show();
- $("#mod_pass").focus();
- } else if (myApp.modPwdReq == 0) {
- $.fn.sendModeratorReq();
- }
- } else if (modText == "Leave Moderation") {
- $("#mirror_users,#mirror_band").hide();
- $.fn.sendLeaveModerationReq();
- $("#moderation_chat").prop("checked", false);
- $("#mod_chat_disp").hide();
- myApp.moderatorName = "";
- $(this).html("Become Moderator");
- myApp.isMirrorUsers = "No";
- $("#dnd_toggle").attr('src', 'icons/dnd_dis.png');
- if (myApp.modToggleDnd == 1) {
- if ($("#dnd_toggle").attr("src") == "icons/dnd_ena.png") {
- $.fn.disableDnd();
- }
- }
- $("#dnd_toggle").hide();
- $(".mod,#mod_error").hide();
- $("#mod_pass").val("");
- }
- })
- $(document).on("click", "#mod_cancel", function () {
- $(".mod,#mod_error").hide();
- $("#mod_pass").val("");
- })
- $(document).on("click", "#mod_submit", function () {
- $.fn.authenticateModerator();
- })
- $(document).on("click", "#moderation_chat", function () {
- if (this.checked == true) {
- //$("#user_listing,#allparticipants").addClass("inactiveLink");
- myApp.socketId.send(JSON.stringify({
- "request": "manageModChat", "message": "ChatEnabled", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- } else {
- myApp.socketId.send(JSON.stringify({
- "request": "manageModChat", "message": "ChatDisabled", "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- //$("#user_listing,#allparticipants").removeClass("inactiveLink");
- }
- });
- $(document).on("click", "#accept_present,#reject_present", function () {
- $(this).closest("div").remove();
- if (this.id == "accept_present") {
- publishPresenting();
- }
- $(".allow_present_screen").hide();
- })
- $(document).on("click", ".allow_dual_first", function () {
- //Dual display
- var presentReqFrom = $(this).attr('data-allowto');
- myApp.socketId.send(JSON.stringify({
- "request": "allowDualScreen", "message": "GDAllowedOne", "jid": myApp.jid, "presentReqFrom": presentReqFrom, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $(this).closest("div").remove();
- if ($('.allow_dual_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_dual_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".allow_dual_second", function () {
- //Dual display
- var presentReqFrom = $(this).attr('data-allowto');
- myApp.socketId.send(JSON.stringify({
- "request": "allowDualScreen", "message": "GDAllowedTwo", "jid": myApp.jid, "presentReqFrom": presentReqFrom, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $(this).closest("div").remove();
- if ($('.allow_dual_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_dual_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".allow_dual_auto_position", function () {
- //Dual display
- var presentReqFrom = $(this).attr('data-allowto');
- myApp.socketId.send(JSON.stringify({
- "request": "allowDualScreen", "message": "GDAllowedShare", "jid": myApp.jid, "presentReqFrom": presentReqFrom, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $(this).closest("div").remove();
- if ($('.allow_dual_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_dual_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".deny_access_dual", function () {
- //Dual display
- //var userDeleteClass = $(this).closest("div").attr("class").split(" ")[0];
- //displayUserWaiting.splice(displayUserWaiting.indexOf(userDeleteClass), 1);
- $(this).closest('.allow_dual').remove();
- var denyUser = $(this).attr('data-denyto');
- myApp.socketId.send(JSON.stringify({
- "request": "denyDualPresentRequest", "message": "GDADeny", "jid": myApp.jid, "presentReqFrom": denyUser, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- //$("#" + this.id).closest("div").remove();
- if ($(".allow_dual_share_cross .allow_dual").length == 0) {
- $(".allow_present_screen").hide();
- }
- if ($("#users").is(":visible") == false) {
- window.resizeTo(585, 145);
- }
- })
- $(document).on("click", ".allow_share_cross", function () {
- /*displayUserWaiting.push(classNameAllow + "~" + startTime);
- var elemsArray = displayUserWaiting[i].split("~");*/
- var userDeleteClass = $(this).closest("div").attr("class").split(" ")[0];
- displayUserWaiting.splice(displayUserWaiting.indexOf(userDeleteClass), 1);
- if ($('.allow_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- }
- $(this).closest("div").remove();
- })
- $(document).on("click", ".allow_full_screen", function () {
- var presentReqFrom = $(this).closest("div").attr("class").split("_allow");
- var userDeleteClass = $(this).closest("div").attr("class").split(" ")[0];
- displayUserWaiting.splice(displayUserWaiting.indexOf(userDeleteClass), 1);
- //stopPresenting();
- myApp.socketId.send(JSON.stringify({
- "request": "allowFullScreen", "message": "GDAllowedOne", "jid": myApp.jid, "presentReqFrom": presentReqFrom[0] + "@" + myApp.domain, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- //////console.log("IpAddress", myApp.domain);
- /*$(".allow").remove();
- $(".allow_present_screen").empty();
- $(".allow_present_screen").hide();
- */
- $(this).closest("div").remove();
- if ($('.allow_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".mirror_full_screen", function () {
- var uniqueClassName = $(this).attr('data-from');
- stopPresenting();
- myApp.socketId.send(JSON.stringify({
- "request": "allowFullScreen", "message": "GDAllowedOne", "jid": myApp.jid,
- "presentReqFrom": myApp.mirrorUsers[uniqueClassName].fullName,
- "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("." + myApp.mirrorUsers[uniqueClassName].time).remove();
- delete myApp.mirrorUsers[uniqueClassName];
- if ($('.allow_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".allow_auto_position", function () {
- var presentReqFrom = $(this).closest("div").attr("class").split("_allow");
- var userDeleteClass = $(this).closest("div").attr("class").split(" ")[0];
- displayUserWaiting.splice(displayUserWaiting.indexOf(userDeleteClass), 1);
- myApp.socketId.send(JSON.stringify({
- "request": "allowDualAutoPosition", "message": "GDAllowedShare", "jid": myApp.jid, "presentReqFrom": presentReqFrom[0] + "@" + myApp.domain, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $(this).closest("div").remove();
- if ($('.allow_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".mirror_auto_position", function () {
- var uniqueClassName = $(this).attr('data-from');
- myApp.socketId.send(JSON.stringify({
- "request": "allowAutoPosition", "message": "GDAllowedShare", "jid": myApp.jid,
- "presentReqFrom": myApp.mirrorUsers[uniqueClassName].fullName,
- "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("." + myApp.mirrorUsers[uniqueClassName].time).remove();
- delete myApp.mirrorUsers[uniqueClassName];
- if ($('.allow_share_cross').length == 0) {
- $(".allow_present_screen").hide();
- } else {
- $(".allow_share_cross").last().closest("div").show();
- }
- })
- $(document).on("click", ".deny_access", function () {
- var userDeleteClass = $(this).closest("div").attr("class").split(" ")[0];
- displayUserWaiting.splice(displayUserWaiting.indexOf(userDeleteClass), 1);
- var denyUser = this.id.split("_deny")[0] + "@" + myApp.domain;
- myApp.socketId.send(JSON.stringify({
- "request": "denyPresentRequest", "message": "GDADeny", "jid": myApp.jid, "presentReqFrom": denyUser, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("#" + this.id).closest("div").remove();
- if ($(".allow_present_screen .allow").length == 0) {
- $(".allow_present_screen").hide();
- }
- if ($("#users").is(":visible") == false) {
- window.resizeTo(585, 145);
- }
- })
- $(document).on("click", ".deny_mirror", function () {
- var uniqueClassName = $(this).attr('data-from');
- myApp.socketId.send(JSON.stringify({
- "request": "denyPresentRequest", "message": "GDADeny", "jid": myApp.jid,
- "presentReqFrom": myApp.mirrorUsers[uniqueClassName].fullName, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("." + myApp.mirrorUsers[uniqueClassName].time).remove();
- delete myApp.mirrorUsers[uniqueClassName];
- if ($(".allow_present_screen .allow").length == 0) {
- $(".allow_present_screen").hide();
- }
- if ($("#users").is(":visible") == false) {
- window.resizeTo(585, 145);
- }
- })
- $(document).on("click", "#dnd_toggle", function () {
- var imgaePath = this.src;
- var pathArray = this.src.split("/");
- var imageName = pathArray[pathArray.length - 1];
- if (imageName == "dnd_dis.png") {
- $.fn.enableDnd();
- } else {
- $.fn.disableDnd();
- }
- })
- $(document).on("click", "#btnpause", function (e) {
- if (pauseFlag === false) {
- pauseFlag = true;
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "makePause",
- "type": "client"
- }));
- //////console.log("pause clicked");
- $("#btnpause").attr('src', 'icons/play25.png');
- } else {
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "makePlay",
- "type": "client"
- }));
- //////console.log("resume clicked", shareStream);
- $("#btnpause").attr('src', 'icons/pause25.png');
- pauseFlag = false;
- }
- });
- $(document).on("click", "#btnfullscreen", function (e) {
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "makeFullScreen",
- "type": "client"
- }));
- $("#btnpause").attr('src', 'icons/pause25.png');
- ////// dnd need to be added////
- });
- presentmeimg
- var isAskingPermission = "No";
- $(document).on("click", "#presentmeimg,#presentmetext", function () {
- if ($('#presentmeimg').attr("src") == "icons/present_waiting.png") {
- $(".prompt_present_screen").hide();
- stopPresenting();
- } else {
- $(".file_transfer_options").hide();
- if (myApp.currentLoginMode != "") {
- if (myApp.currentLoginMode == 3) {
- if (myApp.moderatorName != "") {
- if (myApp.moderatorName != myApp.jid) {
- $("#presentmeimg").attr("src", "icons/present_waiting.png");
- if (isPresentor == false) {
- $('.present_type_radio').prop('checked', false);
- isAskingPermission = "Yes";
- $(".prompt_present_screen").show();
- window.resizeTo(585, 650);
- $("#chat_window,#chat_user,#features_disp,#third_party_apps,#touch_pad,#myfooter,.file_receive_prompt,#file_transfer_disp").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- } else if (isPresentor == true) {
- publishPresenting();
- }
- } else {
- publishPresenting();
- }
- } else {
- publishPresenting();
- }
- } else if (myApp.currentLoginMode == 4 || myApp.currentLoginMode == 9) {
- console.log(myApp.moderatorNames);
- if (myApp.moderatorNames.indexOf(myApp.jid) != -1) {
- publishPresenting();
- } else {
- $("#presentmeimg").attr("src", "icons/present_waiting.png");
- if (isPresentor == false) {
- $('.present_type_radio').prop('checked', false);
- isAskingPermission = "Yes";
- $(".prompt_present_screen").show();
- window.resizeTo(585, 650);
- $("#chat_window,#chat_user,#features_disp,#third_party_apps,#touch_pad,#myfooter,.file_receive_prompt,#file_transfer_disp").hide();
- $("#users,#detail_grid,.always-at-bottom").show();
- } else if (isPresentor == true) {
- publishPresenting();
- }
- }
- }
- } else {
- publishPresenting();
- }
- }
- });
- document.querySelector('#minwowpng').addEventListener('click', function (e) {
- //////console.log("minimize app");
- var window = chrome.app.window.current();
- window.minimize();
- });
- $("#domain").on("input", function () {
- $(this).removeClass("text_error");
- //////console.log(this.value);
- if (this.value != "") {
- if (this.value in myApp.chromeIpAddressKeyValue) {
- checkUiMode(myApp.chromeIpAddressKeyValue[this.value].logintype);
- } else {
- $(".db,.rc").hide();
- $(".basic").show();
- $("#loginBtnTd").css({"padding-top": "90px"});
- $("#myfooter").css({"padding-top": "30px"});
- }
- }
- });
- $("#username").on("input", function () {
- $(this).removeClass("text_error");
- });
- $("#db_name").on("input", function () {
- $(this).removeClass("text_error");
- });
- $("#db_pass").on("input", function () {
- $(this).removeClass("text_error");
- });
- $("#roomCode").on("input", function () {
- $(this).removeClass("text_error");
- });
- $(document).on("click", "#files_transfer,.files_transfer", function () {
- $(".file_transfer_options").show();
- $("#media_support_err").hide();
- $(".download_from_via,.download_from_via_files").show();
- })
- $(document).on("click", ".delete_tranfer", function () {
- var deleteSendTo = $(this).parents().eq("2").find(".transfer_file_send").attr("data-sendto");
- var deleteFile = $(this).parents().eq("2").find(".transfer_file_send").text().split(":")[1].trim();
- $(this).parents().eq("2").remove();
- if (myApp.fileTransferQue[0].name.trim() == deleteFile) {
- myApp.stopFileTransfer = true;
- myApp.sendFileTo = "";
- myApp.socketId.send(JSON.stringify({
- "request": "deleteTransferFile", "fileName": deleteFile, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- for (var i = 0; i < myApp.fileTransferQue.length; i++) {
- if (myApp.fileTransferQue[i].name.trim() == deleteFile) {
- delete myApp.filesTransferNameWithUser[deleteSendTo + "~" + deleteFile];
- if (i != 0) {
- if (i == 1) {
- myApp.fileTransferQue.splice(1, 1);
- } else {
- myApp.fileTransferQue.splice((i - 1), 1);
- }
- } else {
- myApp.fileTransferQue.shift();
- }
- setTimeout(function () {
- myApp.stopFileTransfer = false;
- //myApp.fileTransferQue.shift();
- myApp.shareFileWith = "";
- if (myApp.fileTransferQue.length > 0) {
- var reader = new window.FileReader();
- reader.readAsBinaryString(myApp.fileTransferQue[0]);
- reader.onload = onReadAsDataURL;
- } else {
- myApp.isTransferMode = "yes";
- $(".file_receive_prompt,.always-at-bottom").hide();
- window.resizeTo(585, 130);
- }
- }, 500);
- }
- }
- } else {
- //console.log("Waiting");
- for (var i = 0; i < myApp.fileTransferQue.length; i++) {
- // console.log(myApp.fileTransferQue);
- //console.log(myApp.fileTransferQue[i].name.trim(), deleteFile);
- if (myApp.fileTransferQue[i].name.trim() == deleteFile) {
- if (i != 0) {
- if (i == 1) {
- myApp.fileTransferQue.splice(1, 1);
- } else {
- myApp.fileTransferQue.splice((i - 1), 1);
- }
- } else {
- myApp.isTransferMode = "yes";
- myApp.fileTransferQue.shift();
- }
- }
- //console.log(myApp.fileTransferQue);
- }
- }
- //$("#file_transfer_disp").hide();
- //$.fn.showParticipants("participants");
- })
- $(document).on("click", ".delete_openvia", function () {
- var deleteFile = $(this).parents().eq("2").find(".openvia_file_class").text().split(":")[1].trim();
- $(this).parents().eq("2").remove();
- myApp.stopFileTransfer = true;
- myApp.socketId.send(JSON.stringify({
- "request": "deleteTransferFile", "fileName": deleteFile, "jid": myApp.jid, "type": "client", "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- $("#file_transfer_disp").hide();
- myApp.sendFileOpenOnVia = true;
- $.fn.showParticipants("participants");
- setTimeout(function () {
- myApp.stopFileTransfer = false;
- }, 250);
- })
- // stop the connection on button click
- function disconnect() {
- //////console.log("disconnect()");
- if (myApp.socketId != null) {
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "byeUser",
- "gatewayUniqueId": myApp.uniqueGatewayId,
- "type": "client"
- }));
- }
- stop();
- shareStream = null;
- videoStream = null;
- pendingPresentId = null;
- rtcInfo = {};
- peerId = null;
- //if (myApp.socketId != null) {
- // myApp.socketId.close();
- // myApp.socketId = null;
- // }
- ///////////////////////////////////
- // myApp.socketId = null;
- }
- function stopPresenting() {
- if (shareStream) {
- shareStream.getTracks().forEach(function (track) {
- track.stop();
- });
- }
- isPresentor = false;
- joinReceived = false;
- pauseclickflag = false;
- if (myApp.currentLoginMode == "") {
- var isModSending = "Yes";
- } else if (myApp.currentLoginMode == 3) {
- var isModSending = myApp.moderatorName == myApp.jid ? "Yes" : "No";
- } else if (myApp.currentLoginMode == 4 || myApp.currentLoginMode == 9) {
- var isModSending = myApp.moderatorNames.indexOf(myApp.jid) != -1 ? "Yes" : "No";
- }
- ////////////////////////todo code for Stop Presenting////////////////////////////////////
- // turn off audio \ video on attendee
- if (myApp.socketId != null) {
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "stopSharing",
- "gatewayUniqueId": myApp.uniqueGatewayId,
- "type": "client",
- "jid": myApp.jid,
- "isModerator": isModSending,
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- if (myApp.modToggleDnd == 1) {
- if ($("#dnd_toggle").attr("src") == "icons/dnd_ena.png") {
- $.fn.disableDnd();
- }
- }
- }
- stop();
- //document.getElementById("strMsg-label").innerHTML = "Sharing Stopped";
- //document.getElementById("btnStartShare").innerHTML="Present";
- document.getElementById("btnfullscreen").style.display = "none";
- //document.getElementById("btnpause").style.display="none";
- setupUILogin(2);
- }
- //onsuccess of desktop sharing
- function publishPresenting() {
- if (isPresentor == false) {
- isPresentor = true;
- joinReceived = false;
- myApp.socketId.send(JSON.stringify({
- "request": "publish",
- "boxId": myApp.domain,
- "gatewayUniqueId": myApp.uniqueGatewayId,
- "username": myApp.loginUserId,
- "clientReqKey": myApp.clientReqKey,
- "type": "client"
- }));
- } else {
- stopPresenting();
- }
- }
- function onAccessApproved(id) {
- if (myApp.currentLoginMode == "") {
- var isModSending = "Yes";
- } else if (myApp.currentLoginMode == 3) {
- var isModSending = myApp.moderatorName == myApp.jid ? "Yes" : "No";
- } else if (myApp.currentLoginMode == 4 || myApp.currentLoginMode == 9) {
- var isModSending = myApp.moderatorNames.indexOf(myApp.jid) != -1 ? "Yes" : "No";
- }
- isPresentor = true;
- if (!id) {
- isPresentor = false;
- joinReceived = false;
- //window.resizeTo(585, 145);
- $.fn.screenAfterPresentation();
- ////console.log("Anuj Bhargava");
- // send message on cancel screen sharing
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "stopPresentStatus",
- "isModerator": isModSending,
- "jid": myApp.jid,
- "type": "client",
- "xmppExeReqKey": myApp.xmppExeReqKey
- }));
- return;
- }
- //sending actual window
- $("#btnpause").attr('src', 'icons/pause25.png');
- $("#btnpause").show();
- var numDispRun = myApp.totalDisplayRunning == 0 ? 1 : myApp.totalDisplayRunning;
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "showScreen",
- "username": myApp.loginUserId,
- "extwidth": screen.width,
- "extheight": screen.height,
- "type": "client",
- "jid": myApp.jid,
- "isModerator": isModSending,
- "numDispRun": numDispRun,
- "xmppExeReqKey": myApp.xmppExeReqKey,
- "clientReqKey": myApp.clientReqKey,
- }));
- navigator.webkitGetUserMedia({
- audio: {
- mandatory: {
- chromeMediaSource: "system",
- chromeMediaSourceId: id,
- }
- },
- video: {
- mandatory: {
- chromeMediaSource: "desktop",
- chromeMediaSourceId: id,
- maxWidth: screen.width,
- maxHeight: screen.height,
- minFrameRate: 5,
- maxFrameRate: 20
- }
- }
- }, gotShareStream, errorCallback);
- }
- ////////////////////////////////////////////////////////////////////shikha////////////////////////////////////////////
- function gotShareStream(stream) {
- //console.log(stream);
- shareStream = stream;
- seltabid = null;
- share();
- $.fn.screenAfterPresentation();
- //window.resizeTo(585, 145);
- setupUILogin(3);
- if ("WebSocket" in window) {
- myApp.socketId.onopen = function () {
- //////console.log("WebSocket connection open");
- };
- } else {
- //////console.log("No web socket connection");
- }
- if (seltabid == null)
- {
- chrome.tabs.query({active: true, highlighted: true}, function (tab) {
- //////console.log("captureinfo",tab.length,tab);
- if (tab.length > 0) {
- seltabid = tab[0].id;
- //////console.log("seltabid", seltabid);
- chrome.tabs.update(seltabid, {muted: true}, function (seltab) {
- //////console.log("captureinfo", seltab);
- });
- }
- });
- }
- stream.oninactive = function () {
- //////console.log("new code to catch stop event");
- stopPresenting();
- };
- }
- function share() {
- if (shareStream) {
- if (!rtcInfo[peerId]) {
- createPeerConnection(peerId);
- }
- //////console.log('function share Adding local stream...');
- rtcInfo[peerId].addStream(shareStream);
- shareFlowing = true;
- //////console.log("peer " + peerId + " share ", shareStream);
- rtcInfo[peerId].createOffer(setLocalDescAndSendMessagePCOffer, errorCallback, mediaConstraints);
- //startVideo();
- } else {
- //////console.log("Local share stream not running.");
- }
- }
- function createPeerConnection(pcID) {
- //////console.log("Creating peer connection");
- RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
- var pc_config = {
- "iceServers": myApp.pcConfig
- };
- try {
- rtcInfo[pcID] = new RTCPeerConnection(pc_config);
- //////console.log(pc_config);
- } catch (e) {
- //////console.log("Failed to create PeerConnection, exception: " + e.message);
- }
- // send any ice candidates to the other peer
- rtcInfo[pcID].onicecandidate = function (evt) {
- if (evt.candidate) {
- //////console.log('Sending ICE candidate...');
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "iceCandidate",
- "candidate": evt.candidate,
- "type": "client"
- }));
- } else {
- //////console.log("End of candidates.");
- }
- };
- //////console.log('Adding local stream...');
- if (!isPresentor) {
- rtcInfo[pcID].addStream(videoStream);
- }
- rtcInfo[pcID].addEventListener("addstream", onRemoteStreamAdded, false);
- rtcInfo[pcID].addEventListener("removestream", onRemoteStreamRemoved, false)
- }
- function onRemoteStreamAdded(event) {
- //////console.log("Added remote stream");
- if (!shareVideoActive && !isPresentor) {
- shareVideo.src = window.URL.createObjectURL(event.stream);
- shareVideo.play();
- shareVideoActive = true;
- return;
- }
- }
- function onRemoteStreamRemoved(event) {
- //////console.log("Remove remote stream");
- }
- //login to ui of screen share ///////////////////////////////////////////////////////////////////////////
- function setupUILogin(caller) {
- if (caller == 1) { // called in case of login is success.
- //////console.log("coming to set start");
- document.getElementById("present-div").style.display = "block";
- document.getElementById("presentmetext").innerHTML = "Present";
- window.resizeTo(585, 145);
- document.getElementById("boxAddress").setAttribute("class", "server-box-before");
- document.getElementById("usernickname").setAttribute("class", "server-box-before");
- document.getElementById("roomCode").setAttribute("class", "server-box-before");
- } else if (caller == 2) {
- //////console.log("coming to set stop");
- document.getElementById("presentmeimg").src = "icons/PRESENT-OFF.png";
- document.getElementById("presentmetext").innerHTML = "Present";
- $("#dnd_toggle").hide();
- //////////////////b13//////////////////////////
- document.getElementById("btnfullscreen").style.display = "none";
- //window.resizeTo(585,86);
- } else if (caller == 3) {
- document.getElementById("presentmetext").innerHTML = "Stop Presenting";
- document.getElementById("presentmeimg").src = "icons/PRESENT-ON.png";
- } else if (caller == 4) { // on socket error.
- $.fn.reboot();
- //window.resizeTo(397, 450);
- document.getElementById("outer-div").style.display = "block";
- document.getElementById("myfooter").style.display = "block";
- //document.getElementById("present-div").style.display = "none";
- }
- }
- //////////////////////////////////////Stop screen shring and reinitialize all elements/////////////////////////////////////
- function stop() {
- if (shareStream) {
- var track = shareStream.getTracks()[0];
- track.stop();
- shareStream = null;
- }
- if (rtcInfo[peerId] != null) {
- //////console.log("coming to close connection");
- rtcInfo[peerId].close();
- rtcInfo[peerId] = null;
- }
- shareFlowing = false;
- videoFlowing = false;
- isPresentor = false;
- shareVideoActive = false;
- remoteVideoActive = false;
- joinReceived = false;
- document.getElementById("btnpause").style.display = "none";
- pauseclickflag = false;
- if (seltabid != null) {
- //////console.log("seltabid", seltabid);
- chrome.tabs.update(seltabid, {muted: false}, function (seltab) {
- //////console.log("captureinfo", seltab);
- });
- }
- }
- function downloadDataHtml() {
- var htmlData = '<div class="view_file_bar" style="background-color: #707070; height: 25px; margin-right: 1px;margin-top: 1px; margin-bottom: 10px;color: #FFFFFF; text-align: center; padding-top: 10px; font-size: 13px;">VIA Cloud</div>';
- htmlData += '<div style="padding-top: 5px; margin-left: 5px;margin-top: 5px;padding-bottom: 10px;" class="download_file_class"></div>';
- htmlData += '<div style="margin-left: 5px;" class="basic_download">0%</div>';
- htmlData += '<div style="margin-left: 5px;" class="color_download"></div>';
- htmlData += '<div class="download_operation"> <input type="button" style="width:75px; height:30px; vertical-align: bottom; margin-top:5px; " class="logout cancel_download" value="cancel"/></div>';
- htmlData += '<div style="margin-top: 15px;padding-bottom: 10px;margin-left: 5px;" class="transfer_length">Total Size: <span class="total_download_length"></span> MB <span style="padding-right: 180px;" > </span> Current Size: <span class="remaining_download_length"></span></div>';
- $("#file_download_info").append(htmlData);
- }
- function showErrorState(calledfrom) {
- if (calledfrom == 1 && networkErrorCounter == 0) {
- networkErrorCounter = 1;
- myNotifications("Login unsuccessful. Unable to reach chrome at this address");
- //document.getElementById("strMsg-label").innerHTML = "Network error occurred, please try after later.";
- }
- $.fn.reboot();
- }
- //////////////////////////////////////TODO/////////////////////////////////////
- // Chrome can do share and video using one PeerConnection .
- var bandwidth = {
- screen: 512, // 300kbits minimum
- audio: 80, // 50kbits minimum
- video: 1500 // 256kbits (both min-max)
- };
- //////////////////////////////////////TODO/////////////////////////////////////
- // Chrome can do share and video using one PeerConnection .
- function setLocalDescAndSendMessagePCOffer(sessionDescription) {
- //sessionDescription.sdp = setBandwidth(sessionDescription.sdp);
- sessionDescription.sdp = BandwidthHandler.setApplicationSpecificBandwidth(sessionDescription.sdp, bandwidth, shareFlowing);
- sessionDescription.sdp = BandwidthHandler.setVideoBitrates(sessionDescription.sdp, {min: bandwidth.video, max: bandwidth.video});
- sessionDescription.sdp = BandwidthHandler.setOpusAttributes(sessionDescription.sdp, {
- 'stereo': 0, // to disable stereo (to force mono audio)
- 'sprop-stereo': 1,
- 'maxaveragebitrate': 128 * 1024 * 8, // 500 kbits
- 'maxplaybackrate': 128 * 1024 * 8, // 500 kbits
- 'cbr': 1, // disable cbr
- 'useinbandfec': 1, // use inband fec
- 'usedtx': 1, // use dtx
- 'maxptime': 3
- });
- //sessionDescription.sdp = BandwidthHandler.setOpusAttributes(sessionDescription.sdp);
- // //console.log("peer " + peerId + " offrsdp ", sessionDescription);
- rtcInfo[peerId].setLocalDescription(sessionDescription);
- //////console.log("Sending: SDP");
- //////console.log(sessionDescription);
- //////console.log("peer " + peerId + " offrsdp ", sessionDescription);
- myApp.socketId.send(JSON.stringify({
- "boxPeerId": peerId,
- "request": "offer",
- "peerDescription": sessionDescription,
- "type": "client"
- }));
- }
- function roomnotavilable() {
- $("#login").html("Login");
- if (pendingPresentId != null) {
- chrome.desktopCapture.cancelChooseDesktopMedia(pendingPresentId);
- }
- disconnect();
- document.getElementById("login").innerHTML = 'Login';
- document.getElementById("username").disabled = false;
- document.getElementById("domain").disabled = false;
- }
- function errorCallback(error) {
- //console.error('An error occurred: [CODE ' + error + ']');
- return;
- }
- function showMirroringTimer(counter, mirrorIpAddr) {
- var timerClass = myApp.mirrorUsers[mirrorIpAddr].time + "_timer";
- var mainClass = myApp.mirrorUsers[mirrorIpAddr].time;
- var timer = setInterval(function () {
- $("." + timerClass).text(counter);
- if (counter == 1) {
- delete myApp.mirrorUsers[mirrorIpAddr];
- $("." + mainClass).remove();
- if ($(".allow_present_screen .allow").length == 0) {
- $(".allow_present_screen").hide();
- }
- clearInterval(timer);
- }
- counter--;
- }, 1000);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement