-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
171 lines (149 loc) · 5.02 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Product Verification</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,700&display=swap" rel="stylesheet">
<style>
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background: linear-gradient(135deg, #74EBD5 0%, #9FACE6 100%);
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
animation: fadeIn 2s ease-in-out;
}
.container {
background-color: rgba(255, 255, 255, 1);
transition: transform 0.3s ease, box-shadow 0.3s ease;
padding: 30px;
border-radius: 10px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12), 0 6px 6px rgba(0, 0, 0, 0.23);
width: 250px;
animation: fadeIn 2s ease-in-out;
}
.container:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}
.title {
color: #003366;
text-align: center;
margin-bottom: 20px;
font-size: 28px;
font-family: 'Open Sans', sans-serif;
}
.input-group {
margin-bottom: 20px;
}
input[type="text"], input[type="submit"] {
width: 100%;
padding: 15px 20px;
margin: 10px 0;
display: inline-block;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
transition: all 0.3s ease;
font-size: 16px;
background-color: rgba(240, 240, 240, 0.8);
}
input[type="text"] {
background-color: #f0f0f0;
color: #333;
}
input[type="text"]:focus {
border-color: #007bff;
outline: none;
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.5);;
}
input[type="submit"] {
border-radius: 20px; /* Rounded corners */
padding: 15px 25px; /* Larger, more touch-friendly size */
font-size: 18px; /* Larger font size */
background-color: #0056b3; /* Different color for a fresh look */
transition: background-color 0.3s ease, transform 0.3s ease;
}
input[type="submit"]:hover, input[type="submit"]:focus {
background-color: #007bff; /* Slightly lighter color on hover/focus */
transform: scale(1.05); /* Slightly larger on hover/focus */
}
.loading-spinner {
border: 4px solid #f3f3f3;
border-top: 4px solid #3498db;
border-radius: 50%;
width: 20px;
height: 20px;
animation: spin 2s linear infinite;
display: inline-block;
}
</style>
</head>
<body>
<div class="container">
<img src="logo.png" alt="AuthenTEZ Logo" style="display: block; margin-left: auto; margin-right: auto; width: 50%;"/>
<h1 class="title">Web3 Product Verification</h1>
<div class="input-group">
</div>
<input type="submit" value="Tap Phone on RFID" onclick="verifyProduct()">
<div id="loading" class="loading-spinner" style="display:none;"></div>
</div>
<script>
window.onload = function() {
// Get the current URL
const currentUrl = new URL(window.location.href);
// Extract the pathname after "/verify"
const verifyPath = '/verify';
let remainingPath = currentUrl.pathname.startsWith(verifyPath) ?
currentUrl.pathname.substring(verifyPath.length) : '';
// Remove leading slash if it exists
if (remainingPath.startsWith('/')) {
remainingPath = remainingPath.substring(1);
}
// Now remainingPath contains the part of the URL after "/verify"
// You can split it into further segments if needed
const pathSegments = remainingPath.split('/');
// If there are more segments, you can process them as needed
// For example, if you're expecting a SHA256 hash next
if (pathSegments.length > 0 && pathSegments[0].length === 256) {
// Assuming the first segment is the SHA256 hash
const sha256Hash = pathSegments[0];
// Do something with sha256Hash, for example, set it as input value
document.getElementById('sha256Input').value = sha256Hash;
}
};
function verifyProduct() {
var sha256Identifier = document.getElementById('sha256Input').value;
// Simple validation check
if (sha256Identifier.length !== 64) {
window.location.href = '/wrong_code.html'; // Redirect to the "wrong code" page
return;
}
fetch('/verify/' + sha256Identifier)
.then(response => response.json()) // Corrected this line
.then(data => {
if (data.status === 'valid') {
window.location.href = '/real_product.html'; // Redirect to the "real product" page
} else {
window.location.href = '/fake_product.html'; // Redirect to the "fake product" page
}
})
.catch(error => {
console.error('Error:', error);
});
}
</script>
</body>
</html>