hireme.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var messageModified = false;
  2. function calculateEstimate() {
  3. var time = +hourinput.value*60 + +minuteinput.value;
  4. rate = 3.5
  5. var total = time*rate;
  6. if (nonprofit.checked) total *= 0.7
  7. if (min.checked) total *= 0.5
  8. if (fullstack.checked) total *= 1.15
  9. if (hackhands.checked) total *= 1.2
  10. totalestimate.innerHTML = '$' + Math.round(total)
  11. var timeText = ''
  12. if (+hourinput.value !== 0) timeText = hourinput.value + ' hours' + timeText
  13. if (+minuteinput.value !== 0 && +hourinput.value !== 0) timeText += ' and '
  14. if (+minuteinput.value !== 0) timeText += minuteinput.value + ' minutes'
  15. if (+hourinput.value === 1) timeText = timeText.replace(/hours/g, 'hour')
  16. if (+minuteinput.value === 1) timeText = timeText.replace(/minutes/g, 'minute')
  17. if (time === 0) timeText = 'no time at all'
  18. if (!messageModified) {
  19. if (time >= 0) message.value = "Hi Owen,\n\nI'd like to hire you for " + timeText + ' to work on ______.'
  20. else message.value = "Hi Owen,\n\nI'd like you to pay me to work on something, entirely disregarding the purpose of this form."
  21. message.value += "\n\nCheers, _____"
  22. }
  23. if(window.mixpanel) mixpanel.track('Estimate', {'Total': total, 'Time': time, 'Min': min.checked, 'Nonprofit': nonprofit.checked, 'Fullstack': fullstack.checked, 'Hackhands': hackhands.checked, 'Modified': messageModified})
  24. }
  25. calculateEstimate()
  26. var inputs = document.querySelectorAll('.pod input');
  27. for (var i=0; i<inputs.length; i++) {
  28. inputs[i].onchange = inputs[i].keyup = inputs[i].mouseup = inputs[i].oninput = calculateEstimate
  29. }