-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewEuropa.js
252 lines (202 loc) · 8.32 KB
/
newEuropa.js
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
class MenuPrices {
constructor() {
this.sauces = {
rhodium: 1.5,
palladium: 1.79,
gold: 1.21,
eridium: 1.99,
}
this.toppings = {
diamonds: 1.12,
emeralds: 1.01,
pinkDiamonds: 1.2,
taaffeite: 1.9,
painite: 1.79
}
this.protein = {
anthrorodentia: 9.4,
koaladropp: 2.1,
lumberingGecko: 0.5,
spincattle: 1.2,
kuslolm: 1.212,
senpaiSauce: 2.34
}
this.cheese = {
zebraWormShavings: 1.8,
nettleweb: 1.9,
monkeygakk: 1.101
}
}
updateDynamicMenu(reference) {
let randomNum = Math.ceil(Math.random() * 10);
for (let menuItem in this.sauces) {
this.sauces.rhodium = reference.sauces.rhodium * randomNum;
this.sauces.palladium = reference.sauces.palladium * randomNum;
this.sauces.gold = reference.sauces.gold * randomNum;
this.sauces.eridium = reference.sauces.eridium * randomNum;
}
for (let menuItem in this.sauces) {
this.toppings.diamonds = reference.toppings.diamonds * randomNum;
this.toppings.emeralds = reference.toppings.emeralds * randomNum;
this.toppings.pinkDiamonds = reference.toppings.pinkDiamonds * randomNum;
this.toppings.taaffeite = reference.toppings.taaffeite * randomNum;
this.toppings.painite = reference.toppings.painite * randomNum;
}
for (let menuItem in this.sauces) {
this.protein.anthrorodentia = reference.protein.anthrorodentia * randomNum;
this.protein.koaladropp = reference.protein.koaladropp * randomNum;
this.protein.lumberingGecko = reference.protein.lumberingGecko * randomNum;
this.protein.spincattle = reference.protein.spincattle * randomNum;
this.protein.kuslolm = reference.protein.kuslolm * randomNum;
this.protein.senpaiSauce = reference.protein.senpaiSauce * randomNum;
}
for (let menuItem in this.sauces) {
this.cheese.zebraWormShavings = reference.cheese.zebraWormShavings * randomNum;
this.cheese.nettleweb = reference.cheese.nettleweb * randomNum;
this.cheese.monkeygakk = reference.cheese.monkeygakk * randomNum;
}
}
onInterval(reference) {
setInterval(this.updateDynamicMenu(reference), 500);
}
}
window.addEventListener("load", function() {
//////////////////////////////////////////////////
//////////////////////////////////////////////////
///////////////////////////////////////SCROLL DOWN
//I consider the entirety of this code to be UI logic
// menuDynamic.onInterval(menuReference, 500);
function getHeaderScrollButtons() {
const menuButton = document.getElementById("menuButton");
const psychorderButton = document.getElementById("psychorderButton");
const headerButtonArray = [menuButton, psychorderButton];
return headerButtonArray;
}
function scrollToOnClick() {
window.scrollTo({
left: 0,
top: 100000,
behavior: "smooth"
});
}
const headerButtonArrayGlobal = getHeaderScrollButtons();
headerButtonArrayGlobal[0].addEventListener("click", e => {
e.preventDefault();
scrollToOnClick();
});
headerButtonArrayGlobal[1].addEventListener("click", e => {
e.preventDefault();
scrollToOnClick();
});
//////////////////////////////////////////////////
//////////////////////////////////////////////////
/////////////////////////////////////////SET EMAIL
//UI Logic --> Come back to later, for some reason
//it isn't working
// const hrefEmail = this.document.getElementById("addHrefEmail");
// hrefEmail.addEventListener("click", e => {
// window.location.href="mailto:[email protected]";
// })
//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////CAROUSEL
//I consider the entirety of this code to be UI logic
function carousel(counterPricesParam, counterCarouselParam) {
console.log("hello");
let counterCarousel = counterCarouselParam;
let counterPrices = counterPricesParam;
let imagesForCarousel = document.getElementsByClassName("images");
console.log(counterPrices);
counterCarousel++;
counterPrices = counterPrices + 1;
const menuReference = new MenuPrices;
const menuDynamic = new MenuPrices;
if (counterPrices === 3) {
menuDynamic.updateDynamicMenu(menuReference);
document.getElementsByClassName("saucesRhodium").innerText = menuDynamic.sauces.rhodium;
counterPrices = 0;
}
if (counterCarousel === 47) {
counterCarousel = 0;
for (let i = 0; i < imagesForCarousel.length; i++) {
imagesForCarousel[i].style.display = "none";
}
let slideIndex = 0;
slideIndex++;
if (slideIndex > imagesForCarousel.length) {
slideIndex = 1
}
imagesForCarousel[slideIndex-1].style.display = "block";
}
}
// for (let i = 0; i < 48; i++)
// let counterPrices1 = 0;
// let counterCarousel1 = 0;
// setInterval(() => {carousel(counterPrices1, counterCarousel1)}, 100); // Change image every 4.7 seconds
window.addEventListener("load", function() {
function getHeaderScrollButtons() {
const menuButton = document.getElementById("menuButton");
const psychorderButton = document.getElementById("psychorderButton");
const headerButtonArray = [menuButton, psychorderButton];
return headerButtonArray;
}
let test = getHeaderScrollButtons;
console.log(test);
console.log(getHeaderScrollButtons());
console.log("test");
});
//////////////////////////////////////////////////
//////////////////////////////////////////////////
////////////////////////PRE-MADE SCROLL & POPULATE
//UI Logic
//Business Logic
//////////////////////////////////////////////////
//////////////////////////////////////////////////
/////////////////////CALCULATE PRICES IN REAL TIME
//UI Logic
//Business Logic
//////////////////////////////////////////////////
//////////////////////////////////////////////////
/////////////////////////HOW PRICES ARE CALCULATED
//UI Logic
const orderForm = document.getElementById("orderForm");
const getQuote = this.document.getElementById("getQuote");
orderForm.addEventListener("submit", e => {
e.preventDefault();
const arrayOfBoxValues = document.getElementsByClassName("checkbox");
const checkedValues = filterForChecked(arrayOfBoxValues);
let sumBTC = calculateTotalSum(checkedValues);
getQuote.innerText = `${sumBTC} BTC `;
sumBTC = 0;
//Business Logic
// function roundFloatTo3Dec(float) {
// const roundedFloat = Math.round(float * 100) / 100;
// return roundedFloat;
// }
// function calculateTotalSum(arrayToSum) {
// arrayToSum.forEach(constantValue => {
// sum = sum + (parseFloat(constantValue) * ((Math.random() * 9) + 1));
// })
// sum = roundFloatTo3Dec(sum);
// return sum;
// }
function calculateTotalSum(arrayToSum) {
let sum = 0;
arrayToSum.forEach(constantValue => {
sum = sum + (parseFloat(constantValue));
})
// sum = roundFloatTo3Dec(sum);
return sum;
}
function filterForChecked(unfilteredArray) {
const arrayOfCheckedValues = [];
for (let i = 0; i < unfilteredArray.length; i++) {
if (unfilteredArray[i].checked) {
arrayOfCheckedValues.push(unfilteredArray[i].value);
}
}
return arrayOfCheckedValues;
}
});
//console.log(calculateTotalSum(array));
});