daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Aug 19th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title></title>
  5.     <script type="text/javascript">
  6.        
  7.         const $ = (id) => {
  8.             return document.querySelector(id);
  9.         }
  10.  
  11.         const getTax = () => {
  12.             let desiredValue = Number($('#x-value').value || "0");
  13.             let costTable = { 30: 1, 60: 1.75, 120: 3 }
  14.  
  15.             if(desiredValue < 1)
  16.                 return alert(`Valor insuficiente, valor mínimo R$: ${costTable["30"].toFixed(2)}`);
  17.  
  18.             let usedTime = (desiredValue >= 1 && desiredValue < 1.75) ? 30 :
  19.                         (desiredValue >= 1.75 && desiredValue < 3) ? 60 : 120;
  20.  
  21.             $("#inLabelTroco").textContent = `Tempo: ${usedTime} min`;
  22.             $("#inLabelTempo").textContent = `Troco R$: ${(desiredValue - costTable[usedTime]).toFixed(2)}`;
  23.         }
  24.  
  25.         window.addEventListener('load', () => {
  26.             $('#x-calcular').addEventListener('click', () => {
  27.                 getTax();
  28.             })
  29.         })
  30.  
  31.     </script>
  32. </head>
  33. <body>
  34.     <input type='text' id='x-value'/>
  35.     <input type='button' id='x-calcular' value='calcular'/><br/>
  36.     <label id="inLabelTroco"></label><br>
  37.     <label id="inLabelTempo"></label>
  38. </body>
  39. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top