src/js/utils.js
branchpopcorn-port
changeset 308 495ef0f3e483
parent 297 ed4a459c9290
child 354 002c314cabbf
equal deleted inserted replaced
307:db5ecd5bbcf2 308:495ef0f3e483
    44 IriSP.secondsToTime = function(secs) {  
    44 IriSP.secondsToTime = function(secs) {  
    45   var hours = Math.abs(parseInt( secs / 3600 ) % 24);
    45   var hours = Math.abs(parseInt( secs / 3600 ) % 24);
    46   var minutes = Math.abs(parseInt( secs / 60 ) % 60);
    46   var minutes = Math.abs(parseInt( secs / 60 ) % 60);
    47   var seconds = parseFloat(Math.abs(secs % 60).toFixed(0));
    47   var seconds = parseFloat(Math.abs(secs % 60).toFixed(0));
    48   
    48   
    49   return {"hours" : hours, "minutes" : minutes, "seconds" : seconds};
    49   var toString_fn = function() {
       
    50     var ret = "";
       
    51     if (hours > 0)
       
    52        ret = IriSP.padWithZeros(this.hours) + ":";
       
    53     ret += IriSP.padWithZeros(this.minutes) + ":" + IriSP.padWithZeros(this.seconds);
       
    54 
       
    55     return ret;
       
    56   }
       
    57   return {"hours" : hours, "minutes" : minutes, "seconds" : seconds, toString: toString_fn};
    50 };
    58 };
       
    59 
       
    60 IriSP.secondsToString
    51 
    61 
    52 /* format a tweet - replaces @name by a link to the profile, #hashtag, etc. */
    62 /* format a tweet - replaces @name by a link to the profile, #hashtag, etc. */
    53 IriSP.formatTweet = function(tweet) {
    63 IriSP.formatTweet = function(tweet) {
    54   var rNickname = /@(\w+)/gi; // matches a @handle
    64   var rNickname = /@(\w+)/gi; // matches a @handle
    55   var rHashtag = /#(\w+)/gi;  // matches a hashtag
    65   var rHashtag = /#(\w+)/gi;  // matches a hashtag