WXdraw.js 22 KB

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