qr.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. <script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
  9. <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>
  10. <script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.js" integrity="sha512-gnoBksrDbaMnlE0rhhkcx3iwzvgBGz6mOEj4/Y5ZY09n55dYddx6+WYc72A55qEesV8VX2iMomteIwobeGK1BQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  11. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.9.3/semantic.min.css" integrity="sha512-3quBdRGJyLy79hzhDDcBzANW+mVqPctrGCfIPosHQtMKb3rKsCxfyslzwlz2wj1dT8A7UX+sEvDjaUv+WExQrA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
  12. <link rel="preconnect" href="https://fonts.googleapis.com">
  13. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  14. <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@100;200&display=swap" rel="stylesheet">
  15. <style>
  16. body {
  17. }
  18. .main{
  19. display: flex;
  20. align-items: center;
  21. justify-content: center;
  22. height: calc(100vh - 60px);
  23. margin: 0;
  24. }
  25. #qr-code {
  26. max-width: 300px;
  27. height: 300px;
  28. }
  29. #generate-btn {
  30. cursor: pointer;
  31. }
  32. .ui.header,button,input{
  33. font-family: 'Noto Sans TC', sans-serif !important;
  34. }
  35. @media screen and (min-width: 768px) {
  36. #title{
  37. padding-top: 15em;
  38. border-right: 1px solid #dedede;
  39. padding-right: 5em;
  40. }
  41. #title .ui.header{
  42. width: 300px;
  43. }
  44. #qrgrid{
  45. padding-left: 5em;
  46. }
  47. }
  48. </style>
  49. </head>
  50. <body>
  51. <div class="main">
  52. <div class="ui stackable grid">
  53. <div id="title" class="eight wide column" align="center">
  54. <h2 class="ui header">
  55. QR Code Generator
  56. <div class="sub header">No ads and it just works</div>
  57. </h2>
  58. <br>
  59. <a href="../">Back to homepage</a>
  60. </div>
  61. <div id="qrgrid" class="eight wide column" align="center">
  62. <div style="width: 300px">
  63. <div class="ui fluid input" style="margin-bottom: 1em;">
  64. <input type="text" id="text-input" placeholder="Enter text for QR code" onkeypress="handleKeyPress(event)">
  65. </div>
  66. <button class="ui fluid basic button" id="generate-btn" onclick="generateQRCode()">Generate QR Code</button>
  67. <div class="ui divider"></div>
  68. <div id="qr-code"></div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <script>
  74. function initQrCode(){
  75. var qrcode = new QRCode(document.getElementById('qr-code'), {
  76. text: "https://imuslab.com",
  77. width: 300,
  78. height: 300
  79. });
  80. }
  81. initQrCode();
  82. function generateQRCode() {
  83. var textInput = document.getElementById('text-input').value;
  84. var qrCodeDiv = document.getElementById('qr-code');
  85. if (textInput.trim() === "") {
  86. alert("Please enter text for the QR code.");
  87. return;
  88. }
  89. qrCodeDiv.innerHTML = ""; // Clear previous QR code
  90. var qrcode = new QRCode(qrCodeDiv, {
  91. text: textInput,
  92. width: 300,
  93. height: 300
  94. });
  95. $(qrCodeDiv).transition('fade down', function(){
  96. $(qrCodeDiv).transition('fade down');
  97. });
  98. }
  99. function handleKeyPress(event) {
  100. // Check if the pressed key is Enter (key code 13)
  101. if (event.key === 'Enter') {
  102. generateQRCode();
  103. }
  104. }
  105. </script>
  106. </body>
  107. </html>