-
Notifications
You must be signed in to change notification settings - Fork 2
/
shop.html
executable file
·247 lines (243 loc) · 10.8 KB
/
shop.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shop - Parking Master 3.0</title>
<style>
@font-face {
font-family: "Modern";
src: url(fonts/GlacialIndifference.ttf);
}
html, body {
font-family: "Modern", Arial;
}
.row {
position: relative;
width: calc(100 - 10px);
height: 150px;
background: #fefefe;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.24);
padding: 10px;
margin-bottom: 10px;
}
.row #row-img {
height: 100%;
float: left;
border-right: 2px solid #999;
}
.row h2 {
position: relative;
left: 100px;
color: #333;
word-wrap: break-word;
width: 80%;
}
.row .price {
position: relative;
float: right;
right: 100px !important;
border-bottom: 1px solid #333;
}
button {
background: #e9e9ed;
border: 1px solid #8f8f9d;
border-radius: 4px;
}
button:hover {
background: #cecece;
}
.swal-overlay {
z-index: 500 !important;
}
.swal-button {
background: #333 !important;
box-shadow: none !important;
color: #fff !important;
width: 100% !important;
}
.swal-modal * {
font-family: Arial, Helvetica, sans-serif !important;
}
</style>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script src="scripts/user/user.js"></script>
</head>
<body>
<div class="wrapper">
<div class="row" data-price="0" data-item="mini_cooper">
<img src="shop/images/cars/mini_cooper.png" id="row-img">
<h2>
2014 Mini Cooper-S
<br>
<p style="font-size: 10px; font-family: Arial, Helvetica, sans-serif; font-weight: 100;">The Classic Mini Cooper has about 189-HP, RWD and Automatic Collision Sensors (ACS). It is available for free on any new or old account.</p>
<button class="preview" onclick="preview(this)">Preview</button> <button onclick="purchase(this)" class="buy">Buy</button>
<div class="price">
<img src="shop/images/icons/point.png" style="width: 60px; vertical-align: middle; margin-top: -6px"><span style="color: #333">0</span>    
</div>
</h2>
</div>
<div class="row" data-price="1900" data-item="countach_lamborghini">
<img src="shop/images/cars/countach_lamborghini.png" id="row-img">
<h2>
2022 Countach Lamborghini
<br>
<p style="font-size: 10px; font-family: Arial, Helvetica, sans-serif; font-weight: 100;">The Lamborghini (Model-Contach) is a very aerodynamic vehicle, kind of like a plane, and has very high horse power too (374 HP).</p>
<button class="preview" onclick="preview(this)">Preview</button> <button onclick="purchase(this)" class="buy">Buy</button>
<div class="price">
<img src="shop/images/icons/point.png" style="width: 60px; vertical-align: middle; margin-top: -6px"><span style="color: #333">1,900</span>    
</div>
</h2>
</div>
<div class="row" data-price="5250" data-item="tesla_roadster">
<img src="shop/images/cars/tesla_roadster.png" id="row-img">
<h2>
2019 Tesla Roadster
<br>
<p style="font-size: 10px; font-family: Arial, Helvetica, sans-serif; font-weight: 100;">Get around in style in this brand-new 2019 Tesla Roadster. Fully electric model.</p>
<button class="preview" onclick="preview(this)">Preview</button> <button onclick="purchase(this)" class="buy">Buy</button>
<div class="price">
<img src="shop/images/icons/point.png" style="width: 60px; vertical-align: middle; margin-top: -6px"><span style="color: #333">5,250</span>    
</div>
</h2>
</div>
<div class="row" data-price="6700" data-item="volkswagen_beetle">
<img src="shop/images/cars/volkswagen_beetle.png" id="row-img">
<h2>
1975 Volkswagen Beetle
<br>
<p style="font-size: 10px; font-family: Arial, Helvetica, sans-serif; font-weight: 100;">The 1975 Volkswagen Beetle is a small, round, stylish vehicle with a rear-engine layout. It was popular, affordable, and simple choice among car buyers at the time.</p>
<button class="preview" onclick="preview(this)">Preview</button> <button onclick="purchase(this)" class="buy">Buy</button>
<div class="price">
<img src="shop/images/icons/point.png" style="width: 60px; vertical-align: middle; margin-top: -6px"><span style="color: #333">6,700</span>    
</div>
</h2>
</div>
<div class="row" data-price="8000" data-item="ferarri_italia">
<img src="shop/images/cars/ferarri_italia.png" id="row-img">
<h2>
2013 Ferarri Italia
<br>
<p style="font-size: 10px; font-family: Arial, Helvetica, sans-serif; font-weight: 100;">The 2013 Ferarri Italia is a high-performance, luxurious sports car with a distinct design. It is a powerful and elegant car that many car enthusiasts and Ferarri fans dream of owning.</p>
<button class="preview" onclick="preview(this)">Preview</button> <button onclick="purchase(this)" class="buy">Buy</button>
<div class="price">
<img src="shop/images/icons/point.png" style="width: 60px; vertical-align: middle; margin-top: -6px"><span style="color: #333">8,000</span>    
</div>
</h2>
</div>
<div class="row" data-price="8550" data-item="bmw_3series">
<img src="shop/images/cars/bmw_3series.png" id="row-img">
<h2>
1985 BMW - 3 Series
<br>
<p style="font-size: 10px; font-family: Arial, Helvetica, sans-serif; font-weight: 100;">The BMW 3 Series is a luxury compact sedan with a sporty design and high-quality interior. It is available in different trims and body styles to suit different needs.</p>
<button class="preview" onclick="preview(this)">Preview</button> <button onclick="purchase(this)" class="buy">Buy</button>
<div class="price">
<img src="shop/images/icons/point.png" style="width: 60px; vertical-align: middle; margin-top: -6px"><span style="color: #333">8,550</span>    
</div>
</h2>
</div>
</div>
<script>
function purchase(el) {
let parent = el.parentElement.parentElement;
let price = parent.dataset.price - 0;
if (userMan.isLoggedIn) {
if (userMan.get("points") - 0 >= price) {
swal({
text: "Are you sure you want to purchase \"" + parent.dataset.item.split("_").join(" ") + "\" for " + price + " points?",
buttons: ["No", "Yes"]
}).then((e) => {
if (e) {
swal({
text: "Purchasing...",
button: "Cancel"
}).then(() => location.reload());
userMan.set("points", userMan.get("points") - price, () => {}, ["username", "t_password"]);
let newItems = userMan.get("items");
newItems.push(parent.dataset.item);
userMan.set("items", newItems, () => {}, ["username", "t_password"]);
setTimeout(() => {
location.reload();
}, 2500);
}
})
} else {
swal("You do not have enough points to purchase this item!");
}
} else {
swal("You must be logged in to buy anything!");
}
}
window.addEventListener("load", function() {
userMan.update(["username", "t_password"]);
document.querySelectorAll(".row").forEach(x => {
if (userMan.isLoggedIn) {
if (userMan.get("items").indexOf(x.dataset.item) > -1) {
x.querySelector("button.buy").textContent = "Sell";
x.querySelector("button.buy").setAttribute("onclick", "sell(this)");
x.querySelector("button.buy").className = "sell";
if (userMan.get("car") == x.dataset.item) {
x.querySelector("button.preview").textContent = "Equip";
x.querySelector("button.preview").onclick = null;
x.querySelector("button.preview").disabled = "disabled";
x.querySelector("button.preview").style.textDecoration = "line-through";
x.querySelector(".price").innerHTML = `
<span style="color: #999">Equipped</span>
`;
return;
}
x.querySelector(".price").innerHTML = `
<span style="color: #999">Owned</span>
`;
x.querySelector("button.preview").textContent = "Equip";
x.querySelector("button.preview").setAttribute("onclick", "equip(this)");
x.querySelector("button.preview").className = "equip";
}
}
});
});
function preview(el) {
let parent = el.parentElement.parentElement;
let type = parent.dataset.item;
location.assign("playground/test_site.html?car=" + type);
}
function equip(el) {
let parent = el.parentElement.parentElement;
swal({
text: "Do you want to equip your main vehicle as \"" + parent.dataset.item.split("_").join(" ") + "\"?",
buttons: ["No", "Yes"]
}).then((e) => {
if (e) {
userMan.set("car", parent.dataset.item, () => {
location.reload();
}, ["username", "t_password"]);
}
});
}
function sell(el) {
let parent = el.parentElement.parentElement;
let sellPrice = (parent.dataset.price - 0) / 2;
swal({
text: "Are you sure you want to sell this item for " + sellPrice + " points?",
buttons: ["No", "Yes"]
}).then((e) => {
if (e) {
if (userMan.get("items").length <= 1) {
return swal("Error: Could not sell this item. You have no other items of this type that you own.");
}
let newItems = userMan.get("items");
newItems.splice(newItems.indexOf(parent.dataset.item), 1);
let otherCar = newItems[0];
userMan.set("points", userMan.get("points") - sellPrice, () => {}, ["username", "t_password"]);
userMan.set("car", otherCar, () => {}, ["username", "t_password"]);
userMan.set("items", newItems, () => {}, ["username", "t_password"]);
setTimeout(() => {
location.reload();
}, 2500);
}
});
}
</script>
</body>
</html>