Rev 1608 | Rev 1614 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1608 | Rev 1609 | ||
|---|---|---|---|
| 1 | 1 | ||
| 2 | var |
2 | var global_legacy = false; |
| 3 | 3 | ||
| 4 | function Start() |
4 | function Start(legacy) |
| 5 | { |
5 | { |
| - | 6 | global_legacy = legacy; |
|
| - | 7 | ||
| 6 | if ( |
8 | if (global_legacy) |
| 7 | { |
9 | { |
| 8 | LoadScript("legacy/System/Base.js"); |
10 | LoadScript("legacy/System/Base.js"); |
| 9 | LoadScript("legacy/System/Startup.js"); |
11 | LoadScript("legacy/System/Startup.js"); |
| 10 | LoadScript("legacy/Autostart.js"); |
12 | LoadScript("legacy/Autostart.js"); |
| 11 | 13 | ||
| 12 | autostart(); |
14 | autostart(); |
| 13 | } |
15 | } |
| 14 | else |
16 | else |
| 15 | { |
17 | { |
| 16 | LoadScript("user/autostart.js"); |
18 | LoadScript("user/autostart.js"); |
| 17 | } |
19 | } |
| 18 | } |
20 | } |
| 19 | 21 | ||
| 20 | function Extend(descendant, parent) |
22 | function Extend(descendant, parent) |
| 21 | { |
23 | { |
| 22 | var s_constructor = parent.toString(); |
24 | var s_constructor = parent.toString(); |
| 23 | var a_match = s_constructor.match(/\s*function (.*)\(/); |
25 | var a_match = s_constructor.match(/\s*function (.*)\(/); |
| 24 | 26 | ||
| 25 | if (a_match != null) |
27 | if (a_match != null) |
| 26 | { |
28 | { |
| 27 | descendant.prototype[a_match[1]] = parent; |
29 | descendant.prototype[a_match[1]] = parent; |
| 28 | } |
30 | } |
| 29 | 31 | ||
| 30 | for (var m in parent.prototype) |
32 | for (var m in parent.prototype) |
| 31 | { |
33 | { |
| 32 | descendant.prototype[m] = parent.prototype[m]; |
34 | descendant.prototype[m] = parent.prototype[m]; |
| 33 | } |
35 | } |
| 34 | } |
36 | } |
| 35 | 37 | ||
| 36 | String.prototype.ltrim = function(charlist) |
38 | String.prototype.ltrim = function(charlist) |
| 37 | { |
39 | { |
| 38 | charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); |
40 | charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); |
| 39 | var re = new RegExp('^[' + charlist + ']+', 'g'); |
41 | var re = new RegExp('^[' + charlist + ']+', 'g'); |
| 40 | return this.replace(re, ''); |
42 | return this.replace(re, ''); |
| 41 | } |
43 | } |
| 42 | 44 | ||
| 43 | String.prototype.rtrim = function(charlist) |
45 | String.prototype.rtrim = function(charlist) |
| 44 | { |
46 | { |
| 45 | charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); |
47 | charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); |
| 46 | var re = new RegExp('[' + charlist + ']+$', 'g'); |
48 | var re = new RegExp('[' + charlist + ']+$', 'g'); |
| 47 | return this.replace(re, ''); |
49 | return this.replace(re, ''); |
| 48 | } |
50 | } |
| 49 | 51 | ||
| 50 | String.prototype.trim = function(charlist) |
52 | String.prototype.trim = function(charlist) |
| 51 | { |
53 | { |
| 52 | var str = this.ltrim(charlist); |
54 | var str = this.ltrim(charlist); |
| 53 | return str.rtrim(charlist); |
55 | return str.rtrim(charlist); |
| 54 | } |
56 | } |
| 55 | 57 | ||
| 56 | function EventBase() |
58 | function EventBase() |
| 57 | { |
59 | { |
| 58 | this.callbacks_ = new Array(); |
60 | this.callbacks_ = new Array(); |
| 59 | } |
61 | } |
| 60 | 62 | ||
| 61 | EventBase.prototype.callbacks_ = null; |
63 | EventBase.prototype.callbacks_ = null; |
| 62 | 64 | ||
| 63 | EventBase.prototype.Bind = function(event_name, callback) |
65 | EventBase.prototype.Bind = function(event_name, callback) |
| 64 | { |
66 | { |
| 65 | if (typeof this.callbacks_[event_name] == 'undefined') |
67 | if (typeof this.callbacks_[event_name] == 'undefined') |
| 66 | { |
68 | { |
| 67 | this.callbacks_[event_name] = new Array(); |
69 | this.callbacks_[event_name] = new Array(); |
| 68 | } |
70 | } |
| 69 | 71 | ||
| 70 | this.callbacks_[event_name].push(callback); |
72 | this.callbacks_[event_name].push(callback); |
| 71 | } |
73 | } |
| 72 | 74 | ||
| 73 | EventBase.prototype.Trigger = function(event_name) |
75 | EventBase.prototype.Trigger = function(event_name) |
| 74 | { |
76 | { |
| 75 | if (typeof this.callbacks_[event_name] != 'undefined') |
77 | if (typeof this.callbacks_[event_name] != 'undefined') |
| 76 | { |
78 | { |
| 77 | for (var n = 0; n < this.callbacks_[event_name].length; n++) |
79 | for (var n = 0; n < this.callbacks_[event_name].length; n++) |
| 78 | { |
80 | { |
| 79 | this.callbacks_[event_name][n].apply(null, Array.prototype.slice.call(arguments, 0)); |
81 | this.callbacks_[event_name][n].apply(null, Array.prototype.slice.call(arguments, 0)); |
| 80 | } |
82 | } |
| 81 | } |
83 | } |
| 82 | } |
84 | } |
| 83 | 85 | ||