Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. // calculator-input
  2. $(document).ready(function() {
  3. $('.btn-minus').click(function () {
  4. var $input = $(this).parent().find('input');
  5. var count = parseInt($input.val()) - 1;
  6. count = count < 1 ? 1 : count;
  7. $input.val(count);
  8. $input.change();
  9. return false;
  10. });
  11. $('.btn-plus').click(function () {
  12. var $input = $(this).parent().find('input');
  13. $input.val(parseInt($input.val()) + 1);
  14. $input.change();
  15. return false;
  16. });
  17. });
  18. // left-block-data
  19. var data = {
  20. cores : 4,
  21. ram : 4,
  22. storage:512,
  23. transfer:8
  24. };
  25. var toggle= false;
  26. var totalCost = {};
  27. // total-cost-and-savings
  28. for (let i = 0; i < 100 ; i++) {
  29. let value = i+1;
  30. totalCost[value] = {
  31. total : { monthly : value* 1000, yearly : value*12000},
  32. serversCost : {
  33. Hireserver : {
  34. price: { monthly : value*10, yearly : value*100 },
  35. savings: { monthly : value*10/2, yearly : value*100/2 }
  36. },
  37. Aws : {
  38. price: { monthly : value*10, yearly : value*100 },
  39. savings: { monthly : value*10/2, yearly : value*100/2 }
  40. },
  41. Google : {
  42. price: { monthly : value*10, yearly : value*100 },
  43. savings: { monthly : value*10/2, yearly : value*100/2 }
  44. },
  45. Azure : {
  46. price: { monthly : value*10, yearly : value*100 },
  47. savings: { monthly : value*10/2, yearly : value*100/2 }
  48. },
  49. Digital : {
  50. price: { monthly : value*10, yearly : value*100 },
  51. savings: { monthly : value*10/2, yearly : value*100/2 }
  52. },
  53. Linode : {
  54. price: { monthly : value*10, yearly : value*100 },
  55. savings: { monthly : value*10/2, yearly : value*100/2 }
  56. }
  57. }
  58. }
  59. }
  60. var blockValue = 1;
  61. var subscriptionType = "monthly";
  62. // purchase-btn
  63. $("#total-cost").html(totalCost[1].total.monthly);
  64. // calculator-input
  65. $(document).ready(function() {
  66. // toggleswitch
  67. $('#block-calculator-toggle-switch').change(function() {
  68. blockValue = $("#block-input").val();
  69. if(blockValue == 0) return;
  70. if(this.checked) {
  71. subscriptionType = "yearly";
  72. toggle=true;
  73. }else{
  74. subscriptionType = "monthly";
  75. toggle=false;
  76. }
  77. changeTotalCost();
  78. });
  79. $("#block-input").change(function(){
  80. let blockInp=$(this).val();
  81. if(blockInp==0 || blockInp >= 100) return;
  82. data.cores=4*blockInp;
  83. data.ram =4*blockInp;
  84. data.storage =512*blockInp;
  85. data.transfer = 8*blockInp;
  86. addLeftBlockHTML();
  87. })
  88. $("#btn-plus").click(function () {
  89. let value = $("#block-input").val();
  90. data.cores *= 2;
  91. data.ram *= 2;
  92. data.storage *= 2;
  93. data.transfer *= 2;
  94. addLeftBlockHTML();
  95. })
  96. $("#btn-minus").click(function () {
  97. let value1 = $("#block-input").val();
  98. if(value1==1){
  99. return
  100. }
  101. data.cores /= 2;
  102. data.ram /= 2;
  103. data.storage /= 2;
  104. data.transfer /= 2;
  105. addLeftBlockHTML();
  106. });
  107. // input
  108. addLeftBlockHTML();
  109. });
  110. // leftblock
  111. function addLeftBlockHTML(){
  112. let html = `
  113. <div class="block-calculator-content d-flex justify-content-between border-bottom align-items-center">
  114. <div class="content-data ">
  115. <ul class="list-unstyled">
  116. <li>
  117. <ul class="d-flex align-items-center justify-content-evenly list-unstyled">
  118. <li><img src="./images/home-page/new-svg/chip-icon.svg"
  119. class="img-fluid me-4" alt="core-icon"></li>
  120. <ul class="list-unstyled"><li>
  121. <p class="card-text mb-0">CPU's</p>
  122. <p class="sub-card-text">Core AMD EPYC 7003</p>
  123. </li></ul>
  124. </div>
  125. <div class="content-value">
  126. <p >${data.cores} cores</p>
  127. </div></div>
  128. <div class="block-calculator-content d-flex justify-content-between border-bottom align-items-center">
  129. <div class="content-data d-flex align-items-center">
  130. <img src="./images/home-page/new-svg/chip-icon.svg"
  131. class="img-fluid me-4" alt="core-icon">
  132. <p class="card-text">RAM</p>
  133. </div>
  134. <div class="content-value">
  135. <p>${data.ram}GB</p>
  136. </div></div>
  137. <div class="block-calculator-content d-flex justify-content-between border-bottom align-items-center">
  138. <div class="content-data ">
  139. <ul class="d-flex align-items-center justify-content-evenly list-unstyled">
  140. <li> <img src="./images/home-page/new-svg/chip-icon.svg"
  141. class="img-fluid me-4" alt="core-icon"></li>
  142. <ul class="list-unstyled"><li>
  143. <p class="card-text mb-0">STORAGE</p>
  144. <p class="sub-card-text">NVMe SSD</p>
  145. </li></ul>
  146. </ul> </div>
  147. <div class="content-value">
  148. <p>${data.storage}GB</p>
  149. </div></div>
  150. <div class="block-calculator-content d-flex justify-content-between border-bottom align-items-center">
  151. <div class="content-data ">
  152. <ul class="d-flex align-items-center justify-content-evenly list-unstyled">
  153. <li> <img src="./images/home-page/new-svg/chip-icon.svg"
  154. class="img-fluid me-4" alt="core-icon"></li>
  155. <li> <p class="card-text">TRANSFER</p></li>
  156. </ul>
  157. </div>
  158. <div class="content-value">
  159. <p>${data.transfer}TB</p>
  160. </div></div>
  161. `
  162. $("#block-content-main").html(html);
  163. changeServerPricing();
  164. changeTotalCost();
  165. }
  166. // total-cost-change-purchase-btn
  167. function changeTotalCost() {
  168. blockValue = $("#block-input").val();
  169. if(blockValue == 0) return;
  170. if(!totalCost[blockValue]) return;
  171. $("#total-cost").html(totalCost[blockValue].total[subscriptionType]);
  172. changeServerPricing(blockValue);
  173. }
  174. // right-block
  175. function changeServerPricing () {
  176. $("#hire-server-cost").html(totalCost[blockValue].serversCost.Hireserver.savings[subscriptionType]);
  177. $("#hire-server-total-cost").html(totalCost[blockValue].serversCost.Hireserver.price[subscriptionType]);
  178. $("#aws-cost").html(totalCost[blockValue].serversCost.Aws.savings[subscriptionType]);
  179. $("#aws-total-cost").html(totalCost[blockValue].serversCost.Aws.price[subscriptionType]);
  180. $("#google-cost").html(totalCost[blockValue].serversCost.Google.savings[subscriptionType]);
  181. $("#google-total-cost").html(totalCost[blockValue].serversCost.Google.price[subscriptionType]);
  182. $("#azure-cost").html(totalCost[blockValue].serversCost.Azure.savings[subscriptionType]);
  183. $("#azure-total-cost").html(totalCost[blockValue].serversCost.Azure.price[subscriptionType]);
  184. $("#digital-cost").html(totalCost[blockValue].serversCost.Digital.savings[subscriptionType]);
  185. $("#digital-total-cost").html(totalCost[blockValue].serversCost.Digital.price[subscriptionType]);
  186. $("#linode-cost").html(totalCost[blockValue].serversCost.Linode.savings[subscriptionType]);
  187. $("#linode-total-cost").html(totalCost[blockValue].serversCost.Linode.price[subscriptionType]);
  188. }
  189. // passing values to order-summary
  190. $("#purchase-button").click(function(){
  191. let subscriptionData = {
  192. currentBlock : blockValue,
  193. subscriptionType : subscriptionType,
  194. blockDetails: data,
  195. totalCost: totalCost,
  196. toggleSwitch:toggle
  197. };
  198. localStorage.setItem("subscription-data",JSON.stringify(subscriptionData));
  199. window.location.href="../login-register.html";
  200. })
  201. // export {data};