rx.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <html>
  2. <meta name="viewport" content="width=device-width, initial-scale=1">
  3. <head>
  4. <title>QuickSend RX</title>
  5. <link rel="stylesheet" href="tocas.css">
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
  7. <script type="text/javascript" src="js/grid.js"></script>
  8. <script type="text/javascript" src="js/version.js"></script>
  9. <script type="text/javascript" src="js/detector.js"></script>
  10. <script type="text/javascript" src="js/formatinf.js"></script>
  11. <script type="text/javascript" src="js/errorlevel.js"></script>
  12. <script type="text/javascript" src="js/bitmat.js"></script>
  13. <script type="text/javascript" src="js/datablock.js"></script>
  14. <script type="text/javascript" src="js/bmparser.js"></script>
  15. <script type="text/javascript" src="js/datamask.js"></script>
  16. <script type="text/javascript" src="js/rsdecoder.js"></script>
  17. <script type="text/javascript" src="js/gf256poly.js"></script>
  18. <script type="text/javascript" src="js/gf256.js"></script>
  19. <script type="text/javascript" src="js/decoder.js"></script>
  20. <script type="text/javascript" src="js/qrcode.js"></script>
  21. <script type="text/javascript" src="js/findpat.js"></script>
  22. <script type="text/javascript" src="js/alignpat.js"></script>
  23. <script type="text/javascript" src="js/databr.js"></script>
  24. <script type="text/javascript">
  25. function qdecode(){
  26. var result = qrcode.decode();
  27. if (result.includes("imuslab.com")){
  28. window.location.replace(result);
  29. }else{
  30. alert(result);
  31. }
  32. }
  33. </script>
  34. </head>
  35. <body>
  36. <div class="ts inverted heading fluid slate" style="background-color:#2c2835;color:white;">
  37. <span class="large header">Quick Send System</span>
  38. <span class="description">Send data between mobile and laptops.<br> Powered by IMUS Laboratory</span>
  39. <div class="ts bottom attached tabbed menu" style="color:white;">
  40. <a class="item" href="index.php" style="color:#9d9ca3;">Text</a>
  41. <a class="item" href="file.php" style="color:#9d9ca3;">Files</a>
  42. <a class="active item" href="rx.php" style="">Receive</a>
  43. <!-- <a class="item" href="img.php" style="color:#9d9ca3;">Image</a> -->
  44. </div>
  45. </div>
  46. <div class="ts container">
  47. <br><br>
  48. <div class="ts stackable grid">
  49. <div class="four wide column" align="center">
  50. <h4>QuickSend ID</h4>
  51. <div class="ts tiny statistic" onClick="//cloneCode();">
  52. <div class="label">Latest QSCode Number</div>
  53. <div class="value" id="lcode"><?php
  54. $max = 0;
  55. foreach (new DirectoryIterator('Memo/') as $fileInfo) {
  56. if ($fileInfo->isDot()) continue;
  57. $current = pathinfo($fileInfo->getFilename())['filename'];
  58. if (!is_numeric($current)) continue;
  59. if ($current > $max) $max = $current;
  60. }
  61. echo $max;
  62. ?></div>
  63. </div>
  64. <button id="viewbtn"class="ts basic primary fluid button" style="" onclick="view_latest();" >View Latest</button>
  65. <div class="ts horizontal divider">or </div>
  66. <div class="ts fluid input">
  67. <input type="text" id="mid" placeholder="Memo ID" style="width:100%;">
  68. </div>
  69. <button id="viewbtn"class="ts basic fluid button" onclick="manual_redirect();" >View Share Code</button>
  70. </div>
  71. <div class="twelve wide column">
  72. <h4>QR-Code ID</h4>
  73. <form>
  74. <div>
  75. <input class="ts button" type="file" accept="image/*" id="file-input" capture="camera">
  76. </div>
  77. </form>
  78. <canvas id="qr-canvas" width="256px" height="256px" style="display:none;"></canvas>
  79. <canvas id="preview-canvas" width="256px" height="256px"></canvas>
  80. <div class="ts container" align="right">
  81. <button class="ts basic button" onclick="qdecode()">Decode</button>
  82. </div>
  83. </div>
  84. </div>
  85. <br><br><br><br><br><br>
  86. <div style="position: fixed;
  87. z-index: 100;
  88. bottom: 0;
  89. left: 0;
  90. width: 100%;
  91. background-color:#2c2835;
  92. color:white;">
  93. <div class="ts container">
  94. <img class="ts tiny right floated image" src="img/cube.png"></img>
  95. </div>
  96. <div align="left" class="ts container">
  97. <br>
  98. CopyRight IMUS Laboratory 2021, All right reserved.
  99. </div>
  100. </div>
  101. </div>
  102. <script>
  103. $("#viewbtn").keyup(function(event) {
  104. if (event.keyCode == 13) {
  105. manual_redirect();
  106. }
  107. });
  108. function view_latest(){
  109. var latestCode = $("#lcode").text().trim();
  110. $("#mid").val(latestCode);
  111. manual_redirect();
  112. }
  113. function resizeCanvasImage(img, canvas, maxWidth, maxHeight) {
  114. var imgWidth = img.width,
  115. imgHeight = img.height;
  116. var ratio = 1, ratio1 = 1, ratio2 = 1;
  117. ratio1 = maxWidth / imgWidth;
  118. ratio2 = maxHeight / imgHeight;
  119. // Use the smallest ratio that the image best fit into the maxWidth x maxHeight box.
  120. if (ratio1 < ratio2) {
  121. ratio = ratio1;
  122. }
  123. else {
  124. ratio = ratio2;
  125. }
  126. var canvasContext = canvas.getContext("2d");
  127. var canvasCopy = document.createElement("canvas");
  128. var copyContext = canvasCopy.getContext("2d");
  129. var canvasCopy2 = document.createElement("canvas");
  130. var copyContext2 = canvasCopy2.getContext("2d");
  131. canvasCopy.width = imgWidth;
  132. canvasCopy.height = imgHeight;
  133. copyContext.drawImage(img, 0, 0);
  134. // init
  135. canvasCopy2.width = imgWidth;
  136. canvasCopy2.height = imgHeight;
  137. copyContext2.drawImage(canvasCopy, 0, 0, canvasCopy.width, canvasCopy.height, 0, 0, canvasCopy2.width, canvasCopy2.height);
  138. var rounds = 2;
  139. var roundRatio = ratio * rounds;
  140. for (var i = 1; i <= rounds; i++) {
  141. console.log("Step: "+i);
  142. // tmp
  143. canvasCopy.width = imgWidth * roundRatio / i;
  144. canvasCopy.height = imgHeight * roundRatio / i;
  145. copyContext.drawImage(canvasCopy2, 0, 0, canvasCopy2.width, canvasCopy2.height, 0, 0, canvasCopy.width, canvasCopy.height);
  146. // copy back
  147. canvasCopy2.width = imgWidth * roundRatio / i;
  148. canvasCopy2.height = imgHeight * roundRatio / i;
  149. copyContext2.drawImage(canvasCopy, 0, 0, canvasCopy.width, canvasCopy.height, 0, 0, canvasCopy2.width, canvasCopy2.height);
  150. } // end for
  151. // copy back to canvas
  152. canvas.width = imgWidth * roundRatio / rounds;
  153. canvas.height = imgHeight * roundRatio / rounds;
  154. canvasContext.drawImage(canvasCopy2, 0, 0, canvasCopy2.width, canvasCopy2.height, 0, 0, canvas.width, canvas.height);
  155. }
  156. $(function() {
  157. $('#file-input').change(function(e) {
  158. var file = e.target.files[0],
  159. imageType = /image.*/;
  160. if (!file.type.match(imageType))
  161. return;
  162. var reader = new FileReader();
  163. reader.onload = fileOnload;
  164. reader.readAsDataURL(file);
  165. });
  166. function fileOnload(e) {
  167. var $img = $('<img>', { src: e.target.result });
  168. $img.load(function() {
  169. var canvas = $('#qr-canvas')[0];
  170. var context = canvas.getContext('2d');
  171. canvas.width = this.naturalWidth;
  172. canvas.height = this.naturalHeight;
  173. context.drawImage(this, 0, 0);
  174. //grab the context from your destination canvas
  175. var pcanvas = $('#preview-canvas')[0];
  176. var destCtx = pcanvas.getContext('2d');
  177. //call its drawImage() function passing it the source canvas directly
  178. destCtx.drawImage(canvas, 0, 0, 256, 256 * this.height / this.width);
  179. });
  180. }
  181. });
  182. function manual_redirect(){
  183. var id = $("#mid").val();
  184. window.location.replace("http://imuslab.com/qs/display.php?id=" + id);
  185. }
  186. function cloneCode(){
  187. $("#mid").val($("#lcode").html());
  188. }
  189. </script>
  190. </body>
  191. </html>