index.html 16.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
<!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;" />&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">
	

	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-公有
		// window.location = url;
		var is_private = false;
		if (checked == 0) {
			is_private = true;
		}
	    let datas = {
	    	meetingName: meetingName,
	    	meetingDetails: meetingDetails,
	    	selfName: selfName,
	    	pwd: pwd,
	    	checked: checked
	    }
	    console.log(JSON.stringify(datas));
		var create = { 
			"request": "create", 
			"room": parseInt(meetingName), 
			"pin": pwd, 
			"description": meetingDetails, 
			"publishers": 5,
			"is_private": is_private,
			"notify_joining":true,
			"bitrate":512000,
			"selfName":selfName
		};
		init(1, 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;
var feeds = [];
 //初始化
function init(status, value) {
	Janus.init({debug: "all", callback: function() {		
	    if(!Janus.isWebrtcSupported()) {
			bootbox.alert("No WebRTC support... ");
			return;
		}
	    janus = new Janus({
			server: server,
			success: function() {
				videoroom(status, value)
			},
			error: function(error) {
				Janus.error(error);
				bootbox.alert(error, function() {
				   window.location.reload();
				});
			},
			destroyed: function() {
				window.location.reload();
			}	
		})
	}
  })
}

function videoroom(status, value) {
	janus.attach({
		plugin: "janus.plugin.videoroom",
		opaqueId: "videoroom-"+Janus.randomString(12),
		success: function(pluginHandle) {
			roomhandler = pluginHandle;
			if (status == 1) {
				creatRoomisExit(value)
			}
			if (status == 2) {
				joinisExit(value)
			}	
		}
	});
}

function creatRoomisExit(create) {
	var exits = {"request": "exists", "room": parseInt(create["room"])};
	roomhandler.send({"message": exits, success: function(result) {
		 var event = result["exists"];
		 if (event) {
			bootbox.alert(create["room"] + "房间已创建");
		 } else {
			creatRoom(create)
		 }
	  }
	})
}

function joinisExit(room) {
	var exits = {"request": "exists", "room":parseInt(room)};
	roomhandler.send({"message": exits, success: function(result) {
		console.log(result)
		 var event = result["exists"];
		 if (!event) {
			bootbox.alert(room + "房间未创建");
		 } else {
			list(room)
		 }
	  }
	})
}

function creatRoom(create) {
	Janus.log("插件 (" + roomhandler.getPlugin() + ", id=" + roomhandler.getId() + ")");
	roomhandler.send({"message": create, success: function(result) {
		var event = result["videoroom"];
		if (event === "created") {
			sessionStorage.setItem("status", 0) 
			sessionStorage.setItem("description", create['selfName'])
			sessionStorage.setItem("room", create['room'])
			sessionStorage.setItem("pin", create['pin'])
			sessionStorage.setItem("checks", create['checks'])
			sessionStorage.setItem("roomname", create['description'])
			location.href ="./home.html";
		} else {
			bootbox.alert("创建会议失败");
			Janus.debug("创建会议失败: " + result["error"]);
			//janus.destroy();
		}
	  }
    });
}


function list(room) {
	var list = {"request": "list"};
	roomhandler.send({"message": list, success: function(result) {
		 var event = result["list"];
		 for(var index in event){
			 if (room == event[index]["room"]) {
				sessionStorage.setItem("roomname", event[index]['description'])
				location.href ="./home.html";
			 }
         }
	  }
    });
}

	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
		}
		init(2, roomNum)
		sessionStorage.setItem("status", 1) 
		sessionStorage.setItem("description", joinName)
		sessionStorage.setItem("room", roomNum)
		sessionStorage.setItem("pin", pwd)
		sessionStorage.setItem("checks", checks)
		
	}

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