Guest User

Untitled

a guest
Feb 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. $('.vertical .progress-fill').each(function(){
  2. var toFirst = $(this).find("span.to").html();
  3.  
  4. var to = parseInt(toFirst); //Transforms sting into number
  5.  
  6. if (toN == 2018) {
  7. to = 100;
  8. } else if (toN == 2019) {
  9. to = 89;
  10. } else if (toN == 2020) {
  11. to = 78;
  12. } else if (toN == 2021) {
  13. to = 66.5;
  14. } else if (toN == 2022) {
  15. to = 55;
  16. } else if (toN == 2023) {
  17. to = 43.5;
  18. } else if (toN == 2024) {
  19. to = 32.5;
  20. } else if (toN == 2025) {
  21. to = 21;
  22. } else {
  23. to = 9.5;
  24. }
  25.  
  26. var fromFirst = $(this).find("span.from").html();
  27. var fromN = parseInt(fromFirst);
  28.  
  29. if (fromN == 2018) { //This doesn't work. Returns just the first number
  30. from = 100;
  31. } else if (fromN == 2019) {
  32. from = 89;
  33. } else if (fromN == 2020) {
  34. from = 78;
  35. } else if (fromN == 2021) {
  36. from = 66.5;
  37. } else if (fromN == 2022) {
  38. from = 55;
  39. } else if (fromN == 2023) {
  40. from = 43.5;
  41. } else if (fromN == 2024) {
  42. from = 32.5;
  43. } else if (fromN == 2025) {
  44. from = 21;
  45. } else {
  46. from = 9.5;
  47. }
  48.  
  49. console.log(from); //Just to see if it's returning the correct dates
  50. console.log(to); //Just to see if it's returning the correct dates
  51.  
  52. var percentFrom = from + "%";
  53.  
  54. var pBottom = 0 + ( from.slice(0, from.length - 1) );0
  55. var pTop = 100 - (to) + "%" ;
  56.  
  57. var bottom = (pBottom) + "%";
  58. var top = (to - from) + "%";
  59.  
  60.  
  61. $(this).parent().css({
  62. 'height' : top,
  63. 'top' : pTop,
  64. 'bottom' : percentFrom,
  65. });
  66. });
Add Comment
Please, Sign In to add comment