forked from Adissuu/Grocery-team1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_Tuna.php
121 lines (98 loc) · 4.73 KB
/
p3_Tuna.php
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
<?php include('./assets/php/header.php'); ?>
<main>
<!-- details of single product -->
<div class="small-container single-product">
<div class="row">
<div class="col-2">
<img src="./images/Tuna.jpg" width="100%" id="ProductImg">
</div>
<div class="col-2">
<h2><a href="./index.php">Home</a>/<a href="./p2_SeafoodAisle.php">Seafood</a>/Tuna</h2>
<h1>Tuna</h1>
<h4 style="display: none;" id="unitPrice">11.99</h4>
<h4 class="product-price">$11.99 /<span>bag</span>
</h4>
<br>
<input id="quantity" type="number" min="0" value="1" onchange="updatePrice();saveValue(this)">
<a href="" class="btn">Add To Cart</a>
<br>
<h2 class="proddetail">Product Details <i class="fa fa-indent"></i></h2>
<br>
<p class="prod-dsc">Local, ethically sourced and any other adjective the marketing team can think of
<span id="dots">...</span><span id="more">Lorem ipsum dolor sit amet consectetur, adipisicing
elit. Neque sapiente alias maxime quasi dolorem iusto id magni, voluptatem, ab quibusdam
aperiam enim eligendi ad ipsum ipsa blanditiis. Repellat, aliquam nemo!</span>
</p>
<br>
<button onclick="myFunction()" id="myBtn">Read more</button>
<br>
</div>
</div>
</div>
<!-- product list -->
<section>
<h1 class="section-title"><span>Similar Offerings</span></h1>
<!-- the files path will have to be changed -->
<div class="row2">
<div class="col-5">
<div class="product">
<a href="./p3_Lobster.php">
<img src="./images/Lobster.jpg" alt="Lobster">
<h4 class="aisle-text">Lobster</h4>
<p class="aisle-text">$34.30/unit</p>
</a>
</div>
</div>
<div class="col-5">
<div class="product">
<a href="./p3_Shrimps.php">
<img src="./images/Shrimps.jpg" alt="Shrimps">
<h4 class="aisle-text">Shrimps</h4>
<p class="aisle-text">$8.97/bag</p>
</a>
</div>
</div>
</div>
</section>
</main>
<!---- Footer --->
<div id="footer"></div>
<!-End Of Footer->
<script src="js/script.js"></script>
<script>
function myFunction() {
var dots = document.getElementById("dots");
var moreText = document.getElementById("more");
var btnText = document.getElementById("myBtn");
if (dots.style.display === "none") {
dots.style.display = "inline";
btnText.innerHTML = "Read more";
moreText.style.display = "none";
} else {
dots.style.display = "none";
btnText.innerHTML = "Read less";
moreText.style.display = "inline";
}
}
</script>
<script type="text/javascript">
document.querySelector(".product-price").innerHTML = updatePrice2(getSavedValue("quantity")); // set the value to this input
document.getElementById("quantity").value = getSavedValue("quantity");
//Save the value function - save it to localStorage as (ID, VALUE)
function saveValue(e) {
var id = e.id; // get the sender's id to save it .
var val = e.value; // get the value.
localStorage.setItem(id, val); // Every time user writing something, the localStorage's value will override .
var unitPrice = parseFloat(document.querySelector(".product-price").innerHTML);
localStorage.setItem('product-price', unitPrice);
}
//get the saved value function - return the value of "v" from localStorage.
function getSavedValue(v) {
if (!localStorage.getItem(v)) {
return 0;
}
return localStorage.getItem(v);
}
</script>
</body>
</html>