Repository navigation
Expand file tree
/
Copy pathTheLife.html
More file actions
142 lines (123 loc) · 5.8 KB
/
Copy pathTheLife.html
File metadata and controls
142 lines (123 loc) · 5.8 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" media="screen">
<title>The Life</title>
<style type="text/css">
.container {
width: 100%;
}
.canvas {
width: 100%;
height: 60px;
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 25px;
background: #000000;
outline: none;
opacity: 0.7;
-webkit-transition: .2s;
transition: opacity .2s;
}
#currentYearRange {
-webkit-appearance: none;
width: 100%;
height: 25px;
background: #ffffff;
outline: none;
-webkit-transition: .2s;
}
</style>
<script type="text/javascript">
function defineAll() {
const d = new Date();
let year = d.getFullYear();
currentYearRange.value = year;
// Update Cannvas
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
startPixel = canvas.width * ((birthRange.value - birthRange.min) / (birthRange.max-birthRange.min));
endPixel = (canvas.width * ((deathRange.value - deathRange.min) / (deathRange.max-deathRange.min)) - startPixel);
currentYearPixel = canvas.width * ((currentYearRange.value - currentYearRange.min) / (currentYearRange.max-currentYearRange.min));
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'green';
ctx.fillRect(startPixel, 10, endPixel, 200);
ctx.fillStyle = 'red';
ctx.fillRect(startPixel, 10, currentYearPixel-startPixel, 200);
}
function onBirthSliderChange(value) {
birthRangeValue.innerText = value;
deathRangeValue.innerText = (parseInt(value) + 73);
deathRange.value = (parseInt(value) + 73)
// Update Cannvas
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
startPixel = canvas.width * ((birthRange.value - birthRange.min) / (birthRange.max-birthRange.min));
endPixel = (canvas.width * ((deathRange.value - deathRange.min) / (deathRange.max-deathRange.min)) - startPixel);
currentYearPixel = canvas.width * ((currentYearRange.value - currentYearRange.min) / (currentYearRange.max-currentYearRange.min));
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'green';
ctx.fillRect(startPixel, 10, endPixel, 200);
ctx.fillStyle = 'red';
if(currentYearPixel-startPixel > 0) {
if(currentYearPixel-startPixel > endPixel) {
ctx.fillRect(startPixel, 10, endPixel, 200);
} else {
ctx.fillRect(startPixel, 10, currentYearPixel-startPixel, 200);
}
}
}
function onDeathSliderChange(value) {
deathRangeValue.innerText = value
// Update Cannvas
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
startPixel = canvas.width * ((birthRange.value - birthRange.min) / (birthRange.max-birthRange.min));
endPixel = (canvas.width * ((deathRange.value - deathRange.min) / (deathRange.max-deathRange.min)) - startPixel);
currentYearPixel = canvas.width * ((currentYearRange.value - currentYearRange.min) / (currentYearRange.max-currentYearRange.min));
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = 'green';
ctx.fillRect(startPixel, 10, endPixel, 200);
ctx.fillStyle = 'red';
if(currentYearPixel-startPixel > 0) {
if(currentYearPixel-startPixel > endPixel) {
ctx.fillRect(startPixel, 10, endPixel, 200);
} else {
ctx.fillRect(startPixel, 10, currentYearPixel-startPixel, 200);
}
}
}
</script>
</head>
<body onload="defineAll()">
<br/>
<div>
<h1 style="font-weight: 150;text-align: center;font-family: 'Roboto', sans-serif;"><b>The Life</b></h1>
<h4 style="font-weight: 100;text-align: center;font-family: 'Roboto', sans-serif;">Do you know how much time we have already crossed????</h4>
</div>
<br/>
<div class="container">
<center style="font-weight: 80;text-align: center;font-family: 'Roboto', sans-serif;"><b>Birth Year: </b><div id="birthRangeValue">1992</div></center>
<input type="range" min="1900" max="2200" value="1992" class="slider" id="birthRange" oninput="onBirthSliderChange(this.value)">
<canvas id="canvas" class="canvas"></canvas>
<input type="range" min="1900" max="2200" value="2022" class="slider" id="currentYearRange" hidden="true">
<input type="range" min="1900" max="2200" value="2065" class="slider" id="deathRange" oninput="onDeathSliderChange(this.value)">
<center style="font-weight: 80;text-align: center;font-family: 'Roboto', sans-serif;"><b>*Tentative Death Year: </b><div id="deathRangeValue">2065</div>
<div>*Life Expectancy of the World Population (Data based on the latest United Nations Population Division estimates.) : <b>73.2 years</b></div></center>
</div>
<br/>
<div>
<h4 style="font-weight: 100;text-align: center;font-family: 'Roboto', sans-serif;">Inspired from</h4>
<h4 style="font-weight: 100;text-align: center;font-family: 'Roboto', sans-serif;">The Instant Gratification Monkey</h4>
</div>
<hr/>
<h6 style="text-align: center;font-family: 'Roboto', sans-serif;"><b> PRIVACY POLICY </b> : We don't store your data, period.</h6>
<h6 style="text-align: center;font-family: 'Roboto', sans-serif;">Made with ❤️ in India!</h6>
<h6 style="text-align: center;font-family: 'Roboto', sans-serif;"><a href="index.html">vickysam</a></h6>
</body>
</html>