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