No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test.js 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. let components = [
  2. {
  3. name: "BAREBONE",
  4. items: [
  5. {
  6. name: "Anwi C252 Chipset - 1U - 2x SATA - 1x M.2 - Dual Anwi 1-Gigabit Ethernet (RJ45 - 350W Power Supply",
  7. price: 99,
  8. quantity: 1,
  9. },
  10. ],
  11. },
  12. {
  13. name: "PROCESSOR",
  14. serises: [
  15. {
  16. name: "Intel<sup>®</sup> Xeon<sup>®</sup> E-2300 Processor Series",
  17. items: [
  18. {
  19. name: "Quad-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2314 Processor 2.8GHz 8MB Cache (65W)",
  20. price: 99,
  21. quantity: 1,
  22. },
  23. ],
  24. },
  25. {
  26. name: "Intel<sup>®</sup> Xeon<sup>®</sup> E-2300 Processor Series",
  27. items: [
  28. {
  29. name: "Quad-Core Intel<sup>®</sup> Xeon<sup>®</sup> E-2334 Processor 3.4GHz 8MB Cache (65W)",
  30. price: 99,
  31. quantity: 1,
  32. },
  33. ],
  34. },
  35. ],
  36. },
  37. {
  38. name: "Memory",
  39. items: [
  40. {
  41. name: "16GB PC4-25600 3200MHz DDR4 ECC UDIMM",
  42. price: 99,
  43. quantity: 1,
  44. },
  45. {
  46. name: "32GB PC4-25600 3200MHz DDR4 ECC UDIMM",
  47. price: 99,
  48. quantity: 1,
  49. },
  50. ],
  51. },
  52. ];
  53. $("input:checkbox[name=driver-check-btns]")
  54. .unbind("change")
  55. .change(function () {
  56. if (
  57. $(this).prop("checked") &&
  58. $(this)[0].classList[0] == "form-check-input"
  59. ) {
  60. let drivetext = $(this).siblings("label").children().text();
  61. let qty = parseInt(
  62. $(this).parent().parent().find(".form-select option:selected").val()
  63. );
  64. let value = $(this).parent().parent().find(".wish-list-price").text();
  65. let html =
  66. '<li class="row my-1 align-items-center"> <span class="col-md-2" id="driver-qty"></span> <span class="order-middle-left col-md-8" id="driver-name">' +
  67. drivetext +
  68. '</span><span class="order-price col-md-1"><span id="driver-price" class="price-span "> ' +
  69. value +
  70. "</span></span></li>";
  71. $("#m-2-drive").append(html);
  72. //$("#driver-name").text($(this).val());
  73. //$("#driver-price").text('$99.00');
  74. }
  75. $(":checkbox").on("change", function () {
  76. var $list = $("#m-2-drive").empty();
  77. var name = $(":checkbox:checked")
  78. .map(function () {
  79. var title = $(this).next("label").text();
  80. let value = $(this).parent().parent().find(".wish-list-price").text();
  81. $(
  82. `<li class="row my-1 align-items-center"> <span class="col-md-2" id="driver-qty"></span> <span class="order-middle-left col-md-8" id="driver-name"> ${title} </span><span class="order-price col-md-1"><span id="driver-price" class="price-span ">${value}</span></span></li>'`
  83. ).appendTo($list);
  84. return title;
  85. })
  86. .get();
  87. console.log(name);
  88. });
  89. updateItems();
  90. });
  91. // driver-config-section
  92. $(this)
  93. .find(".drivers-1-select")
  94. .on("change", function () {
  95. let blockInp = parseInt($(this).val());
  96. data.driversOne = 99 * blockInp;
  97. $("#driver-qty").text(blockInp + "X");
  98. $(this)
  99. .parent()
  100. .siblings(".confi-pricing")
  101. .find(".driversOne-total-price")
  102. .text(parseFloat(data.driversOne).toFixed(2));
  103. $("#driver-price").text(parseFloat(data.driversOne).toFixed(2));
  104. $(driversCheckBox).prop("checked", true);
  105. $("#driver-name").text($(driversCheckBox).val());
  106. $("#driver-price").text(
  107. $(this)
  108. .parent()
  109. .siblings(".confi-pricing")
  110. .find(".driversOne-total-price")
  111. .html()
  112. );
  113. updateItems();
  114. });
  115. $(this)
  116. .find(".drivers-2-select")
  117. .on("change", function () {
  118. let blockInp = parseInt($(this).val());
  119. data.driversTwo = 149 * blockInp;
  120. $("#driver-qty").text(blockInp + "X");
  121. $(this)
  122. .parent()
  123. .siblings(".confi-pricing")
  124. .find(".driversTwo-total-price")
  125. .text(parseFloat(data.driversTwo).toFixed(2));
  126. $("#driver-price").text(parseFloat(data.driversTwo).toFixed(2));
  127. $(driversCheckBox).prop("checked", true);
  128. $("#driver-name").text($(driversCheckBox).val());
  129. $("#driver-price").text(
  130. $(this)
  131. .parent()
  132. .siblings(".confi-pricing")
  133. .find(".driversTwo-total-price")
  134. .html()
  135. );
  136. updateItems();
  137. });
  138. $(this)
  139. .find(".drivers-3-select")
  140. .on("change", function () {
  141. let blockInp = parseInt($(this).val());
  142. data.driversThree = 269 * blockInp;
  143. $("#driver-qty").text(blockInp + "X");
  144. $(this)
  145. .parent()
  146. .siblings(".confi-pricing")
  147. .find(".driversThree-total-price")
  148. .text(parseFloat(data.driversThree).toFixed(2));
  149. $("#driver-price").text(parseFloat(data.driversThree).toFixed(2));
  150. $(driversCheckBox).prop("checked", true);
  151. $("#driver-name").text($(driversCheckBox).val());
  152. $("#driver-price").text(
  153. $(this)
  154. .parent()
  155. .siblings(".confi-pricing")
  156. .find(".driversThree-total-price")
  157. .html()
  158. );
  159. updateItems();
  160. });
  161. $(":checkbox").on("change", function () {
  162. // if($('#check-btn2[type="checkbox"]').prop("checked")){ // true
  163. // $('#check-btn2[type="checkbox"]').prop("checked", false)
  164. // }else{
  165. // $('#check-btn2[type="checkbox"]').prop("checked", true)
  166. // }
  167. var $list = $("#m-2-drive").empty();
  168. var name = $(":checkbox:checked")
  169. .map(function () {
  170. var title = $(this).next("label").text();
  171. let value = $(this).parent().parent().find(".wish-list-price").text();
  172. $(
  173. `<li class="row my-1 align-items-center"> <span class="col-md-2" id="driver-qty"></span> <span class="order-middle-left col-md-8" id="driver-name"> ${title} </span><span class="order-price col-md-1"><span id="driver-price" class="price-span ">${value}</span></span></li>'`
  174. ).appendTo($list);
  175. return title;
  176. })
  177. .get();
  178. console.log(name);
  179. });