first commit
This commit is contained in:
129
WebRoot/jsp/visual/CeShiOne.jsp
Normal file
129
WebRoot/jsp/visual/CeShiOne.jsp
Normal file
@ -0,0 +1,129 @@
|
||||
<%@ page language="java" pageEncoding="UTF-8"%>
|
||||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
|
||||
<%@ page import="com.sipai.entity.base.ServerObject"%>
|
||||
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security"%>
|
||||
<!DOCTYPE html>
|
||||
<!-- <html lang="zh-CN"> -->
|
||||
<!-- BEGIN HEAD -->
|
||||
<head>
|
||||
<title><%= ServerObject.atttable.get("TOPTITLE")%></title>
|
||||
<!-- 引用页头及CSS页-->
|
||||
<jsp:include page="/jsp/inc.jsp"></jsp:include>
|
||||
<script type="text/javascript">
|
||||
|
||||
var websocket = null;
|
||||
//websocket接收信息,触发换屏
|
||||
function registerEvent() {
|
||||
websocket.onopen = function (event) {
|
||||
console.log("方案one已连接");
|
||||
}
|
||||
|
||||
websocket.onmessage = function (event) {
|
||||
var gettype = Object.prototype.toString;
|
||||
if (gettype.call(event.data) == "[object Array]") {
|
||||
var json = eval(event.data);
|
||||
console.log("" + json[0].name + "当前分辨率:" +
|
||||
json[0].width + "x" + json[0].height + "");
|
||||
} else {
|
||||
console.log("切换指令:" + event.data + "");
|
||||
if(event.data.indexOf("ceshi") >= 0){
|
||||
if($('body').hasClass('modal-open')){
|
||||
$('#myModal').modal('hide');
|
||||
}else{
|
||||
$('#myModal').modal('show');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
websocket.onclose = function (event) {
|
||||
console.log("方案one已断开");
|
||||
websocket.close();
|
||||
};
|
||||
//连接发生错误的回调方法
|
||||
websocket.onerror = function () {
|
||||
console.log("方案one错误");
|
||||
reconnect();
|
||||
};
|
||||
}
|
||||
|
||||
//setTimeout(function(){location.reload()},3600000); //指定1小时刷新一次
|
||||
//自动重连websocket
|
||||
function reconnect() {
|
||||
var userName = "方案one";
|
||||
if (websocket) {
|
||||
websocket.close();
|
||||
}
|
||||
websocket = new WebSocket('ws://' + window.location.host+ext.contextPath + '/chat?userName=' + userName);
|
||||
websocket.onopen = function (event) {
|
||||
console.log("方案one已连接");
|
||||
}
|
||||
|
||||
websocket.onmessage = function (event) {
|
||||
var gettype = Object.prototype.toString;
|
||||
if (gettype.call(event.data) == "[object Array]") {
|
||||
var json = eval(event.data);
|
||||
console.log("" + json[0].name + "当前分辨率:" +
|
||||
json[0].width + "x" + json[0].height + "");
|
||||
} else {
|
||||
console.log("切换指令:" + event.data + "");
|
||||
if(event.data.indexOf("ceshi") >= 0){
|
||||
if($('body').hasClass('modal-open')){
|
||||
$('#myModal').modal('hide');
|
||||
}else{
|
||||
$('#myModal').modal('show');
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
websocket.onclose = function (event) {
|
||||
websocket.close();
|
||||
};
|
||||
//连接发生错误的回调方法
|
||||
websocket.onerror = function () {
|
||||
websocket.close();
|
||||
};
|
||||
}
|
||||
//websocket触发换屏
|
||||
$(document).ready(function () {
|
||||
if ('WebSocket' in window) {
|
||||
// 创建websocket对象
|
||||
var userName = "方案one";
|
||||
if (websocket) {
|
||||
websocket.close();
|
||||
}
|
||||
websocket = new WebSocket('ws://' + window.location.host+ext.contextPath + '/chat?userName=' + userName);
|
||||
registerEvent();
|
||||
}
|
||||
else {
|
||||
alert('当前浏览器不支持websocket')
|
||||
}
|
||||
$(window).unload(function(){
|
||||
websocket.close();
|
||||
console.log("方案one关闭");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body style="width:100%;height:100%;margin:0;padding:0">
|
||||
<div style="width:100%;height:100%;margin:0;padding:0;" id='content'>
|
||||
<img src="<%=request.getContextPath()%>/IMG/ceshi/ceshione.jpg" style="width:100%;height:100%;"alt="" id="img" />
|
||||
</div>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="CloseModel()"><span aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<h2>测试交互</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user