123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- //蒙版
- var canvas_bak = document.getElementById("box");
- var winHeight = window.screen.height - window.innerHeight;
- var vowidth = window.screen.width;
- var topwinHeightDraw = window.screen.height - window.innerHeight + 30; // 计算title top 头部
- var numse = window.screen.height;
- // 计算title top 头部
- if (numse <= 70) {
- var voheight = window.screen.height - winHeight - 34 - 20
- } else {
- var voheight = window.screen.height - topwinHeightDraw - 20
- }
- // 画笔大小
- var resolving;
- var url = window.location.href;
- url = url.split('/');
- var parameters = GetRequest();
- var form = {};
- form.clientType = parameters["clientType"];
- form.cardIp = parameters["cardIp"];
- form.port = parameters["port"];
- form.sn = parameters["sn"];
- form.username = parameters["username"];
- form.userCardId = parameters["userCardId"];
- form.ip = parameters["ip"];
- var cUrl = "ws://192.168.199.243/card?cardIp=" + form.ip;
- var wsss = new WebSocket(cUrl);
- wsss.binaryType = 'arraybuffer';
- wsss.onopen = function () {
- var pings = {
- "event": "getScreenStatus"
- }
- wsss.send(JSON.stringify(pings));
- var bitRate = {
- "data": {
- "bitRate": 2243000
- },
- "event": "bitRate"
- }
- wsss.send(ExexuteMove(JSON.stringify(bitRate), form.sn))
- };
- wsss.onclose = function (event) {
- console.log("onclose==============");
- };
- wsss.onerror = function (event) {
- console.log("onerror==============");
- };
- $('#box').on("click", function () {
- draw_graph('pencil', this)
- })
- //剪切板
- $(".upload").on("click", function () {
- var texts = $(this).attr("data-text")
- if (texts == "uploads") {
- $(".mainbox").css({
- "display": "block"
- })
- $(".sbox").css({
- "display": "none"
- })
- }
- })
- //home 控制home
- $(".botmat1img").on("click", function () {
- var codes = $(this).attr("data-text")
- if (codes == "home") {
- wsss.send(ExexuteKeyBoard(3), form.sn);
- } else if (codes == "return") {
- wsss.send(ExexuteKeyBoard(4), form.sn);
- } else if (codes == "gengduo") {
- wsss.send(ExexuteKeyBoard(187), form.sn);
- }
- })
- //高清控制
- $(".PictureQuality").on("click", function () {
- $(this).addClass("avit").siblings().removeClass('avit')
- var id = $(this).attr("data-id")
- var bitRate = {
- "data": {
- "bitRate": id
- },
- "event": "bitRate"
- }
- wsss.send(ExexuteMove(JSON.stringify(bitRate), form.sn))
- })
- //画图形
- var draw_graph = function (graphType, obj) {
- //把蒙版放于画板上面
- $("#container").css("z-index", 30);
- $("#dedit").css("z-index", 20);
- var canDraw = false;
- //鼠标按下获取 开始xy开始画图
- var touchstart = function (e) {
- $('.control-right-img').attr({
- "data-id": "2"
- })
- $(".leftmains").css({
- "right": "-4rem"
- })
- var touchfor = e.originalEvent.targetTouches; //for 的手指数组
- //是否横屏
- if (resolving == 0) {
- var ping;
- for (var i = 0; i < touchfor.length; i++) {
- var cawidthXs = touchfor[i].pageY * (1280 / voheight)
- var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
- ping = {
- "data": {
- "action": 0,
- "count": touchfor.length,
- "pointerId": i,
- "x": cawidthXs.toFixed(2),
- "y": caheightYs.toFixed(2)
- },
- "event": "0"
- }
- }
- wsss.send(ExexuteMove(JSON.stringify(ping), form.sn))
- } else {
- var ping;
- for (var i = 0; i < touchfor.length; i++) {
- var cawidthXs = touchfor[i].pageX * (720 / vowidth)
- var caheightYs = touchfor[i].pageY * (1280 / voheight)
- ping = {
- "data": {
- "action": 0,
- "count": touchfor.length,
- "pointerId": i,
- "x": cawidthXs.toFixed(2),
- "y": caheightYs.toFixed(2)
- },
- "event": "0"
- }
- }
- wsss.send(ExexuteMove(JSON.stringify(ping), form.sn));
- }
- canDraw = true;
- };
- //鼠标离开 把蒙版canvas的图片生成到canvas中
- var touchend = function (e) {
- var touchfor = e.originalEvent.changedTouches; //for 的手指数组
- //是否横屏 morePortionUp
- if (resolving == 0) {
- var ping;
- for (var i = 0; i < touchfor.length; i++) {
- var cawidthXs = touchfor[i].pageY * (1280 / voheight);
- var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth);
- ping = {
- "data": {
- "action": 1,
- "count": touchfor.length,
- "pointerId": i,
- "x": cawidthXs.toFixed(2),
- "y": caheightYs.toFixed(2)
- },
- "event": "1"
- }
- }
- wsss.send(ExexuteMove(JSON.stringify(ping), form.sn));
- } else {
- var ping;
- for (var i = 0; i < touchfor.length; i++) {
- var cawidthXs = touchfor[i].pageX * (720 / vowidth);
- var caheightYs = touchfor[i].pageY * (1280 / voheight);
- ping = {
- "data": {
- "action": 1,
- "count": touchfor.length,
- "pointerId": i,
- "x": cawidthXs.toFixed(2),
- "y": caheightYs.toFixed(2)
- },
- "event": "1"
- }
- }
- wsss.send(ExexuteMove(JSON.stringify(ping), form.sn))
- }
- canDraw = false;
- };
- //清空层 云手机超出屏幕的开关
- var clearContext = function () {
- canDraw = false;
- }
- // 鼠标移动
- var touchmove = function (e) {
- e = e || window.event;
- var touchfor = e.originalEvent.targetTouches; //for 的手指数组
- var ping;
- //是否横屏 morePortionMove
- if (resolving == 0) {
- for (var i = 0; i < touchfor.length; i++) {
- var cawidthXs = touchfor[i].pageY * (1280 / voheight)
- var caheightYs = 720 - touchfor[i].pageX * (720 / vowidth)
- ping = {
- "data": {
- "action": 2,
- "count": touchfor.length,
- "pointerId": i,
- "x": cawidthXs.toFixed(2),
- "y": caheightYs.toFixed(2)
- },
- "event": "2"
- }
- }
- wsss.send(ExexuteMove(JSON.stringify(ping), form.sn))
- } else {
- var ping;
- for (var i = 0; i < touchfor.length; i++) {
- var cawidthXs = touchfor[i].pageX * (720 / vowidth);
- var caheightYs = touchfor[i].pageY * (1280 / voheight);
- ping = {
- "data": {
- "action": 2,
- "count": touchfor.length,
- "pointerId": i,
- "x": cawidthXs.toFixed(2),
- "y": caheightYs.toFixed(2)
- },
- "event": "2"
- }
- }
- wsss.send(ExexuteMove(JSON.stringify(ping), form.sn));
- };
- };
- //鼠标离开区域以外 除了涂鸦 都清空
- var mouseout = function () {
- if (graphType != 'handwriting') {
- clearContext();
- }
- }
- $(canvas_bak).unbind();
- $(canvas_bak).bind('touchstart', touchstart);
- $(canvas_bak).bind('touchmove', touchmove);
- $(canvas_bak).bind('touchend', touchend);
- $(canvas_bak).bind('mouseout', mouseout);
- }
- // 获取url中"?"符后的字串
- function GetRequest() {
- var url = location.search;
- var obj = new Object();
- if (url.indexOf("?") != -1) {
- var str = url.substr(1);
- strs = str.split("&");
- for (var i = 0; i < strs.length; i++) {
- obj[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
- }
- }
- return obj;
- }
|