dashboard.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. const homeStrand = require("./home.js");
  2. const ingredientsStrand = require("./ingredients.js");
  3. const ordersStrand = require("./orders.js");
  4. const recipeBookStrand = require("./recipeBook.js");
  5. const transactionsStrand = require("./transactions.js");
  6. const addIngredientsComp = require("./addIngredients.js");
  7. const ingredientDetailsComp = require("./ingredientDetails.js");
  8. const newIngredientComp = require("./newIngredient.js");
  9. const newOrderComp = require("./newOrder.js");
  10. const newRecipeComp = require("./newRecipe.js");
  11. const newTransactionComp = require("./newTransaction.js");
  12. const orderDetailsComp = require("./orderDetails.js");
  13. const recipeDetailsComp = require("./recipeDetails.js");
  14. const transactionDetailsComp = require("./transactionDetails.js");
  15. const ingredients = require("./ingredients.js");
  16. const recipeBook = require("./recipeBook.js");
  17. const orders = require("./orders.js");
  18. const transactions = require("./transactions.js");
  19. class Ingredient{
  20. constructor(id, name, category, unitType, unit, parent){
  21. this.id = id;
  22. this.name = name;
  23. this.category = category;
  24. this.unitType = unitType;
  25. this.unit = unit;
  26. this.parent = parent;
  27. }
  28. convert(quantity){
  29. if(this.unitType === "mass"){
  30. switch(this.unit){
  31. case "g": break;
  32. case "kg": quantity /= 1000; break;
  33. case "oz": quantity /= 28.3495; break;
  34. case "lb": quantity /= 453.5924; break;
  35. }
  36. }else if(this.unitType === "volume"){
  37. switch(this.unit){
  38. case "ml": quantity *= 1000; break;
  39. case "l": break;
  40. case "tsp": quantity *= 202.8842; break;
  41. case "tbsp": quantity *= 67.6278; break;
  42. case "ozfl": quantity *= 33.8141; break;
  43. case "cup": quantity *= 4.1667; break;
  44. case "pt": quantity *= 2.1134; break;
  45. case "qt": quantity *= 1.0567; break;
  46. case "gal": quantity /= 3.7854; break;
  47. }
  48. }else if(this.unitType === "length"){
  49. switch(this.unit){
  50. case "mm": quantity *= 1000; break;
  51. case "cm": quantity *= 100; break;
  52. case "m": break;
  53. case "in": quantity *= 39.3701; break;
  54. case "ft": quantity *= 3.2808; break;
  55. }
  56. }
  57. return quantity;
  58. }
  59. }
  60. class Recipe{
  61. constructor(id, name, price, ingredients, parent){
  62. this.id = id;
  63. this.name = name;
  64. this.price = price;
  65. this.parent = parent;
  66. this.ingredients = [];
  67. for(let i = 0; i < ingredients.length; i++){
  68. for(let j = 0; j < parent.ingredients.length; j++){
  69. if(ingredients[i].ingredient === parent.ingredients[j].ingredient.id){
  70. this.ingredients.push({
  71. ingredient: parent.ingredients[j].ingredient,
  72. quantity: ingredients[i].quantity
  73. });
  74. break;
  75. }
  76. }
  77. }
  78. }
  79. }
  80. class Transaction{
  81. constructor(id, date, recipes, parent){
  82. this.id = id;
  83. this.parent = parent;
  84. this.date = new Date(date);
  85. this.recipes = [];
  86. for(let i = 0; i < recipes.length; i++){
  87. for(let j = 0; j < parent.recipes.length; j++){
  88. if(recipes[i].recipe === parent.recipes[j].id){
  89. this.recipes.push({
  90. recipe: parent.recipes[j],
  91. quantity: recipes[i].quantity
  92. });
  93. break;
  94. }
  95. }
  96. }
  97. }
  98. }
  99. class Order{
  100. constructor(id, name, date, ingredients, parent){
  101. this.id = id;
  102. this.name = name;
  103. this.date = new Date(date);
  104. this.ingredients = [];
  105. this.parent = parent;
  106. for(let i = 0; i < ingredients.length; i++){
  107. for(let j = 0; j < parent.ingredients.length; j++){
  108. if(ingredients[i].ingredient === parent.ingredients[j].ingredient.id){
  109. this.ingredients.push({
  110. ingredient: parent.ingredients[j].ingredient,
  111. quantity: ingredients[i].quantity,
  112. price: ingredients[i].price
  113. });
  114. }
  115. }
  116. }
  117. }
  118. convertPrice(unitType, unit, price){
  119. if(unitType === "mass"){
  120. switch(unit){
  121. case "g": break;
  122. case "kg": price *= 1000; break;
  123. case "oz": price *= 28.3495; break;
  124. case "lb": price *= 453.5924; break;
  125. }
  126. }else if(unitType === "volume"){
  127. switch(unit){
  128. case "ml": price /= 1000; break;
  129. case "l": break;
  130. case "tsp": price /= 202.8842; break;
  131. case "tbsp": price /= 67.6278; break;
  132. case "ozfl": price /= 33.8141; break;
  133. case "cup": price /= 4.1667; break;
  134. case "pt": price /= 2.1134; break;
  135. case "qt": price /= 1.0567; break;
  136. case "gal": price *= 3.7854; break;
  137. }
  138. }else if(unitType === "length"){
  139. switch(unit){
  140. case "mm": price /= 1000; break;
  141. case "cm": price /= 100; break;
  142. case "m": break;
  143. case "in": price /= 39.3701; break;
  144. case "ft": price /= 3.2808; break;
  145. }
  146. }
  147. return price;
  148. }
  149. }
  150. class Merchant{
  151. constructor(oldMerchant, transactions){
  152. this.name = oldMerchant.name;
  153. this.pos = oldMerchant.pos;
  154. this.ingredients = [];
  155. this.recipes = [];
  156. this.transactions = [];
  157. this.orders = [];
  158. this.units = {
  159. mass: ["g", "kg", "oz", "lb"],
  160. volume: ["ml", "l", "tsp", "tbsp", "ozfl", "cup", "pt", "qt", "gal"],
  161. length: ["mm", "cm", "m", "in", "foot"]
  162. }
  163. for(let i = 0; i < oldMerchant.inventory.length; i++){
  164. this.ingredients.push({
  165. ingredient: new Ingredient(
  166. oldMerchant.inventory[i].ingredient._id,
  167. oldMerchant.inventory[i].ingredient.name,
  168. oldMerchant.inventory[i].ingredient.category,
  169. oldMerchant.inventory[i].ingredient.unitType,
  170. oldMerchant.inventory[i].defaultUnit,
  171. this
  172. ),
  173. quantity: oldMerchant.inventory[i].quantity
  174. });
  175. }
  176. for(let i = 0; i < oldMerchant.recipes.length; i++){
  177. this.recipes.push(new Recipe(
  178. oldMerchant.recipes[i]._id,
  179. oldMerchant.recipes[i].name,
  180. oldMerchant.recipes[i].price,
  181. oldMerchant.recipes[i].ingredients,
  182. this
  183. ));
  184. }
  185. for(let i = 0; i < transactions.length; i++){
  186. this.transactions.push(new Transaction(
  187. transactions[i]._id,
  188. transactions[i].date,
  189. transactions[i].recipes,
  190. this
  191. ));
  192. }
  193. }
  194. /*
  195. Updates all specified item in the merchant's inventory and updates the page
  196. If ingredient doesn't exist, add it
  197. ingredients = {
  198. ingredient: Ingredient object,
  199. quantity: new quantity,
  200. defaultUnit: the default unit to be displayed
  201. }
  202. remove = set true if removing
  203. isOrder = set true if this is coming from an order
  204. */
  205. editIngredients(ingredients, remove = false, isOrder = false){
  206. for(let i = 0; i < ingredients.length; i++){
  207. let isNew = true;
  208. for(let j = 0; j < merchant.ingredients.length; j++){
  209. if(merchant.ingredients[j].ingredient === ingredients[i].ingredient){
  210. if(remove){
  211. merchant.ingredients.splice(j, 1);
  212. }else if(!remove && isOrder){
  213. merchant.ingredients[j].quantity += ingredients[i].quantity;
  214. }else{
  215. merchant.ingredients[j].quantity = ingredients[i].quantity;
  216. }
  217. isNew = false;
  218. break;
  219. }
  220. }
  221. if(isNew){
  222. merchant.ingredients.push({
  223. ingredient: ingredients[i].ingredient,
  224. quantity: parseFloat(ingredients[i].quantity),
  225. defaultUnit: ingredients[i].defaultUnit
  226. });
  227. }
  228. }
  229. homeStrandObj.drawInventoryCheckCard();
  230. ingredientsStrandObj.populateByProperty("category");
  231. addIngredientsComp.isPopulated = false;
  232. closeSidebar();
  233. }
  234. /*
  235. Updates a recipe in the merchants list of recipes
  236. Can create, edit or remove
  237. recipe = [Recipe object]
  238. remove = will remove recipe when true
  239. */
  240. editRecipes(recipes, remove = false){
  241. let isNew = true;
  242. for(let i = 0; i < recipes.length; i++){
  243. for(let j = 0; j < this.recipes.length; j++){
  244. if(recipes[i] === this.recipes[j]){
  245. if(remove){
  246. this.recipes.splice(j, 1);
  247. }else{
  248. this.recipes[j] = recipes[i];
  249. }
  250. isNew = false;
  251. break;
  252. }
  253. }
  254. if(isNew){
  255. merchant.recipes.push(recipes[i]);
  256. }
  257. }
  258. transactionsStrandObj.isPopulated = false;
  259. recipeBookStrandObj.populateRecipes();
  260. closeSidebar();
  261. }
  262. /*
  263. Updates a list of orders in the merchants list of orders
  264. Create/edit/remove
  265. orders = [Order object]
  266. remove = will remove order when true
  267. */
  268. editOrders(orders, remove = false){
  269. for(let i = 0; i < orders.length; i++){
  270. let isNew = true;
  271. for(let j = 0; j < this.orders.length; j++){
  272. if(orders[i] === this.orders[j]){
  273. if(remove){
  274. this.orders.splice(j, 1);
  275. }else{
  276. this.orders[j] = orders[i];
  277. }
  278. isNew = false;
  279. break;
  280. }
  281. }
  282. if(isNew){
  283. this.orders.push(orders[i]);
  284. }
  285. }
  286. ordersStrandObj.populate();
  287. closeSidebar();
  288. }
  289. editTransactions(transaction, remove = false){
  290. let isNew = true;
  291. for(let i = 0; i < this.transactions.length; i++){
  292. if(this.transactions[i] === transaction){
  293. if(remove){
  294. this.transactions.splice(i, 1);
  295. }
  296. isNew = false;
  297. break;
  298. }
  299. }
  300. if(isNew){
  301. this.transactions.push(transaction);
  302. this.transactions.sort((a, b) => a.date > b.date ? 1 : -1);
  303. }
  304. transactionsStrandObj.isPopulated = false;
  305. transactionsStrandObj.display();
  306. closeSidebar();
  307. }
  308. /*
  309. Gets the indices of two dates from transactions
  310. Inputs
  311. from: starting date
  312. to: ending date (default to now)
  313. Output
  314. Array containing starting index and ending index
  315. Note: Will return false if it cannot find both necessary dates
  316. */
  317. transactionIndices(from, to = new Date()){
  318. let indices = [];
  319. for(let i = 0; i < this.transactions.length; i++){
  320. if(this.transactions[i].date > from){
  321. indices.push(i);
  322. break;
  323. }
  324. }
  325. for(let i = this.transactions.length - 1; i >=0; i--){
  326. if(this.transactions[i].date < to){
  327. indices.push(i);
  328. break;
  329. }
  330. }
  331. if(indices.length < 2){
  332. return false;
  333. }
  334. return indices;
  335. }
  336. revenue(indices){
  337. let total = 0;
  338. for(let i = indices[0]; i <= indices[1]; i++){
  339. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  340. for(let k = 0; k < this.recipes.length; k++){
  341. if(this.transactions[i].recipes[j].recipe === this.recipes[k]){
  342. total += this.transactions[i].recipes[j].quantity * this.recipes[k].price;
  343. }
  344. }
  345. }
  346. }
  347. return total / 100;
  348. }
  349. /*
  350. Gets the quantity of each ingredient sold between two dates (dateRange)
  351. Inputs
  352. dateRange: list containing a start date and an end date
  353. Return:
  354. [{
  355. ingredient: Ingredient object,
  356. quantity: quantity of ingredient sold
  357. }]
  358. */
  359. ingredientsSold(dateRange){
  360. if(!dateRange){
  361. return false;
  362. }
  363. let recipes = this.recipesSold(dateRange);
  364. let ingredientList = [];
  365. for(let i = 0; i < recipes.length; i++){
  366. for(let j = 0; j < recipes[i].recipe.ingredients.length; j++){
  367. let exists = false;
  368. for(let k = 0; k < ingredientList.length; k++){
  369. if(ingredientList[k].ingredient === recipes[i].recipe.ingredients[j].ingredient){
  370. exists = true;
  371. ingredientList[k].quantity += recipes[i].quantity * recipes[i].recipe.ingredients[j].quantity;
  372. break;
  373. }
  374. }
  375. if(!exists){
  376. ingredientList.push({
  377. ingredient: recipes[i].recipe.ingredients[j].ingredient,
  378. quantity: recipes[i].quantity * recipes[i].recipe.ingredients[j].quantity
  379. });
  380. }
  381. }
  382. }
  383. return ingredientList;
  384. }
  385. singleIngredientSold(dateRange, ingredient){
  386. let total = 0;
  387. for(let i = dateRange[0]; i < dateRange[1]; i++){
  388. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  389. for(let k = 0; k < this.transactions[i].recipes[j].recipe.ingredients.length; k++){
  390. if(this.transactions[i].recipes[j].recipe.ingredients[k].ingredient === ingredient.ingredient){
  391. total += this.transactions[i].recipes[j].recipe.ingredients[k].quantity;
  392. break;
  393. }
  394. }
  395. }
  396. }
  397. return total;
  398. }
  399. /*
  400. Gets the number of recipes sold between two dates (dateRange)
  401. Inputs:
  402. dateRange: array containing a start date and an end date
  403. Return:
  404. [{
  405. recipe: a recipe object
  406. quantity: quantity of the recipe sold
  407. }]
  408. */
  409. recipesSold(dateRange){
  410. let recipeList = [];
  411. for(let i = dateRange[0]; i <= dateRange[1]; i++){
  412. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  413. let exists = false;
  414. for(let k = 0; k < recipeList.length; k++){
  415. if(recipeList[k].recipe === this.transactions[i].recipes[j].recipe){
  416. exists = true;
  417. recipeList[k].quantity += this.transactions[i].recipes[j].quantity;
  418. break;
  419. }
  420. }
  421. if(!exists){
  422. recipeList.push({
  423. recipe: this.transactions[i].recipes[j].recipe,
  424. quantity: this.transactions[i].recipes[j].quantity
  425. });
  426. }
  427. }
  428. }
  429. return recipeList;
  430. }
  431. /*
  432. Create revenue data for graphing
  433. Input:
  434. dateRange: [start index, end index] (this.transactionIndices)
  435. Return:
  436. [total revenue for each day]
  437. */
  438. graphDailyRevenue(dateRange){
  439. if(!dateRange){
  440. return false;
  441. }
  442. let dataList = new Array(30).fill(0);
  443. let currentDate = this.transactions[dateRange[0]].date;
  444. let arrayIndex = 0;
  445. for(let i = dateRange[0]; i <= dateRange[1]; i++){
  446. if(this.transactions[i].date.getDate() !== currentDate.getDate()){
  447. currentDate = this.transactions[i].date;
  448. arrayIndex++;
  449. }
  450. for(let j = 0; j < this.transactions[i].recipes.length; j++){
  451. dataList[arrayIndex] += (this.transactions[i].recipes[j].recipe.price / 100) * this.transactions[i].recipes[j].quantity;
  452. }
  453. }
  454. return dataList;
  455. }
  456. /*
  457. Groups all of the merchant's ingredients by their category
  458. Return: [{
  459. name: category name,
  460. ingredients: [Ingredient Object]
  461. }]
  462. */
  463. categorizeIngredients(){
  464. let ingredientsByCategory = [];
  465. for(let i = 0; i < this.ingredients.length; i++){
  466. let categoryExists = false;
  467. for(let j = 0; j < ingredientsByCategory.length; j++){
  468. if(this.ingredients[i].ingredient.category === ingredientsByCategory[j].name){
  469. ingredientsByCategory[j].ingredients.push(this.ingredients[i]);
  470. categoryExists = true;
  471. break;
  472. }
  473. }
  474. if(!categoryExists){
  475. ingredientsByCategory.push({
  476. name: this.ingredients[i].ingredient.category,
  477. ingredients: [this.ingredients[i]]
  478. });
  479. }
  480. }
  481. return ingredientsByCategory;
  482. }
  483. unitizeIngredients(){
  484. let ingredientsByUnit = [];
  485. for(let i = 0; i < this.ingredients.length; i++){
  486. let unitExists = false;
  487. for(let j = 0; j < ingredientsByUnit.length; j++){
  488. if(this.ingredients[i].ingredient.unit === ingredientsByUnit[j].name){
  489. ingredientsByUnit[j].ingredients.push(this.ingredients[i]);
  490. unitExists = true;
  491. break;
  492. }
  493. }
  494. if(!unitExists){
  495. ingredientsByUnit.push({
  496. name: this.ingredients[i].ingredient.unit,
  497. ingredients: [this.ingredients[i]]
  498. });
  499. }
  500. }
  501. return ingredientsByUnit;
  502. }
  503. getRecipesForIngredient(ingredient){
  504. let recipes = [];
  505. for(let i = 0; i < this.recipes.length; i++){
  506. for(let j = 0; j < this.recipes[i].ingredients.length; j++){
  507. if(this.recipes[i].ingredients[j].ingredient === ingredient){
  508. recipes.push(this.recipes[i]);
  509. }
  510. }
  511. }
  512. return recipes;
  513. }
  514. }
  515. let convertToMain = (unit, quantity)=>{
  516. let converted = 0;
  517. if(merchant.units.mass.includes(unit)){
  518. switch(unit){
  519. case "g": converted = quantity; break;
  520. case "kg": converted = quantity * 1000; break;
  521. case "oz": converted = quantity * 28.3495; break;
  522. case "lb": converted = quantity * 453.5924; break;
  523. }
  524. }else if(merchant.units.volume.includes(unit)){
  525. switch(unit){
  526. case "ml": converted = quantity / 1000; break;
  527. case "l": converted = quantity; break;
  528. case "tsp": converted = quantity / 202.8842; break;
  529. case "tbsp": converted = quantity / 67.6278; break;
  530. case "ozfl": converted = quantity / 33.8141; break;
  531. case "cup": converted = quantity / 4.1667; break;
  532. case "pt": converted = quantity / 2.1134; break;
  533. case "qt": converted = quantity / 1.0567; break;
  534. case "gal": converted = quantity * 3.7854; break;
  535. }
  536. }else if(merchant.units.length.includes(unit)){
  537. switch(unit){
  538. case "mm": converted = quantity / 1000; break;
  539. case "cm": converted = quantity / 100; break;
  540. case "m": converted = quantity; break;
  541. case "in": converted = quantity / 39.3701; break;
  542. case "ft": converted = quantity / 3.2808; break;
  543. }
  544. }else{
  545. converted = quantity;
  546. }
  547. return converted;
  548. }
  549. /*
  550. Switches to a different strand
  551. Input:
  552. name: name of the strand. Must end with "Strand"
  553. */
  554. window.changeStrand = (name)=>{
  555. closeSidebar();
  556. for(let strand of document.querySelectorAll(".strand")){
  557. strand.style.display = "none";
  558. }
  559. let buttons = document.querySelectorAll(".menuButton");
  560. for(let i = 0; i < buttons.length - 1; i++){
  561. buttons[i].classList = "menuButton";
  562. buttons[i].disabled = false;
  563. }
  564. let activeButton = {};
  565. switch(name){
  566. case 1:
  567. activeButton = document.getElementById("homeBtn");
  568. document.getElementById("homeStrand").style.display = "flex";
  569. homeStrand.display();
  570. break;
  571. case 2:
  572. activeButton = document.getElementById("ingredientsBtn");
  573. document.getElementById("ingredientsStrand").style.display = "flex";
  574. ingredients.display();
  575. break;
  576. case 3:
  577. activeButton = document.getElementById("recipeBookBtn");
  578. document.getElementById("recipeBookStrand").style.display = "flex";
  579. recipeBook.display();
  580. break;
  581. case 4:
  582. activeButton = document.getElementById("ordersBtn");
  583. document.getElementById("ordersStrand").style.display = "flex";
  584. orders.display();
  585. break;
  586. case 5:
  587. activeButton = document.getElementById("transactionsBtn");
  588. document.getElementById("transactionsStrand").style.display = "flex";
  589. transactions.display();
  590. break;
  591. }
  592. activeButton.classList = "menuButton active";
  593. activeButton.disabled = true;
  594. if(window.screen.availWidth <= 1000){
  595. closeMenu();
  596. }
  597. }
  598. //Close any open sidebar
  599. let closeSidebar = ()=>{
  600. let sidebar = document.querySelector("#sidebarDiv");
  601. for(let i = 0; i < sidebar.children.length; i++){
  602. sidebar.children[i].style.display = "none";
  603. }
  604. sidebar.classList = "sidebarHide";
  605. if(window.screen.availWidth <= 1000){
  606. document.querySelector(".contentBlock").style.display = "flex";
  607. document.getElementById("mobileMenuSelector").style.display = "block";
  608. document.getElementById("sidebarCloser").style.display = "none";
  609. }
  610. }
  611. /*
  612. Open a specific sidebar
  613. Input:
  614. sidebar: the outermost element of the sidebar (must contain class sidebar)
  615. */
  616. let openSidebar = (sidebar)=>{
  617. document.querySelector("#sidebarDiv").classList = "sidebar";
  618. let sideBars = document.querySelector("#sidebarDiv").children;
  619. for(let i = 0; i < sideBars.length; i++){
  620. sideBars[i].style.display = "none";
  621. }
  622. sidebar.style.display = "flex";
  623. if(window.screen.availWidth <= 1000){
  624. document.querySelector(".contentBlock").style.display = "none";
  625. document.getElementById("mobileMenuSelector").style.display = "none";
  626. document.getElementById("sidebarCloser").style.display = "block";
  627. }
  628. }
  629. let changeMenu = ()=>{
  630. let menu = document.querySelector(".menu");
  631. let buttons = document.querySelectorAll(".menuButton");
  632. if(!menu.classList.contains("menuMinimized")){
  633. menu.classList = "menu menuMinimized";
  634. for(let button of buttons){
  635. button.children[1].style.display = "none";
  636. }
  637. document.querySelector("#max").style.display = "none";
  638. document.querySelector("#min").style.display = "flex";
  639. }else if(menu.classList.contains("menuMinimized")){
  640. menu.classList = "menu";
  641. for(let button of buttons){
  642. button.children[1].style.display = "block";
  643. }
  644. setTimeout(()=>{
  645. document.querySelector("#max").style.display = "flex";
  646. document.querySelector("#min").style.display = "none";
  647. }, 150);
  648. }
  649. }
  650. let openMenu = ()=>{
  651. document.getElementById("menu").style.display = "flex";
  652. document.querySelector(".contentBlock").style.display = "none";
  653. document.getElementById("mobileMenuSelector").onclick = ()=>{closeMenu()};
  654. }
  655. let closeMenu = ()=>{
  656. document.getElementById("menu").style.display = "none";
  657. document.querySelector(".contentBlock").style.display = "flex";
  658. document.getElementById("mobileMenuSelector").onclick = ()=>{openMenu()};
  659. }
  660. if(window.screen.availWidth > 1000 && window.screen.availWidth <= 1400){
  661. changeMenu();
  662. document.getElementById("menuShifter2").style.display = "none";
  663. }
  664. merchant = new Merchant(data.merchant, data.transactions);
  665. homeStrand.display(merchant);