Guest User

Untitled

a guest
Apr 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 KB | None | 0 0
  1. $(function () {
  2. var austDay = new Date();
  3. $('#year').hide();
  4. $('#month').hide();
  5. $('#day').hide();
  6. $('#hour').hide();
  7. $('#minutes').hide();
  8.  
  9. austDay = new Date($('#year').html(), $('#month').html() - 1 , $('#day').html(), $('#hour').html(), $('#minutes').html());
  10. $('#defaultCountdown').countdown({until: austDay});
  11.  
  12.  
  13.  
  14. $( "#datepicker" ).datetimepicker({
  15. hour: $('#hour').html(),
  16. minute: $('#minutes').html(),
  17. closeText: 'Ok',
  18. currentText: 'Hoje',
  19. timeText: 'Horas',
  20. hourText: 'Horas',
  21. minuteText: 'Minutos',
  22. monthNames: ['Janeiro','Fevereiro','Маrço','Abril','Maio','Junho',
  23. 'Julho','Agosto','Setembro','Оutubro','Novembro','Dezembro'],
  24. dayNamesMin: ['D','S','T','Q','Q','S','S'],
  25. dateFormat: 'dd-mm-yy'
  26. });
  27.  
  28. $( "#normalizar" ).submit(function() {
  29. $( "#inicial").val(Math.round($( "#inicial").val()).toFixed(2));
  30. $( "#final").val(Math.round($( "#final").val()).toFixed(2));
  31. $( "#desconto").val(Math.round($( "#desconto").val()).toFixed(1));
  32.  
  33. });
  34.  
  35. $( "#inicial" ).change(calculoInicial);
  36. $( "#desconto" ).change(calculoInicial);
  37. $( "#final" ).change(calculoInicial2);
  38.  
  39. function calculoInicial2(){
  40. if($( "#final").val() < 0 || $( "#desconto").val() < 0 || $( "#desconto").val() > 100 || $( "#inicial").val() < 0 ){
  41. alert("Valores Inválidos");
  42. }
  43. else{
  44. if($( "#inicial").val().length == 0 && $( "#desconto").val().length > 0 && $( "#final").val().length > 0 ){
  45. var resultado = $( "#final" ).val() / ( 1- ($( "#desconto" ).val()/100));
  46. $( "#inicial").val(Math.round(resultado).toFixed(2));
  47. }
  48. else if( $( "#inicial").val().length > 0 && $( "#final").val().length > 0){
  49.  
  50. var resultado = ((1-($( "#final" ).val()/$( "#inicial" ).val()))*100);
  51.  
  52. if(resultado < 0){
  53. alert("Valores Inválidos");
  54.  
  55. }
  56. else{
  57. $( "#desconto" ).val(Math.round(resultado).toFixed(1));
  58. }
  59. }
  60. }
  61. }
  62. function calculoInicial(){
  63. if($( "#final").val() < 0 || $( "#desconto").val() < 0 || $( "#desconto").val() > 100 || $( "#inicial").val() < 0 ){
  64. alert("Valores Inválidos");
  65.  
  66. }
  67. else{
  68. if($( "#inicial").val().length == 0 && $( "#desconto").val().length > 0 && $( "#final").val().length > 0 ){
  69. var resultado = $( "#final" ).val() / ( 1- ($( "#desconto" ).val()/100));
  70. $( "#inicial").val(Math.round(resultado).toFixed(2));
  71. }
  72. else if( $( "#inicial").val().length > 0 && $( "#desconto").val().length > 0){
  73. var resultado = ($( "#inicial" ).val()-($( "#inicial" ).val()*$( "#desconto" ).val()/100));
  74.  
  75. if(resultado < 0){
  76. alert("Valores Inválidos");
  77. }
  78. else{
  79. $( "#final" ).val(Math.round(resultado).toFixed(2));
  80. }
  81.  
  82. }
  83.  
  84. else if( $( "#inicial").val().length > 0 && $( "#final").val().length > 0){
  85. var resultado = ((1-($( "#final" ).val()/$( "#inicial" ).val()))*100);
  86.  
  87. if(resultado < 0){
  88. alert("Valores Inválidos");
  89. }
  90. else{
  91. $( "#desconto" ).val(Math.round(resultado).toFixed(1));
  92. }
  93.  
  94. }
  95.  
  96. }
  97. }
  98.  
  99. $("#shopping option[value=-1]").attr("selected","selected") ;
  100. $('#loja').attr('disabled', 'disabled');
  101.  
  102. });
  103.  
  104. function update_lojas(shopping_id) {
  105.  
  106. var js_var = "<%= @lojas %>";
  107. if(shopping_id != -1)
  108. {
  109. $('#loja').empty();
  110. $.get("lojas_by_shopping?shopping_id=" + shopping_id, function(data) {
  111.  
  112. var array = data.split(',');
  113.  
  114. for (i=0;i<array.length;i+=2)
  115. {
  116. $('#loja').append(
  117. $('<option></option>').val(array[i]).html(array[i+1])
  118. );
  119. }
  120.  
  121. });
  122.  
  123. $('#loja').removeAttr("disabled");
  124.  
  125. }
  126. else
  127. {
  128. $('#loja').attr('disabled', 'disabled');
  129. $('#loja').empty();
  130. $('#loja').append(
  131. $('<option></option>').html("-1").html("Todas")
  132. );
  133. }
  134.  
  135. }
Add Comment
Please, Sign In to add comment