src/js/utils.js
branchpopcorn-port
changeset 253 95c6b77f005e
parent 252 fd84e0fb26d8
child 254 cafaa694b709
equal deleted inserted replaced
252:fd84e0fb26d8 253:95c6b77f005e
    15 /* used in callbacks - because in callbacks we lose "this",
    15 /* used in callbacks - because in callbacks we lose "this",
    16    we need to have a special function which wraps "this" in 
    16    we need to have a special function which wraps "this" in 
    17    a closure. This way, the 
    17    a closure. This way, the 
    18 */   
    18 */   
    19 IriSP.wrap = function (obj, fn) {
    19 IriSP.wrap = function (obj, fn) {
    20   return function() {
    20   return function() {    
    21     var args = [].slice.call(this, arguments);
    21     var args = Array.prototype.slice.call(arguments, 0);
    22     return fn.call(obj, args);
    22     return fn.apply(obj, args);
    23   }
    23   }
    24 }
    24 }
    25 
    25 
    26 /* convert a time to a percentage in the media */
    26 /* convert a time to a percentage in the media */
    27 IriSP.timeToPourcent = function(time, timetotal){
    27 IriSP.timeToPourcent = function(time, timetotal){
    28 	// return (parseInt(Math.round(time/timetotal*100)));
    28 	var time = Math.abs(time);
       
    29   var timetotal = Math.abs(timetotal);
       
    30   
    29 	return Math.floor((time/timetotal) * 100);
    31 	return Math.floor((time/timetotal) * 100);
    30 };
    32 };
    31 
    33 
    32 /* convert a number of seconds to a tuple of the form 
    34 /* convert a number of seconds to a tuple of the form 
    33    [hours, minutes, seconds]
    35    [hours, minutes, seconds]