| author | hamidouk |
| Thu, 20 Oct 2011 10:19:00 +0200 | |
| branch | popcorn-port |
| changeset 99 | 912f100fecb0 |
| parent 78 | d77fe3283530 |
| child 103 | 2dfd89e91c3a |
| permissions | -rw-r--r-- |
| 31 | 1 |
/* utils.js - various utils that don't belong anywhere else */ |
2 |
||
3 |
/* trace function, for debugging */ |
|
4 |
||
5 |
IriSP.traceNum = 0; |
|
6 |
IriSP.trace = function( msg, value ) { |
|
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
7 |
/* |
| 31 | 8 |
if( IriSP.config.gui.debug === true ) { |
9 |
IriSP.traceNum += 1; |
|
10 |
IriSP.jQuery( "<div>"+IriSP.traceNum+" - "+msg+" : "+value+"</div>" ).appendTo( "#Ldt-output" ); |
|
11 |
} |
|
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
12 |
*/ |
| 31 | 13 |
}; |
14 |
||
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
15 |
/* used in callbacks - because in callbacks we lose "this", |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
16 |
we need to have a special function which wraps "this" in |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
17 |
a closure. This way, the |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
18 |
*/ |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
19 |
IriSP.wrap = function (obj, fn) { |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
20 |
return function() { |
| 78 | 21 |
var args = [].slice.call(this, arguments); |
22 |
return fn.call(obj, args); |
|
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
23 |
} |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
24 |
} |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
25 |
|
|
99
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
26 |
/* convert a time to a percentage in the media */ |
|
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
27 |
IriSP.timeToPourcent = function(time,timetotal){ |
|
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
28 |
return (parseInt(Math.round(time/timetotal*100))); |
|
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
29 |
}; |
|
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
30 |
|
| 60 | 31 |
/* for ie compatibility |
32 |
if (Object.prototype.__defineGetter__&&!Object.defineProperty) { |
|
33 |
Object.defineProperty=function(obj,prop,desc) { |
|
34 |
if ("get" in desc) obj.__defineGetter__(prop,desc.get); |
|
35 |
if ("set" in desc) obj.__defineSetter__(prop,desc.set); |
|
36 |
} |
|
37 |
} |
|
38 |
*/ |