-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.html
1145 lines (865 loc) · 37 KB
/
profile.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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<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">
<title>Profile Page</title>
<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://fonts.googleapis.com/css?family=Nunito:400,600,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600,700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="https://cdnjs.cloudflare.com/ajax/libs/air-datepicker/2.2.3/css/datepicker.css" rel="stylesheet">
<link href="https://maxcdn.icons8.com/fonts/line-awesome/1.1/css/line-awesome-font-awesome.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js"></script>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js"></script>
<link href="assets/css/profile.css" rel="stylesheet">
<link href="assets/css/profile2.css" rel="stylesheet">
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Raleway:300,300i,400,400i,500,500i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<!-- Vendor CSS Files -->
<link href="assets/vendor/animate.css/animate.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
<link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
<link href="assets/vendor/glightbox/css/glightbox.min.css" rel="stylesheet">
<!-- <link href="assets/vendor/swiper/swiper-bundle.min.css" rel="stylesheet"> -->
<!-- Template Main CSS File -->
<link href="assets/css/style.css" rel="stylesheet">
<!-- VueJs -->
<script src="https://unpkg.com/vue@next"></script>
<style>
body {
font-family: 'Quicksand', sans-serif;
color: #324e63;
background: url(assets/img/wallpaper.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<div id='navHead'>
<navhead index='nav-link scrollto' about='nav-link scrollto' tracker='nav-link scrollto active' team='nav-link scrollto' contact='nav-link scrollto'></navhead>
</div>
<div class="wrapper">
<div class="profile-card js-profile-card">
<!-- <div class="profile-card__img">
<img src="./data/downloadss.jpg" alt="profile card">
</div> -->
<div class="profile-card__cnt js-profile-cnt">
<a href="profiling.php" class="btn btn-primary" style="float: right;position: absolute;right: 0;margin-right: 10px;">Update</a>
<H2 style="margin-top: 50px;">Welcome! </H2>
<div class="profile-card__name" id="username"></div>
<div class="profile-card-inf">
<div class="profile-card-inf__item">
<div class="profile-card-inf__title" id= "Height"></div>
<div class="profile-card-inf__txt">Height</div>
</div>
<div class="profile-card-inf__item">
<div class="profile-card-inf__title" id= "Weight"></div>
<div class="profile-card-inf__txt">Weight</div>
</div>
</div>
<br>
<div class="profile-card__txt">This is your Monthly Nultrition Count:</div>
<div class="profile-card-inf">
<div class="profile-card-inf__item">
<div class="profile-card-inf__title" id= "TotalCaloriesBurned"></div>
<div class="profile-card-inf__txt">Calories Burnt</div>
</div>
<div class="profile-card-inf__item">
<div class="profile-card-inf__title" id= "TotalCalories"></div>
<div class="profile-card-inf__txt" >Calories</div>
</div>
<div class="profile-card-inf__item">
<div class="profile-card-inf__title" id= "TotalProtein"></div>
<div class="profile-card-inf__txt">Protein</div>
</div>
<div class="profile-card-inf__item">
<div class="profile-card-inf__title" id= "TotalCarb"></div>
<div class="profile-card-inf__txt">Carbohydrate</div>
</div>
</div>
<!-------------------------- Start of Chart -------------------------------------------->
<div class="p-5">
<h2 class="mb-4">Full Calendar</h2>
<div class="card">
<div class="card-body p-0">
<div id="calendar"></div>
</div>
</div>
</div>
<canvas id="myChart" width="400" height="200"></canvas> <br><br>
<label for="nutrition analysis">Choose an analysis:</label>
<select name="nutrition" onchange="piechart(this.value)" id="analysis">
<option value="calories" selected>Calories</option>
<option value="protein">Protein</option>
<option value="carbs">Carbohydrate</option>
</select>
<canvas id="oilChart" width="600" height="400"></canvas>
<canvas id="oilChart1" width="600" height="400"></canvas>
<canvas id="oilChart2" width="600" height="400"></canvas>
<!-------------------------- End Of Chart ---------------------------------------------->
<input type="hidden" id="recoCal">
<input type="hidden" id="recoCarbs">
<input type="hidden" id="recoProt">
<!--------------------------Start of calender-------------------------------------------->
<div class="btn btn-danger" onclick="logout()">logout</div>
<!-- <div class="form-group">
<strong>How are you feeling today: </strong>
<span v-if="rating == 1">☹️Bad.</span>
<span v-else-if="rating == 2">😐Not good.</span>
<span v-else-if="rating == 3">🙂Ok</span>
<span v-else-if="rating == 4">😄Good</span>
<span v-else>😍Great!</span> <br>
<input type="range" min=1 max=5 v-model="rating">
</div> -->
<!------------------------- calendar modal ---------------------------------------------->
<div id="app1">
<calenderdiv></calenderdiv>
</div>
<!-----------------------------------------------------End Of calender------------------------------------------------------------------------->
<script>
// $.ajax({
// type: "POST",
// dataType: "json",
// url: "https://api.foodai.org/v4.1/classify",
// crossDomain: true,
// headers:{
// "Access-Control-Allow-Origin": "*"
// },
// data: {
// image_url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQIpeyTr_Ao9ClVVsewKytiTjBxnxvpUqJ0hA&usqp=CAU",
// num_tag: 5,
// api_key:"03123fb19ceaba0f1a7c658a23fb610af005c2a0"
// },
// success: function(respones){
// console.log(respones)
// },
// error: function(error){
// console.log(error)
// }
// });
////////////////////////////////Calender///////////////////////////////////////////
var username = localStorage.getItem("username");
if (username === null){
window.location.href = "login/loginpage.php";
}
function logout() {
localStorage.removeItem('username')
window.location.href = "login/logout.php";
}
const app1 = Vue.createApp({
});
app1.component("calenderdiv",{
// props:[foodname],
data() {
return{
rating: 1,
foodname: "",
answer: "",
Carbohydrates: "",
Protein:"",
Calories:"",
tog: true
}
},
watch: {
// whenever question changes, this function will run
foodname: function (newQuestion, oldQuestion) {
this.debouncedGetAnswer()
}
},
created: function () {
this.debouncedGetAnswer = _.debounce(this.getAnswer, 900)
},
methods: {
getAnswer: function () {
console.log(document.getElementById("name").value)
$.ajax({
type: "GET",
dataType: "json",
url: "https://api.edamam.com/api/recipes/v2?type=public&q="+ this.foodname +"&app_id=01b3b5d9&app_key=388ac25dc41e876768b68fa8fa57df91&",
crossDomain: false,
success: function(response) {
console.log(response)
if (response.hits.length == 0){
localStorage.setItem('Carbohydrates', " ");
localStorage.setItem('Calories', " " )
localStorage.setItem('Protein', " ")
document.getElementById("result") = "<div class='text-danger'>Food cant be detected, please key in calories yourself</div>"
}
else{
localStorage.setItem('Carbohydrates', response.hits[0].recipe.totalNutrients.CHOCDF.quantity);
localStorage.setItem('Calories', response.hits[0].recipe.totalNutrients.ENERC_KCAL.quantity )
localStorage.setItem('Protein', +response.hits[0].recipe.totalNutrients.PROCNT.quantity)
}
},
error : function(xhr, status, error)
{
console.log("Status of error message" + status + "Error is" + error);
}
});
this.Carbohydrates = localStorage.getItem('Carbohydrates');
this.Calories = localStorage.getItem('Calories');
this.Protein = localStorage.getItem('Protein');
},
capture: function(){
},
toggle: function(){
},
},
template: `
<div id="modal-view-event" class="modal modal-top fade calendar-modal">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-body">
<h4 class="modal-title"><span class="event-icon"></span><span class="event-title"></span></h4>
<div class="event-body"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div id="modal-view-event-add" class="modal modal-top fade calendar-modal">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form id="add-event">
<div class="modal-body">
<h4>Add Food Details</h4>
<div class="form-group">
<label>Food Name</label>
<input type="text" class="form-control" v-model="foodname" value={{answer}} id="name" name="ename">
</div>
<div class="btn btn-primary" id="oncam" >Image Recognition</div>
<div id="cam" style="display:none;">
<video width=320 height=240 id="player" controls autoplay ref="input"></video><br>
<div class="btn btn-primary" id="capture" >Capture</div>
<div class="btn btn-primary" id="closecam" >Close</div>
<canvas id="canvas" width=320 height=240></canvas> <br>
Results: <div class="container"><div id="result" class="row"></div></div>
</div>
<div class="form-group">
<label>Event Date</label>
<input type='text' class="datetimepicker form-control" name="edate">
</div>
<div class="form-group">
<label>Calories (kcal)</label>
<textarea class="form-control" :value="Calories" id="Calories" name="Calories"></textarea>
</div>
<div class="form-group">
<label>Protein (g)</label>
<textarea class="form-control" :value="Protein" id="Protein" name="Protein"></textarea>
</div>
<div class="form-group">
<label>Carbohydrates (g)</label>
<textarea class="form-control" :value="Carbohydrates" id="Carbohydrates" name="Carbohydrates"></textarea>
</div>
<div class="form-group" style="display:none;">
<label>Event Color</label>
<select class="form-control" name="ecolor">
<option value="fc-bg-default">fc-bg-default</option>
<option value="fc-bg-blue">fc-bg-blue</option>
<option value="fc-bg-lightgreen">fc-bg-lightgreen</option>
<option value="fc-bg-pinkred">fc-bg-pinkred</option>
<option value="fc-bg-deepskyblue">fc-bg-deepskyblue</option>
</select>
</div>
<div class="form-group" style="display:none;">
<label>Event Icon</label>
<select class="form-control" name="eicon">
<option value="circle">circle</option>
<option value="cog">cog</option>
<option value="group">group</option>
<option value="suitcase">suitcase</option>
<option value="calendar">calendar</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" >Save</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
</div>
`
})
app1.mount('#app1')
$("#closecam").click(function(){
$("#cam").fadeOut();
player.srcObject.getVideoTracks().forEach(track => track.stop());
});
$("#oncam").click(function(){
$("#cam").fadeIn();
const player = document.getElementById('player');
const canvas = document.getElementById('canvas');
const context = canvas.getContext('2d');
const captureButton = document.getElementById('capture');
const constraints = {
video: true,
};
navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {
player.srcObject = stream;
});
captureButton.addEventListener('click', () => {
// Draw the video frame to the canvas.
context.drawImage(player, 0, 0, canvas.width, canvas.height);
console.log(canvas)
var Pic = canvas.toDataURL("image/png");
//Pic = Pic.replace(/^data:image\/(png|jpg);base64,/, "")
$.ajax({
type: "POST",
dataType: "json",
url: "https://api.foodai.org/v4.1/classify",
crossDomain: true,
data: {
image_url: Pic,
num_tag: 5,
api_key:"62f40985765435783d123372c0bd5dc29a4b5da0"
},
success: function(respones){
console.log(respones)
console.log(respones.food_results[0][0])
if (respones.food_results[0][0] == "Non Food"){
document.getElementById("result").innerHTML = "<div class='text-danger'>Please capture a proper food leh</div>"
}
else{
document.getElementById("result").innerHTML= ""
for (i in respones.food_results){
document.getElementById("result").innerHTML += "<div class='col-6 results' style='border-style: groove;display:inline-block;color:#444;border:1px solid #CCC;background:#DDD;box-shadow: 0 0 5px -1px rgba(0,0,0,0.2);cursor:pointer;vertical-align:middle; max-width: 100px;padding: 5px;text-align: center;'>"+ respones.food_results[i][0] +"</div>"
}
}
$('.results').click(function() {
var text = $(this).text();
console.log(text)
// do something with the text
document.getElementById("name").value = text
$.ajax({
type: "GET",
dataType: "json",
url: "https://api.edamam.com/api/recipes/v2?type=public&q="+ text +"&app_id=01b3b5d9&app_key=388ac25dc41e876768b68fa8fa57df91",
crossDomain: false,
success: function(response) {
console.log(response)
if (response.hit.length == 0){
document.getElementById("Carbohydrates").value = ""
document.getElementById("Calories").value =""
document.getElementById("Protein").value = ""
}
else{
document.getElementById("Carbohydrates").value = response.hits[0].recipe.totalNutrients.CHOCDF.quantity;
document.getElementById("Calories").value = response.hits[0].recipe.totalNutrients.ENERC_KCAL.quantity
document.getElementById("Protein").value = response.hits[0].recipe.totalNutrients.PROCNT.quantity
}
},
error : function(xhr, status, error)
{
console.log("Status of error message" + status + "Error is" + error);
}
});
});
},
error: function(error){
console.log(error)
}
});
});
});
// const app = Vue.createApp({
// data() {
// return{
// rating: 1
// }
// }
// });
// app.mount('#app')
// app.component('navhead', {
// props: ['index', 'about', 'tracker', 'team', 'contact'],
// template: `
// <header id="header" class="d-flex align-items-center">
// <div class="container d-flex align-items-center">
// <h1 class="logo me-auto"><a href="index.html">HealthYou</a></h1>
// <nav id="navbar" class="navbar">
// <ul>
// <li><a :class="index" href="index.html#hero">Home</a></li>
// <li><a :class="about" href="index.html#about">About</a></li>
// <li class="dropdown"><a :class="tracker" href="#services"><span>Calories Tracker</span> <i class="bi bi-chevron-down"></i></a>
// <ul>
// <li><a href="home.html">Food Calorie Tracker</a></li>
// <li><a href="profile.html">Calendar</a></li>
// <li><a href="anotherplace.html">Walking Distance Tracker</a></li>
// </ul>
// </li>
// <li><a :class="team" href="index.html#team">Team</a></li>
// <li><a :class="contact" href="index.html#contact">Contact</a></li>
// </ul>
// <i class="bi bi-list mobile-nav-toggle"></i>
// </nav>
// </div>
// </header>
// `
// } ).mount('#navHead')
// //app.mount('#navHead')
// app.component("calenderdiv",{
// })
///////////////////////////////Insert Calender///////////////////////////////////////
var username = localStorage.getItem("username");
document.getElementById("username").innerHTML = username
jQuery(document).ready(function(){
jQuery('.datetimepicker').datepicker({
dateFormat: 'yyyy-mm-dd',
timepicker: true,
language: 'en',
range: true,
multipleDates: true,
multipleDatesSeparator: " - "
});
jQuery("#add-event").submit(function(){
alert("Submitted");
// event.preventDefault();
var values = {};
$.each($('#add-event').serializeArray(), function(i, field) {
values[field.name] = field.value;
});
var date = values.edate
var date1 = date.substring(0, date.length-3);
axios.get("server/insertcalender.php",
{params:{
username: username,
className :"fc-bg-default",
starts:date1,
ends: date1,
descriptions: {"Calories":values.Calories, "Protein":values.Protein, "Carbohydrates":values.Carbohydrates},
icon: "circle",
title: values.ename
}}).then(response=>{
console.log(response.data)
}).catch(error=>{
alert(error)
})
console.log(
values
);
});
});
///////////////////////////////End Insert Calender///////////////////////////////////////
///////////////////////////////Get Calender///////////////////////////////////////
var username = localStorage.getItem("username");
(function () {
'use strict';
// ------------------------------------------------------- //
// Calendar
// ------------------------------------------------------ //
$.ajax({
url:"server/getcalender.php",
data: {
"username": username
},
type:"POST",
crossDomain:true,
success:function(msg){
//id_numbers = msg;
// id_numbers = JSON.parse(msg);
console.log(msg)
var TotalCalories = 0
var TotalProtein = 0
var TotalCarb = 0
// for (let i = 0; i < msg.length; i++){
// var eachNultrition = JSON.parse(msg[i].description)
// TotalCalories += parseFloat(eachNultrition.Calories)
// TotalProtein += parseFloat(eachNultrition.Protein)
// TotalCarb += parseFloat(eachNultrition.Carbohydrates)
// }
// document.getElementById("TotalCalories").innerHTML = TotalCalories.toFixed(0)
// document.getElementById("TotalProtein").innerHTML = TotalProtein.toFixed(0)
// document.getElementById("TotalCarb").innerHTML = TotalCarb.toFixed(0)
var event = msg
jQuery(function() {
// page is ready
jQuery('#calendar').fullCalendar({
themeSystem: 'bootstrap4',
// emphasizes business hours
businessHours: false,
defaultView: 'month',
// event dragging & resizing
editable: true,
// header
header: {
left: 'title',
center: 'month,agendaWeek,agendaDay',
right: 'today prev,next'
},
events:event,
eventRender: function(event, element) {
if(event.icon){
element.find(".fc-title").prepend("<i class='fa fa-"+event.icon+"'></i>");
}
},
dayClick: function(info) {
jQuery('#modal-view-event-add').modal();
},
eventClick: function(event, jsEvent, view) {
console.log(JSON.parse(event.description))
console.log(view.start._d)
var details = JSON.parse(event.description)
jQuery('.event-icon').html("<i class='fa fa-"+event.icon+"'></i>");
jQuery('.event-title').html(event.title);
jQuery('.event-body').html("Calories: "+details.Calories+"<br>Protein: " + details.Protein +"<br>Carbohydrates:"+ details.Carbohydrates );
jQuery('.eventUrl').attr('href',event.url);
jQuery('.modal-footer').html(`
<form action="server/deleteFoodRecord.php" method="post">
<input type="hidden" style="display:none;" name="username" value="${username}">
<input type="hidden" style="display:none;" name="foodName" value="${event.title}">
<input type="hidden" style="display:none;" name="timing" value="${event.start._i}">
<input type="submit" type="button" onclick="alert('Food record has been deleted')" class="btn btn-primary" value="Delete food record">
</form>
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>`);
jQuery('#modal-view-event').modal();
},
})
});
},
dataType:"json"
});
})(jQuery);
///////////////////////////////End Calender///////////////////////////////////////
////////////////////////////Get user details//////////////////////////////////////
$.ajax({
url:"server/getUserDetail.php",
data: {
"username": username,
},
type:"POST",
crossDomain:true,
success:function(msg){
msg = JSON.parse(msg)
console.log(msg)
document.getElementById("Height").innerHTML = msg[0].height
document.getElementById("Weight").innerHTML = msg[0].weight
document.getElementById("recoCal").value = msg[0].recoCal
document.getElementById("recoCarbs").value = msg[0].recoCarbs
document.getElementById("recoProt").value = msg[0].recoProt
console.log( document.getElementById("recoCarbs").value)
// for (var i = 0; i < msg.length; i++){
// var eachNultrition = JSON.parse(msg[i].description)
// TotalCalories += parseFloat(eachNultrition.Calories)
// TotalProtein += parseFloat(eachNultrition.Protein)
// TotalCarb += parseFloat(eachNultrition.Carbohydrates)
// }
// document.getElementById("TotalCalories").innerHTML = TotalCalories.toFixed(0)
// document.getElementById("TotalProtein").innerHTML = TotalProtein.toFixed(0)
// document.getElementById("TotalCarb").innerHTML = TotalCarb.toFixed(0)
}
});
//////////////////////////End Get user Details/////////////////////////////////////////
///////////////////////////////Get Nultrition///////////////////////////////////////
var username = localStorage.getItem("username");
const today = new Date()
var year = today.getFullYear()
var date = today.getMonth() +1
console.log(date)
$.ajax({
url:"server/getnultrition.php",
data: {
"username": username,
"date": date,
"year": year
},
type:"POST",
crossDomain:true,
success:function(msg){
var TotalCalories = 0
var TotalProtein = 0
var TotalCarb = 0
msg = JSON.parse(msg)
for (var i = 0; i < msg.length; i++){
var eachNultrition = JSON.parse(msg[i].description)
TotalCalories += parseFloat(eachNultrition.Calories)
TotalProtein += parseFloat(eachNultrition.Protein)
TotalCarb += parseFloat(eachNultrition.Carbohydrates)
}
document.getElementById("TotalCalories").innerHTML = TotalCalories.toFixed(0)
document.getElementById("TotalProtein").innerHTML = TotalProtein.toFixed(0)
document.getElementById("TotalCarb").innerHTML = TotalCarb.toFixed(0)
}
});
$.ajax({
url:"server/getCaloriesBurn.php",
data: {
"username": username,
"date": date,
"year": year
},
type:"POST",
crossDomain:true,
success:function(response){
var CalBurn = 0
response = JSON.parse(response)
console.log(response[0].caloriesBurned)
for (let i = 0; i < response.length; i++){
// var eachNultrition = JSON.parse(response[i].caloriesBurned)
CalBurn += parseFloat(response[i].caloriesBurned)
}
document.getElementById("TotalCaloriesBurned").innerHTML = CalBurn.toFixed(0)
}
})
///////////////////////////////////Get Nultrition//////////////////////////////////////////
///////////////////////////////////Chart JS//////////////////////////////////////////
var username = localStorage.getItem("username");
const today2 = new Date()
//var date = today2.getMonth() +1
var year = today2.getFullYear()
console.log(year)
var Protein1 = [];
var Carbohydrates1 = [];
//var num = 0;
for (let q = 1; q <= 12; q++){
var TotalProtein = 0
var TotalCarb = 0
$.ajax({
url:"server/getnultrition.php",
data: {
"username": username,
"date": q,
"year": year
},
type:"POST",
crossDomain:true,
success:function(msg){
msg = JSON.parse(msg)
console.log(msg)
if (msg.length == 0){
Protein1[q-1] = 0
Carbohydrates1[q-1] = 0
}
else{
TotalProtein = 0
TotalCarb = 0
for (let i = 0; i < msg.length; i++){
var eachNultrition = JSON.parse(msg[i].description)
//TotalCalories += parseFloat(eachNultrition.Calories)
TotalProtein += parseFloat(eachNultrition.Protein)
TotalCarb += parseFloat(eachNultrition.Carbohydrates)
}
Protein1[q-1] = TotalProtein
Carbohydrates1[q-1] = TotalCarb
// console.log(Protein)
// console.log(Carbohydrates)
}
var ctx = document.getElementById("myChart");
var chart = new Chart(ctx, {
type: "bar",
data: {
labels: ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" ],
datasets: [
{
type: "bar",
backgroundColor: "rgba(54, 162, 235, 0.2)",
borderColor: "rgba(54, 162, 235, 1)",
borderWidth: 1,
label: "Protein",
data: Protein1
},
{
type: "bar",
label: "Carbohydrates",
data: Carbohydrates1,
lineTension: 0,
fill: true
}
]
}
});
}
});
}
function piechart(changes){
var username = localStorage.getItem("username");
const today1 = new Date()
var date = today1.getMonth() +1
var year = today1.getFullYear()
console.log(year)
var pieData = []
$.ajax({
url:"server/getnultrition.php",
data: {
"username": username,
"date": date,
"year": year
},
type:"POST",
crossDomain:true,
success:function(msg){
var TotalCalories = 0
var TotalProtein = 0
var TotalCarb = 0
msg = JSON.parse(msg)
if (changes == "calories"){
document.getElementById("oilChart").style.display = "block";
document.getElementById("oilChart2").style.display = "none";
document.getElementById("oilChart1").style.display = "none";
for (let i = 0; i < msg.length; i++){
var eachNultrition = JSON.parse(msg[i].description)
TotalCalories += parseFloat(eachNultrition.Calories)
// TotalProtein += parseFloat(eachNultrition.Protein)
// TotalCarb += parseFloat(eachNultrition.Carbohydrates)
}
pieData.push(TotalCalories)
var CalBurn = 0
$.ajax({
url:"server/getCaloriesBurn.php",
data: {
"username": username,
"date": date,
"year": year
},
type:"POST",
crossDomain:true,
success:function(response){
console.log(JSON.parse(response))
response = JSON.parse(response)
if (response.length == 0){
pieData.push(0)
}
else{
CalBurn = 0
for (let i = 0; i < response.length; i++){
//var eachNultrition = JSON.parse(response[i].caloriesBurned)
CalBurn += parseFloat(response[i].caloriesBurned)
}
pieData.push(CalBurn)
}
console.log(pieData)
var oilCanvas = document.getElementById("oilChart");
var oilData = {
labels: [
"Calories",
"Calories Burned"
],
datasets: [
{
data: pieData,
backgroundColor: [
"#FF6384",
"#84FF63"
]
}]
};