index.html 15.3 KB
<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<title>视频会议-登陆</title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/cerulean/bootstrap.min.css" type="text/css"/>

	<!--图标-->
	<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
	
	<!--布局框架-->
	<link rel="stylesheet" type="text/css" href="css/util.css">
	
	<!--主要样式-->
	<link rel="stylesheet" type="text/css" href="css/main.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>

<body>

<div class="login">
	<div class="container-login100">
		<div class="wrap-login100">
			<div class="login100-pic js-tilt" data-tilt>
				<span style="position: absolute;left: 28%;top: 32%;font-size: 32px;color: #FFFFFF;">统一通信视频会议系统</span>
				<img src="img/loginBanner.png" alt="IMG">
			</div>

			<form class="login100-form validate-form">
				<div class="container1">
					<div class="login_body " >
						<div class="login_form l_float" >
		                    <div class="login_top">
		                        <div class="login_tags b_clear">
		                        	<div class="top_tag l_float img_title"  onClick="HostLogin()" style="margin-left: 60px;">
		                        		<img src="img/icon-speaker.png" style="height: 32px;width: 32px;margin-top: 12px;">
		                            	<p>主持人</p>
		                        	</div>
		                        	<div class="top_tag r_float img_title"  onClick="Joiner()" style="margin-right: 60px;">
		                        		<img src="img/icon-user.png" style="height: 32px;width: 32px;margin-top: 12px;">
		                            	<p>参与者</p>
		                            </div>
		                        </div>
		                    </div>
		                    <div style="margin-left: 40px;margin-right: 40px;">
		                    	<div class="typeLine" id="type_line"></div>
			                    <div class="login_con"> <!--主持人-->
			                    	<div class="login_input">
			                    		<span>会议名称</span>
			                    		<input name="" type="text" placeholder="请输入会议名称" style="margin-left: 20px;" id="meeting_name" />
			                    	</div>
			                    	<div class="login_input">
			                    		<span>会议描述</span>
			                    		<input name="" type="text" placeholder="请输入会议内容" style="margin-left: 20px;" id="meeting_details" />
			                    	</div>
			                    	<div class="login_input">
			                    		<span>你的名字</span>
			                    		<input name="" type="text" placeholder="请输入你的名字" style="margin-left: 20px;" id="self_name" />
			                    	</div>
			                    	<div class="login_input">
			                    		<span>是否私有</span>
			                    		<label style="margin-left: 19px;"><input name="isPrivate" type="radio" value="0"  style="margin-left: 5px;" />&nbsp;&nbsp;私有</label>
			                    		<label style="margin-left: 19px;"><input name="isPrivate" type="radio" value="1"  style="margin-left: 5px;" checked/>&nbsp;&nbsp;公有</label>
			                    	</div>
			                    	<div class="login_input">
			                    		<span>房间密码</span>
			                    		<input type="password" id="p1" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(1)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p2" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(2)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p3" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(3)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p4" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(4)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p5" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(5)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p6" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(6)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
			                    	</div>
			                    	<!-- <div class="login_submit">
			                    		
			                    	</div> -->
			                    	<button type="button" class="login_submit" onclick="createMeeting();">创建会议</button>
			                    </div>

			                    <div class="login_con hidden"> <!--参会者-->
			                        <div class="login_input">
			                    		<span>你的名字</span>
			                    		<input name="" type="text" placeholder="请输入你的名字" style="margin-left: 20px;" id="join_name" />
			                    	</div>
			                    	<div class="login_input">
			                    		<span>房间号码</span>
			                    		<input name="" type="text" placeholder="请输入房间号码" style="margin-left: 20px;" id="room_num" />
			                    	</div>
			                    	<div class="login_input">
			                    		<span>房间密码</span>
			                    		<input type="password" id="p7" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(7)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p8" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(8)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p9" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(9)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p10" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(10)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p11" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(11)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1);; opacity: .5;text-align: center;">
										<input type="password" id="p12" namme="" oninput="if(value.length>1)value=value.slice(0,1)" class="pwd_input" onkeypress="keypress(12)" value="" style="width: 30px; border: 1px solid rgba(219,219,219,1); ; opacity: .5;text-align: center;">
			                    	</div>
			                    	<div class="login_input">
			                    		<input type="radio" name="box" value="Mute"  />&nbsp;&nbsp;入会时静音
			                    		<input type="radio" name="box" value="CloseCamera" style="margin-left: 21px;" />&nbsp;&nbsp;入会时关闭摄像头
			                    	</div>
			                    	<button type="button" class="login_submit" onclick="joinMeeting();">加入会议</button>
			                    </div>
		                    </div>
		                </div>
	            	</div>
            	</div>
			</form>
		</div>
	</div>
</div>
<script src="js/login.js"></script> 
<script src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/webrtc-adapter/6.4.0/adapter.min.js" ></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.blockUI/2.70/jquery.blockUI.min.js" ></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.1.0/bootbox.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js"></script>
<script type="text/javascript" src="js/janus.js"></script>
<script type="text/javascript" src="js/util.js"></script>

<script type="text/javascript">
	

	window.onload = function() {
	    window.onkeydown = function() {
	        if (event.code == "Backspace") {
	            var eles = document.getElementsByClassName("pwd_input");
	            for (var i = 0; i < eles.length; i++) {
	                if (eles[i] == document.activeElement) {
	                    if (i == 0) {
	                        break;
	                    }
	                    console.log(eles[i].value)
	                    if (eles[i].value == "") {
	                        eles[i - 1].value = "";
	                        eles[i - 1].name = "";
	                        eles[i - 1].focus();
	                    }
	                    break;
	                }
	            }
	        }
	    }

	    var eles = document.getElementsByClassName("pwd_input");
	    for (var i = 0; i < eles.length; i++) {
	        var ele = eles[i];
	        ele.onfocus = function() {
	            var str = this.id
	            var vv = str.substr(1, str.length);
	            var a = parseInt(vv);
	            if (this.name == "") {
	                jumHead(a);
	            } else if (this.name != "") {
	                jumEnd(a)
	            }
	        }
		}
		
	}

	function jumHead(n) {
	    for (var j = 1; j < n; j++) {
	        var v1 = document.getElementById("p" + j);
	        if (v1.name == "") {
	            console.log(this)
	            v1.focus();
	            break;
	        }
	    }
	}

	function jumEnd(n) {
	    for (var j = n; j < 7; j++) {
	        var v1 = document.getElementById("p" + j);
	        if (j == 6) {
	            v1.focus();
	            break;
	        }
	        if (v1.value == "") {
	            v1.focus();
	            break;
	        }
	    }
	}

	function keypress(val) {
	    var ev = window.event;
	    var nowindex = val
	    var nextindex = val + 1;
	    if (nextindex == 7) {
	        var inputele = document.getElementById("p" + nowindex);
	        inputele.value = ev.key;
	        inputele.blur();
	        return;
		}
		if (nextindex == 13) {
	        var inputele = document.getElementById("p" + nowindex);
	        inputele.value = ev.key;
	        inputele.blur();
	        return;
	    }

	    if (nextindex == 13) {
	        var inputele = document.getElementById("p" + nowindex);
	        inputele.value = ev.key;
	        inputele.blur();
	        return;
	    }

	    var inputelenow = document.getElementById("p" + nowindex);
	    inputelenow.name = ev.key;
	    var inputele = document.getElementById("p" + nextindex);
	    inputele.focus();
	}

	function copyText() {
	    console.log("copyText");
	    var canvas = document.getElementById("canvas");
	    var ctx = canvas.getContext("2d");
	    console.log(ctx);
	    //      ctx.rect(20,20,150,100);
	    //      ctx.stroke();
	    var hh = 20;
	    for (var i = 0; i < 6; i++) {

	        var xx = 20 * i + hh;

	        ctx.rect(20 * i + 20, 10, 20, 20);
	        ctx.stroke();
	    }

	}

	function drawrect() {
	    console.log("drawrect");
	    var canvas = document.getElementById("canvas");
	    var ctx = canvas.getContext("2d");
	    ctx.fillrect(0, 0, 100, 100);

	}

	function createMeeting(){
		var meetingName = document.getElementById("meeting_name").value;
		var meetingDetails = document.getElementById("meeting_details").value;
		var selfName = document.getElementById("self_name").value;
		var pwd = "";
		for (var i = 1; i <= 6; i++) {
			var singlePwd = document.getElementById('p' + i).value;
			pwd += singlePwd;
		}
		var checked = $('input:radio:checked').val();  //0-私有	1-公有
		var is_private = (checked == 0) ? true: false;
		var create = { 
			"request": "create", 
			"room": parseInt(meetingName), 
			"pin": pwd, 
			"description": meetingDetails, 
			"publishers": 5,
			"is_private": is_private,
			"notify_joining":true,
			"bitrate":512000			
		};
		sessionStorage.setItem("description", selfName)
		sessionStorage.setItem("room", create['room'])
		sessionStorage.setItem("pin", create['pin'])
		init1(create)

	}
var server = "null";
if(window.location.protocol === 'http:')
	server = "https://janusctest.uccc.cc:24000/janus";
else
    server = "https://janusctest.uccc.cc:24000/janus";
var janus = null;
var roomhandler = null;

function init1(create) {
	//初始化
	init(server, janus, (j) => {
		janus = j;
		//创建句柄
		attach(j, (handler) => {
			roomhandler = handler;
			//房间是否存在
			exit(handler, parseInt(create["room"]), (event) => {
				if (event) {
					bootbox.alert(create["room"] + "房间已创建");
				} else {
					//不存在,创建会议
					creatRoom(handler, create, (event) => {
						if (event === "created") {
							location.href ="./home.html";
						} else {
							bootbox.alert("创建会议失败");
							Janus.debug("创建会议失败: " + event["error"]);
							j.destroy();
						}
					})
				}})
		})
	}, (error) => {
		Janus.error(error);
		bootbox.alert(error, function() {
		    window.location.reload();
		});
	}, () => {
		window.location.reload();
	})
}



function init2(room) {
	//初始化
	init(server, janus, (j) => {
		janus = j;
		//创建句柄
		attach(j, (handler) => {
			roomhandler = handler;
			//房间是否存在
			exit(handler, parseInt(room), (event) => {
				if (!event) {
					bootbox.alert(room + "房间未创建");
				} else {
					location.href ="./home.html";
				}
			})
		})
	}, (error) => {
		Janus.error(error);
		bootbox.alert(error, function() {
		    window.location.reload();
		});
	}, () => {
		window.location.reload();
	})
}
	function joinMeeting() {
		var joinName = document.getElementById("join_name").value;
		var roomNum = document.getElementById("room_num").value;
		var pwd = "";
		for (var i = 7; i <= 12; i++) {
			var singlePwd = document.getElementById('p' + i).value;
			pwd += singlePwd;
		}
		var checks = $('input:radio[name="box"]:checked').val();
        let datas = {
        	joinName: joinName,
        	roomNum: roomNum,
        	pwd: pwd,
        	checks: checks
		}
		init2(roomNum)
		sessionStorage.setItem("description", joinName)
		sessionStorage.setItem("room", roomNum)
		sessionStorage.setItem("pin", pwd)
		sessionStorage.setItem("checks", checks)		
	}

</script>
</body>
</html>