-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindUp.js
More file actions
135 lines (118 loc) · 5.24 KB
/
FindUp.js
File metadata and controls
135 lines (118 loc) · 5.24 KB
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
function openForm() {
document.getElementById("myForm").style.display = "block";
}
function closeForm() {
document.getElementById("myForm").style.display = "none";
}
var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
window.IDBCursor = window.IDBCursor || window.webkitIDBCursor;
window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange;
var db;
var currentEdit = null;
$(document).ready(function () {
var openReq = indexedDB.open("DetailsDB", 1);
openReq.onupgradeneeded = function (e) {
db = e.target.result;
var store = db.createObjectStore("Details", { keyPath: "id", autoIncrement: true });
console.log(store);
}
openReq.onsuccess = function (e) {
db = e.target.result;
console.log(db);
readAll();
}
});
function readAll() {
var tx = db.transaction(["Details"], "readonly");
var req = tx.objectStore("Details").openCursor();
req.onsuccess = function (e) {
var cursor = e.target.result;
if (!cursor) return;
$(".rightBody").append(
`<div id="produtItems" class="produtItems">
<div class="imgContainer ">
<img class="productImg" src="Images/${cursor.value.Image}" alt="Bat" />
</div>
<div class="productDetalils">
<div>
<h4 class="productName">Product Name:  <a>${cursor.value.ProductName}</a> </h4>
</div>
<p class="priceTag">
<span class="productPrice ">Price:   <a><u>${cursor.value.Price}</u></a> BDT</span>
</p>
<div class="cartBtn">
<button id="addToCart" class="addTocart" onclick="openForm()" data-product-id="${cursor.key}">Add To Cart</button>
</div>
</div>
</div>`
)
cursor.continue();
}
req.onerror = function (err) {
console.log(err);
}
};
$("#searchButton").on('click', function () {
var searchText = $("#searchButton").val();
var tx = db.transaction(["Details"], "readonly");
var req = tx.objectStore("Details").openCursor();
req.onsuccess = function (e) {
var cursor = e.target.result;
if (!cursor) return;
if (cursor.value.ProductName.toLowerCase().includes(searchText.toLowerCase())) {
$(".rightBody").append(
`<div id="produtItems" class="produtItems">
<div class="imgContainer ">
<img class="productImg" src="Images/${cursor.value.Image}" alt="Bat" />
</div>
<div class="productDetalils">
<div>
<h4 class="productName">Product Name:  <a>${cursor.value.ProductName}</a> </h4>
</div>
<p class="priceTag">
<span class="productPrice ">Price:   <a><u>${cursor.value.Price}</u></a> BDT</span>
</p>
<div class="cartBtn">
<button id="addToCart" data-id="${cursor.key}ss">Add To Cart</button>
<button id="goToCart" class="goTocart" onclick="openForm()">Go To Cart</button>
</div>
</div>
</div>`
)
}
cursor.continue();
}
req.onerror = function (err) {
console.log(err);
}
});
//function totall() {
// var unitPrice = document.getElementById("Price").value;
// var quntity = document.getElementById("Price").value;
// document.getElementById("Price") = unitPrice * quntity;
//}
//function mortgageCalc() {
// var amountBorrowed;
// var mortgageTerm;
// var monthlyCost;
// var result = document.getElementById('monthlyCost')
// amountBorrowed = document.getElementById("amountBorrowed").value;
// mortgageTerm = document.getElementById("mortgageTerm").value;
// mortgageTerm *= 12;
// monthlyCost = (amountBorrowed / mortgageTerm);
// console.log(monthlyCost);
// result.innerHTML = monthlyCost
//}
//function totall() {
// var num1;
// var num2;
// var Total;
// var result = document.getElementById('mulPrice')
// var uprice = parseInt(document.getElementById("UnitPrice").value);
// var quantity = parseInt(document.getElementById("quntity").value);
// monthly = uprice * quantity;
// result.innerHTML = Total;
// /*document.getElementById("Price") = total;*/
// /*if (total > 100) console.log("It's over!");*/
//}