diff --git a/package-lock.json b/package-lock.json
index 89fbad1..32b5057 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,6 +12,7 @@
"@types/qrcode": "^1.5.5",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-vue": "^5.0.5",
+ "html5-qrcode": "^2.3.8",
"qrcode": "^1.5.3",
"vite": "^5.3.3",
"vite-plugin-copy": "^0.1.6",
@@ -3571,6 +3572,11 @@
}
}
},
+ "node_modules/html5-qrcode": {
+ "version": "2.3.8",
+ "resolved": "https://registry.npmjs.org/html5-qrcode/-/html5-qrcode-2.3.8.tgz",
+ "integrity": "sha512-jsr4vafJhwoLVEDW3n1KvPnCCXWaQfRng0/EEYk1vNcQGcG/htAdhJX0be8YyqMoSz7+hZvOZSTAepsabiuhiQ=="
+ },
"node_modules/htmlparser2": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz",
diff --git a/package.json b/package.json
index 3575293..dd26221 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"@types/qrcode": "^1.5.5",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-vue": "^5.0.5",
+ "html5-qrcode": "^2.3.8",
"qrcode": "^1.5.3",
"vite": "^5.3.3",
"vite-plugin-copy": "^0.1.6",
diff --git a/public/style/4nk.css b/public/style/4nk.css
index d481fe2..abf34bd 100644
--- a/public/style/4nk.css
+++ b/public/style/4nk.css
@@ -360,6 +360,9 @@ body {
border-bottom: none;
}
+ .qr-code-scanner {
+ display: none;
+ }
diff --git a/src/html/home.html b/src/html/home.html
index 09bab2d..3cc3c57 100644
--- a/src/html/home.html
+++ b/src/html/home.html
@@ -56,18 +56,24 @@
Scan your other device :
-

+

+
-
+
+
+
+
+
diff --git a/src/html/home.js b/src/html/home.js
index 97c0a42..caf702d 100644
--- a/src/html/home.js
+++ b/src/html/home.js
@@ -1,3 +1,4 @@
+import Routing from "/src/services/routing.service.ts";
import Services from "/src/services/service.ts";
document.querySelectorAll('.tab').forEach(tab => {
@@ -22,25 +23,14 @@ document.querySelectorAll('.tab').forEach(tab => {
}
}
-
+
//// Modal
- export function openModal() {
- document.getElementById('modal').style.display = 'flex';
+ export async function openModal() {
+ const router = await Routing.getInstance();
+ router.openLoginModal()
}
- function closeModal() {
- document.getElementById('modal').style.display = 'none';
- }
-
- // Close modal when clicking outside of it
- window.onclick = function(event) {
- const modal = document.getElementById('modal');
- if (event.target === modal) {
- closeModal();
- }
- }
-
function openCloseNotifications() {
const notifications = document.querySelector('.notification-board')
notifications.style.display = notifications?.style.display === 'none' ? 'block' : 'none'
@@ -50,4 +40,45 @@ const service = await Services.getInstance()
service.setNotification()
window.toggleMenu = toggleMenu;
-window.openModal = openModal;
\ No newline at end of file
+window.openModal = openModal;
+
+/// Scan QR Code
+function docReady(fn) {
+ // see if DOM is already available
+ if (document.readyState === "complete"
+ || document.readyState === "interactive") {
+ // call on next available tick
+ setTimeout(fn, 1);
+ } else {
+ document.addEventListener("DOMContentLoaded", fn);
+ }
+}
+
+docReady(function () {
+ var resultContainer = document.getElementById('qr-reader-results');
+ var lastResult, countResults = 0;
+ function onScanSuccess(decodedText, decodedResult) {
+ // if (decodedText !== lastResult) {
+ ++countResults;
+ lastResult = decodedText;
+ // Handle on success condition with the decoded message.
+ console.log(`Scan result ${decodedText}`, decodedResult);
+ service.sendPairingTx(decodedText)
+ // }
+ }
+
+ var html5QrcodeScanner = new Html5QrcodeScanner(
+ "qr-reader", { fps: 10, qrbox: 250 });
+ html5QrcodeScanner.render(onScanSuccess);
+});
+
+function scanDevice() {
+ service.sendPairingTx('decodedText')
+
+ // const scannerImg = document.querySelector('#scanner')
+ // if(scannerImg) scannerImg.style.display = 'none'
+ // const scannerQrCode = document.querySelector('.qr-code-scanner')
+ // if(scannerQrCode) scannerQrCode.style.display = 'block'
+}
+
+window.scanDevice = scanDevice
\ No newline at end of file
diff --git a/src/html/login-modal.html b/src/html/login-modal.html
new file mode 100644
index 0000000..48677b1
--- /dev/null
+++ b/src/html/login-modal.html
@@ -0,0 +1,9 @@
+
\ No newline at end of file
diff --git a/src/html/login-modal.js b/src/html/login-modal.js
new file mode 100644
index 0000000..f5fe78a
--- /dev/null
+++ b/src/html/login-modal.js
@@ -0,0 +1,14 @@
+import Routing from "/src/services/routing.service.ts";
+
+const router = await Routing.getInstance();
+export async function confirmLogin() {
+ router.confirmLogin()
+}
+
+export async function closeLoginModal() {
+ router.closeLoginModal()
+}
+
+
+window.confirmLogin = confirmLogin;
+window.closeLoginModal = closeLoginModal;
\ No newline at end of file
diff --git a/src/index.html b/src/index.html
index cc7b87b..2e696aa 100644
--- a/src/index.html
+++ b/src/index.html
@@ -7,6 +7,7 @@
+
4NK Application
@@ -14,6 +15,5 @@
-