qr.html 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>QR Code Generator</title>
  7. <link rel="icon" type="image/png" href="/favicon.png" />
  8. <!-- QR Code -->
  9. <script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
  10. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  11. <!-- css -->
  12. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/5.0.2/tocas.min.css">
  13. <script src="https://cdnjs.cloudflare.com/ajax/libs/tocas-ui/5.0.2/tocas.min.js"></script>
  14. <link rel="preconnect" href="https://fonts.googleapis.com">
  15. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  16. <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&display=swap" rel="stylesheet">
  17. <style>
  18. @media screen and (min-width: 768px) {
  19. #title{
  20. padding-top: 15em;
  21. border-right: 1px solid #dedede;
  22. padding-right: 5em;
  23. }
  24. #title .ui.header{
  25. width: 300px;
  26. }
  27. #qrgrid{
  28. padding-left: 5em;
  29. }
  30. }
  31. #qr-code {
  32. display: flex;
  33. justify-content: center;
  34. align-items: center;
  35. margin: 0 auto;
  36. height: 300px; /* Match the QR code height */
  37. width: 300px; /* Match the QR code width */
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div class="ts-app-center">
  43. <div class="ts-content">
  44. <div >
  45. <div class="ts-input is-circular" style="margin-bottom: 1em;">
  46. <input type="text" id="text-input" placeholder="Enter text for QR code" onkeypress="handleKeyPress(event)">
  47. </div>
  48. <button class="ts-button is-fluid" id="generate-btn" onclick="generateQRCode()">Generate QR Code</button>
  49. <div class="ts-divider has-top-spaced-large has-bottom-spaced-large"></div>
  50. <div id="qr-code"></div>
  51. </div>
  52. </div>
  53. </div>
  54. <script>
  55. function initQrCode(){
  56. var qrcode = new QRCode(document.getElementById('qr-code'), {
  57. text: "https://imuslab.com",
  58. width: 300,
  59. height: 300
  60. });
  61. }
  62. initQrCode();
  63. function generateQRCode() {
  64. var textInput = document.getElementById('text-input').value;
  65. var qrCodeDiv = document.getElementById('qr-code');
  66. if (textInput.trim() === "") {
  67. alert("Please enter text for the QR code.");
  68. return;
  69. }
  70. qrCodeDiv.innerHTML = ""; // Clear previous QR code
  71. var qrcode = new QRCode(qrCodeDiv, {
  72. text: textInput,
  73. width: 300,
  74. height: 300
  75. });
  76. $(qrCodeDiv).transition('fade down', function(){
  77. $(qrCodeDiv).transition('fade down');
  78. });
  79. }
  80. function handleKeyPress(event) {
  81. // Check if the pressed key is Enter (key code 13)
  82. if (event.key === 'Enter') {
  83. generateQRCode();
  84. }
  85. }
  86. </script>
  87. </body>
  88. </html>