Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // declare a function expression called filterTimeCode that takes in timeInSeconds as a parameter
  2. var filterTimeCode = function(timeInSeconds) {
  3.   //set time in seconds to equal the parsed float of timeInSeconds
  4.   parseFloat(timeInSeconds);
  5.   // declare a variable called seconds that concatinates a "0" to the result of remainder of timeInSeconds and 60 run through Math.floor to return the highest integer
  6.   var seconds = Math.floor(timeInSeconds % 3600 % 60);
  7.   // declare a variable called minutes that divides timeInSeconds by 60 and runs it through Math.floor to return the highest integer
  8.   var minutes = Math.floor(timeInSeconds % 3600 / 60);
  9.   // Remove the 0 in front of seconds with more than 2 characters, e.g. 010 but not 09
  10.   var formattedSeconds = ("00" + seconds).slice(-2);
  11.   // return the concatination of minutes, a colon, and the value of last two elements in seconds (look up slice() method)
  12.   return minutes + ":" + formattedSeconds;  
  13. };
  14.  // end function
  15.  
  16.  
  17.  // To do:
  18.  // 1. change "+ <td class="song-item-duration">' + songLength + '</td>'"" in createSongRow to use the filterTimeCode function and display the result of running songLength through the function
  19.  // 2. update updateSeekBarWhileSongPlays function so that setCurrentTimeInPlayerBar shows the current time run through the filterTimeCode function (you will need to use getTime())
  20.  
  21.  // declare a function called setCurrentTimeInPlayerBar that accepts currentTime as a parameter
  22.  var setCurrentTimeInPlayerBar = function(currentTime) {
  23.    // use jquery to select the .current-time class and change the text inside of that to currentTime
  24.    $(".current-time").text(currentTime)
  25.  };
  26.  // end function
  27.  
  28.   // declare a function called setTotalTimeInPlayerBar that accepts totalTime as a parameter
  29.  var setTotalTimeInPlayerBar = function(totalTime) {
  30.    // use jquery to select the .total-time class and change the text inside of that to totalTime
  31.    $(".total-time").text(totalTime);
  32.  } ;
  33.  // end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement