-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplayDelivery.html
666 lines (548 loc) · 29.2 KB
/
displayDelivery.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
<!DOCTYPE html>
<html>
<head>
<script>
function preloadFunc() {
if (localStorage.getItem("Username") === null) {
window.location.href = ("login.html");
}
}
window.onpaint = preloadFunc();
</script>
<title>Your Deliveries</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-------CSS----------->
<link href="https://fonts.googleapis.com/css?family=Nunito:400,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.11.2/css/all.css">
<link rel="stylesheet" href="md/css/bootstrap.min.css">
<link rel="stylesheet" href="md/css/mdb.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="jquery.toast.css">
<style type="text/css">
.loader {
position: relative;
text-align: center;
margin: 15px auto 35px auto;
z-index: 9999;
display: block;
width: 80px;
height: 80px;
border: 10px solid rgba(0, 0, 0, .3);
border-radius: 50%;
border-top-color: #21b30e;
animation: spin 1s ease-in-out infinite;
-webkit-animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to {
-webkit-transform: rotate(360deg);
}
}
@-webkit-keyframes spin {
to {
-webkit-transform: rotate(360deg);
}
}
/** MODAL STYLING **/
.modal-content {
border-radius: 0px;
box-shadow: 0 0 20px 8px rgba(0, 0, 0, 0.7);
}
.modal-backdrop.show {
opacity: 0.75;
}
.loader-txt {
p {
font-size: 13px;
color: #666;
small {
font-size: 11.5px;
color: #999;
}
}
}
.myOrderCard {
height: 190px !important;
}
.productImage4 {
height: 130px;
padding: 8px;
margin-top: -24px;
}
.productCategoryClass {
font-family: Nunito;
color: #757575 !important;
margin-top: -14px;
}
.quantityClass2 {
background-color: green;
color: white;
font-family: Nunito;
font-size: 16px;
border: none;
text-align: center;
border-radius: 30px;
padding: 2px 8px;
width: 75px;
margin-top: -9px;
}
.paymentStatus {
font-size: 16px;
font-family: Nunito !important;
margin-top: -8px;
}
.priceClass2 {
font-family: Nunito;
font-weight: bold !important;
font-size: 19px;
margin-top: -15px;
}
.priceClass2:hover {
color: red !important;
}
</style>
</head>
<body>
<!-- Modal -->
<div class="modal fade" id="loadMe" tabindex="-1" role="dialog" aria-labelledby="loadMeLabel">
<div class="modal-dialog modal-sm modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body text-center">
<div class="loader"></div>
<div class="loader-txt">
<p id="loadermsg">Loading please wait....</p>
</div>
</div>
</div>
</div>
</div>
<!-- navbar -->
<nav class="navbar navbar-expand-lg navbar-light white-color sticky-top " align="center" id="MainNavbar">
<a class="navbar-brand" href="#"><span><img src="images/logoTitle.png" id="brand"
class="d-inline-block align-center"></a>
<!-- Collapse button -->
<button class="navbar-toggler float-right ml-auto" type="button" data-toggle="collapse" data-target="#navMenu" aria-controls="#navMenu" aria-expanded="false" aria-label="Expand" id="toggleBtn">
<span class="navbar-toggler-icon black-text"></span>
</button>
<!-- cart and profile -->
<span>
<ul class="nav">
<li class="nav-item" onclick="expandcart()">
<a class="nav-link" data-target="#cartModal" data-toggle="modal"><i
class="fas fa-shopping-cart fa-lg "></i><span class="badge white-text" id="cartCountBadge"></span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link " id="navbarDropdownMenuLink-4" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-user fa-lg"></i></a>
<div class="dropdown-menu dropdown-menu-right dropdown-info">
<a class="dropdown-item" href="profile.html">PROFILE</a>
<a class="dropdown-item" href="#" onclick="logout()">LOGOUT</a>
</div>
</li>
</ul>
</span>
<div class="input-group form-inline ml-auto col-sm-10 col-lg-4 searchBarClass">
<input class="form-control my-0 py-1" type="text" placeholder="Search" id="myInput">
<div class="input-group-append">
<span class="input-group-text" id="searchBtn"><i class="fas fa-search" aria-hidden="true"
id="searchIcon"></i></span>
</div>
</div>
<div class="collapse navbar-collapse " id="navMenu">
<ul class="nav navbar-nav ml-auto ">
<li class="nav-item ">
<a class="nav-link" href="homepage.html">HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="DisplayFilterWise.html">CATEGORIES </a>
</li>
</ul>
</div>
</nav>
<!-- navbar -->
<!-- modal for cart -->
<div class="modal fade" id="cartModal" tabindex="-1" role="dialog" aria-labelledby="cartModalTitle" aria-hidden="true">
<!-- Add .modal-dialog-centered to .modal-dialog to vertically center the modal -->
<div class="modal-dialog modal-xl modal-dialog-centered" role="document">
<div class="modal-content cart-modal-class">
<div class="modal-body">
<div class="container">
<!-- Section: Block Content -->
<section>
<div class="row " id="cart-row-header">
<div class="col-md-12 col-lg-12 text-center">
<h5 id="cart-header-title">YOUR CART</h5>
<span id="cart-close-icon" aria-hidden="true" type="button" class="close" data-dismiss="modal">×</span>
</div>
</div>
<hr>
</section>
<!-- Section: Block Content -->
<div class="cart-list" id="cartbody">
</div>
<div class="cart-footer">
<div class="cart-subtotal-div text-center">
<p id="cart-subtotal">Subtotal </p>
</div>
<div class="cart-checkout-div d-flex d-inline justify-content-center">
<button id="continue-shopping-btn" data-dismiss="modal">Continue</button>
<button id="checkout-btn" onclick="window.location.href=('checkout.html');">Checkout</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- main content -->
<div class="container py-4 px-0">
<div class="d-flex px-1 px-md-3 pt-3 pb-5">
<div class="flex-fill">
<div class="card pt-3 pb-4 px-0 px-md-4">
<p class="text-center font-weight-bold py-2" style="font-size: 20px;">Your Deliveries</p>
<div class="flex-column category-product-list" id="productlist">
</div>
</div>
</div>
</div>
</div>
<!-- feedback modal -->
<div class="modal fade" id="modalContactForm" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header text-center">
<h4 class="modal-title w-100 font-weight-bold" style="font-family: Nunito;color: green;">Write to us</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body mx-3">
<div class="md-form">
<textarea type="text" class=" form-control p-2" id="feedback" rows="4" placeholder="Your Message..." style="font-family: Nunito;"></textarea>
</div>
</div>
<div class="modal-footer d-flex justify-content-center">
<button id="feedbackSendBtn" onclick="feedback()">Send</button>
</div>
</div>
</div>
</div>
<!-- footer -->
<footer class="page-footer font-small unique-color-dark pt-4 z-depth-2">
<!-- Footer Links -->
<div class="container text-center text-md-left">
<!-- Grid row -->
<div class="row">
<!-- Grid column -->
<div class="col-md-4 mx-auto">
<img src="images/logoTitle2.png" class="footerLogo">
<p>AgriTech is a E-commerce platform for farmers, which serves farmers the tools and pesticides easily,quickly and at reasonable rates.</p>
</div>
<!-- Grid column -->
<hr class="clearfix w-100 d-md-none">
<!-- Grid column -->
<div class="col-md-2 mx-auto">
<!-- Links -->
<h5 class="text-uppercase mt-3 mb-4 footerLinkClass">Company</h5>
<ul class="list-unstyled">
<li>
<a href="about.html">About Us</a>
</li>
<!-- <li>
<a href="#!">Core Values</a>
</li>
<li>
<a href="#!">Careers</a>
</li>
<li>
<a href="#!">Sitemap</a>
</li> -->
</ul>
</div>
<!-- Grid column -->
<hr class="clearfix w-100 d-md-none">
<!-- Grid column -->
<div class="col-md-2 mx-auto">
<!-- Links -->
<h5 class=" text-uppercase mt-3 mb-4 footerLinkClass">Policy Info</h5>
<ul class="list-unstyled">
<li>
<a href="#!">Privacy Policy</a>
</li>
<!-- <li>
<a href="#!">Terms of Sale</a>
</li> -->
<li>
<a href="#!">Terms of Use</a>
</li>
<!-- <li>
<a href="#!">Report Abuse</a>
</li> -->
</ul>
</div>
<!-- Grid column -->
<hr class="clearfix w-100 d-md-none">
<!-- Grid column -->
<div class="col-md-2 mx-auto">
<!-- Links -->
<h5 class="text-uppercase mt-3 mb-4 footerLinkClass">help</h5>
<ul class="list-unstyled">
<li>
<a href="#!">FAQ</a>
</li>
<li>
<a href="" data-toggle="modal" data-target="#modalContactForm">Contact Us</a>
</li>
</ul>
</div>
<!-- Grid column -->
</div>
<!-- Grid row -->
</div>
<!-- Footer Links -->
<hr>
<!-- Social buttons -->
<ul class="list-unstyled list-inline text-center">
<li class="list-inline-item">
<a class="btn-floating btn-fb mx-1">
<i class="fab fa-facebook-f"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-tw mx-1">
<i class="fab fa-twitter"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-gplus mx-1">
<i class="fab fa-google-plus-g"> </i>
</a>
</li>
<li class="list-inline-item">
<a class="btn-floating btn-li mx-1">
<i class="fab fa-linkedin-in"> </i>
</a>
</li>
</ul>
<!-- Social buttons -->
<!-- Copyright -->
<div class="footer-copyright text-center py-3">© 2020 Copyright:
<a href="#">AgriTech</a>
</div>
<!-- Copyright -->
</footer>
<!-- js -->
<script type="text/javascript" src="md/js/jquery.min.js"></script>
<script type="text/javascript" src="md/js/popper.min.js"></script>
<script type="text/javascript" src="md/js/bootstrap.min.js"></script>
<script type="text/javascript" src="md/js/mdb.min.js"></script>
<script src="jquery.toast.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.6.1/firebase.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyBw4RVlD1ZdnNNn4ow5hahtxPxBSpL_tpA",
authDomain: "website-e1c2c.firebaseapp.com",
databaseURL: "https://website-e1c2c.firebaseio.com",
projectId: "website-e1c2c",
storageBucket: "website-e1c2c.appspot.com",
messagingSenderId: "640557542653",
appId: "1:640557542653:web:215d1a31f7ace2f72fe294"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<script>
var catagory = "Pesticide";
var cnt = 0;
var ordBy = "name";
window.onload = () => {
load_data(ordBy);
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").on("value", function(snapshot) {
var cartCnt = snapshot.numChildren();
document.getElementById("cartCountBadge").innerHTML = cartCnt;
if (cartCnt == 0) {
document.getElementById("checkout-btn").disabled = true;
document.getElementById("checkout-btn").style = "background-color:grey !important";
} else {
document.getElementById("checkout-btn").disabled = false;
document.getElementById("checkout-btn").style = "background-color:green !important";
}
});
//document.getElementById("myName").innerHTML=localStorage.getItem("Username");
};
/*firebase.database().ref().child("HomeImages").limitToLast(3).on('value', function(snapshot1) {
if (snapshot1.exists())
{
document.getElementById("carouselimages").innerHTML="";
snapshot1.forEach(function(childSnapshot) {
document.getElementById("carouselimages").innerHTML+="<div class='carousel-item active'><img class='d-block w-100 sliderImageClass' src="+childSnapshot.val().ImageUri+"></div>";
});
}
});*/
function load_data(orderBy) {
$("#loadMe").modal({
backdrop: "static", //remove ability to close modal with click
keyboard: false, //remove option to close with keyboard
show: true //Display loader!
});
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("delivery").orderByChild(orderBy).on('value', function(snapshot1) {
if (snapshot1.exists()) {
var cnt = 0,
cnt1 = 0,
cnt3 = 1;
var ele;
document.getElementById("productlist").innerHTML = "<div id='notfound'class='text-center py-3 mb-1' style='display: none;'><img class='image-fluid' src='images/alert.png' style='height:80px; width:80px;' /><br><p style='font-size:18px;font-weight:bold;margin-top:12px;'>Sorry, No Results Found !</p></div>";
snapshot1.forEach(function(childSnapshot) {
cnt1++;
var storageRef = firebase.storage().ref();
if (cnt3 % 2 == 0) {
document.getElementById("productlist").innerHTML += "<div class='row mx-2'>" + ele + "<div class='col-lg-6 col-md-12 col-sm-12 border' id='search' onclick=openNext('" + childSnapshot.val().ordid + "')> <div class='card-body myOrderCard'> <div class='row align-items-center'><div class='col-5 px-0 align-items-center justify-content-center text-center'> <view class='zoom'><img id=imgcat" + cnt1 + " class='img-fluid productImage4'> </view></div> <div class='col-7'><p class='product-name-class-3 text-left font-weight-bold'><a>" + (childSnapshot.val().name).toUpperCase() + "</a></p><p class='productCategoryClass'>" + childSnapshot.val().catagory + "</p> <p class='quantityClass2'>Qty : " + childSnapshot.val().qty + " </p><p class='paymentStatus black-text'>Payment - <b class='paymentStatus'>" + childSnapshot.val().payment + "</b> </p><p class='priceClass2 float-left black-text'>Rs." + childSnapshot.val().totalprice + "</p></div> </div></div></div>";
ele = "";
} else {
ele = "<div class='col-lg-6 col-md-12 col-sm-12 border' id='search' onclick=openNext('" + childSnapshot.val().ordid + "')> <div class='card-body myOrderCard'> <div class='row align-items-center'><div class='col-5 px-0 align-items-center justify-content-center text-center'> <view class='zoom'><img id=imgcat" + cnt1 + " class='img-fluid productImage4'> </view></div> <div class='col-7'><p class='product-name-class-3 text-left font-weight-bold'><a>" + (childSnapshot.val().name).toUpperCase() + "</a></p><p class='productCategoryClass'>" + childSnapshot.val().catagory + "</p> <p class='quantityClass2'>Qty : " + childSnapshot.val().qty + " </p><p class='paymentStatus black-text'>Payment - <b class='paymentStatus'>" + childSnapshot.val().payment + "</b> </p><p class='priceClass2 float-left black-text'>Rs." + childSnapshot.val().totalprice + "</p></div> </div></div></div>";
}
(function(pid) {
storageRef.child(childSnapshot.val().image).getDownloadURL().then(function(url) {
document.getElementById("imgcat" + pid).src = url;
}).catch(function(error) {
console.log(error);
});
})(cnt1);
cnt3++;
});
if (cnt3 % 2 == 0)
document.getElementById("productlist").innerHTML += "<div class='row mx-2'>" + ele + "</div>";
}
setTimeout(function() {
$("#loadMe").modal("hide");
}, 1000);
});
}
function openNext(id) {
localStorage.setItem("ordId", id);
window.location.href = ("displayDetailDelivery.html");
}
$(document).ready(function() {
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#productlist #search").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
if ($("#productlist #search:visible").length == 0) {
document.getElementById("notfound").style = "display:block;";
} else {
document.getElementById("notfound").style = "display:none;";
}
});
});
function changeqty(name, qty) {
name = decodeURIComponent(name);
if (qty == 0)
qty = 1;
qty = parseInt(qty);
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").child(name).child("qty").set(qty);
}
function nextProduct(name) {
//localStorage.setItem("pname",name);
window.location.href = ("ProductDetails.html?pname=" + name);
}
function expandcart() {
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").orderByChild("name").on('value', function(snapshot1) {
var storageRef = firebase.storage().ref();
document.getElementById("cartbody").innerHTML = "";
if (snapshot1.exists()) {
var cnt = 0,
cnt1 = 0,
total = 0;
document.getElementById("cartbody").innerHTML = "";
snapshot1.forEach(function(childSnapshot) {
total += childSnapshot.val().price * childSnapshot.val().qty;
//document.getElementById("cartbody").innerHTML+="<!-- First row --><tr><th scope='row'><img id=img"+cnt+" alt='' class='img-fluid z-depth-0' style='height: 120px;'></th><td><h5 class='mt-3'><strong>"+childSnapshot.val().name+"</strong></h5><p class='text-muted'>"+childSnapshot.val().catagory+"</p></td><td></td><td>"+childSnapshot.val().price+"</td><td><input type='number' value='2' aria-label='Search' class='form-control' style='width: 100px'></td><td class='font-weight-bold'><strong>"+childSnapshot.val().price+"</strong></td><td><button type='button' class='btn btn-sm btn-primary' id=removebtn"+cnt+" data-toggle='tooltip' data-placement='top' title='Remove item' onclick=removeitem('"+ encodeURIComponent(childSnapshot.val().name)+"')>X</button></td></tr><!-- First row -->";
// $("#removebtn"+cnt).click(function(){
// firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").child(childSnapshot.val().name).remove();
// });
cnt++;
document.getElementById("cartbody").innerHTML += "<div class='row cart-item-row' ><div class='col-lg-2 col-md-2 col-sm-12 text-center' onclick=nextProduct('" + encodeURIComponent(childSnapshot.val().name) + "')><img id=img" + cnt + " class='cart-item-image img-fluid'></div><div class='col-lg-10 col-md-10 col-sm-12' style='padding-top: 24px'><div class='row'><div class='col-lg-8 col-md-8 col-sm-12 ' style='padding-bottom:2px;'><div class='text-center'> <div class='flex-column text-md-left'> <p class='cart-item-name-class px-4 ' onclick=nextProduct('" + encodeURIComponent(childSnapshot.val().name) + "')> <a>" + childSnapshot.val().name + " </a> </p> <p class='cart-category-class px-4'> <a>" + childSnapshot.val().catagory + "</a> </p></div></div></div><div class='col-lg-4 col-md-4 col-sm-12 text-center'><div class='row'><div class='col text-right'><p class='cart-item-price'>Rs." + childSnapshot.val().price + "</p></div><div class='col'><div class='row cart-item-quantity'><input type='button' id='minus' class='cart-item-quantity-button' value='-' onclick=changeqty('" + encodeURIComponent(childSnapshot.val().name) + "','" + (childSnapshot.val().qty - 1) + "')><input value=" + childSnapshot.val().qty + " pattern='\d*' onkeyup=changeqty('" + encodeURIComponent(childSnapshot.val().name) + "',this.value) class='text-center cart-item-quantity-input'><input type='button' id='plus' value='+' onclick=changeqty('" + encodeURIComponent(childSnapshot.val().name) + "','" + (parseInt(childSnapshot.val().qty) + 1) + "') class='cart-item-quantity-button'> </div></div></div></div></div> <div class='d-flex d-inline justify-content-center cart-item-remove-div'><p class='cart-item-remove-button'><a id=removebtn" + cnt + " onclick=removeitem('" + encodeURIComponent(childSnapshot.val().name) + "')>Remove Item <i class='far fa-trash-alt'></i></a></p></div></div></div><hr>";
(function(pid) {
storageRef.child(childSnapshot.val().image).getDownloadURL().then(function(url) {
document.getElementById("img" + pid).src = url;
}).catch(function(error) {
console.log(error);
});
})(cnt);
// storageRef.child(childSnapshot.val().image).getDownloadURL().then(function(url) {
// document.getElementById("img"+cnt).src=url;
// cnt++;
// });
});
document.getElementById("cart-subtotal").innerHTML = "Subtotal = Rs. " + total;
}
});
}
function removeitem(val) {
val = decodeURIComponent(val);
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").child(val).remove();
expandcart();
}
function addtocart(item) {
item = decodeURIComponent(item);
firebase.database().ref().child("Posts").child(item).once('value', function(snapshot1) {
var obj = {
name: snapshot1.val().name,
price: snapshot1.val().price,
image: snapshot1.val().image,
catagory: snapshot1.val().catagory,
seller: snapshot1.val().seller,
qty: 1
};
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").child(item).set(obj);
});
}
function feedback() {
if (document.getElementById("feedback").value == "") {
alert("Write something !");
return;
}
firebase.database().ref().child("Feedbacks").push({
Feedback: document.getElementById("feedback").value,
Name: localStorage.getItem("Username")
});
$("#modalContactForm").modal("hide");
$.toast({
text: "Success", // Text that is to be shown in the toast
heading: 'Thanks for your Feedback!', // Optional heading to be shown on the toast
icon: 'success', // Type of toast icon
showHideTransition: 'fade', // fade, slide or plain
allowToastClose: true, // Boolean value true or false
hideAfter: 3000, // false to make it sticky or number representing the miliseconds as time after which toast needs to be hidden
stack: 5, // false if there should be only one toast at a time or a number representing the maximum number of toasts to be shown at a time
position: 'bottom-right', // bottom-left or bottom-right or bottom-center or top-left or top-right or top-center or mid-center or an object representing the left, right, top, bottom values
textAlign: 'left', // Text alignment i.e. left, right or center
loader: true, // Whether to show loader or not. True by default
loaderBg: '#9EC600', // Background color of the toast loader
beforeShow: function() {}, // will be triggered before the toast is shown
afterShown: function() {}, // will be triggered after the toat has been shown
beforeHide: function() {}, // will be triggered before the toast gets hidden
afterHidden: function() {} // will be triggered after the toast has been hidden
});
document.getElementById("feedback").value = "";
}
function logout() {
localStorage.clear();
window.location.href = ("login.html");
}
firebase.database().ref().child("Users").child(localStorage.getItem("Username")).child("cart").orderByChild("name").on('value', function(snapshot1) {
if (parseInt(snapshot1.numChildren()) == 0) {
document.getElementById("cart-subtotal").innerHTML = "Subtotal = Rs. 0";
document.getElementById("cartbody").style = "background-image:url('images/emptycart.png');background-repeat: no-repeat;background-size: 290px 250px;background-position: center center; ";
} else {
document.getElementById("cartbody").style = "background-color:white;";
}
});
</script>
</body>
</html>