WXdraw.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. let noOperationSetTimeoutTime = null
  2. let noOperationSetIntervalTime = null
  3. let isFiringNoOperationSetTimeout = false
  4. // 没有任何触碰时会触发该定时器
  5. function noOperationSetTimeout() {
  6. clearTimeout(noOperationSetTimeoutTime)
  7. clearTimeout(noOperationSetIntervalTime)
  8. noOperationSetTimeoutTime = setTimeout(() => {
  9. let index = 10
  10. $.modal({
  11. text: "由于您长时间未操作,将自动断开视频链接(不影响云手机内应用运行)",
  12. buttons: [
  13. { text: "继续操作", className: "default", onClick: function () { noOperationSetTimeout() } },
  14. { text: "退出(10秒)", className: 'operate-time-exit', onClick: function () { quit() } },
  15. ]
  16. });
  17. noOperationSetIntervalTime = setInterval(() => {
  18. if (index <= 0) {
  19. $('.operate-time-exit').text(`退出`)
  20. clearInterval(noOperationSetIntervalTime)
  21. quit()
  22. $.closeModal();
  23. return
  24. }
  25. index--
  26. $('.operate-time-exit').text(`退出(${index}秒)`)
  27. }, 1000)
  28. }, 300000)
  29. }
  30. // 蒙版
  31. var canvas_bak = document.getElementById('box');
  32. var winHeight = window.screen.height - window.innerHeight;
  33. var vowidth = window.screen.width;
  34. var topwinHeightDraw = window.screen.height - window.innerHeight + 30; //计算title top 头部
  35. var numse = window.screen.height; // -winHeight
  36. //计算title top 头部
  37. if (numse <= 70) {
  38. var voheight = window.screen.height - winHeight - 34 - 20;
  39. } else {
  40. var voheight = window.screen.height - topwinHeightDraw - 20;
  41. }
  42. //画笔大小
  43. var resolving = 1; // 1: 竖屏;2:横屏;
  44. var url = window.location.href;
  45. url = url.split('/');
  46. var parameters = GetRequest();
  47. var videoWidth, videoHeight;
  48. var isControl = false; // 是否是观看模式
  49. changIsControl(true);
  50. var isAuth = parameters['authPhone']; // 是否是获取的云手机
  51. var wsss;
  52. var errorTime = 0;
  53. var first = true;
  54. let intervalerPing = null
  55. function changIsControl(value) {
  56. isControl = value;
  57. // if(){}
  58. $('#open-set-phone-size-dialog-btn').attr('hidden', !value);
  59. }
  60. let directivesTimeInterval = 1
  61. // function throttle(fn, delay) {
  62. // var flag = true;
  63. // return () => {
  64. // if (!flag) return;
  65. // flag = false;
  66. // errorTime += delay;
  67. // timer = setTimeout(() => {
  68. // fn();
  69. // flag = true;
  70. // }, delay);
  71. // };
  72. // }
  73. // const throttleDoConnectDirectives = throttle(() => {
  74. // doConnectDirectives();
  75. // }, 100);
  76. function doConnectDirectives() {
  77. videoWidth = Number(resolvingPower) ? Number(resolvingPower) : 720;
  78. videoHeight = videoWidth === 720 ? 1280 : 1920;
  79. wsss = new WebSocket(cUrl);
  80. wsss.binaryType = 'arraybuffer';
  81. wsss.onopen = function () {
  82. $.ajax({
  83. url: baseUrl + '/api/public/v5/pushflow/popup',
  84. headers: {
  85. Authorization: token,
  86. },
  87. type: 'get',
  88. dataType: 'json',
  89. success: function (res) {
  90. let { data } = res
  91. if (data) {
  92. isFiringNoOperationSetTimeout = data
  93. noOperationSetTimeout()
  94. }
  95. },
  96. });
  97. clearInterval(intervalerPing)
  98. // 获取虚拟场景状态
  99. intervalerPing = setInterval(() => {
  100. if (wsss.readyState === 1) {
  101. wsss.send('ping');
  102. } else {
  103. clearInterval(intervalerPing);
  104. }
  105. }, 3000)
  106. errorTime = 0;
  107. var pings = { type: 'getVsStatus' };
  108. wsss.send(JSON.stringify(pings));
  109. var bitRate = {
  110. data: {
  111. bitRate: 1243000,
  112. },
  113. type: 'bitRate',
  114. };
  115. wsss.send(JSON.stringify(bitRate));
  116. // 键盘透传 2 是用云机内置的
  117. wsss.send(JSON.stringify({ data: { type: 2 }, type: 'InputMethod' }));
  118. // // 进入发起询问
  119. // var pings2 = {
  120. // type: 'forwardMsg',
  121. // data: {
  122. // code: '3000',
  123. // userName: username,
  124. // desc: '询问是否有在控制', // 可选
  125. // },
  126. // };
  127. // wsss.send(JSON.stringify(pings2));
  128. wsss.send(
  129. JSON.stringify({
  130. type: 'getPhoneSize',
  131. }),
  132. );
  133. };
  134. wsss.onerror = function (e) {
  135. clearInterval(intervalerPing)
  136. if (!quitBool) return
  137. if (directivesTimeInterval > 7) {
  138. quit();
  139. return
  140. }
  141. // console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
  142. // wsss.close(1006);
  143. // throttle(doConnectDirectives, 100);
  144. // if (errorTime > 1000) {
  145. // quit();
  146. // }
  147. directivesTimeInterval++
  148. // 异常关闭,重连
  149. doConnectDirectives();
  150. // doConnectDirectives();
  151. // throttle(doConnectDirectives, 100);
  152. };
  153. wsss.onclose = function (e) {
  154. // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e);
  155. // new WebSocket(e.)
  156. // doConnectDirectives();
  157. // if (e.code === 1006) {
  158. // // 异常关闭,重连
  159. // throttleDoConnectDirectives();
  160. // // doConnectDirectives();
  161. // // throttle(doConnectDirectives, 100);
  162. // if (errorTime > 1000) {
  163. // quit();
  164. // }
  165. // }
  166. };
  167. wsss.onmessage = function (res) {
  168. var result = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
  169. console.log(
  170. '🚀 ~ file: WXdraw.js ~ line 78 ~ doConnectDirectives ~ result',
  171. result,
  172. );
  173. if (result.type === 'cutting') {
  174. if (result.data.status === 0) {
  175. $.toast('复制成功', 'text');
  176. } else {
  177. $.toast(result.msg, 'text');
  178. }
  179. return;
  180. }
  181. // if (result.type === 'forwardMsgRep') {
  182. // // 当前云机无其他终端在线,获得控制权
  183. // changIsControl(true);
  184. // }
  185. if (result.type === 'downAdnInstallRep') {
  186. $.toast(result.data.msg, 'text', 4000);
  187. }
  188. // if (result.type === 'forwardMsg') {
  189. // /**
  190. // * @type {boolean} isControl 当前是否拥有控制权,初始化时为false
  191. // * @type {string} isAuth 当前云机类型 - huo: 获取的云机,none: 自己的云机
  192. // * @type {string} username 当前登录的双子星账号username
  193. // */
  194. // if (result.data.userName !== username) {
  195. // switch (String(result.data.code)) {
  196. // case '3000': {
  197. // if (isControl) {
  198. // // 回复有控制
  199. // wsss.send(
  200. // JSON.stringify({
  201. // type: 'forwardMsg',
  202. // data: {
  203. // code: '4000',
  204. // userName: username,
  205. // desc: '有控制', // 可选
  206. // },
  207. // }),
  208. // );
  209. // return;
  210. // }
  211. // // 回复有观看
  212. // wsss.send(
  213. // JSON.stringify({
  214. // type: 'forwardMsg',
  215. // data: {
  216. // code: '4100',
  217. // userName: username,
  218. // desc: '有观看', // 可选
  219. // },
  220. // }),
  221. // );
  222. // return;
  223. // }
  224. // case '4000': {
  225. // // console.log(
  226. // // '🚀 ~ file: WXdraw.js ~ line 184 ~ doConnectDirectives ~ isAuth',
  227. // // isAuth,
  228. // // );
  229. // // 当前是获取方
  230. // if (isAuth === 'huo' && isControl) {
  231. // $.confirm(
  232. // '授权方已收回控制权,您进入观看屏幕模式',
  233. // function () {
  234. // //点击确认后的回调函数
  235. // changIsControl(false);
  236. // },
  237. // function () {
  238. // changIsControl(false);
  239. // //点击取消后的回调函数
  240. // quit();
  241. // },
  242. // );
  243. // return;
  244. // }
  245. // if (isAuth === 'shou') {
  246. // // 当前是授权方切没有控制权
  247. // $.confirm(
  248. // '当前云手机正在授控,是否请求获取云手机控制权?',
  249. // function () {
  250. // //点击确认后的回调函数
  251. // wsss.send(
  252. // JSON.stringify({
  253. // type: 'forwardMsg',
  254. // data: {
  255. // code: '5000',
  256. // userName: username,
  257. // desc: '控制权限收回', // 可选
  258. // },
  259. // }),
  260. // );
  261. // changIsControl(true);
  262. // },
  263. // function () {
  264. // //点击取消后的回调函数
  265. // changIsControl(false);
  266. // },
  267. // );
  268. // return;
  269. // }
  270. // }
  271. // case '5000': {
  272. // // if (result.data.username === username) {
  273. // // changIsControl(true);
  274. // // return;
  275. // // }
  276. // if (isAuth === 'huo' && isControl) {
  277. // $.confirm(
  278. // '授权方已收回控制权,您进入观看屏幕模式',
  279. // function () {
  280. // //点击确认后的回调函数
  281. // changIsControl(false);
  282. // },
  283. // function () {
  284. // changIsControl(false);
  285. // //点击取消后的回调函数
  286. // quit();
  287. // },
  288. // );
  289. // return;
  290. // }
  291. // return;
  292. // }
  293. // default: {
  294. // return;
  295. // }
  296. // }
  297. // }
  298. // return;
  299. // }
  300. if (result.type === 'payInitiateEvent') {
  301. // var url = window.location.href;
  302. // url = url.split('/');
  303. // var baseUrl = url[0] + '//' + url[2];
  304. $.ajax({
  305. url: baseUrl + '/api/pay/third/order',
  306. data: JSON.stringify({
  307. orderNum: result.data.orderNum,
  308. orderAmount: result.data.orderAmount,
  309. appKey: result.data.appKey,
  310. }),
  311. type: 'POST',
  312. dataType: 'json',
  313. contentType: 'application/json;charset=UTF-8',
  314. success: function (res) {
  315. if (result.data.payType === 1) {
  316. // 微信
  317. if (window.__wxjs_environment === 'miniprogram') {
  318. // 小程序
  319. // copyUrl(result.data.payUrl);
  320. } else {
  321. window.location.href = result.data.payUrl;
  322. }
  323. } else {
  324. window.location.href = result.data.payUrl;
  325. }
  326. },
  327. });
  328. return;
  329. }
  330. if (result.type === 'getPhoneSize' || result.type === 'setPhoneSize') {
  331. // console.log(result);
  332. if (
  333. window.currentPhoneSize &&
  334. (window.currentPhoneSize.width !==
  335. Math.min(result.data.width, result.data.height) ||
  336. window.currentPhoneSize.height !==
  337. Math.max(result.data.width, result.data.height) ||
  338. window.currentPhoneSize.dpi !== result.data.dpi)
  339. ) {
  340. // 获取到的分辨率与当前分辨率不符
  341. const data = window.phoneSizeList.find(function (v) {
  342. return (
  343. v.width === Math.min(result.data.width, result.data.height) &&
  344. v.height === Math.max(result.data.width, result.data.height) &&
  345. v.dpi === result.data.dpi
  346. );
  347. });
  348. window.currentPhoneSize = data || {
  349. width: Math.min(result.data.width, result.data.height),
  350. height: Math.max(result.data.width, result.data.height),
  351. dpi: result.data.dpi,
  352. };
  353. if (result.type === 'setPhoneSize') {
  354. lastSetPhone = Date.now();
  355. }
  356. // if (result.type === 'getPhoneSize') {
  357. // 上报给后端
  358. $.ajax({
  359. url:
  360. baseUrl +
  361. '/api/resources/v5/machine/resolution/operationResolvingPower',
  362. headers: {
  363. Authorization: token,
  364. },
  365. type: 'post',
  366. dataType: 'json',
  367. contentType: 'application/json; charset=UTF-8',
  368. data: JSON.stringify({
  369. userCardId: window.userCardId,
  370. resolvingPowerId: window.currentPhoneSize.id,
  371. }),
  372. });
  373. }
  374. // }
  375. updateDB(db, storeName, {
  376. id: userCardId,
  377. socketURL: socketURL,
  378. cUrl: cUrl,
  379. cardToken: cardToken,
  380. resolvingPower: resolvingPower,
  381. width: window.currentPhoneSize.width,
  382. height: window.currentPhoneSize.height,
  383. dpi: window.currentPhoneSize.dpi,
  384. });
  385. return;
  386. }
  387. if (result.type === 'reProduceText') {
  388. // 接收到云机剪贴板复制事件
  389. // window.copyToClipboard(result.data.text);
  390. if (navigator.clipboard) {
  391. navigator.clipboard.writeText(result.data.text);
  392. }
  393. }
  394. };
  395. }
  396. $('body').on('click', function () {
  397. draw_graph('pencil', this);
  398. });
  399. //剪切板
  400. $('.upload').on('click', function () {
  401. var texts = $(this).attr('data-text');
  402. if (texts == 'uploads') {
  403. $('.mainbox').css({
  404. display: 'block',
  405. });
  406. $('.sbox').css({
  407. display: 'none',
  408. });
  409. }
  410. });
  411. //home 控制home
  412. $('.botmat1img').on('click', function () {
  413. var codes = $(this).attr('data-text');
  414. if (codes == 'home' && isControl) {
  415. wsss.send(ExexuteKeyBoard(3));
  416. } else if (codes == 'return' && isControl) {
  417. wsss.send(ExexuteKeyBoard(4));
  418. } else if (codes == 'gengduo' && isControl) {
  419. wsss.send(ExexuteKeyBoard(187));
  420. }
  421. });
  422. // 高清控制
  423. $('.PictureQuality').on('click', function () {
  424. if (!isControl) {
  425. return;
  426. }
  427. $(this).addClass('avit').siblings().removeClass('avit');
  428. var id = $(this).attr('data-id');
  429. var cmd = {
  430. type: 'switchSharpness',
  431. };
  432. decodeWoker.postMessage(cmd); //通知解码器worker切换分辨率
  433. var buffer = makeSharpness(Number(id));
  434. webSocketWorker.postMessage(buffer);
  435. $('.control-right-img').attr({
  436. 'data-id': '1',
  437. });
  438. $('.leftmains').css({
  439. right: '-4rem',
  440. });
  441. });
  442. var canDraw = false;
  443. //画图形
  444. var draw_graph = function (graphType) {
  445. //把蒙版放于画板上面
  446. $('#container').css('z-index', 30);
  447. $('#dedit').css('z-index', 20);
  448. // 先画在蒙版上 再复制到画布上
  449. //鼠标按下获取 开始xy开始画图
  450. // var ongoingTouches = [];
  451. var touchstart = function (e) {
  452. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  453. // console.log('🚀 ~ file: WXdraw.js ~ line 244 ~ touchstart ~ e', e);
  454. if (!isControl) {
  455. return;
  456. }
  457. const action = 0;
  458. Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
  459. const x = item.clientX - item.target.getBoundingClientRect().x;
  460. const y = item.clientY - item.target.getBoundingClientRect().y;
  461. return wsss.send(
  462. JSON.stringify({
  463. type: 'event',
  464. data: {
  465. action,
  466. count: e.originalEvent.touches.length,
  467. pointerId: item.identifier,
  468. x: (function () {
  469. return (
  470. resolving
  471. ? x * (window.currentPhoneSize.width / vowidth)
  472. : y * (window.currentPhoneSize.height / voheight)
  473. ).toFixed(2);
  474. })(),
  475. y: (function () {
  476. return (
  477. resolving
  478. ? y * (window.currentPhoneSize.height / voheight)
  479. : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
  480. ).toFixed(2);
  481. })(),
  482. },
  483. }),
  484. );
  485. });
  486. canDraw = true;
  487. };
  488. //鼠标离开 把蒙版canvas的图片生成到canvas中
  489. var touchend = function (e) {
  490. if (!isControl) {
  491. return;
  492. }
  493. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  494. const action = 1;
  495. Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
  496. const x = item.clientX - item.target.getBoundingClientRect().x;
  497. const y = item.clientY - item.target.getBoundingClientRect().y;
  498. return wsss.send(
  499. JSON.stringify({
  500. type: 'event',
  501. data: {
  502. action,
  503. count: e.originalEvent.touches.length,
  504. pointerId: item.identifier,
  505. x: (function () {
  506. return (
  507. resolving
  508. ? x * (window.currentPhoneSize.width / vowidth)
  509. : y * (window.currentPhoneSize.height / voheight)
  510. ).toFixed(2);
  511. })(),
  512. y: (function () {
  513. return (
  514. resolving
  515. ? y * (window.currentPhoneSize.height / voheight)
  516. : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
  517. ).toFixed(2);
  518. })(),
  519. },
  520. }),
  521. );
  522. });
  523. // var touchfor = e.originalEvent.changedTouches; //for 的手指数组
  524. // //是否横屏
  525. // for (var i = 0; i < touchfor.length; i++) {
  526. // // var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
  527. // // var acrossHeightY =
  528. // // videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
  529. // // if (resolving) {
  530. // // var verticalWidthX =
  531. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  532. // // var verticalHeightY =
  533. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  534. // // } else {
  535. // // var verticalWidthX =
  536. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  537. // // var verticalHeightY =
  538. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  539. // // }
  540. // var ping =
  541. // // resolving == 0 ?
  542. // // { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
  543. // {
  544. // data: {
  545. // action: 1,
  546. // count: ongoingTouches.length,
  547. // pointerId: touchfor[i].identifier,
  548. // x: (() =>
  549. // (resolving
  550. // ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
  551. // : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
  552. // ).toFixed(2))(),
  553. // y: (() =>
  554. // (resolving
  555. // ? touchfor[i].pageY *
  556. // (window.currentPhoneSize.height / voheight)
  557. // : (vowidth - touchfor[i].pageX) *
  558. // (window.currentPhoneSize.height / vowidth)
  559. // ).toFixed(2))(),
  560. // },
  561. // type: 'event',
  562. // };
  563. // wsss.send(JSON.stringify(ping));
  564. // ongoingTouches.forEach(function (item, index) {
  565. // if (item.identifier === touchfor[i].identifier) {
  566. // ongoingTouches.splice(index, 1);
  567. // }
  568. // });
  569. // }
  570. canDraw = false;
  571. };
  572. //清空层 云手机超出屏幕的开关
  573. var clearContext = function () {
  574. canDraw = false;
  575. };
  576. // 鼠标移动
  577. var touchmove = function (e) {
  578. e.preventDefault();
  579. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  580. if (!isControl) {
  581. return;
  582. }
  583. const action = 2;
  584. Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
  585. const x = item.clientX - item.target.getBoundingClientRect().x;
  586. const y = item.clientY - item.target.getBoundingClientRect().y;
  587. return wsss.send(
  588. JSON.stringify({
  589. type: 'event',
  590. data: {
  591. action,
  592. count: e.originalEvent.touches.length,
  593. pointerId: item.identifier,
  594. x: (function () {
  595. return (
  596. resolving
  597. ? x * (window.currentPhoneSize.width / vowidth)
  598. : y * (window.currentPhoneSize.height / voheight)
  599. ).toFixed(2);
  600. })(),
  601. y: (function () {
  602. return (
  603. resolving
  604. ? y * (window.currentPhoneSize.height / voheight)
  605. : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
  606. ).toFixed(2);
  607. })(),
  608. },
  609. }),
  610. );
  611. });
  612. // var touchfor = e.originalEvent.targetTouches; //for 的手指数组
  613. // for (var i = 0; i < touchfor.length; i++) {
  614. // // var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
  615. // // var acrossHeightY =
  616. // // videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
  617. // // let verticalWidthX = 0;
  618. // // let verticalHeightY = 0;
  619. // // if (resolving) {
  620. // // verticalWidthX =
  621. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  622. // // verticalHeightY =
  623. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  624. // // } else {
  625. // // verticalWidthX =
  626. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  627. // // verticalHeightY =
  628. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  629. // // }
  630. // var ping =
  631. // // resolving == 0 ?
  632. // // { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
  633. // {
  634. // data: {
  635. // action: 2,
  636. // count: touchfor.length,
  637. // pointerId: touchfor[i].identifier,
  638. // x: (() =>
  639. // (resolving
  640. // ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
  641. // : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
  642. // ).toFixed(2))(),
  643. // y: (() =>
  644. // (resolving
  645. // ? touchfor[i].pageY *
  646. // (window.currentPhoneSize.height / voheight)
  647. // : (vowidth - touchfor[i].pageX) *
  648. // (window.currentPhoneSize.height / vowidth)
  649. // ).toFixed(2))(),
  650. // },
  651. // type: 'event',
  652. // };
  653. // wsss.send(JSON.stringify(ping));
  654. // }
  655. };
  656. //鼠标离开区域以外 除了涂鸦 都清空
  657. var mouseout = function () {
  658. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  659. if (graphType != 'handwriting') {
  660. clearContext();
  661. }
  662. };
  663. $(canvas_bak).off();
  664. $(canvas_bak).on('touchstart', touchstart);
  665. $(canvas_bak).on('touchmove', touchmove);
  666. $(canvas_bak).on('touchend', touchend);
  667. $(canvas_bak).on('mouseout', mouseout);
  668. };
  669. function GetRequest() {
  670. var url = location.search; // 获取url中"?"符后的字串
  671. var obj = new Object();
  672. if (url.indexOf('?') != -1) {
  673. var str = url.substr(1);
  674. strs = str.split('&');
  675. for (var i = 0; i < strs.length; i++) {
  676. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  677. }
  678. }
  679. return obj;
  680. }