-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
109 lines (95 loc) · 3.18 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
<!DOCTYPE html>
<html>
<head>
<title>GenerAI</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
background-color: #f0f0f0;
}
h1 {
color: #333;
}
#userIdLabel {
font-weight: bold;
}
#userId {
padding: 10px;
font-size: 16px;
}
a {
text-decoration: none;
color: #007bff;
margin: 5px;
}
a:hover {
text-decoration: underline;
}
button {
background-color: #007bff;
color: #fff;
border: none;
padding: 10px 20px;
margin: 5px;
cursor: pointer;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
transition: background-color 0.3s, transform 0.2s;
}
button:hover {
background-color: #0056b3;
transform: translateY(-2px);
}
</style>
</head>
<body>
<h1>GenerAI - Customer Profiling with BigData and Generative AI</h1>
<label for="userId" id="userIdLabel">Enter your username:</label>
<input type="text" id="userId" placeholder="Username">
<br><br>
<a href="#" onclick="registerAction('internal-link')">Internal Link</a>
<a href="https://www.example.com" onclick="registerAction('external-link')">External Link</a>
<br><br>
<button onclick="registerAction('informative')">Informative Button</button>
<button onclick="registerAction('download')">Download Button</button>
<button onclick="registerAction('purchase')">Purchase Button</button>
<script>
let timeSpent = 0; // Global variable to store time spent
function registerAction(action) {
const username = document.getElementById('userId').value;
if (!username) {
console.error('Enter a username');
return;
}
console.log('Registering action:', action, 'for user:', username);
const data = {
username: username,
action: action,
timeSpent: timeSpent
};
fetch('http://localhost:3000/register-action', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(responseData => {
console.log('Server response:', responseData);
})
.catch(error => {
console.error('Error sending data:', error);
});
}
// Function to calculate time spent on the page
function calculateTimeSpent() {
timeSpent += 1000; // Increase by 1000 ms (1 second)
console.log('Time spent:', timeSpent);
}
// Start the timer
setInterval(calculateTimeSpent, 1000); // Call the function every 1000 ms (1 second)
</script>
</body>
</html>