|
12 | 12 | <textarea class="mt-3" id="txt" name="wallet_data" placeholder="Enter your wallet data here"></textarea> |
13 | 13 |
|
14 | 14 | <div class="popup hidden rounded-md overflow-hidden" id="popup"> |
15 | | - <video muted playsinline id="qr-video"></video> |
| 15 | + <video muted playsinline id="qr-video"></video> |
16 | 16 | </div> |
17 | 17 |
|
18 | 18 | <div> |
|
34 | 34 |
|
35 | 35 |
|
36 | 36 | <script type="module"> |
37 | | - import QrScanner from "{{ url_for('static', filename='qr/qr-scanner.min.js') }}"; |
| 37 | + import QrScanner from "{{ url_for('static', filename='qr/qr-scanner.min.js') }}"; |
38 | 38 | document.addEventListener("DOMContentLoaded", function(){ |
39 | 39 | QrScanner.WORKER_PATH = "{{ url_for('static', filename='qr/qr-scanner-worker.min.js') }}"; |
40 | 40 |
|
|
68 | 68 |
|
69 | 69 | <script type="text/javascript"> |
70 | 70 | document.addEventListener("DOMContentLoaded", function(){ |
71 | | - var el = document.getElementById("file"); |
72 | | - var txt = document.getElementById("txt"); |
| 71 | + var el = document.getElementById("file"); |
| 72 | + const txtTextarea = document.getElementById("txt"); |
73 | 73 |
|
74 | | - if (el != null) { |
75 | | - el.addEventListener("change", (e) => { |
76 | | - files = e.currentTarget.files; |
77 | | - console.log(files); |
| 74 | + if (el != null) { |
| 75 | + el.addEventListener("change", (e) => { |
| 76 | + files = e.currentTarget.files; |
| 77 | + console.log(files); |
78 | 78 | for(let i=0; i<files.length; i++){ |
79 | | - console.log(files[i].name); |
80 | | - let reader = new FileReader(); |
81 | | - reader.onload = function(e) { |
82 | | - document.getElementById("txt").value = reader.result; |
83 | | - } |
84 | | - reader.readAsText(files[i]); |
85 | | - } |
86 | | - }); |
87 | | - } |
88 | | - }); |
89 | | -
|
90 | | - function onCancelOverlay() { |
| 79 | + console.log(files[i].name); |
| 80 | + let reader = new FileReader(); |
| 81 | + reader.onload = function (e) { |
| 82 | + txtTextarea.value = reader.result; |
| 83 | + } |
| 84 | + reader.readAsText(files[i]); |
| 85 | + } |
| 86 | + }); |
| 87 | + } |
| 88 | +
|
| 89 | + txtTextarea.addEventListener("paste", function (event) { |
| 90 | + event.preventDefault() |
| 91 | + const clipboardData = event.clipboardData || window.clipboardData |
| 92 | + const pastedText = clipboardData.getData("text/plain") |
| 93 | + const cleanedText = pastedText.replace(/("label":\s?"[^"]*")|\s/g, (_, label) => { |
| 94 | + if (label) { |
| 95 | + return label.replace(/\n/g, ' ') // Convert newline characters to spaces within labels |
| 96 | + } else { |
| 97 | + return ''; // Remove whitespace characters otherwise |
| 98 | + } |
| 99 | + }) |
| 100 | + txtTextarea.value = cleanedText |
| 101 | + }); |
| 102 | + }); |
| 103 | +
|
| 104 | + function onCancelOverlay() { |
91 | 105 | if (window.scanner) { |
92 | 106 | document.getElementById("popup").style.display = 'none'; |
93 | 107 | window.scanner.stop(); |
94 | 108 | } |
95 | | - } |
| 109 | + } |
96 | 110 |
|
97 | 111 | // Deletes the global scanner property again if there is a reload |
98 | 112 | window.addEventListener('unload', () => { |
|
0 commit comments