rust.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. $('#rust').ajaxForm({
  2. dataType: 'json',
  3. success: function (data) {
  4. $.each(data, function (i, val) {
  5. if (i == 'e')
  6. bootbox.dialog('<h3 class="red">Ошибка</h3>' + val,
  7. [{
  8. "label": "Продолжить",
  9. }]
  10. );
  11. if (i == 's')
  12. location.href = home + 'servers/id/' + data['id'];
  13. });
  14. loading(0);
  15. }
  16. });
  17. function change_data(data) {
  18. $.getJSON('services/section/rust/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/get/' + data, function (arr) {
  19. $.each(arr, function (id, val) {
  20. $('#' + id).html(val);
  21. });
  22. upd_price();
  23. promo();
  24. });
  25. }
  26. function upd_price() {
  27. $.getJSON('services/section/rust/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/slots/' + $('#slots').val() + '/time/' + $('#time').val() + '/tickrate/' + $('#tickrate').val() + '/get/price', function (arr) {
  28. $.each(arr, function (id, val) {
  29. $('#' + id).html(val);
  30. });
  31. promo();
  32. });
  33. }
  34. function promo() {
  35. if ($('#promo').val() == '') {
  36. $('#promo_tr').css('display', 'none');
  37. $('#sum_info').css('text-decoration', 'none');
  38. return false;
  39. }
  40. $.getJSON('services/section/rust/id/' + $('#unit').val() + '/tarif/' + $('#tarifs').val() + '/slots/' + $('#slots').val() + '/time/' + $('#time').val() + '/tickrate/' + $('#tickrate').val() + '/cod/' + $('#promo').val() + '/get/promo', function (arr) {
  41. $('#promo_tr').css('display', 'table-row');
  42. if (arr['e'] != undefined) {
  43. $('#promo_info').html(arr['e']);
  44. $('#sum_info').css('text-decoration', 'none');
  45. } else {
  46. if (arr['discount'] == 1) {
  47. $('#sum_info').css('text-decoration', 'line-through');
  48. $('#promo_info').html('Цена с учетом промо-кода: ' + arr['sum'] + ' ' + arr['cur']);
  49. } else {
  50. $('#sum_info').css('text-decoration', 'none');
  51. $('#promo_info').html('Подарочные дни: ' + arr['days']);
  52. }
  53. }
  54. });
  55. }