-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a66ed83
commit d4a6855
Showing
4 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Work-Life Balance Calculator</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Work-Life Balance Calculator</h1> | ||
<form id="balance-form"> | ||
<label for="work">Work Hours:</label> | ||
<input type="number" id="work" required min="0" max="24" placeholder="Enter hours for work" required> | ||
<br/> | ||
<label for="personal">Personal Care Hours:</label> | ||
<input type="number" id="personal" required min="0" max="24" placeholder="Enter hours for personal care" required> | ||
<br/> | ||
<label for="leisure">Leisure Hours:</label> | ||
<input type="number" id="leisure" required min="0" max="24" placeholder="Enter hours for leisure" required> | ||
|
||
<button type="button" id="calculate">Calculate</button> | ||
</form> | ||
<div id="result"></div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// script.js | ||
document.getElementById('calculate').addEventListener('click', () => { | ||
const work = parseFloat(document.getElementById('work').value) || 0; | ||
const personal = parseFloat(document.getElementById('personal').value) || 0; | ||
const leisure = parseFloat(document.getElementById('leisure').value) || 0; | ||
|
||
const totalHours = work + personal + leisure; | ||
if(totalHours > 24){ | ||
alert("Enter valid time"); | ||
return; | ||
} | ||
const balanceScore = ((personal + leisure) / 24).toFixed(2); | ||
|
||
const resultDiv = document.getElementById('result'); | ||
resultDiv.innerHTML = ` | ||
<p>Total Hours: ${totalHours} / 24</p> | ||
<p>Work-Life Balance Score: ${balanceScore}</p> | ||
<p>${balanceScore >= 0.5 ? 'Good Balance!' : 'You need more personal/leisure time.'}</p> | ||
`; | ||
}); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* styles.css */ | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-image: url('bcg.jpg'); | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
color: #333; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} | ||
|
||
.container { | ||
background: #fff; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); | ||
width: 450px; | ||
} | ||
|
||
h1 { | ||
font-size: 24px; | ||
margin-bottom: 20px; | ||
text-align: center; | ||
} | ||
|
||
label { | ||
display: block; | ||
margin-top: 10px; | ||
font-size: 14px; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
padding: 7px; | ||
margin-top: 5px; | ||
margin-bottom: 10px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
font-size: 14px; | ||
padding-right: 5px; | ||
} | ||
|
||
button { | ||
width: 100%; | ||
padding: 10px; | ||
background: #007bff; | ||
color: #fff; | ||
border: none; | ||
border-radius: 5px; | ||
font-size: 16px; | ||
cursor: pointer; | ||
} | ||
|
||
button:hover { | ||
background: #0056b3; | ||
} | ||
|
||
#result { | ||
margin-top: 20px; | ||
text-align: center; | ||
font-size: 16px; | ||
font-weight: bold; | ||
} |