Browse Source

copy account

am
Amirul Anwar 4 months ago
parent
commit
217bca17f9
1 changed files with 78 additions and 25 deletions
  1. 78
    25
      resources/views/modals/emoney-modal.blade.php

+ 78
- 25
resources/views/modals/emoney-modal.blade.php View File

@@ -1,28 +1,81 @@
1
+<style>
2
+  .copy-link {
3
+            color: blue;
4
+            text-decoration: underline;
5
+            cursor: pointer;
6
+            float: right;
7
+        }
8
+</style>
1 9
 <dialog id="emoney" class="modal">
2
-    <div class="modal-box w-11/12 max-w-5xl">
3
-      <h3 class="text-lg font-bold">Hadiah</h3>
4
-      <label class="form-control w-full max-w-xs">
5
-        <div class="label">
6
-          <span class="label-text">Nama Bank</span>
7
-        </div>
8
-        <input type="text" value="RHB Bank Berhad" class="input input-bordered input-sm input-accent w-full max-w-xs" disabled/>
9
-      </label>
10
-      <label class="form-control w-full max-w-xs">
11
-        <div class="label">
12
-          <span class="label-text">No. Akaun</span>
13
-        </div>
14
-        <input type="text" value="15601700275298" class="input input-bordered input-sm input-accent w-full max-w-xs" disabled/>
15
-      </label>
16
-      <label class="form-control w-full max-w-xs">
17
-        <div class="label">
18
-          <span class="label-text">Kod QR</span>
19
-        </div>
20
-        <img src="{{asset('assets/qr-bank.jpeg')}}" alt="">
21
-      </label>
22
-      <div class="modal-action">
23
-        <form method="dialog">
24
-          <button class="btn">Tutup</button>
25
-        </form>
10
+  <div class="modal-box w-11/12 max-w-5xl">
11
+    <h3 class="text-lg font-bold">Hadiah</h3>
12
+    <label class="form-control w-full max-w-xs">
13
+      <div class="label">
14
+        <span class="label-text">Nama Bank</span>
26 15
       </div>
16
+      <input type="text" value="RHB Bank Berhad" class="input input-bordered input-sm input-accent w-full max-w-xs" disabled/>
17
+    </label>
18
+    <label class="form-control w-full max-w-xs">
19
+      <div class="label">
20
+        <span class="label-text">No. Akaun</span>
21
+      </div>
22
+      <p class="input input-bordered input-sm input-accent w-full max-w-xs">
23
+        15601700275298 
24
+          <span id="copyText" class="copy-link">(copy)</span>
25
+      </p>
26
+      <p id="copyMessage" class="text-green-500" style="display:none;">Copied to clipboard!</p>
27
+    </label>
28
+    <label class="form-control w-full max-w-xs">
29
+      <div class="label">
30
+        <span class="label-text">Kod QR</span>
31
+      </div>
32
+      <img src="{{asset('assets/qr-bank.jpeg')}}" alt="">
33
+    </label>
34
+    <div class="modal-action">
35
+      <form method="dialog">
36
+        <button class="btn">Tutup</button>
37
+      </form>
27 38
     </div>
28
-  </dialog>
39
+  </div>
40
+</dialog>
41
+<script>
42
+        document.getElementById('copyText').addEventListener('click', function() {
43
+            var textToCopy = "15601700275298";
44
+            
45
+            if (navigator.clipboard && window.isSecureContext) {
46
+                // navigator.clipboard API method
47
+                navigator.clipboard.writeText(textToCopy).then(function() {
48
+                    var copyMessage = document.getElementById('copyMessage');
49
+                    copyMessage.style.display = 'block';
50
+                    setTimeout(function() {
51
+                        copyMessage.style.display = 'none';
52
+                    }, 2000);
53
+                }).catch(function(error) {
54
+                    alert('Failed to copy text: ' + error);
55
+                });
56
+            } else {
57
+                // Fallback method for older browsers or non-secure contexts
58
+                // Create a temporary textarea element
59
+                var tempTextArea = document.createElement('textarea');
60
+                tempTextArea.value = textToCopy;
61
+                document.body.appendChild(tempTextArea);
62
+                
63
+                // Select the text
64
+                tempTextArea.select();
65
+                tempTextArea.setSelectionRange(0, 99999); // For mobile devices
66
+
67
+                try {
68
+                    document.execCommand('copy');
69
+                    var copyMessage = document.getElementById('copyMessage');
70
+                    copyMessage.style.display = 'block';
71
+                    setTimeout(function() {
72
+                        copyMessage.style.display = 'none';
73
+                    }, 2000);
74
+                } catch (error) {
75
+                    alert('Failed to copy text: ' + error);
76
+                }
77
+
78
+                document.body.removeChild(tempTextArea);
79
+            }
80
+        });
81
+    </script>

Loading…
Cancel
Save