WXdraw.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  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. draw_graph('pencil', $('body'));
  397. //剪切板
  398. $('.upload').on('click', function () {
  399. var texts = $(this).attr('data-text');
  400. if (texts == 'uploads') {
  401. $('.mainbox').css({
  402. display: 'block',
  403. });
  404. $('.sbox').css({
  405. display: 'none',
  406. });
  407. }
  408. });
  409. //home 控制home
  410. $('.botmat1img').on('click', function () {
  411. var codes = $(this).attr('data-text');
  412. if (codes == 'home' && isControl) {
  413. wsss.send(ExexuteKeyBoard(3));
  414. } else if (codes == 'return' && isControl) {
  415. wsss.send(ExexuteKeyBoard(4));
  416. } else if (codes == 'gengduo' && isControl) {
  417. wsss.send(ExexuteKeyBoard(187));
  418. }
  419. });
  420. // 高清控制
  421. $('.PictureQuality').on('click', function () {
  422. if (!isControl) {
  423. return;
  424. }
  425. $(this).addClass('avit').siblings().removeClass('avit');
  426. var id = $(this).attr('data-id');
  427. var cmd = {
  428. type: 'switchSharpness',
  429. };
  430. decodeWoker.postMessage(cmd); //通知解码器worker切换分辨率
  431. var buffer = makeSharpness(Number(id));
  432. webSocketWorker.postMessage(buffer);
  433. $('.control-right-img').attr({
  434. 'data-id': '1',
  435. });
  436. $('.leftmains').css({
  437. right: '-4rem',
  438. });
  439. });
  440. var canDraw = false;
  441. //画图形
  442. function draw_graph(graphType) {
  443. //把蒙版放于画板上面
  444. $('#container').css('z-index', 30);
  445. $('#dedit').css('z-index', 20);
  446. // 先画在蒙版上 再复制到画布上
  447. //鼠标按下获取 开始xy开始画图
  448. // var ongoingTouches = [];
  449. var touchstart = function (e) {
  450. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  451. // console.log('🚀 ~ file: WXdraw.js ~ line 244 ~ touchstart ~ e', e);
  452. if (!isControl) {
  453. return;
  454. }
  455. const action = 0;
  456. Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
  457. const x = item.clientX - item.target.getBoundingClientRect().x;
  458. const y = item.clientY - item.target.getBoundingClientRect().y;
  459. return wsss.send(
  460. JSON.stringify({
  461. type: 'event',
  462. data: {
  463. action,
  464. count: e.originalEvent.touches.length,
  465. pointerId: item.identifier,
  466. x: (function () {
  467. return (
  468. resolving
  469. ? x * (window.currentPhoneSize.width / vowidth)
  470. : y * (window.currentPhoneSize.height / voheight)
  471. ).toFixed(2);
  472. })(),
  473. y: (function () {
  474. return (
  475. resolving
  476. ? y * (window.currentPhoneSize.height / voheight)
  477. : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
  478. ).toFixed(2);
  479. })(),
  480. },
  481. }),
  482. );
  483. });
  484. canDraw = true;
  485. };
  486. //鼠标离开 把蒙版canvas的图片生成到canvas中
  487. var touchend = function (e) {
  488. if (!isControl) {
  489. return;
  490. }
  491. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  492. const action = 1;
  493. Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
  494. const x = item.clientX - item.target.getBoundingClientRect().x;
  495. const y = item.clientY - item.target.getBoundingClientRect().y;
  496. return wsss.send(
  497. JSON.stringify({
  498. type: 'event',
  499. data: {
  500. action,
  501. count: e.originalEvent.touches.length,
  502. pointerId: item.identifier,
  503. x: (function () {
  504. return (
  505. resolving
  506. ? x * (window.currentPhoneSize.width / vowidth)
  507. : y * (window.currentPhoneSize.height / voheight)
  508. ).toFixed(2);
  509. })(),
  510. y: (function () {
  511. return (
  512. resolving
  513. ? y * (window.currentPhoneSize.height / voheight)
  514. : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
  515. ).toFixed(2);
  516. })(),
  517. },
  518. }),
  519. );
  520. });
  521. // var touchfor = e.originalEvent.changedTouches; //for 的手指数组
  522. // //是否横屏
  523. // for (var i = 0; i < touchfor.length; i++) {
  524. // // var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
  525. // // var acrossHeightY =
  526. // // videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
  527. // // if (resolving) {
  528. // // var verticalWidthX =
  529. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  530. // // var verticalHeightY =
  531. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  532. // // } else {
  533. // // var verticalWidthX =
  534. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  535. // // var verticalHeightY =
  536. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  537. // // }
  538. // var ping =
  539. // // resolving == 0 ?
  540. // // { "data": { "action": 1, "count": ongoingTouches.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
  541. // {
  542. // data: {
  543. // action: 1,
  544. // count: ongoingTouches.length,
  545. // pointerId: touchfor[i].identifier,
  546. // x: (() =>
  547. // (resolving
  548. // ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
  549. // : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
  550. // ).toFixed(2))(),
  551. // y: (() =>
  552. // (resolving
  553. // ? touchfor[i].pageY *
  554. // (window.currentPhoneSize.height / voheight)
  555. // : (vowidth - touchfor[i].pageX) *
  556. // (window.currentPhoneSize.height / vowidth)
  557. // ).toFixed(2))(),
  558. // },
  559. // type: 'event',
  560. // };
  561. // wsss.send(JSON.stringify(ping));
  562. // ongoingTouches.forEach(function (item, index) {
  563. // if (item.identifier === touchfor[i].identifier) {
  564. // ongoingTouches.splice(index, 1);
  565. // }
  566. // });
  567. // }
  568. canDraw = false;
  569. };
  570. //清空层 云手机超出屏幕的开关
  571. var clearContext = function () {
  572. canDraw = false;
  573. };
  574. // 鼠标移动
  575. var touchmove = function (e) {
  576. e.preventDefault();
  577. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  578. if (!isControl) {
  579. return;
  580. }
  581. const action = 2;
  582. Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
  583. const x = item.clientX - item.target.getBoundingClientRect().x;
  584. const y = item.clientY - item.target.getBoundingClientRect().y;
  585. return wsss.send(
  586. JSON.stringify({
  587. type: 'event',
  588. data: {
  589. action,
  590. count: e.originalEvent.touches.length,
  591. pointerId: item.identifier,
  592. x: (function () {
  593. return (
  594. resolving
  595. ? x * (window.currentPhoneSize.width / vowidth)
  596. : y * (window.currentPhoneSize.height / voheight)
  597. ).toFixed(2);
  598. })(),
  599. y: (function () {
  600. return (
  601. resolving
  602. ? y * (window.currentPhoneSize.height / voheight)
  603. : (vowidth - x) * (window.currentPhoneSize.width / vowidth)
  604. ).toFixed(2);
  605. })(),
  606. },
  607. }),
  608. );
  609. });
  610. // var touchfor = e.originalEvent.targetTouches; //for 的手指数组
  611. // for (var i = 0; i < touchfor.length; i++) {
  612. // // var acrossWidthX = touchfor[i].pageY * (videoHeight / voheight);
  613. // // var acrossHeightY =
  614. // // videoWidth - touchfor[i].pageX * (videoWidth / vowidth);
  615. // // let verticalWidthX = 0;
  616. // // let verticalHeightY = 0;
  617. // // if (resolving) {
  618. // // verticalWidthX =
  619. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  620. // // verticalHeightY =
  621. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  622. // // } else {
  623. // // verticalWidthX =
  624. // // touchfor[i].pageX * (window.currentPhoneSize.width / vowidth);
  625. // // verticalHeightY =
  626. // // touchfor[i].pageY * (window.currentPhoneSize.height / voheight);
  627. // // }
  628. // var ping =
  629. // // resolving == 0 ?
  630. // // { "data": { "action": 2, "count": touchfor.length, "pointerId": touchfor[i].identifier, "x": acrossWidthX.toFixed(2), "y": acrossHeightY.toFixed(2) }, "type": "event" } :
  631. // {
  632. // data: {
  633. // action: 2,
  634. // count: touchfor.length,
  635. // pointerId: touchfor[i].identifier,
  636. // x: (() =>
  637. // (resolving
  638. // ? touchfor[i].pageX * (window.currentPhoneSize.width / vowidth)
  639. // : touchfor[i].pageY * (window.currentPhoneSize.width / voheight)
  640. // ).toFixed(2))(),
  641. // y: (() =>
  642. // (resolving
  643. // ? touchfor[i].pageY *
  644. // (window.currentPhoneSize.height / voheight)
  645. // : (vowidth - touchfor[i].pageX) *
  646. // (window.currentPhoneSize.height / vowidth)
  647. // ).toFixed(2))(),
  648. // },
  649. // type: 'event',
  650. // };
  651. // wsss.send(JSON.stringify(ping));
  652. // }
  653. };
  654. //鼠标离开区域以外 除了涂鸦 都清空
  655. var mouseout = function () {
  656. if (isFiringNoOperationSetTimeout) noOperationSetTimeout()
  657. if (graphType != 'handwriting') {
  658. clearContext();
  659. }
  660. };
  661. $(canvas_bak).off();
  662. $(canvas_bak).on('touchstart', touchstart);
  663. $(canvas_bak).on('touchmove', touchmove);
  664. $(canvas_bak).on('touchend', touchend);
  665. $(canvas_bak).on('mouseout', mouseout);
  666. };
  667. function GetRequest() {
  668. var url = location.search; // 获取url中"?"符后的字串
  669. var obj = new Object();
  670. if (url.indexOf('?') != -1) {
  671. var str = url.substr(1);
  672. strs = str.split('&');
  673. for (var i = 0; i < strs.length; i++) {
  674. obj[strs[i].split('=')[0]] = strs[i].split('=')[1];
  675. }
  676. }
  677. return obj;
  678. }