File: freej_stdlib.js

package info (click to toggle)
freej 0.10git20080824-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 13,504 kB
  • ctags: 19,398
  • sloc: ansic: 135,255; cpp: 32,550; sh: 9,318; perl: 2,932; asm: 2,355; yacc: 1,178; makefile: 1,119; java: 136; lex: 94; python: 16
file content (62 lines) | stat: -rw-r--r-- 1,293 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
user settings
*/
script_search_path = new Array("/usr/lib/freej/scripts", "~/.freej/scripts", ".", "./scripts", "./Scripts");
// TODO: font path, "media" path, lets see.

/*
	Compatiblity with old freej behaviour
*/
this._add_layer = add_layer;
this.add_layer = function (l) {
	debug("kicking " + l);
	this._add_layer(l);
	l.activate(true); // layer_set_fps: argument 0 is not a number
	l.start();
	l.set_fps();
}


/*
	include file, look in script_search_path
*/
this.include_search = function(file) {
	for (path_idx in script_search_path) {
		var filename = script_search_path[path_idx] + "/" + file;
		try {
			include(filename);
			debug("included " + filename);
			return;
		} catch (e) { 
			// FIXME TODO: status/exception code?
			// file not found -> continue,
			// otherwise not (syntax error in included file)
			debug("include("+filename+") failed:" + e);
		}
	}
}

/*
	some goodies
*/
Math.int = function(i) {
    if (i>0) 
        return this.floor(i)
    else
        return this.ceil(i)
}
Number.prototype.int = function() {
    return Math.int(this);
}
// round a number of d digits
Number.prototype.round = function(d) {
    if (d == 0)
        return Math.round(this);
    d = Math.pow(10,d);
    return Math.round(this*d)/d;
}

echo("freej std js library loaded.");