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