Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +64 -98
index.html
CHANGED
@@ -1,116 +1,82 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
label { font-weight: bold; display: block; margin-bottom: 5px; }
|
13 |
-
input[type="file"] { display: block; }
|
14 |
-
textarea { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-family: monospace; font-size: 14px; }
|
15 |
-
button { background-color: #007bff; color: white; padding: 10px 15px; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; transition: background-color 0.2s; }
|
16 |
-
button:disabled { background-color: #aaa; cursor: not-allowed; }
|
17 |
-
button:hover:not(:disabled) { background-color: #0056b3; }
|
18 |
-
#image-preview { max-width: 300px; max-height: 200px; margin-top: 10px; border: 1px solid #ccc; display: none; }
|
19 |
-
#result-output { margin-top: 10px; background: #e9ecef; padding: 15px; border-radius: 5px; white-space: pre-wrap; word-wrap: break-word; font-family: monospace; min-height: 50px; }
|
20 |
-
</style>
|
21 |
</head>
|
22 |
<body>
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
<h2>Step 3: Decode!</h2>
|
41 |
-
<button id="decode-button" disabled>Decode Credentials</button>
|
42 |
-
<h3>Result:</h3>
|
43 |
-
<div id="result-output">Awaiting input...</div>
|
44 |
</div>
|
45 |
-
</div>
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
const decodeButton = document.getElementById('decode-button');
|
55 |
-
const resultOutput = document.getElementById('result-output');
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
}
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
if (file) {
|
66 |
-
const reader = new FileReader();
|
67 |
-
reader.onload = (e) => {
|
68 |
-
imagePreview.src = e.target.result;
|
69 |
-
imagePreview.style.display = 'block';
|
70 |
-
// The 'load' event on the image ensures it's fully rendered before we might use it
|
71 |
-
imagePreview.onload = () => {
|
72 |
-
isImageLoaded = true;
|
73 |
-
checkInputs();
|
74 |
-
};
|
75 |
-
};
|
76 |
-
reader.readAsDataURL(file);
|
77 |
-
} else {
|
78 |
-
isImageLoaded = false;
|
79 |
-
imagePreview.style.display = 'none';
|
80 |
-
checkInputs();
|
81 |
-
}
|
82 |
-
});
|
83 |
|
84 |
-
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
|
87 |
-
decodeButton.disabled = true;
|
88 |
-
decodeButton.textContent = 'Processing...';
|
89 |
-
resultOutput.textContent = 'Decoding... please wait.';
|
90 |
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
// Success! Display the credentials and do something with them.
|
96 |
-
resultOutput.style.color = 'green';
|
97 |
-
resultOutput.textContent = `✅ Success!\n\n${JSON.stringify(credentials, null, 2)}`;
|
98 |
-
|
99 |
-
// In a real app, you would now use these credentials:
|
100 |
-
// e.g., make an authenticated API call.
|
101 |
-
console.log("Decoded Credentials:", credentials);
|
102 |
-
alert(`Successfully decoded user: ${credentials.USERNAME || 'N/A'}`);
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
resultOutput.style.color = 'red';
|
107 |
-
resultOutput.textContent = `❌ Error: ${error.message}`;
|
108 |
-
} finally {
|
109 |
-
decodeButton.textContent = 'Decode Credentials';
|
110 |
-
checkInputs(); // Re-enable button if inputs are still valid
|
111 |
-
}
|
112 |
-
});
|
113 |
-
</script>
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
</body>
|
116 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="en">
|
3 |
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Plugin API Client Example</title>
|
6 |
+
<style>
|
7 |
+
body { font-family: sans-serif; max-width: 700px; margin: 2rem auto; }
|
8 |
+
.container { display: flex; flex-direction: column; gap: 1rem; border: 1px solid #ccc; padding: 1.5rem; border-radius: 8px; }
|
9 |
+
button { font-size: 1rem; padding: 0.5rem 1rem; cursor: pointer; }
|
10 |
+
#result { background: #f0f0f0; padding: 1rem; border-radius: 5px; white-space: pre-wrap; font-family: monospace; }
|
11 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
</head>
|
13 |
<body>
|
14 |
+
<h1>KeyLock Plugin Client</h1>
|
15 |
+
<p>This page demonstrates how to send an encrypted image to the decoder plugin API.</p>
|
16 |
+
|
17 |
+
<div class="container">
|
18 |
+
<div>
|
19 |
+
<label for="api-url"><b>API Endpoint URL:</b></label>
|
20 |
+
<input type="text" id="api-url" value="http://localhost:3000/api/decode" style="width: 100%;">
|
21 |
+
</div>
|
22 |
+
<div>
|
23 |
+
<label for="image-upload"><b>Upload KeyLock Image:</b></label>
|
24 |
+
<input type="file" id="image-upload" accept="image/png">
|
25 |
+
</div>
|
26 |
+
<button id="submit-button">Decode Image</button>
|
27 |
+
<div>
|
28 |
+
<h3>Result:</h3>
|
29 |
+
<div id="result">...</div>
|
30 |
+
</div>
|
|
|
|
|
|
|
|
|
31 |
</div>
|
|
|
32 |
|
33 |
+
<script>
|
34 |
+
const apiUrlInput = document.getElementById('api-url');
|
35 |
+
const imageInput = document.getElementById('image-upload');
|
36 |
+
const submitButton = document.getElementById('submit-button');
|
37 |
+
const resultDiv = document.getElementById('result');
|
38 |
|
39 |
+
submitButton.addEventListener('click', async () => {
|
40 |
+
const file = imageInput.files[0];
|
41 |
+
const apiUrl = apiUrlInput.value;
|
|
|
|
|
42 |
|
43 |
+
if (!file) {
|
44 |
+
resultDiv.textContent = 'Please select an image file first.';
|
45 |
+
return;
|
46 |
+
}
|
47 |
+
if (!apiUrl) {
|
48 |
+
resultDiv.textContent = 'Please provide the API endpoint URL.';
|
49 |
+
return;
|
50 |
+
}
|
51 |
|
52 |
+
resultDiv.textContent = 'Uploading and decoding...';
|
53 |
+
submitButton.disabled = true;
|
|
|
54 |
|
55 |
+
const formData = new FormData();
|
56 |
+
formData.append('authImage', file);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
+
try {
|
59 |
+
const response = await fetch(apiUrl, {
|
60 |
+
method: 'POST',
|
61 |
+
body: formData,
|
62 |
+
});
|
63 |
|
64 |
+
const result = await response.json();
|
|
|
|
|
|
|
65 |
|
66 |
+
if (!response.ok) {
|
67 |
+
throw new Error(result.error || 'An unknown error occurred.');
|
68 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
+
resultDiv.style.color = 'green';
|
71 |
+
resultDiv.textContent = JSON.stringify(result.data, null, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
+
} catch (error) {
|
74 |
+
resultDiv.style.color = 'red';
|
75 |
+
resultDiv.textContent = `Error: ${error.message}`;
|
76 |
+
} finally {
|
77 |
+
submitButton.disabled = false;
|
78 |
+
}
|
79 |
+
});
|
80 |
+
</script>
|
81 |
</body>
|
82 |
</html>
|