Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

config_new_1.js 56KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. // configuration js
  2. let m2DriveMaxQty = 4;
  3. let m2DriveSelectedQty = 0;
  4. let nvmeDrivemaxqty = 4;
  5. let nvmeDriveselectedqty = 0;
  6. let hardDriveMaxQty = 10;
  7. let hardDriveSelectedQty = 0;
  8. // configuration items
  9. if (localStorage.getItem("defaultCurrency") === null) {
  10. localStorage.setItem("defaultCurrency", undefined);
  11. localStorage.setItem("currentCurrency", undefined);
  12. }
  13. // api for getting current location along with currencies
  14. const configCatgories = [
  15. {
  16. id: 1,
  17. title: "barebone",
  18. maxQty: 1,
  19. },
  20. {
  21. id: 2,
  22. title: "processor",
  23. maxQty: 3,
  24. },
  25. {
  26. id: 3,
  27. title: "memory",
  28. maxQty: 1,
  29. },
  30. {
  31. id: 4,
  32. title: "m.2 drive",
  33. maxQty: 4,
  34. },
  35. {
  36. id: 5,
  37. title: "U.2/U.3 NVME DRIVE",
  38. maxQty: 4,
  39. },
  40. {
  41. id: 6,
  42. title: "HARD DRIVE",
  43. maxQty: 10,
  44. },
  45. ];
  46. const bareboneProducts = [
  47. {
  48. id: 1,
  49. title: `Anwi C252 Chipset - 1U - 2x SATA - 1x M.2 - Dual Anwi 1-Gigabit Ethernet (RJ45) - 350W Power Supply`,
  50. qty: 3,
  51. price: 99,
  52. },
  53. ];
  54. const processorProducts = [
  55. {
  56. productcatid: 1,
  57. productcattitle: `Intel<sup>®</sup> Xeon<sup>®</sup> E-2300 Processor Series`,
  58. products: [
  59. {
  60. id: 1,
  61. title: `Quad-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2314 Processor 2.8GHz 8MB
  62. Cache (65W)`,
  63. qty: 3,
  64. price: 99,
  65. },
  66. {
  67. id: 2,
  68. title: `Quad-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2334 Processor 3.4GHz 8MB Cache (65W)`,
  69. qty: 3,
  70. price: 99,
  71. },
  72. {
  73. id: 3,
  74. title: `Eight-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2378 Processor 2.6GHz 16MB Cache (65W)`,
  75. qty: 3,
  76. price: 99,
  77. },
  78. ],
  79. },
  80. {
  81. productcatid: 2,
  82. productcattitle: `Intel<sup>®</sup> Xeon<sup>®</sup> E-2300 Processor Series with Anwi UHD P750 Graphics`,
  83. products: [
  84. {
  85. id: 1,
  86. title: `Quad-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2324G Processor 3.1GHz
  87. 8MB Cache (65W)`,
  88. qty: 3,
  89. price: 99,
  90. },
  91. {
  92. id: 2,
  93. title: `Quad-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2374G Processor 3.7GHz 8MB Cache (80W)`,
  94. qty: 2,
  95. price: 99,
  96. },
  97. {
  98. id: 3,
  99. title: `Six-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2356G Processor 3.2GHz 12MB Cache (80W)`,
  100. qty: 1,
  101. price: 99,
  102. },
  103. {
  104. id: 4,
  105. title: `Six-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2386G Processor 3.5GHz 12MB Cache (95W)`,
  106. qty: 1,
  107. price: 99,
  108. },
  109. ],
  110. },
  111. ];
  112. const memoryProducts = [
  113. {
  114. id: 1,
  115. title: `16GB PC4-25600 3200MHz DDR4 ECC UDIMM`,
  116. qty: 2,
  117. price: 99,
  118. },
  119. {
  120. id: 2,
  121. title: `32GB PC4-25600 3200MHz DDR4 ECC UDIMM`,
  122. qty: 2,
  123. price: 220,
  124. },
  125. ];
  126. const m2driveProducts = [
  127. {
  128. productcatid: 1,
  129. productcattitle: `Kioxia XG6 M.2 PCIe 3.1 x4 NVMe Solid State Drives`,
  130. products: [
  131. {
  132. id: 1,
  133. title: `256GB Kioxia XG6 M.2 PCIe 3.1 x4 NVMe Solid State
  134. Drive`,
  135. qty: 4,
  136. price: 99,
  137. },
  138. {
  139. id: 2,
  140. title: `512GB Kioxia XG6 M.2 PCIe 3.1 x4 NVMe Solid State Drive`,
  141. qty: 4,
  142. price: 149,
  143. },
  144. {
  145. id: 3,
  146. title: `1.0TB Kioxia XG6 M.2 PCIe 3.1 x4 NVMe Solid State Drive`,
  147. qty: 4,
  148. price: 269,
  149. },
  150. ],
  151. },
  152. {
  153. productcatid: 2,
  154. productcattitle: `Anwi DC P4801X M.2 PCIe 3.0 x4 NVMe Solid State Drives`,
  155. products: [
  156. {
  157. id: 1,
  158. title: `100GB Intel<sup>®</sup> Optane™ SSD DC P4801X Series M.2 PCIe 3.0 x4 NVMe
  159. Solid State Drive`,
  160. qty: 4,
  161. price: 99,
  162. },
  163. {
  164. id: 2,
  165. title: `200GB Intel<sup>®</sup> Optane™ SSD DC P4801X Series M.2 PCIe
  166. 3.0 x4 NVMe Solid State Drive`,
  167. qty: 4,
  168. price: 149,
  169. },
  170. {
  171. id: 3,
  172. title: `1.0TB Kioxia XG6 M.2 PCIe 3.1 x4 NVMe Solid State Drive`,
  173. qty: 4,
  174. price: 269,
  175. },
  176. ],
  177. },
  178. {
  179. productcatid: 3,
  180. productcattitle: `Micron 7400 PRO M.2 PCIe 4.0 x4 NVMe Solid State Drives`,
  181. products: [
  182. {
  183. id: 1,
  184. title: `480GB Micron 7400 PRO Series M.2 22x80 PCIe 4.0 x4 NVMe Solid
  185. State Drive`,
  186. qty: 4,
  187. price: 99,
  188. },
  189. {
  190. id: 2,
  191. title: `960GB Micron 7400 PRO Series M.2 22x80 PCIe 4.0 x4
  192. NVMe Solid State Drive`,
  193. qty: 4,
  194. price: 149,
  195. },
  196. {
  197. id: 3,
  198. title: `1.92TB Micron 7400 PRO Series M.2 22x110 PCIe 4.0 x4 NVMe Solid
  199. State Drive`,
  200. qty: 4,
  201. price: 269,
  202. },
  203. ],
  204. },
  205. ];
  206. const NvmeDriveProducts = [
  207. {
  208. productcatid: 1,
  209. productcattitle: `Anwi P4510 Series PCIe 3.1 x4 NVMe Solid State Drives (1x DWPD)`,
  210. products: [
  211. {
  212. id: 1,
  213. title: `8.0TB Anwi SSD DC P4510 Series U.2 PCIe 3.1 x4 NVMe Solid State Drive`,
  214. qty: 4,
  215. price: 99,
  216. },
  217. ],
  218. },
  219. {
  220. productcatid: 2,
  221. productcattitle: `Anwi P5510 Series PCIe 4.0 x4 NVMe Solid State Drives`,
  222. products: [
  223. {
  224. id: 1,
  225. title: `3.84TB Anwi SSD D7 P5510 Series U.2 PCIe 4.0 x4 NVMe Solid State Drive`,
  226. qty: 4,
  227. price: 99,
  228. },
  229. {
  230. id: 2,
  231. title: `7.68TB Anwi SSD D7 P5510 Series U.2 PCIe 4.0 x4 NVMe Solid State Drive`,
  232. qty: 4,
  233. price: 149,
  234. },
  235. {
  236. id: 3,
  237. title: `1.5TB Intel<sup>®</sup> Optane™ SSD DC P4800X Series U.2 PCIe 3.0 x4 NVMe Solid State Drive`,
  238. qty: 4,
  239. price: 269,
  240. },
  241. ],
  242. },
  243. {
  244. productcatid: 3,
  245. productcattitle: `Intel<sup>®</sup> Optane™ DC P4801X Series PCIe 3.0 x4 NVMe Solid State Drives`,
  246. products: [
  247. {
  248. id: 1,
  249. title: `100GB Intel<sup>®</sup> Optane™ SSD DC P4801X Series U.2 PCIe 3.0 x4 NVMe Solid State Drive`,
  250. qty: 4,
  251. price: 99,
  252. },
  253. ],
  254. },
  255. {
  256. productcatid: 4,
  257. productcattitle: `Micron 7400 PRO Series PCIe 4.0 x4 NVMe Solid State Drives (1x DWPD)`,
  258. products: [
  259. {
  260. id: 1,
  261. title: `960GB Micron 7400 PRO Series U.3 7mm PCIe 4.0 x4 NVMe Solid State Drive`,
  262. qty: 4,
  263. price: 99,
  264. },
  265. {
  266. id: 2,
  267. title: `1.92TB Micron 7400 PRO Series U.3 7mm PCIe 4.0 x4 NVMe Solid State Drive`,
  268. qty: 4,
  269. price: 149,
  270. },
  271. {
  272. id: 3,
  273. title: `3.84TB Micron 7400 PRO Series U.3 7mm PCIe 4.0 x4 NVMe Solid State Drive`,
  274. qty: 4,
  275. price: 269,
  276. },
  277. {
  278. id: 4,
  279. title: `7.68TB Micron 7400 PRO Series U.3 7mm PCIe 4.0 x4 NVMe Solid State Drive`,
  280. qty: 4,
  281. price: 269,
  282. },
  283. ],
  284. },
  285. ];
  286. const HardDriveProducts = [
  287. {
  288. productcatid: 1,
  289. productcattitle: `Seagate Enterprise-Class 6Gb/s SATA 7.2k Hard Drives`,
  290. products: [
  291. {
  292. id: 1,
  293. title: `1.0TB SATA 6.0Gb/s 7200RPM - 2.5" - Seagate Exos 7E2000 Series (512e)`,
  294. qty: 4,
  295. price: 99,
  296. },
  297. {
  298. id: 2,
  299. title: `2.0TB SATA 6.0Gb/s 7200RPM - 2.5" - Seagate Exos 7E2000 Series (512e)`,
  300. qty: 4,
  301. price: 149,
  302. },
  303. ],
  304. },
  305. {
  306. productcatid: 2,
  307. productcattitle: `Seagate Enterprise-Class 12Gb/s SAS 7.2k Hard Drives`,
  308. products: [
  309. {
  310. id: 1,
  311. title: `1.0TB SAS 3.0 12.0Gb/s 7200RPM - 2.5" - Seagate Exos 7E2000 Series (512e)`,
  312. qty: 4,
  313. price: 99,
  314. },
  315. {
  316. id: 2,
  317. title: `2.0TB SAS 3.0 12.0Gb/s 7200RPM - 2.5" - Seagate Exos 7E2000 Series (512e)`,
  318. qty: 4,
  319. price: 149,
  320. },
  321. ],
  322. },
  323. {
  324. productcatid: 3,
  325. productcattitle: `Intel<sup>®</sup> Optane™ DC P4801X Series PCIe 3.0 x4 NVMe Solid State Drives`,
  326. products: [
  327. {
  328. id: 1,
  329. title: `100GB Intel<sup>®</sup> Optane™ SSD DC P4801X Series U.2 PCIe 3.0 x4 NVMe Solid State Drive`,
  330. qty: 4,
  331. price: 99,
  332. },
  333. ],
  334. },
  335. {
  336. productcatid: 4,
  337. productcattitle: `Seagate Enterprise-Class 12Gb/s SAS 10k Hard Drives`,
  338. products: [
  339. {
  340. id: 1,
  341. title: `600GB SAS3 12.0Gb/s 10000RPM - 2.5" - Seagate Exos 10E2400 Series (512e/4Kn)`,
  342. qty: 4,
  343. price: 99,
  344. },
  345. {
  346. id: 2,
  347. title: `1.2TB SAS3 12.0Gb/s 10000RPM - 2.5" - Seagate Exos 10E2400 Series (512e/4Kn)`,
  348. qty: 4,
  349. price: 149,
  350. },
  351. {
  352. id: 3,
  353. title: `1.8TB SAS3 12.0Gb/s 10000RPM - 2.5" - Seagate Exos 10E2400 Series (512e/4Kn)`,
  354. qty: 4,
  355. price: 269,
  356. },
  357. {
  358. id: 4,
  359. title: `2.4TB SAS3 12.0Gb/s 10000RPM - 2.5" - Seagate Exos 10E2400 Series (512e/4Kn)`,
  360. qty: 4,
  361. price: 269,
  362. },
  363. ],
  364. },
  365. {
  366. productcatid: 5,
  367. productcattitle: `Micron 5300 MAX Enterprise-Class SATA Solid State Drives`,
  368. products: [
  369. {
  370. id: 1,
  371. title: `240GB Micron 5300 MAX Series 2.5" SATA 6.0Gb/s Solid State Drive`,
  372. qty: 4,
  373. price: 99,
  374. },
  375. {
  376. id: 2,
  377. title: `480GB Micron 5300 MAX Series 2.5" SATA 6.0Gb/s Solid State Drive`,
  378. qty: 4,
  379. price: 149,
  380. },
  381. {
  382. id: 3,
  383. title: `960GB Micron 5300 MAX Series 2.5" SATA 6.0Gb/s Solid State Drive`,
  384. qty: 4,
  385. price: 269,
  386. },
  387. {
  388. id: 4,
  389. title: `1.92TB Micron 5300 MAX Series 2.5" SATA 6.0Gb/s Solid State Drive`,
  390. qty: 4,
  391. price: 269,
  392. },
  393. {
  394. id: 5,
  395. title: `1.92TB Micron 5300 MAX Series 2.5" SATA 6.0Gb/s Solid State Drive`,
  396. qty: 4,
  397. price: 269,
  398. },
  399. ],
  400. },
  401. ];
  402. //Bind Config Categories
  403. bindConfigurations();
  404. updateItemsCount();
  405. // max quantity-progress-bar
  406. function bindConfigurations() {
  407. let configCatHtml = "";
  408. $.each(configCatgories, function (i, cat) {
  409. const id = cat.id;
  410. let title = cat.title;
  411. let qty = cat.maxQty;
  412. let maxQtyHtml = "";
  413. if (title == "m.2 drive") {
  414. title = "m2-drive";
  415. } else if (title == "U.2/U.3 NVME DRIVE") {
  416. title = "nvme-drive";
  417. } else if (title == "HARD DRIVE") {
  418. title = "hard-drive";
  419. }
  420. if (title == "m2-drive" || title == "processor") {
  421. let quantityHtml = "";
  422. if (title == "m2-drive") {
  423. let qtyProgressBarHtml = "";
  424. for (let i = 0; i < qty; i++) {
  425. qtyProgressBarHtml += `<span class="sms progress-bar progress-bar-${i}"></span>`;
  426. }
  427. quantityHtml = `<span>Quantity:</span><div class="max-qty-wrap ml-15"><div class="d-flex justify-content-between align-items-center"><div class="d-flex flex-column"><div class="qty-progress-bars d-flex align-items-center">${qtyProgressBarHtml}</div><div class="d-flex justify-content-between flex-wrap align-items-center mt-1"><span class="small">Max Quantity: ${qty}</span><div class="small"><span class="selected-qty">0</span>/<span class="max-qty-span">${qty}</span></div></div></div></div></div>`;
  428. }
  429. maxQtyHtml = `<div class="text-white p-3 border-radius-custom flex-wrap float-lg-end d-flex align-items-center config-max-quantity">${quantityHtml}</div>`;
  430. }
  431. if (title == "nvme-drive") {
  432. let quantityHtml = "";
  433. if (title == "nvme-drive") {
  434. let qtyProgressBarHtml = "";
  435. for (let i = 0; i < qty; i++) {
  436. qtyProgressBarHtml += `<span class="nvdrive progress-bar progress-bar-${i}"></span>`;
  437. }
  438. quantityHtml = `<span>Quantity:</span><div class="max-qty-wrap ml-15"><div class="d-flex justify-content-between align-items-center"><div class="d-flex flex-column"><div class="qty-progress-bars nvme d-flex align-items-center">${qtyProgressBarHtml}</div><div class="d-flex justify-content-between flex-wrap align-items-center mt-1"><span class="small">Max Quantity: ${qty}</span><div class="small"><span class="selected-qty">0</span>/<span class="max-qty-span">${qty}</span></div></div></div></div></div>`;
  439. }
  440. maxQtyHtml = `<div class="text-white p-3 border-radius-custom flex-wrap float-lg-end d-flex align-items-center config-max-quantity">${quantityHtml}</div>`;
  441. }
  442. if (title == "hard-drive") {
  443. let quantityHtml = "";
  444. if (title == "hard-drive") {
  445. let qtyProgressBarHtml = "";
  446. for (let i = 0; i < qty; i++) {
  447. qtyProgressBarHtml += `<span class="sms progress-bar progress-bar-${i}"></span>`;
  448. }
  449. quantityHtml = `<span>Quantity:</span><div class="max-qty-wrap ml-15"><div class="d-flex justify-content-between align-items-center"><div class="d-flex flex-column"><div class="qty-progress-bars d-flex align-items-center">${qtyProgressBarHtml}</div><div class="d-flex justify-content-between flex-wrap align-items-center mt-1"><span class="small">Max Quantity: ${qty}</span><div class="small"><span class="selected-qty">0</span>/<span class="max-qty-span">${qty}</span></div></div></div></div></div>`;
  450. }
  451. maxQtyHtml = `<div class="text-white p-3 border-radius-custom flex-wrap float-lg-end d-flex align-items-center config-max-quantity">${quantityHtml}</div>`;
  452. }
  453. configCatHtml += `<div class="product-config-selector accordion mb-20" id="config-${title}" data-maxqty='${qty}'>
  454. <div class="config-heading d-flex justify-content-between flex-wrap align-items-center">
  455. <h5 class="text-white p-3 border-radius-custom text-uppercase">${title}
  456. </h5>
  457. ${maxQtyHtml}
  458. </div>
  459. <div class="config-content p-0"></div>
  460. </div>`;
  461. });
  462. $("#block-content-main").html(configCatHtml);
  463. bindAllConfigProducts();
  464. }
  465. //bindNvmeConfigurations();
  466. updateItemsCount();
  467. // appending&binding -html
  468. function bindAllConfigProducts() {
  469. bindBareboneAndMemoryProducts("barebone");
  470. bindBareboneAndMemoryProducts("memory");
  471. bindProcessorAndM2DriveProducts("processor");
  472. bindProcessorAndM2DriveProducts("m2-drive");
  473. bindNVMEHARDDRIVEAndProducts("nvme-drive");
  474. bindNVMEHARDDRIVEAndProducts("hard-drive");
  475. bindEventListeners();
  476. }
  477. function bindBareboneAndMemoryProducts(cat) {
  478. let productHtml = "";
  479. let productsArr = bareboneProducts;
  480. let name = "radio-btns-barebone";
  481. if (cat == "memory") {
  482. productsArr = memoryProducts;
  483. name = "radio-btn-memory";
  484. }
  485. $.each(productsArr, function (i, product) {
  486. productHtml += `<p class="provide-content product-item">
  487. <div
  488. class="name-of-config card-body row justify-content-between py-1 align-items-center config-product-item" data-id='${product.id}' data-cat='${cat}' data-price='${product.price}'>
  489. <div class="form-check mt-2 col-lg-7" id="form-check">
  490. <input class="form-check-input product-radio-btn" id="${cat}-radio-btn-${product.id}" type="checkbox" data-checked="false" name= "${name}"
  491. value="${product.title}" >
  492. <label class="form-check-label" for="${cat}-radio-btn-${product.id}">
  493. <strong>${product.title}</strong>
  494. </label>
  495. </div>
  496. <div class="btn-group config-quantity-btn text-black col-lg-2">
  497. <select class="form-select fw-bold qty-selector product2" id="product1"> <option value="0">Select</option>`;
  498. for (let i = 1; i <= product.qty; i++) {
  499. productHtml += `<option value="${i}">Qty: ${i}</option>`;
  500. }
  501. if (".product2")
  502. productHtml += `</select>
  503. </div>
  504. <div class="config-pricing col-lg-2">
  505. <span class="config-price-span p-2 border-radius-custom"><span></span><span class="total-price-amount price-wrap d-flex align-items-center"><span class="currency-symbol">&#8377;</span><span class="product-price">${product.price}</span></span></span>
  506. </div>
  507. </div>
  508. </p>`;
  509. });
  510. $(`#config-${cat} .config-content`).html(productHtml);
  511. }
  512. function bindProcessorAndM2DriveProducts(cat) {
  513. let productCatHtml = "";
  514. let productsArr = processorProducts;
  515. let accordion = "processorProductAccordion";
  516. let collapse = "processorProductcollapse";
  517. let lastSelectDataAttr = "";
  518. if (cat == "m2-drive") {
  519. productsArr = m2driveProducts;
  520. accordion = "m2DriveProductAccordion";
  521. collapse = "m2DriveProductcollapse";
  522. lastSelectDataAttr = 'data-lastval="1"';
  523. }
  524. $.each(productsArr, function (i, productcat) {
  525. const productcatid = productcat.productcatid;
  526. const productcattitle = productcat.productcattitle;
  527. productCatHtml += `<div class="accordion sub-section mt-4 border-radius-custom" id="${accordion}-${productcatid}">
  528. <div class="accordion-item">
  529. <h2 class="accordion-header">
  530. <button class="accordion-button" style="color:#4e4c7d; background-color: #e7e9f4;"
  531. type="button" data-bs-toggle="collapse" data-bs-target="#${collapse}-${productcatid}"
  532. aria-expanded="true" aria-controls="${collapse}-${productcatid}">
  533. <strong>${productcattitle}</strong>
  534. </button>
  535. </h2>
  536. <div id="${collapse}-${productcatid}" class="accordion-collapse collapse show" data-bs-parent="#${accordion}-${productcatid}">
  537. <div class="accordion-body">`;
  538. let productHtml = "";
  539. $.each(productcat.products, function (i, product) {
  540. productHtml += `
  541. <div class="name-of-config row justify-content-between py-1 align-items-center config-product-item" data-id='${
  542. product.id
  543. }' data-cat='${cat}' data-price='${
  544. product.price
  545. }' data-productcatid='${productcatid}'>
  546. <div class="form-check mt-2 col-lg-7" id="form-check">
  547. ${appendProcessorAndM2DriveInput(
  548. cat,
  549. product.id,
  550. product.title,
  551. productcatid
  552. )}
  553. </div>
  554. <div class="btn-group config-quantity-btn text-black col-lg-2">
  555. <select class="form-select fw-bold qty-selector product2" ${lastSelectDataAttr}> <option value="0">Select</option>`;
  556. for (let i = 1; i <= product.qty; i++) {
  557. productHtml += `<option value="${i}">Qty: ${i}</option>`;
  558. }
  559. productHtml += `</select>
  560. </div>
  561. <div class="config-pricing col-lg-2">
  562. <span class="config-price-span p-2 border-radius-custom"><span></span><span class="processor-total-price total-price-amount price-wrap d-flex align-items-center"><span class="currency-symbol">&#8377;</span><span class="product-price">${product.price}</span></span> </span>
  563. </div>
  564. </div>`;
  565. });
  566. productCatHtml += productHtml;
  567. productCatHtml += `</div>
  568. </div>
  569. </div>
  570. </div>`;
  571. });
  572. $(`#config-${cat} .config-content`).html(productCatHtml);
  573. }
  574. function bindNVMEHARDDRIVEAndProducts(cat) {
  575. let productCatHtml = "";
  576. // let productsArr = HardDriveProducts;
  577. // let accordion = 'hardwareProductAccordion';
  578. // let collapse = 'hardwareProductcollapse';
  579. let lastSelectDataAttr = "";
  580. if (cat == "nvme-drive") {
  581. productsArr = NvmeDriveProducts;
  582. accordion = "NVMEDRIVEProductAccordion";
  583. collapse = "NVMEDRIVEProductcollapse";
  584. lastSelectDataAttr = 'data-lastval="1"';
  585. }
  586. if (cat == "hard-drive") {
  587. productsArr = HardDriveProducts;
  588. accordion = "hardwareProductAccordion";
  589. collapse = "hardwareProductcollapse";
  590. lastSelectDataAttr = 'data-lastval="1"';
  591. }
  592. $.each(productsArr, function (i, productcat) {
  593. const productcatid = productcat.productcatid;
  594. const productcattitle = productcat.productcattitle;
  595. productCatHtml += `<div class="accordion sub-section mt-4 border-radius-custom" id="${accordion}-${productcatid}">
  596. <div class="accordion-item">
  597. <h2 class="accordion-header">
  598. <button class="accordion-button" style="color:#4e4c7d; background-color: #e7e9f4;"
  599. type="button" data-bs-toggle="collapse" data-bs-target="#${collapse}-${productcatid}"
  600. aria-expanded="true" aria-controls="${collapse}-${productcatid}">
  601. <strong>${productcattitle}</strong>
  602. </button>
  603. </h2>
  604. <div id="${collapse}-${productcatid}" class="accordion-collapse collapse show" data-bs-parent="#${accordion}-${productcatid}">
  605. <div class="accordion-body">`;
  606. let productHtml = "";
  607. $.each(productcat.products, function (i, product) {
  608. productHtml += `
  609. <div class="name-of-config row justify-content-between py-1 align-items-center config-product-item" data-id='${
  610. product.id
  611. }' data-cat='${cat}' data-price='${
  612. product.price
  613. }' data-productcatid='${productcatid}'>
  614. <div class="form-check mt-2 col-lg-7" id="form-check">
  615. ${appendNVMEHARDDRIVEAndProducts(
  616. cat,
  617. product.id,
  618. product.title,
  619. productcatid
  620. )}
  621. </div>
  622. <div class="btn-group config-quantity-btn text-black col-lg-2">
  623. <select class="form-select fw-bold qty-selector product2" ${lastSelectDataAttr}> <option value="0">Select</option>`;
  624. for (let i = 1; i <= product.qty; i++) {
  625. productHtml += `<option value="${i}">Qty: ${i}</option>`;
  626. }
  627. productHtml += `</select>
  628. </div>
  629. <div class="config-pricing col-lg-2">
  630. <span class="config-price-span p-2 border-radius-custom"><span></span><span class="processor-total-price total-price-amount price-wrap d-flex align-items-center"><span class="currency-symbol">&#8377;</span><span class="product-price">${product.price}</span></span> </span>
  631. </div>
  632. </div>`;
  633. });
  634. productCatHtml += productHtml;
  635. productCatHtml += `</div>
  636. </div>
  637. </div>
  638. </div>`;
  639. });
  640. $(`#config-${cat} .config-content`).html(productCatHtml);
  641. }
  642. function appendProcessorAndM2DriveInput(cat, id, title, productcatid = 0) {
  643. if (cat == "m2-drive") {
  644. return `<input class="form-check-input product-check-btn" type="checkbox" name="m2Drive-check-btns"
  645. id="${cat}-check-btn-${productcatid}-${id}" value="${title}" >
  646. <label class="form-check-label" for="${cat}-check-btn-${productcatid}-${id}">
  647. <strong>${title}</strong>
  648. </label>`;
  649. } else {
  650. return `<input class="form-check-input product-radio-btn" type="checkbox" name="processor-radio-btns" data-checked="false"
  651. id="${cat}-radio-btn-${productcatid}-${id}" value="${title}" >
  652. <label class="form-check-label" for="${cat}-radio-btn-${productcatid}-${id}">
  653. <strong>${title}</strong>
  654. </label>`;
  655. }
  656. }
  657. function appendNVMEHARDDRIVEAndProducts(cat, id, title, productcatid = 0) {
  658. if (cat == "nvme-drive") {
  659. return `<input class="form-check-input product-check" type="checkbox" name="nvme-check-btns"
  660. id="${cat}-check-btn-${productcatid}-${id}" value="${title}" >
  661. <label class="form-check-label" for="${cat}-check-btn-${productcatid}-${id}">
  662. <strong>${title}</strong>
  663. </label>`;
  664. } else {
  665. return `<input class="form-check-input product-hard-btn" type="checkbox" name="hardware-radio-btns"
  666. id="${cat}-check-btn-${productcatid}-${id}" value="${title}" >
  667. <label class="form-check-label" for="${cat}-check-btn-${productcatid}-${id}">
  668. <strong>${title}</strong>
  669. </label>`;
  670. }
  671. }
  672. // function removeActiveClassForPrice(DOM) {
  673. // return DOM.removeClass("active");
  674. // }
  675. // select and radio-check-btn-section
  676. // function bindEventListeners() {}
  677. // select and radio-check-btn-section
  678. function bindEventListeners() {
  679. var alertBox = `<div class="alert alert-warning alert-dismissible fade show" role="alert">
  680. <strong>Holy guacamole!</strong> You should check in on some of those fields below.
  681. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  682. </div>`;
  683. $(".product-radio-btn").click(function (e) {
  684. const radioEl = $(this);
  685. const accordionID = $(this).parents(".accordion").attr("id");
  686. const parentEl = radioEl.parents(".config-product-item");
  687. const val = radioEl.val();
  688. const productCatId = parentEl.attr("data-id");
  689. const cat = parentEl.attr("data-cat");
  690. const qty = parseInt(parentEl.find(".qty-selector").val("1"));
  691. const price = qty * parseInt(parentEl.attr("data-price"));
  692. const id = parentEl.attr("data-id");
  693. $(`#config-${cat}`).find(".config-price-span").removeClass("active");
  694. parentEl.find(".config-price-span").addClass("active");
  695. bindSelectedProduct(cat, val, qty, price, id, productCatId, accordionID);
  696. updateItemsCount();
  697. updateTotalCartPrice();
  698. // $(this).toggleClass("checked");
  699. });
  700. $(".qty-selector").change(function () {
  701. const selectEl = $(this);
  702. const accordionId = $(this).parents(".accordion").attr("id");
  703. const parentEl = selectEl.parents(".config-product-item");
  704. const val = parseInt(selectEl.val());
  705. const lastSelectedVal = parseInt(selectEl.attr("data-lastval"));
  706. const price = (val * parseFloat(parentEl.attr("data-price"))).toFixed(2);
  707. const cat = parentEl.attr("data-cat");
  708. const id = parentEl.attr("data-id");
  709. if (!parentEl.find("input").is(":checked")) {
  710. // parentEl.find("input").trigger("click");
  711. parentEl.find(selectEl).val(val);
  712. parentEl.find(".config-price-span").addClass("active");
  713. }
  714. const selectedQty = val - lastSelectedVal;
  715. if (cat == "m2-drive") {
  716. if (m2DriveMaxQty >= m2DriveSelectedQty + selectedQty) {
  717. m2DriveSelectedQty += selectedQty;
  718. selectEl.attr("data-lastval", val);
  719. m2DriveProgress();
  720. parentEl.find(".product-price").text(price);
  721. const selecedSummaryProduct = $(
  722. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  723. );
  724. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  725. selecedSummaryProduct.find(".product-price").text(price);
  726. updateTotalCartPrice();
  727. } else {
  728. alert("Quantity Max limit reached");
  729. selectEl.val(lastSelectedVal);
  730. // parentEl.find('input').trigger('click');
  731. return false;
  732. }
  733. } else {
  734. parentEl.find(".product-price").text(price);
  735. const selecedSummaryProduct = $(
  736. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  737. );
  738. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  739. selecedSummaryProduct.find(".product-price").text(price);
  740. updateTotalCartPrice();
  741. }
  742. });
  743. $(".product-check-btn").click(function () {
  744. const checkEl = $(this);
  745. const ElementId = $(this).parents(".accordion").attr("id");
  746. const parentEl = checkEl.parents(".config-product-item");
  747. const val = checkEl.val();
  748. const productCatId = parentEl.attr("data-productcatid");
  749. const cat = parentEl.attr("data-cat");
  750. const qtySelectEl = parentEl.find(".qty-selector");
  751. const qty = parseInt(qtySelectEl.val("1"));
  752. const price = parentEl.attr("data-price");
  753. const totalPrice = qty * parseFloat(price).toFixed(2);
  754. const id = parentEl.attr("data-id");
  755. if (checkEl.is(":checked")) {
  756. m2DriveSelectedQty++;
  757. parentEl.addClass("selected");
  758. } else {
  759. m2DriveSelectedQty -= qty;
  760. qtySelectEl.val("1").attr("data-lastval", "1").trigger("change");
  761. parentEl.removeClass("selected").find(".product-price").text(price);
  762. }
  763. if (m2DriveSelectedQty > m2DriveMaxQty) {
  764. alert("Quantity Max limit reached");
  765. return false;
  766. } else {
  767. parentEl.find(".config-price-span").toggleClass("active");
  768. bindSelectedProduct(
  769. cat,
  770. val,
  771. qty,
  772. totalPrice,
  773. id,
  774. productCatId,
  775. ElementId
  776. );
  777. updateItemsCount();
  778. updateTotalCartPrice();
  779. m2DriveProgress();
  780. }
  781. });
  782. // $('.product-check-btn ,.product-radio-btn').click(function() {
  783. // qtySelectEl.val('1').attr('data-lastval', '1').trigger('change');;
  784. // });
  785. }
  786. //progress-bars active and remove
  787. function m2DriveProgress() {
  788. if (m2DriveSelectedQty <= m2DriveMaxQty) {
  789. $("#config-m2-drive .qty-progress-bars .progress-bar").removeClass(
  790. "active"
  791. );
  792. for (let i = 0; i < m2DriveSelectedQty; i++) {
  793. $("#config-m2-drive .qty-progress-bars .progress-bar")
  794. .eq(i)
  795. .addClass("active");
  796. }
  797. $("#config-m2-drive .max-qty-wrap")
  798. .find(".selected-qty")
  799. .text(m2DriveSelectedQty);
  800. }
  801. if (m2DriveSelectedQty == m2DriveMaxQty) {
  802. disableM2DriveOptions();
  803. } else {
  804. enableM2DriveOptions();
  805. }
  806. }
  807. function enableM2DriveOptions() {
  808. $(".product-check-btn").prop("disabled", false);
  809. $("#config-m2-drive .qty-selector").prop("disabled", false);
  810. }
  811. function disableM2DriveOptions() {
  812. $(".product-check-btn").not(":checked").prop("disabled", true);
  813. $("#config-m2-drive .config-product-item")
  814. .not(".selected")
  815. .find(".qty-selector")
  816. .prop("disabled", true);
  817. }
  818. //nvme progress-bars active and remove
  819. function nvmeDriveProgress() {
  820. if (nvmeDriveselectedqty <= nvmeDrivemaxqty) {
  821. $("#config-nvme-drive .qty-progress-bars .progress-bar").removeClass(
  822. "active"
  823. );
  824. for (let i = 0; i < nvmeDriveselectedqty; i++) {
  825. $("#config-nvme-drive .qty-progress-bars .progress-bar")
  826. .eq(i)
  827. .addClass("active");
  828. }
  829. $("#config-nvme-drive .max-qty-wrap")
  830. .find(".selected-qty")
  831. .text(nvmeDriveselectedqty);
  832. }
  833. if (nvmeDriveselectedqty == nvmeDrivemaxqty) {
  834. disablenvmeDriveOptions();
  835. } else {
  836. enablenvmeDriveOptions();
  837. }
  838. }
  839. function enablenvmeDriveOptions() {
  840. $(".product-check").prop("disabled", false);
  841. $("#config-nvme-drive .qty-selector").prop("disabled", false);
  842. }
  843. function disablenvmeDriveOptions() {
  844. $(".product-check").not(":checked").prop("disabled", true);
  845. $("#config-nvme-drive .config-product-item")
  846. .not(".selected")
  847. .find(".qty-selector")
  848. .prop("disabled", true);
  849. }
  850. //hard-drive progress-bars active and remove
  851. function hardDriveProgress() {
  852. if (hardDriveSelectedQty <= hardDriveMaxQty) {
  853. $("#config-hard-drive .qty-progress-bars .progress-bar").removeClass(
  854. "active"
  855. );
  856. for (let i = 0; i < hardDriveSelectedQty; i++) {
  857. $("#config-hard-drive .qty-progress-bars .progress-bar")
  858. .eq(i)
  859. .addClass("active");
  860. }
  861. $("#config-hard-drive .max-qty-wrap")
  862. .find(".selected-qty")
  863. .text(hardDriveSelectedQty);
  864. }
  865. if (hardDriveSelectedQty == hardDriveMaxQty) {
  866. disablehardDriveOptions();
  867. } else {
  868. enablehardDriveOptions();
  869. }
  870. }
  871. function enablehardDriveOptions() {
  872. $(".product-hard-btn").prop("disabled", false);
  873. $("#config-hard-drive .qty-selector").prop("disabled", false);
  874. }
  875. function disablehardDriveOptions() {
  876. $(".product-hard-btn").not(":checked").prop("disabled", true);
  877. $("#config-hard-drive .config-product-item")
  878. .not(".selected")
  879. .find(".qty-selector")
  880. .prop("disabled", true);
  881. }
  882. // summary section
  883. function bindSelectedProduct(
  884. cat,
  885. val,
  886. qty,
  887. price,
  888. id,
  889. productCatId = "",
  890. ElementId,
  891. currency = localStorage.getItem("currentCurrency"),
  892. currencysymbol = rates[currency].symbol
  893. ) {
  894. console.log(cat, val, "qty", qty, price, id, productCatId, ElementId);
  895. const summaryProductHtml = `<li class="w-100 my-1 d-flex align-items-center cart-product-item ${cat}-cart-product-${id}" data-accordionid="${ElementId}" data-productcatid='${productCatId}'><span class="summary-total-qty"><span class="qty-span">${qty}</span><i class="fa fa-times"></i></span>
  896. <div class="flex-grow-1 d-flex align-items-center justify-content-between"><span class="summary-product-val mr-2">${val}</span>
  897. <span class="price-wrap d-flex align-items-center"><span class="summary-plus-sign"></span><span class="currency-symbol" id="summary-currency-symbol">${currencysymbol}</span><span class="order-price price-span product-price ml-auto">${price}</span></span>
  898. </div>
  899. </li>`;
  900. console.log(
  901. $(`#${cat}-summary .summary-list`).find(`[data-accordionid=${ElementId}]`)
  902. .length
  903. );
  904. if (
  905. $(`#${cat}-summary .summary-list`).find(`[data-accordionid=${ElementId}]`)
  906. .length
  907. ) {
  908. $(`#${cat}-summary .summary-list`)
  909. .find(`[data-accordionid=${ElementId}]`)
  910. .remove();
  911. }
  912. if (cat == "barebone") {
  913. if (qty) {
  914. $(
  915. `.barebone-cart-product-${id}[data-productcatid = "${productCatId}"]`
  916. ).remove();
  917. $(`#${cat}-summary .summary-list`).append(summaryProductHtml);
  918. } else {
  919. $(
  920. `.barebone-cart-product-${id}[data-productcatid = "${productCatId}"]`
  921. ).remove();
  922. }
  923. }
  924. if (cat == "m2-drive") {
  925. if (qty) {
  926. $(
  927. `.m2-drive-cart-product-${id}[data-productcatid = "${productCatId}`
  928. ).remove();
  929. $(`#${cat}-summary .summary-list`).append(summaryProductHtml);
  930. } else {
  931. $(
  932. `.m2-drive-cart-product-${id}[data-productcatid = "${productCatId}`
  933. ).remove();
  934. }
  935. }
  936. if (cat == "processor") {
  937. if (qty) {
  938. $(`.cart-product-item[data-accordionid = "${ElementId}"]`).remove();
  939. $(`#${cat}-summary .summary-list`).append(summaryProductHtml);
  940. } else {
  941. $(`.cart-product-item[data-accordionid = "${ElementId}"]`).remove();
  942. }
  943. }
  944. if (cat == "nvme-drive") {
  945. if (qty) {
  946. $(`.cart-product-item[data-accordionid = "${ElementId}"]`).remove();
  947. $(`#${cat}-summary .summary-list`).append(summaryProductHtml);
  948. } else {
  949. $(`.cart-product-item[data-accordionid = "${ElementId}"]`).remove();
  950. }
  951. }
  952. if (cat == "hard-drive") {
  953. if (qty) {
  954. $(
  955. `.hard-drive-cart-product-${id}[data-productcatid = "${productCatId}"] `
  956. ).remove();
  957. $(`#${cat}-summary .summary-list`).append(summaryProductHtml);
  958. } else {
  959. $(
  960. `.hard-drive-cart-product-${id}[data-productcatid = "${productCatId}"] `
  961. ).remove();
  962. }
  963. }
  964. if (cat == "memory") {
  965. if (qty) {
  966. $(`.cart-product-item[data-accordionid = "${ElementId}"]`).remove();
  967. $(`#${cat}-summary .summary-list`).append(summaryProductHtml);
  968. } else {
  969. $(`.cart-product-item[data-accordionid = "${ElementId}"]`).remove();
  970. }
  971. }
  972. if ($(`#${cat}-summary .summary-list li`).length) {
  973. console.log("display if");
  974. $(`#${cat}-summary`).removeClass("d-none");
  975. } else {
  976. console.log("display else");
  977. $(`#${cat}-summary`).addClass("d-none");
  978. }
  979. return;
  980. }
  981. // items-count
  982. function updateItemsCount() {
  983. const cartProductCount = $("#productOrderSummary .cart-product-item").length;
  984. $(".summary-head #items-count").text(cartProductCount);
  985. if (cartProductCount >= 1) {
  986. $(".your-order-wrap").show();
  987. $(".your-order-wrap-empty").hide();
  988. } else {
  989. $(".your-order-wrap").hide();
  990. $(".your-order-wrap-empty").show();
  991. }
  992. }
  993. // total-cart-price
  994. function updateTotalCartPrice() {
  995. let totalPrice = 0;
  996. $("#productOrderSummary .cart-product-item")
  997. .find(".price-span")
  998. .each(function (i, e) {
  999. totalPrice += Number($(e).text().trim());
  1000. cartTotal = parseFloat(totalPrice).toFixed(2);
  1001. });
  1002. $("#productOrderSummary #total-amount").text(cartTotal);
  1003. }
  1004. //currency-converter for pricings:
  1005. var rates = {
  1006. INR: {
  1007. value: 1,
  1008. symbol: "₹",
  1009. USD: 0.01289,
  1010. INR: 1,
  1011. GBP: 0.01041,
  1012. EUR: 0.01226,
  1013. },
  1014. USD: {
  1015. value: 75,
  1016. symbol: "$",
  1017. USD: 1,
  1018. INR: 77.5624,
  1019. GBP: 0.8074,
  1020. EUR: 0.951,
  1021. },
  1022. GBP: {
  1023. value: 100,
  1024. symbol: "£",
  1025. USD: 1.2384,
  1026. INR: 96.0576,
  1027. GBP: 1,
  1028. EUR: 1.1778,
  1029. },
  1030. EUR: {
  1031. value: 81,
  1032. symbol: "€",
  1033. USD: 1.051428,
  1034. INR: 81.551,
  1035. GBP: 0.8489,
  1036. EUR: 1,
  1037. },
  1038. };
  1039. //currency-converter rates for configurator:
  1040. // var rates = {
  1041. // INR: {
  1042. // value: 1,
  1043. // symbol: "₹",
  1044. // USD: 0.01311,
  1045. // INR: 1,
  1046. // GBP: 0.01,
  1047. // },
  1048. // USD: {
  1049. // value: 75,
  1050. // symbol: "$",
  1051. // USD: 1,
  1052. // INR: 76.32,
  1053. // GBP: 0.76,
  1054. // },
  1055. // GBP: {
  1056. // value: 100,
  1057. // symbol: "£",
  1058. // USD: 1.31,
  1059. // INR: 100,
  1060. // GBP: 1,
  1061. // },
  1062. // };
  1063. // let usercurency;
  1064. // if (localStorage.getItem("currentCurrency")) {
  1065. // usercurency = localStorage.getItem("currentCurrency");
  1066. // }
  1067. //else {
  1068. // usercurency = "INR";
  1069. // }
  1070. // $("#custom-selects").val(usercurency.toLowerCase());
  1071. function updatePrices(previousCurrency, currentCurrency) {
  1072. $(".product-price").each(function (i, el) {
  1073. // console.log(currentCurrency);
  1074. let val = parseFloat($(el).text());
  1075. let con = val * rates[previousCurrency][currentCurrency],
  1076. _con;
  1077. if (currentCurrency == "INR") {
  1078. _con = Math.round(con);
  1079. // _con = con;
  1080. } else {
  1081. _con = con;
  1082. }
  1083. let curentSymbol = rates[currentCurrency];
  1084. $(el).text(_con.toFixed(2));
  1085. $(el).siblings(".currency-symbol").text(curentSymbol.symbol);
  1086. });
  1087. $("[data-price]").each(function (i, e) {
  1088. let val = parseFloat($(this).attr("data-price"));
  1089. let con = val * rates[previousCurrency][currentCurrency],
  1090. _con;
  1091. if (currentCurrency == "INR") {
  1092. _con = Math.round(con);
  1093. // _con = con;
  1094. } else {
  1095. _con = con;
  1096. }
  1097. $(this).attr("data-price", _con);
  1098. });
  1099. let amount = parseFloat($("#total-amount").text()).toFixed(2);
  1100. let curentSymbol = rates[currentCurrency];
  1101. let conVal = amount * rates[previousCurrency][currentCurrency],
  1102. _con;
  1103. if (currentCurrency == "INR") {
  1104. _con = Math.round(conVal);
  1105. // _con = conVal;
  1106. } else {
  1107. _con = conVal;
  1108. }
  1109. $("#total-amount").text(parseFloat(_con).toFixed(2));
  1110. $(".currency-symbol").text(curentSymbol.symbol);
  1111. }
  1112. $("#custom-selects").on("change", function (e) {
  1113. let previousCurrency = localStorage.getItem("currency");
  1114. localStorage.setItem("currency", e.target.value.toUpperCase());
  1115. updatePrices(previousCurrency, e.target.value.toUpperCase());
  1116. });
  1117. $("#searchTheKey").on("keyup", function () {
  1118. // search functionality
  1119. var value = $(this).val().toString(),
  1120. value = value.toUpperCase();
  1121. $(".product-config-selector")
  1122. .find(".config-content strong")
  1123. .each(function () {
  1124. let reportName = $(this).text();
  1125. if (reportName.toUpperCase().indexOf(value) > -1) {
  1126. $(this).parents(".name-of-config ").css("display", "flex");
  1127. $(this)
  1128. .closest(".name-of-config")
  1129. .each(function () {
  1130. let reportName = $(this).text();
  1131. if (reportName.toUpperCase().indexOf(value) > -1) {
  1132. $(this).parents(".name-of-config").css("display", "flex");
  1133. $("#config-processor").css("display", "block");
  1134. $("#config-barebone").css("display", "block");
  1135. $("#config-memory").css("display", "block");
  1136. $("#config-m2-drive").css("display", "block");
  1137. $("#config-nvme-drive").css("display", "block");
  1138. $("#config-hard-drive").css("display", "block");
  1139. } else {
  1140. $(this).parents(".name-of-config").css("display", "none");
  1141. }
  1142. });
  1143. } else {
  1144. $(this).parents(".name-of-config").css("display", "none");
  1145. }
  1146. });
  1147. if ($("#config-processor").find(".name-of-config:visible").length == 0) {
  1148. $("#config-processor").css("display", "none");
  1149. } else {
  1150. $("#config-processor").css("display", "block");
  1151. $("#config-processor")
  1152. .find(".sub-section")
  1153. .each(function () {
  1154. console.log($(this));
  1155. if ($(this).find(".name-of-config:visible").length == 0) {
  1156. $(this).closest(".accordion").css("display", "none");
  1157. }
  1158. });
  1159. }
  1160. if ($("#config-barebone").find(".name-of-config:visible").length == 0) {
  1161. $("#config-barebone").css("display", "none");
  1162. } else {
  1163. $("#config-barebone").css("display", "block");
  1164. }
  1165. if ($("#config-memory").find(".name-of-config:visible").length == 0) {
  1166. $("#config-memory").css("display", "none");
  1167. } else {
  1168. $("#config-memory").css("display", "block");
  1169. }
  1170. if ($("#config-m2-drive").find(".name-of-config:visible").length == 0) {
  1171. $("#config-m2-drive").css("display", "none");
  1172. } else {
  1173. $("#config-m2-drive").css("display", "block");
  1174. $("#config-m2-drive")
  1175. .find(".sub-section")
  1176. .each(function () {
  1177. console.log($(this));
  1178. if ($(this).find(".name-of-config:visible").length == 0) {
  1179. $(this).closest(".accordion").css("display", "none");
  1180. }
  1181. });
  1182. }
  1183. if ($("#config-nvme-drive").find(".name-of-config:visible").length == 0) {
  1184. $("#config-nvme-drive").css("display", "none");
  1185. } else {
  1186. $("#config-nvme-drive").css("display", "block");
  1187. $("#config-nvme-drive")
  1188. .find(".sub-section")
  1189. .each(function () {
  1190. console.log($(this));
  1191. if ($(this).find(".name-of-config:visible").length == 0) {
  1192. $(this).closest(".accordion").css("display", "none");
  1193. }
  1194. });
  1195. }
  1196. if ($("#config-hard-drive").find(".name-of-config:visible").length == 0) {
  1197. $("#config-hard-drive").css("display", "none");
  1198. } else {
  1199. $("#config-hard-drive").css("display", "block");
  1200. $("#config-hard-drive")
  1201. .find(".sub-section")
  1202. .each(function () {
  1203. console.log($(this));
  1204. if ($(this).find(".name-of-config:visible").length == 0) {
  1205. $(this).closest(".accordion").css("display", "none");
  1206. }
  1207. });
  1208. }
  1209. });
  1210. setTimeout(function () {
  1211. //handling check for barebone processor and memory
  1212. const productRadioBtns = document.querySelectorAll(".product-radio-btn");
  1213. // console.log(productRadioBtns);
  1214. for (let i = 0; i < productRadioBtns.length; i++) {
  1215. productRadioBtns[i].addEventListener("click", function () {
  1216. const checkEl = $(this);
  1217. const ElementId = $(this).parents(".accordion").attr("id");
  1218. const parentEl = checkEl.parents(".config-product-item");
  1219. const productCatId = parentEl.attr("data-productcatid");
  1220. const cat = parentEl.attr("data-cat");
  1221. const qtySelectEl = parentEl.find(".qty-selector");
  1222. const id = parentEl.attr("data-id");
  1223. if ($(this).parents(".accordion").length) {
  1224. $(this)
  1225. .closest(".accordion")
  1226. .find(".config-price-span")
  1227. .removeClass("active");
  1228. $(this).closest(".accordion").find(".qty-selector").val(0);
  1229. }
  1230. if (this.checked) {
  1231. console.log("checked");
  1232. $(this).parents(".name-of-config").find(".qty-selector").val("1");
  1233. $(this)
  1234. .parents(".name-of-config")
  1235. .find(".config-price-span")
  1236. .addClass("active");
  1237. $(this)
  1238. .closest(".accordion")
  1239. .find(".product-radio-btn")
  1240. .prop("checked", false);
  1241. $(this).prop("checked", true);
  1242. }
  1243. const qty = parseInt(qtySelectEl.val());
  1244. const actualPrice = parentEl.attr("data-price");
  1245. const price = parseFloat(actualPrice).toFixed(2);
  1246. const totalPrice = qty * parseFloat(price).toFixed(2);
  1247. const val = checkEl.val();
  1248. bindSelectedProduct(cat, val, qty, price, id, productCatId, ElementId);
  1249. updateItemsCount();
  1250. updateTotalCartPrice();
  1251. });
  1252. }
  1253. //handling check for m2-drive
  1254. const productCheckBtns = document.querySelectorAll(".product-check-btn");
  1255. for (let i = 0; i < productCheckBtns.length; i++) {
  1256. productCheckBtns[i].addEventListener("click", function () {
  1257. const checkEl = $(this);
  1258. const ElementId = $(this).parents(".accordion").attr("id");
  1259. const parentEl = checkEl.parents(".config-product-item");
  1260. const val = checkEl.val();
  1261. const productCatId = parentEl.attr("data-productcatid");
  1262. const cat = parentEl.attr("data-cat");
  1263. const qtySelectEl = parentEl.find(".qty-selector");
  1264. const price = parentEl.attr("data-price");
  1265. const id = parentEl.attr("data-id");
  1266. if ($(this).parents(".accordion").length) {
  1267. $(this)
  1268. .closest(".accordion")
  1269. .find(".config-price-span")
  1270. .removeClass("active");
  1271. $(this).closest(".accordion").find(".qty-selector").val(0);
  1272. $(this)
  1273. .closest(".accordion")
  1274. .find(".config-product-item")
  1275. .removeClass("selected");
  1276. }
  1277. if (this.checked) {
  1278. // console.log('checked')
  1279. $(this).parents(".name-of-config").find(".qty-selector").val("1");
  1280. $(this)
  1281. .parents(".name-of-config")
  1282. .find(".config-price-span")
  1283. .addClass("active");
  1284. $(this)
  1285. .closest(".accordion")
  1286. .find(".product-check-btn")
  1287. .prop("checked", false);
  1288. $(this).prop("checked", true);
  1289. parentEl.addClass("selected");
  1290. } else {
  1291. parentEl.removeClass("selected");
  1292. }
  1293. const qty = parseInt(qtySelectEl.val());
  1294. const totalPrice = qty * parseFloat(price).toFixed(2);
  1295. let selectedQty = 0;
  1296. parentEl
  1297. .closest(".config-content")
  1298. .find(".qty-selector")
  1299. .each(function () {
  1300. selectedQty = selectedQty + +$(this).val();
  1301. });
  1302. m2DriveSelectedQty = selectedQty;
  1303. if (m2DriveSelectedQty > m2DriveMaxQty) {
  1304. return false;
  1305. } else {
  1306. bindSelectedProduct(
  1307. cat,
  1308. val,
  1309. qty,
  1310. parseFloat(totalPrice).toFixed(2),
  1311. id,
  1312. productCatId,
  1313. ElementId
  1314. );
  1315. updateItemsCount();
  1316. updateTotalCartPrice();
  1317. m2DriveProgress();
  1318. }
  1319. });
  1320. }
  1321. //handling check for nvme-drive
  1322. const productCheckBtns1 = document.querySelectorAll(".product-check");
  1323. for (let i = 0; i < productCheckBtns1.length; i++) {
  1324. productCheckBtns1[i].addEventListener("click", function () {
  1325. const checkEl = $(this);
  1326. const ElementId = $(this).parents(".accordion").attr("id");
  1327. const parentEl = checkEl.parents(".config-product-item");
  1328. const val = checkEl.val();
  1329. const productCatId = parentEl.attr("data-productcatid");
  1330. const cat = parentEl.attr("data-cat");
  1331. const qtySelectEl = parentEl.find(".qty-selector");
  1332. const price = parentEl.attr("data-price");
  1333. const id = parentEl.attr("data-id");
  1334. if ($(this).parents(".accordion").length) {
  1335. $(this)
  1336. .closest(".accordion")
  1337. .find(".config-price-span")
  1338. .removeClass("active");
  1339. $(this).closest(".accordion").find(".qty-selector").val(0);
  1340. $(this)
  1341. .closest(".accordion")
  1342. .find(".config-product-item")
  1343. .removeClass("selected");
  1344. }
  1345. if (this.checked) {
  1346. $(this).parents(".name-of-config").find(".qty-selector").val("1");
  1347. $(this)
  1348. .parents(".name-of-config")
  1349. .find(".config-price-span")
  1350. .addClass("active");
  1351. $(this)
  1352. .closest(".accordion")
  1353. .find(".product-check")
  1354. .prop("checked", false);
  1355. $(this).prop("checked", true);
  1356. parentEl.addClass("selected");
  1357. } else {
  1358. parentEl.removeClass("selected");
  1359. }
  1360. const qty = parseInt(qtySelectEl.val());
  1361. const totalPrice = qty * parseFloat(price).toFixed(2);
  1362. let selectedQty = 0;
  1363. parentEl
  1364. .closest(".config-content")
  1365. .find(".qty-selector")
  1366. .each(function () {
  1367. selectedQty = selectedQty + +$(this).val();
  1368. });
  1369. nvmeDriveselectedqty = selectedQty;
  1370. if (nvmeDriveselectedqty > nvmeDrivemaxqty) {
  1371. return false;
  1372. } else {
  1373. bindSelectedProduct(
  1374. cat,
  1375. val,
  1376. qty,
  1377. parseFloat(totalPrice).toFixed(2),
  1378. id,
  1379. productCatId,
  1380. ElementId
  1381. );
  1382. updateItemsCount();
  1383. updateTotalCartPrice();
  1384. nvmeDriveProgress()();
  1385. }
  1386. });
  1387. }
  1388. //handling check for hard-drive
  1389. const productHardBtns = document.querySelectorAll(".product-hard-btn");
  1390. for (let i = 0; i < productHardBtns.length; i++) {
  1391. productHardBtns[i].addEventListener("click", function () {
  1392. const checkEl = $(this);
  1393. const ElementId = $(this).parents(".accordion").attr("id");
  1394. const parentEl = checkEl.parents(".config-product-item");
  1395. const val = checkEl.val();
  1396. const productCatId = parentEl.attr("data-productcatid");
  1397. const cat = parentEl.attr("data-cat");
  1398. const qtySelectEl = parentEl.find(".qty-selector");
  1399. const price = parentEl.attr("data-price");
  1400. const id = parentEl.attr("data-id");
  1401. if ($(this).parents(".accordion").length) {
  1402. $(this)
  1403. .closest(".accordion")
  1404. .find(".config-price-span")
  1405. .removeClass("active");
  1406. $(this).closest(".accordion").find(".qty-selector").val(0);
  1407. $(this)
  1408. .closest(".accordion")
  1409. .find(".config-product-item")
  1410. .removeClass("selected");
  1411. }
  1412. if (this.checked) {
  1413. $(this).parents(".name-of-config").find(".qty-selector").val("1");
  1414. $(this)
  1415. .parents(".name-of-config")
  1416. .find(".config-price-span")
  1417. .addClass("active");
  1418. $(this)
  1419. .closest(".accordion")
  1420. .find(".product-hard-btn")
  1421. .prop("checked", false);
  1422. $(this).prop("checked", true);
  1423. parentEl.addClass("selected");
  1424. } else {
  1425. parentEl.removeClass("selected");
  1426. }
  1427. const qty = parseInt(qtySelectEl.val());
  1428. const totalPrice = qty * parseFloat(price).toFixed(2);
  1429. let selectedQty = 0;
  1430. parentEl
  1431. .closest(".config-content")
  1432. .find(".qty-selector")
  1433. .each(function () {
  1434. selectedQty = selectedQty + +$(this).val();
  1435. });
  1436. hardDriveSelectedQty = selectedQty;
  1437. if (hardDriveSelectedQty > hardDriveMaxQty) {
  1438. return false;
  1439. } else {
  1440. bindSelectedProduct(
  1441. cat,
  1442. val,
  1443. qty,
  1444. parseFloat(totalPrice).toFixed(2),
  1445. id,
  1446. productCatId,
  1447. ElementId
  1448. );
  1449. updateItemsCount();
  1450. updateTotalCartPrice();
  1451. hardDriveProgress();
  1452. }
  1453. });
  1454. }
  1455. //qunatity selector handlers
  1456. const qtySelectors = document.querySelectorAll(".qty-selector");
  1457. for (let i = 0; i < qtySelectors.length; i++) {
  1458. qtySelectors[i].addEventListener("change", function () {
  1459. const selectEl = $(this);
  1460. const accordionId = $(this).parents(".accordion").attr("id");
  1461. const parentEl = selectEl.parents(".config-product-item");
  1462. let val = parseInt(selectEl.val());
  1463. const lastSelectedVal = parseInt(selectEl.attr("data-lastval"));
  1464. // const price = val * parseFloat(parentEl.attr('data-price')).toFixed(2);
  1465. const cat = parentEl.attr("data-cat");
  1466. const id = parentEl.attr("data-id");
  1467. const productCatId = parentEl.attr("data-productcatid");
  1468. const qtySelectEl = parentEl.find(".qty-selector");
  1469. // const qty = parseInt(qtySelectEl.val());
  1470. $(this)
  1471. .closest(".accordion")
  1472. .find(".config-price-span")
  1473. .removeClass("active");
  1474. $(this).closest(".accordion").find(".qty-selector").val(0);
  1475. if (val) {
  1476. parentEl.find(".qty-selector").val(val);
  1477. parentEl.find(".config-price-span").addClass("active");
  1478. $(this)
  1479. .closest(".accordion")
  1480. .find(".form-check-input")
  1481. .prop("checked", false);
  1482. parentEl.find(".form-check-input").prop("checked", true);
  1483. } else {
  1484. $(this).val(0);
  1485. parentEl.find(".config-price-span").removeClass("active");
  1486. parentEl.find(".form-check-input").prop("checked", false);
  1487. parentEl.removeClass("selected");
  1488. }
  1489. let selectedQty = 0;
  1490. parentEl
  1491. .closest(".config-content")
  1492. .find(".qty-selector")
  1493. .each(function () {
  1494. selectedQty = selectedQty + +$(this).val();
  1495. });
  1496. $(this)
  1497. .closest(".accordion")
  1498. .find(".config-product-item")
  1499. .removeClass("selected");
  1500. const qty = parseInt(qtySelectEl.val());
  1501. const price = parentEl.attr("data-price");
  1502. const totalPrice = qty * parseFloat(price).toFixed(2);
  1503. // const val = checkEl.val();
  1504. parentEl.addClass("selected");
  1505. bindSelectedProduct(
  1506. cat,
  1507. parentEl.find(".form-check-input").val(),
  1508. qty,
  1509. parseFloat(totalPrice).toFixed(2),
  1510. id,
  1511. productCatId,
  1512. accordionId
  1513. );
  1514. updateItemsCount();
  1515. updateTotalCartPrice();
  1516. //handling m2-drive
  1517. if (cat == "m2-drive") {
  1518. if (m2DriveMaxQty >= selectedQty) {
  1519. m2DriveSelectedQty = selectedQty;
  1520. selectEl.attr("data-lastval", val);
  1521. m2DriveProgress();
  1522. // parentEl.find('.product-price').text(parseFloat(price).toFixed(2));
  1523. const selecedSummaryProduct = $(
  1524. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  1525. );
  1526. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  1527. selecedSummaryProduct
  1528. .find(".product-price")
  1529. .text(parseFloat(price).toFixed(2));
  1530. updateTotalCartPrice();
  1531. } else {
  1532. //alert('Limit Reached Please Select 4 Only ');
  1533. // m2DriveSelectedQty = m2DriveSelectedQty - lastSelectedVal;
  1534. $('[data-bs-target="#alert-modal"]').click();
  1535. // selectEl.val(lastSelectedVal);
  1536. parentEl.find("input").prop("checked", false);
  1537. parentEl.find(".qty-selector").val(0);
  1538. parentEl.find(".config-price-span").removeClass("active");
  1539. let selectedQty = 0;
  1540. parentEl
  1541. .closest(".config-content")
  1542. .find(".qty-selector")
  1543. .each(function () {
  1544. selectedQty = selectedQty + +$(this).val();
  1545. m2DriveSelectedQty = selectedQty;
  1546. });
  1547. m2DriveProgress();
  1548. return false;
  1549. }
  1550. } else {
  1551. // parentEl.find('.product-price').text(parseFloat(price).toFixed(2));
  1552. const selecedSummaryProduct = $(
  1553. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  1554. );
  1555. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  1556. selecedSummaryProduct
  1557. .find(".product-price")
  1558. .text(parseFloat(totalPrice).toFixed(2));
  1559. updateTotalCartPrice();
  1560. }
  1561. //mvme-drive
  1562. if (cat == "nvme-drive") {
  1563. if (nvmeDrivemaxqty >= selectedQty) {
  1564. nvmeDriveselectedqty = selectedQty;
  1565. selectEl.attr("data-lastval", val);
  1566. nvmeDriveProgress();
  1567. // parentEl.find('.product-price').text(parseFloat(price).toFixed(2));
  1568. const selecedSummaryProduct = $(
  1569. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  1570. );
  1571. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  1572. selecedSummaryProduct
  1573. .find(".product-price")
  1574. .text(parseFloat(price).toFixed(2));
  1575. updateTotalCartPrice();
  1576. } else {
  1577. //alert('Limit Reached Please Select 4 Only ');
  1578. nvmeDriveselectedqty = nvmeDriveselectedqty - lastSelectedVal;
  1579. $('[data-bs-target="#alert-modal"]').click();
  1580. selectEl.val(lastSelectedVal);
  1581. parentEl.find("input").trigger("click");
  1582. return false;
  1583. }
  1584. } else {
  1585. // parentEl.find('.product-price').text(parseFloat(price).toFixed(2));
  1586. const selecedSummaryProduct = $(
  1587. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  1588. );
  1589. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  1590. selecedSummaryProduct
  1591. .find(".product-price")
  1592. .text(parseFloat(totalPrice).toFixed(2));
  1593. updateTotalCartPrice();
  1594. }
  1595. //hard-drive
  1596. if (cat == "hard-drive") {
  1597. if (hardDriveMaxQty >= selectedQty) {
  1598. hardDriveSelectedQty = selectedQty;
  1599. selectEl.attr("data-lastval", val);
  1600. hardDriveProgress();
  1601. // parentEl.find(".product-price").text(parseFloat(price).toFixed(2));
  1602. const selecedSummaryProduct = $(
  1603. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  1604. );
  1605. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  1606. // selecedSummaryProduct
  1607. // .find(".product-price")
  1608. // .text(parseFloat(price).toFixed(2));
  1609. updateTotalCartPrice();
  1610. } else {
  1611. //alert('Limit Reached Please Select 4 Only ');
  1612. $('[data-bs-target="#alert-modal-hard"]').click();
  1613. selectEl.val(lastSelectedVal);
  1614. parentEl.find("input").trigger("click");
  1615. return false;
  1616. }
  1617. } else {
  1618. // parentEl.find('.product-price').text(parseFloat(price).toFixed(2));
  1619. const selecedSummaryProduct = $(
  1620. `.${cat}-cart-product-${id}[data-accordionid="${accordionId}"]`
  1621. );
  1622. selecedSummaryProduct.find(".summary-total-qty .qty-span").text(val);
  1623. selecedSummaryProduct
  1624. .find(".product-price")
  1625. .text(parseFloat(totalPrice).toFixed(2));
  1626. updateTotalCartPrice();
  1627. }
  1628. });
  1629. }
  1630. }, 250);
  1631. // updatePrices(rates[usercurency]);