| author | hamidouk |
| Mon, 14 Nov 2011 17:19:26 +0100 | |
| branch | require-js |
| changeset 238 | 6008172a0592 |
| parent 160 | d3f336807ec3 |
| permissions | -rw-r--r-- |
| 31 | 1 |
/* utils.js - various utils that don't belong anywhere else */ |
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
160
diff
changeset
|
2 |
define(["IriSP"], function() { |
| 31 | 3 |
|
4 |
/* trace function, for debugging */ |
|
5 |
||
6 |
IriSP.traceNum = 0; |
|
7 |
IriSP.trace = function( msg, value ) { |
|
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
8 |
/* |
| 31 | 9 |
if( IriSP.config.gui.debug === true ) { |
10 |
IriSP.traceNum += 1; |
|
11 |
IriSP.jQuery( "<div>"+IriSP.traceNum+" - "+msg+" : "+value+"</div>" ).appendTo( "#Ldt-output" ); |
|
12 |
} |
|
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
13 |
*/ |
| 31 | 14 |
}; |
15 |
||
|
73
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
16 |
/* 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
|
17 |
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
|
18 |
a closure. This way, the |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
19 |
*/ |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
20 |
IriSP.wrap = function (obj, fn) { |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
21 |
return function() { |
| 78 | 22 |
var args = [].slice.call(this, arguments); |
23 |
return fn.call(obj, args); |
|
|
73
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 |
} |
|
a8192c57c87d
added a function to make closures (for use in callbacks).
hamidouk
parents:
60
diff
changeset
|
26 |
|
|
99
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
27 |
/* convert a time to a percentage in the media */ |
|
103
2dfd89e91c3a
added a method to sort the json annotations. changed the tests accordingly.
hamidouk
parents:
99
diff
changeset
|
28 |
IriSP.timeToPourcent = function(time, timetotal){ |
| 160 | 29 |
// return (parseInt(Math.round(time/timetotal*100))); |
30 |
return Math.floor((time/timetotal) * 100); |
|
|
99
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
31 |
}; |
|
912f100fecb0
added a small utility function to convert a time to a progression percentage.
hamidouk
parents:
78
diff
changeset
|
32 |
|
| 60 | 33 |
/* for ie compatibility |
34 |
if (Object.prototype.__defineGetter__&&!Object.defineProperty) { |
|
35 |
Object.defineProperty=function(obj,prop,desc) { |
|
36 |
if ("get" in desc) obj.__defineGetter__(prop,desc.get); |
|
37 |
if ("set" in desc) obj.__defineSetter__(prop,desc.set); |
|
38 |
} |
|
39 |
} |
|
|
238
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
160
diff
changeset
|
40 |
*/ |
|
6008172a0592
converted all the source files to use the require.js syntax.
hamidouk
parents:
160
diff
changeset
|
41 |
}); |