Skip to content
This repository was archived by the owner on Oct 2, 2020. It is now read-only.

Commit ca15a0f

Browse files
authored
Merge pull request #83 from LAKSHMANANR25/master
Hacktoberfest2019 LAKSHMANANR25
2 parents 20c6d5e + 0632bc3 commit ca15a0f

File tree

1 file changed

+384
-0
lines changed

1 file changed

+384
-0
lines changed

Hacktober19_Caltracker.html

+384
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,384 @@
1+
<style>
2+
.whole{ /*Whole screen*/
3+
display:flex;
4+
background-color: white;
5+
height:100%;
6+
7+
}
8+
9+
.part1 { /*Whole bg for the form*/
10+
11+
flex-wrap: nowrap;
12+
background-color: lightgrey;
13+
width:500px;
14+
align-items:left;
15+
border-radius: 20px;
16+
position:left;
17+
font-size:em;
18+
box-shadow: 0 0 50px black;
19+
height:100%;
20+
margin-left:100px;
21+
justify-content:center;
22+
align-items:center;
23+
}
24+
25+
.output{ /*table n other output*/
26+
27+
background-color:palegreen;
28+
width:400px;
29+
position:relative;
30+
left:500px;
31+
height:100%;
32+
}
33+
34+
35+
/* .part2 {
36+
37+
flex-wrap: nowrap;
38+
background-color: skyblue;
39+
width:500px;
40+
border-radius: 20px;
41+
position: relative;
42+
left:50px;
43+
font-size:1em;
44+
box-shadow: 0 0 50px midnightblue;
45+
height:600px;
46+
margin-top:100px;
47+
justify-content:center;
48+
align-items:center;
49+
} */
50+
51+
52+
.sm_output{
53+
background-color:palegreen;
54+
width:300px;
55+
border-radius: 20px;
56+
margin:50px;
57+
height:400px;
58+
align-items:left;
59+
box-shadow: 0 0 50px black;
60+
}
61+
62+
.inpdes { /*BlankHolders*/
63+
height: 1.25em;
64+
width: 50%;
65+
margin: 10px;
66+
border: 1px solid;
67+
border-radius: 3px;
68+
font-size:.75em;
69+
70+
}
71+
72+
input { /*Blanks*/
73+
74+
font-size: .75em;
75+
}
76+
77+
78+
table, th, td { /*Table*/
79+
border: 1px solid black;
80+
margin:50px;
81+
text-align:center;
82+
83+
}
84+
85+
.indes{ /*Buttons*/
86+
width:30%;
87+
height:1.5em;
88+
margin:10px;
89+
font-size:.75em;
90+
border:1px dashed;
91+
border-radius:4px;
92+
color:white;
93+
background-color: black;
94+
}
95+
96+
.formfill{ /*Full Form*/
97+
font-size:1.25em;
98+
}
99+
100+
.text{ /*ouput table*/
101+
102+
margin:20px;
103+
}
104+
105+
</style>
106+
107+
108+
<html>
109+
110+
<body class="whole" style="text-align:center">
111+
112+
113+
<span class="part1">
114+
<form name="data" id="data" method="post" class="formfill"><br><br>
115+
116+
Age:<input type="number" class="inpdes" name="Age" id="Age" ><br><br>
117+
Height:<input type="number" class="inpdes" name="ht" id="ht"><br><br>
118+
Weight:<input type="number" class="inpdes" name="wt" id="wt"><br><br>
119+
Gender:<input type="radio" name="gdr" id="gdrm" checked>Male
120+
121+
<input type="radio" name="gdr" id="gdrf">Female
122+
<br><br>
123+
How do you about your physical activity<select class="inpdes" id="PA" value="">
124+
<option value="0">BMR</option>
125+
<option value="1">Sedentary</option>
126+
<option value="2">Less active</option>
127+
<option value="3">Active</option>
128+
<option value="4">very active</option></select><br><br>
129+
Water Intake(in ml):<input class="inpdes" name="water" id="water" ><br >
130+
<input type="button" class="indes" value="SUBMIT" onclick="myform()">
131+
</form>
132+
<!-- </span>
133+
<span class="part1"> -->
134+
<form name="data2" id="data2" method="post" class="formfill">
135+
<br><br>
136+
Name of the Item:<input type="text" class="inpdes" id="fooditem" value=""><br><br>
137+
Calorie content:<input type="number" class="inpdes" id="calorie" value=""><br><br>
138+
Fat content:<input type="number" class="inpdes" id="fat" value=""><br><br>
139+
Carbohydrate content:<input type="number" class="inpdes" id="carb" value=""><br><br>
140+
Protein content:<input type="number" class="inpdes" id="protein" value=""><br><br>
141+
<input type="button" class="indes" value="ADD" onclick="sheet()">
142+
143+
</form>
144+
145+
</span>
146+
<script >
147+
var val1=0,val2=0;
148+
149+
function myform(){
150+
let a=parseInt(document.getElementById("Age").value);
151+
let ht=parseInt(document.getElementById("ht").value);
152+
let wt=parseInt(document.getElementById("wt").value);
153+
let gr=document.getElementById("gdrm").checked;
154+
let pa=parseInt(document.getElementById("PA").value);
155+
let water=parseInt(document.getElementById("water").value);
156+
157+
158+
console.log(a);
159+
console.log(ht);
160+
161+
/*function Write(msg){
162+
var chat = document.getElementById("disp1");
163+
var y = document.createElement("div");
164+
y.textContent = msg;
165+
chat.appendChild(y);
166+
167+
}*/
168+
if(water<2000){
169+
alert("Still a lot more to drink for the day");
170+
}
171+
172+
173+
if(gr){
174+
val1 = 88.362 + 13.397 * wt + 4.799 * ht - 5.677 * a;
175+
document.getElementById("disp1").innerHTML =val1;
176+
//document.write("<br>");
177+
document.getElementById("disp3").innerHTML = pa;
178+
console.log(gr);
179+
console.log(pa);
180+
document.getElementById("disp").innerHTML ='<a href="./calupdated.html"><button>Check Again</button></a>';
181+
}
182+
else{
183+
val2= 447.593 + 9.247 * wt + 3.098 * ht - 4.330 * a;
184+
document.getElementById("disp1").innerHTML = val2;
185+
//document.write("<br>");
186+
document.getElementById("disp3").innerHTML = pa;
187+
console.log(gr);
188+
console.log(pa);
189+
190+
document.getElementById("disp").innerHTML ='<a href="./calupdated.html"><button>Check Again</button></a>';
191+
}
192+
193+
194+
}
195+
196+
197+
//localStorage.clear();
198+
199+
function Write1(msg1){
200+
var chat = document.getElementById("dip1");
201+
var y = document.createElement("div");
202+
y.textContent = msg1;
203+
chat.appendChild(y);
204+
205+
}
206+
207+
function Write2(msg2){
208+
var chat = document.getElementById("dip2");
209+
var y = document.createElement("div");
210+
y.textContent = msg2;
211+
chat.appendChild(y);
212+
213+
}
214+
215+
function Write3(msg3){
216+
var chat = document.getElementById("dip3");
217+
var y = document.createElement("div");
218+
y.textContent = msg3;
219+
chat.appendChild(y);
220+
221+
}
222+
223+
function Write4(msg4){
224+
var chat = document.getElementById("dip4");
225+
var y = document.createElement("div");
226+
y.textContent = msg4;
227+
chat.appendChild(y);
228+
229+
}
230+
231+
function Write5(msg5){
232+
var chat = document.getElementById("dip5");
233+
var y = document.createElement("div");
234+
y.textContent = msg5;
235+
chat.appendChild(y);
236+
237+
}
238+
var i=0;
239+
var tot_cal=0;
240+
var Itar=[];
241+
var Caar=[];
242+
var Far=[];
243+
var Cbar=[];
244+
var pro=[];
245+
var h=0;
246+
var j=1;
247+
248+
function sheet(){
249+
250+
251+
252+
253+
var a=new Object();
254+
a.food=document.getElementById("fooditem").value;
255+
a.cal=document.getElementById("calorie").value;
256+
a.fat=document.getElementById("fat").value;
257+
a.carb=document.getElementById("carb").value;
258+
a.pro=document.getElementById("protein").value;
259+
260+
for(var h=0;h<50;h++){
261+
Itar.push(h*2);
262+
Caar.push(2*h+1);
263+
Far.push(100+ 2*h);
264+
Cbar.push(1000+ 2*h);
265+
pro.push(500+ 2*h)
266+
}
267+
268+
/*if(i===0){
269+
270+
localStorage.setItem(Itar[0],a.food);
271+
localStorage.setItem(Caar[0],a.cal);
272+
i++;
273+
localStorage.setItem("ui",i);
274+
}
275+
else
276+
{*/
277+
278+
if(i===0){
279+
localStorage.setItem(Itar[i],0);
280+
localStorage.setItem(Caar[i],0);
281+
localStorage.setItem(Far[i],0);
282+
localStorage.setItem(Cbar[i],0);
283+
localStorage.setItem(pro[i],0);
284+
285+
i++;
286+
localStorage.setItem("ui",i);
287+
}
288+
i=localStorage.getItem("ui");
289+
if(i>0){
290+
291+
localStorage.setItem(Itar[i],a.food);
292+
localStorage.setItem(Caar[i],a.cal);
293+
localStorage.setItem(Far[i],a.fat);
294+
localStorage.setItem(Cbar[i],a.carb);
295+
localStorage.setItem(pro[i],a.pro);
296+
297+
i++;
298+
localStorage.setItem("ui",i);
299+
}
300+
301+
//}
302+
/*if(j===0){
303+
localStorage.getItem(Itar[j]);
304+
localStorage.getItem(Caar[j]);
305+
localStorage.getItem(Far[j]);
306+
localStorage.getItem(Cbar[j]);
307+
localStorage.getItem(pro[j]);
308+
309+
}
310+
*/
311+
312+
for(;j<i;j++){
313+
314+
Write1(localStorage.getItem(Itar[j]));
315+
Write2(localStorage.getItem(Caar[j]));
316+
Write3(localStorage.getItem(Far[j]));
317+
Write4(localStorage.getItem(Cbar[j]));
318+
Write5(localStorage.getItem(pro[j]));
319+
320+
321+
}
322+
323+
document.getElementById("display2").innerHTML ="click add more to add more food items or press button click";
324+
325+
326+
// document.getElementById("display3").innerHTML ='<br><a href="./maintest.html">Add more</a><br>';
327+
document.getElementById("display4").innerHTML ='<br><button onclick="total()">Total</button><br>';
328+
329+
330+
331+
332+
}
333+
334+
335+
function total(form){
336+
tot_cal=0;
337+
for(var h=1;h<i;h++){
338+
tot_cal=tot_cal+parseInt(localStorage.getItem(Caar[h]),10);
339+
}
340+
341+
document.getElementById("display").innerHTML =tot_cal;
342+
if(val1>0 && tot_cal<val1){
343+
344+
document.getElementById("comment").innerHTML ="com'on man still a bit cal left";
345+
346+
}
347+
else if(val2>0 && tot_cal<val2){
348+
document.getElementById("comment").innerHTML ="com'on still a bit cal left";
349+
}
350+
else
351+
document.getElementById("comment").innerHTML ="done for the day";
352+
}
353+
</script>
354+
355+
356+
<span class="output">
357+
<p id="disp1" class="text" style="float:left" ></p>
358+
<p id="disp3" class="text" style="float:left" ></p>
359+
<p id="disp" class="text" style="float:left" ></p>
360+
<p id="disp2" class="text" style="float:left" ></p>
361+
<table >
362+
<tr>
363+
<th>Item</th>
364+
<th>Calorie</th>
365+
<th>Fat</th>
366+
<th>Carbohydrate</th>
367+
<th>Protein</th>
368+
</tr>
369+
<tr>
370+
<td><p id="dip1" ></p></td>
371+
<td><p id="dip2" ></p></td>
372+
<td><p id="dip3" ></p></td>
373+
<td><p id="dip4" ></p></td>
374+
<td><p id="dip5" ></p></td>
375+
</tr>
376+
</table>
377+
<p id="display2" class="text" ></p>
378+
<p id="display3" class="text"></p>
379+
<p id="display4" class="text" ></p>
380+
<p id="display" class="text" ></p>
381+
<p id="comment" class="text"></p>
382+
</span>
383+
</body>
384+
</html>

0 commit comments

Comments
 (0)