-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
109 lines (100 loc) · 4.29 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 lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Telecom Usage Tracker</title>
<link rel="stylesheet" href="styles.css">
<script src="https://cdn.emailjs.com/dist/email.min.js"></script>
<script src="scripts.js"></script>
</head>
<body>
<header>
<h1>Welcome to Telecom Usage Tracker</h1>
<div class="tabs">
<button class="tab" onclick="showContent('home')">Home</button>
<button class="tab" onclick="showContent('register')">Register</button>
<button class="tab" onclick="showContent('login')">Login</button>
<button class="tab" onclick="showContent('settings')">Settings</button>
</div>
</header>
<main id="content">
<section id="home" class="tab-content">
<h2>Overview</h2>
<p>This app allows you to track your telecom usage and set monthly limits.</p>
<p>Use the settings page to adjust your account preferences and usage limits.</p>
<button onclick="checkUsage()">Check Usage</button>
<div id="result"></div>
</section>
<section id="register" class="tab-content" style="display: none;">
<h2>Register</h2>
<form onsubmit="alert('Registered!'); return false;">
<input type="text" placeholder="Email" required>
<input type="password" placeholder="Password" required>
<button type="submit">Register</button>
</form>
</section>
<section id="login" class="tab-content" style="display: none;">
<h2>Login</h2>
<form onsubmit="alert('Logged in!'); return false;">
<input type="text" placeholder="Email" required>
<input type="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
</section>
<section id="settings" class="tab-content" style="display: none;">
<h2>Set Monthly Limits</h2>
<form id="settingsForm" onsubmit="return validateLimits()">
<label for="dataLimit">Monthly Data Limit (GB):</label>
<input type="number" id="dataLimit" name="dataLimit" min="0" placeholder="Choose or enter..." required>
<br>
<label for="callLimit">Monthly Call Limit (Minutes):</label>
<input type="number" id="callLimit" name="callLimit" min="0" placeholder="Choose or enter..." required>
<br>
<h1>Log Telecom Usage</h1>
<label for="dataUsage"> Log Telecom Usage:</label>
<input type="number" id="dataUsage" placeholder="Enter your data usage" required>
<button onclick="logTelecomUsage()">Log Usage</button>
<button type="submit">Save Settings</button>
</form>
</section>
</main>
<script>
function checkUsage() {
const email = prompt("Enter your email:");
const company = prompt("Enter your company name:");
const data = {
email: email,
company: company
};
fetch('src/run-check', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok: ' + response.statusText);
}
return response.json();
})
.then(data => {
let resultMessage = `${data.message}\n`;
if (!data.error) {
resultMessage += `Data Used: ${data.data_used} MB\n`;
resultMessage += `Data Remaining: ${data.data_remaining} MB\n`;
resultMessage += `Call Minutes Used: ${data.call_used} minutes\n`;
resultMessage += `Call Minutes Remaining: ${data.call_remaining} minutes\n`;
}
document.getElementById('result').innerText = resultMessage;
})
.catch(error => {
console.error('Fetch error:', error);
document.getElementById('result').innerText = "An error occurred while fetching the data: " + error.message;
});
}
</script>
</body>
</html>