-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
846 lines (747 loc) · 39.8 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Kitchen Companion</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Font Awesome icons (free version)-->
<script src="https://use.fontawesome.com/releases/v6.1.0/js/all.js" crossorigin="anonymous"></script>
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic" rel="stylesheet"
type="text/css" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
</head>
<body id="page-top">
<!-- Navigation-->
<nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand" href="#page-top">Kitchen Companion</a>
<button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button"
data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive"
aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fas fa-bars"></i>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ms-auto">
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#about">About</a></li>
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#todo">ToDo</a></li>
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#inventory">Inventory</a></li>
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#budget">Budget</a></li>
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#shopping">ShoppingList</a></li>
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#calendar">Calendar</a></li>
<li class="nav-item mx-0 mx-lg-1" style="border-width:3px; border-style:solid; border-color:white;">
<a class="nav-link py-3 px-0 px-lg-3 rounded text-center" href="#recipe">Recipe</a></li>
</ul>
</div>
</div>
</nav>
<!-- Masthead-->
<header class="masthead bg-primary text-white text-center">
<div class="container d-flex align-items-center flex-column">
<!-- Masthead Avatar Image-->
<img class="masthead-avatar mb-5" src="assets/img/logo.png" alt="..." />
<!-- Masthead Heading-->
<h1 class="masthead-heading text-uppercase mb-0">Kitchen Companion</h1>
<!-- Icon Divider-->
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- Masthead Subheading-->
<p class="masthead-subheading font-weight-light mb-0">The Future of Kitchen Organization</p>
</div>
</header>
<!-- About Section-->
<section class="page-section bg-secondary text-white text-center" id="about">
<h2 class="masthead-heading text-uppercase mb-0">About</h2>
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<div class="container c-flex align-items-center flex-column">
<p class="mb-4">
Kitchen Companion is an application to create an easy process for keeping your household clean and
organized.
The application provides an array of features such as creating a To Do list for tasks that need to be
completed, keeping an
inventory of house hold items, a detailed budget for groceries including a shopping list, as well as a
calendar to help roomates organize
potential times to use the kitchen.
</p>
</div>
</section>
<!-- ToDO Section-->
<section class="page-section" id="todo">
<div class="container d-flex align-items-center flex-column" id="ToDo">
<div id="myDIV" class="header">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">Kitchen ToDo List
</h2>
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<div class="text-center">
<input class="text-center" type="text" id="myInput" placeholder="Ex: Take out the trash."
onclick="displayKeyboard_todo()">
<button class="font-weight-bold bg-secondary text-white rounded button-add" id="addBtn"
onclick="newElement_todo()">Add</button>
</div>
</div>
<ul id="myUL_todo">
</ul>
<img class="keyboard-todo" src="assets/img/keyboard.png">
<button class="font-weight-bold bg-secondary text-white rounded" id="exportBtn_todo"
onclick="export_todo()">Export list</button>
<script>
function displayKeyboard_todo() {
// alert(document.getElementsByClassName("keyboard"));
document.getElementsByClassName("keyboard-todo")[0].style.display = "block";
}
</script>
<script>
var myNodelist = document.getElementsByTagName("ul");
myNodelist = myNodelist[0];
var i;
for (i = 0; i < myNodelist.length - 1; i++) {
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
myNodelist[i].appendChild(span);
}
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
function newElement_todo() {
var li = document.createElement("li");
var inputValue = document.getElementById("myInput").value;
var t = document.createTextNode(inputValue);
li.appendChild(t);
if (inputValue === '') {
alert("You must write something!");
} else {
document.getElementById("myUL_todo").appendChild(li);
}
document.getElementById("myInput").value = "";
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
li.appendChild(span);
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
removeKeyboard_todo()
}
function removeKeyboard_todo() {
document.getElementsByClassName("keyboard-todo")[0].style.display = "none";
}
</script>
<script>
function export_todo() {
var button = document.getElementById("exportBtn_todo");
var makepdf = document.getElementById("myUL_todo");
button.addEventListener("click", function () {
var mywindow = window.open("", "PRINT", "height=600,width=600");
mywindow.document.write(makepdf.innerHTML);
mywindow.document.close();
mywindow.focus();
mywindow.print();
return true;
});
}
</script>
</div>
</section>
<hr class="seperator" />
<!-- inventory Section-->
<section class=" page-section" id="inventory">
<div class="container d-flex align-items-center flex-column" id="ToDo">
<div id="myDIV" class="header">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0"> Inventory</h2>
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<div class="text-center">
<label for="invName">Name</label>
<input class="text-center rounded" type="text" size="12" placeholder="Ex. John" id="invName"
onclick="displayKeyboard_inv()">
<br>
<label for="invItemName">Item Name</label>
<input class="text-center rounded" type="text" size="12" placeholder="Ex. Eggs" id="invItemName"
onclick="displayKeyboard_inv()"> <br>
<label for="invQuant">Quantity</label>
<input class="text-center rounded" type="text" size="12" placeholder="Ex. 12" id="invQuant"
onclick="displayKeyboard_inv()">
<br>
<label for="invLoc">Location</label>
<input class="text-center rounded" type="text" size="12" placeholder="Ex. Refrigerator" id="invLoc"
onclick="displayKeyboard_inv()"> <br>
<label for="invCal">Calendar</label>
<input class="text-center rounded" type="date" size="12" placeholder="" id="invCal"
onclick="removeKeyboard_inv()"> <br>
<button class='font-weight-bold bg-secondary text-white rounded' span onclick="newElement_inv()"
class="invAddBtn">Add Item</span></button>
</div>
</div>
<img class="keyboard-inv" src="assets/img/keyboard.png">
<p>Name | Item Name | Location | Date | Quantity</p>
<ul id="myUL_inventory">
</ul>
<table id="myTable" onclick="removeKeyboard_table()">
</table>
<img class="keyboard-table" src="assets/img/keyboard.png">
<script>
function newElement_inv() {
let name = document.getElementById("invName").value ;
let itemName = " | "+ document.getElementById("invItemName").value ;
let itemLoc = " | " + document.getElementById("invLoc").value;
let itemCal = " | " + document.getElementById("invCal").value + " | ";
let itemQuantBox = document.createElement("input");
itemQuantBox.setAttribute("id", "tableQuant")
itemQuantBox.setAttribute('type', 'number');
let itemQuant = document.getElementById("invQuant").value;
itemQuantBox.setAttribute('value', itemQuant)
itemQuantBox.setAttribute('onkeyup', "displayKeyboard_table()")
let deleteButton = document.createElement("button");
deleteButton.setAttribute("id", "deleteRow")
deleteButton.innerHTML = "Delete";
deleteButton.setAttribute('value', "Delete")
deleteButton.setAttribute('onclick', "deleteRow(this)")
deleteButton.setAttribute('class', 'font-weight-bold bg-secondary text-white rounded')
var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
var cell6 = row.insertCell(5);
cell1.innerHTML = name;
cell2.innerHTML = itemName;
cell3.innerHTML = itemLoc;
cell4.innerHTML = itemCal;
cell5.appendChild(itemQuantBox)
cell6.appendChild(deleteButton)
removeKeyboard_inv()
}
function deleteRow(r) {
var i = r.parentNode.parentNode.rowIndex;
document.getElementById("myTable").deleteRow(i);
}
function displayKeyboard_inv(){
document.getElementsByClassName("keyboard-inv")[0].style.display = "block";
}
function removeKeyboard_inv() {
document.getElementsByClassName("keyboard-inv")[0].style.display = "none";
}
function displayKeyboard_table(){
document.getElementsByClassName("keyboard-table")[0].style.display = "block";
}
function removeKeyboard_table() {
document.getElementsByClassName("keyboard-table")[0].style.display = "none";
}
/*// Create a "close" button and append it to each list item
var myNodelist = document.getElementsByTagName("ul");
var i;
for (i = 0; i < myNodelist.length - 3; i++) {
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
myNodelist[i].appendChild(span);
}
// Click on a close button to hide the current list item
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
function newElement_inv() {
let liItem = document.createElement("p");
let name = document.getElementById("invName").value;
let t1 = document.createTextNode(name);
liItem.appendChild(t1);
let itemName = " | " + document.getElementById("invItemName").value;
let t2 = document.createTextNode(itemName);
liItem.appendChild(t2);
let itemLoc = " | " + document.getElementById("invLoc").value;
let t3 = document.createTextNode(itemLoc);
liItem.appendChild(t3);
let itemCal = " | " + document.getElementById("invCal").value + " | ";
let t4 = document.createTextNode(itemCal);
liItem.appendChild(t4);
let itemQuantBox = document.createElement("input");
itemQuantBox.setAttribute('type', 'number');
let itemQuant = document.getElementById("invQuant").value;
itemQuantBox.setAttribute('value', itemQuant)
liItem.appendChild(itemQuantBox);
document.getElementById("myUL_inventory").appendChild(liItem);
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
liItem.appendChild(span);
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
removeKeyboard_inv()
}
function displayKeyboard_inv() {
document.getElementsByClassName("keyboard-inv")[0].style.display = "block";
}
function removeKeyboard_inv() {
document.getElementsByClassName("keyboard-inv")[0].style.display = "none";
}*/
</script>
</div>
</section>
<hr class="seperator" />
<!-- budget Section-->
<section class="page-section" id="budget">
<div class="wrapper">
<div class="budget-container">
<div class="sub-container text-center">
<!-- Budget -->
<div class="total-amount-container text-center">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">Budget</h2>
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<h3 class="text-center">Total Budget</h3>
<p class="hide error" id="budget-error">
Value cannot be empty or negative
</p>
<input type="number" id="total-amount" placeholder="Enter Total Amount"
onclick="displayKeyboard_budget_set()" />
<button class="font-weight-bold bg-secondary text-white rounded budget-submit"
id="total-amount-button">Set Budget</button>
</div>
<br>
<img class="keyboard-budget-set" src="assets/img/keyboard.png">
<script>
function displayKeyboard_budget_set() {
document.getElementsByClassName("keyboard-budget-set")[0].style.display = "block";
}
</script>
<br>
<!-- Expenditure -->
<div class="user-amount-container text-center">
<h3>Expenses</h3>
<p class="hide error" id="product-title-error">
Values cannot be empty
</p>
<input type="text" class="product-title" id="product-title" placeholder="Enter Title of Product"
onclick="displayKeyboard_budget_check()" />
<input type="number" id="user-amount" placeholder="Enter Cost of Product"
onclick="displayKeyboard_budget_check()" />
<button class=" font-weight-bold bg-secondary text-white rounded budget-submit"
id="check-amount">Check Amount</button>
</div>
<img class="keyboard-budget-check" src="assets/img/keyboard.png">
<script>
function displayKeyboard_budget_check() {
document.getElementsByClassName("keyboard-budget-check")[0].style.display = "block";
}
</script>
</div>
<!-- Output -->
<div class="output-container flex-space">
<div>
<p>Total Budget</p>
<span id="amount">0</span>
</div>
<div>
<p>Expenses</p>
<span id="expenditure-value">0</span>
</div>
<div>
<p>Balance</p>
<span id="balance-amount">0</span>
</div>
</div>
</div>
<!-- List -->
<div class="list">
<h3>Expense List</h3>
<div class="list-container" id="list"></div>
</div>
</div>
<!-- Script -->
<script>
let totalAmount = document.getElementById("total-amount");
let userAmount = document.getElementById("user-amount");
const checkAmountButton = document.getElementById("check-amount");
const totalAmountButton = document.getElementById("total-amount-button");
const productTitle = document.getElementById("product-title");
const errorMessage = document.getElementById("budget-error");
const productTitleError = document.getElementById("product-title-error");
const productCostError = document.getElementById("product-cost-error");
const amount = document.getElementById("amount");
const expenditureValue = document.getElementById("expenditure-value");
const balanceValue = document.getElementById("balance-amount");
const list = document.getElementById("list");
let tempAmount = 0;
//Set Budget Part
totalAmountButton.addEventListener("click", () => {
document.getElementsByClassName("keyboard-budget-set")[0].style.display = "none";
tempAmount = totalAmount.value;
//empty or negative input
if (tempAmount === "" || tempAmount < 0) {
errorMessage.classList.remove("hide");
} else {
errorMessage.classList.add("hide");
//Set Budget
amount.innerHTML = tempAmount;
//Set Balance
balanceValue.innerText = tempAmount - expenditureValue.innerText;
//Clear Input Box
totalAmount.value = "";
}
});
//Function To Modify List Elements
const modifyElement = (element) => {
let parentDiv = element.parentElement;
let currentBalance = balanceValue.innerText;
let currentExpense = expenditureValue.innerText;
let parentAmount = parentDiv.querySelector(".amount").innerText;
balanceValue.innerText = parseInt(currentBalance) + parseInt(parentAmount);
expenditureValue.innerText = parseInt(currentExpense) - parseInt(parentAmount);
parentDiv.remove();
};
//Function To Create List
const listCreator = (expenseName, expenseValue) => {
let sublistContent = document.createElement("div");
sublistContent.classList.add("sublist-content", "flex-space");
list.appendChild(sublistContent);
sublistContent.innerHTML =
`<p class="product">${expenseName}</p><p class="amount">${expenseValue}</p>`;
let deleteButton = document.createElement("button");
deleteButton.classList.add("fa-solid", "fa-trash-can", "delete");
deleteButton.style.fontSize = "1.2em";
deleteButton.addEventListener("click", () => {
modifyElement(deleteButton);
});
sublistContent.appendChild(deleteButton);
document.getElementById("list").appendChild(sublistContent);
};
//Function To Add Expenses
checkAmountButton.addEventListener("click", () => {
//empty checks
document.getElementsByClassName("keyboard-budget-check")[0].style.display = "none";
if (!userAmount.value || !productTitle.value) {
productTitleError.classList.remove("hide");
return false;
}
//Expense
let expenditure = parseInt(userAmount.value);
//Total expense (existing + new)
let sum = parseInt(expenditureValue.innerText) + expenditure;
expenditureValue.innerText = sum;
//Total balance(budget - total expense)
const totalBalance = tempAmount - sum;
balanceValue.innerText = totalBalance;
//Create list
listCreator(productTitle.value, userAmount.value);
//Empty inputs
productTitle.value = "";
userAmount.value = "";
});
</script>
</section>
<hr class="seperator" />
<!-- shoppingList section -->
<section class="page-section" id="shopping">
<div class="container d-flex align-items-center flex-column" id="ShoppingList">
<div id="myDIV" class="header">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0"> Shopping List</h2>
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<div class="text-center">
<input class="text-center rounded" type="text" size="12" id="myInput1" placeholder="Item Name"
onclick="displayKeyboard_shopping()">
<input class="text-center rounded" type="text" size="12" id="myInput2" placeholder="Item Quantity"
onclick="displayKeyboard_shopping()">
<button class='font-weight-bold bg-secondary text-white rounded' span
onclick="newElement_shopping()" class="addBtn">Add Item to List</span></button>
</div>
</div>
<ul id="myUL_shopping">
</ul>
<img class="keyboard-shopping" src="assets/img/keyboard.png">
<button class='font-weight-bold bg-secondary text-white rounded' id="exportBtn_shopping"
onclick="export_shopping()">Export Shopping
List</button>
<script>
function displayKeyboard_shopping() {
document.getElementsByClassName("keyboard-shopping")[0].style.display = "block";
}
var myNodelist = document.getElementsByTagName("ul");
myNodelist = myNodelist[1];
var i;
for (i = 0; i < myNodelist.length - 1; i++) {
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u00D7");
span.className = "close";
span.appendChild(txt);
myNodelist[i].appendChild(span);
}
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
var div = this.parentElement;
div.style.display = "none";
}
}
function newElement_shopping() {
var li = document.createElement("li");
var inputValue = document.getElementById("myInput1").value;
var secoondInput = document.getElementById("myInput2").value;
var t = document.createTextNode(inputValue + ' ' + secoondInput);
li.appendChild(t);
if (inputValue === '') {
alert("You must add an item name!");
} else if (secoondInput === '') {
alert("You must add a quantity!");
} else {
//if(inputValue is in inventory){alert("Item added to list, however some exists in inventory");}
document.getElementById("myUL_shopping").appendChild(li);
}
document.getElementById("myInput1").value = "";
document.getElementById("myInput2").value = "";
var span = document.createElement("SPAN");
var txt = document.createTextNode("\t\u00D7");
span.className = "close";
span.appendChild(txt);
li.appendChild(span);
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
this.parentElement.remove();
}
}
removeKeyboard_shopping();
}
function removeKeyboard_shopping() {
document.getElementsByClassName("keyboard-shopping")[0].style.display = "none";
}
function export_shopping() {
var button = document.getElementById("exportBtn_shopping");
var makepdf = document.getElementById("myUL_shopping");
button.addEventListener("click", function () {
if (makepdf.innerHTML.trim() === '') {
alert("Your Shopping List is Empty!");
} else {
var mywindow = window.open("", "PRINT", "height=600,width=600");
mywindow.document.write(makepdf.innerHTML);
mywindow.document.close();
mywindow.focus();
mywindow.print();
return true;
}
});
}
</script>
</div>
</section>
<hr class="seperator" />
<!-- calendar Section-->
<section class="page-section" id="calendar">
<div id="calender-super">
<div class="calender-container">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0"> Calendar</h2>
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<label for="calender-name">Name:</label>
<input type="text" id="calender-name" onclick="displayKeyboard_calendar()">
<br>
<label for="calendner-date">Date:</label>
<input type="date" id="calender-date">
<br>
<label for="calendnar-start">Start Time:</label>
<input type="number" id="calender-start" min="0" max="23" placeholder ="0-23" onclick="displayKeyboard_calendar()">
<br>
<label for="calendnar-end">End Time:</label>
<input type="number" id="calender-end" min="0" max="23" placeholder ="0-23" onclick="displayKeyboard_calendar()">
<br>
<img class="keyboard-calendar" src="assets/img/keyboard.png">
<script>
function displayKeyboard_calendar() {
document.getElementsByClassName("keyboard-calendar")[0].style.display = "block";
}
</script>
<button class="font-weight-bold bg-secondary text-white rounded" id="calender-button">ADD TO
SLOT</button>
</div>
<div id="cooking-list"></div>
</div>
<script>
let calButton = document.getElementById("calender-button");
calButton.addEventListener("click", () => {
document.getElementsByClassName("keyboard-calendar")[0].style.display = "none";
let name = document.getElementById("calender-name").value;
let date = document.getElementById("calender-date").value;
let startTime = document.getElementById("calender-start").value;
let endTime = document.getElementById("calender-end").value;
console.log(date.toString());
if (name === "" || date.length === 0) {
alert("Please Enter a valid name and date")
} else if (Number(endTime) <= Number(startTime)) {
alert("please enter a correct time range")
} else {
document.querySelector("#cooking-list").innerHTML += `
<div class = "cooking-slot">
<span id = "slotName">
On ${date}, From ${startTime} to ${endTime} was scheduled by ${name}
</span>
<button class =" calender-delete">
<span id = "delete-span">CONFIRM DELETE</span>
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</button>
</div>
`;
var current_slots = document.querySelectorAll(".calender-delete");
for (var i = 0; i < current_slots.length; i++) {
current_slots[i].onclick = function () {
this.parentNode.remove();
}
}
}
});
</script>
</section>
<hr class="seperator" />
<!-- recipe Section-->
<section class="page-section" id="recipe">
<div class="container d-flex align-items-center flex-column" id="Recipe">
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0"> Recipe</h2>
<div class="divider-custom">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<input id="myInputRecipe" type="text" placeholder="Search Your Recipe..."
onclick="displayKeyboard_recipe()"><br>
<button class="font-weight-bold bg-secondary text-white rounded button-add" id="addBtn"
onclick="myFunction()">Search</button>
<img class="keyboard-recipe" src="assets/img/keyboard.png">
</div>
<div class="search-result">
<div class="item">
<img src="assets/img/buffalo-chicken-dip.png">
<div class="flex-container">
<h1 class="recipe-name">Buffalo Chicken Dip</h1>
<a class="view-button" href="recipe1.html">View Recipe</a>
</div>
<p class="item-data"> Calories: 284</p>
</div>
<div class="item">
<img src="assets/img/roasted-chicken.png">
<div class="flex-container">
<h1 class="recipe-name">Juicy Roasted Chicken</h1>
<a class="view-button" href="recipe2.html">View Recipe</a>
</div>
<p class="item-data"> Calories: 423</p>
</div>
<div class="item">
<img src="assets/img/chicken-pot-pie.png">
<div class="flex-container">
<h1 class="recipe-name">Chicken Pot Pie</h1>
<a class="view-button" href="recipe3.html">View Recipe</a>
</div>
<p class="item-data"> Calories: 412</p>
</div>
<div class="item">
<img src="assets/img/waffles.png">
<div class="flex-container">
<h1 class="recipe-name">Pumpkin Waffles with Apple Cider Syrup</h1>
<a class="view-button" href="recipe4.html">View Recipe</a>
</div>
<p class="item-data"> Calories: 530</p>
</div>
</div>
<!--<section id="recipe1">
</section>-->
<script>
function myFunction() {
let input;
input = document.getElementById("myInputRecipe");
filter = input.value.toUpperCase();
let recipeItem = document.getElementsByClassName('item')
let recipeName = document.getElementsByClassName('recipe-name')
console.log(recipeName)
for (i = 0; i < recipeName.length; i++) {
if (!recipeName[i].innerHTML.toUpperCase().includes(input.value.toUpperCase())) {
recipeItem[i].style.display = "None";
} else {
recipeItem[i].style.display = "";
}
}
removeKeyboard_recipe()
}
function displayKeyboard_recipe() {
// alert(document.getElementsByClassName("keyboard"));
document.getElementsByClassName("keyboard-recipe")[0].style.display = "block";
}
function removeKeyboard_recipe() {
document.getElementsByClassName("keyboard-recipe")[0].style.display = "none";
}
</script>
</section>
<!-- Footer-->
<footer class="footer text-center" padding="3px">
<p>Made for CMSC434 Fall 2022</p>
</footer>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-->
<!-- * * SB Forms JS * *-->
<!-- * * Activate your form at https://startbootstrap.com/solution/contact-forms * *-->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *-->
<script src="https://cdn.startbootstrap.com/sb-forms-latest.js"></script>
</body>
</html>