Rev 1601 | Rev 1604 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1601 | Rev 1603 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | LoadScript("user/autostart.js"); |
4 | LoadScript("user/autostart.js"); |
| - | 5 | } |
|
| - | 6 | ||
| - | 7 | function Extend(descendant, parent) |
|
| - | 8 | { |
|
| - | 9 | var s_constructor = parent.toString(); |
|
| - | 10 | var a_match = s_constructor.match(/\s*function (.*)\(/); |
|
| - | 11 | ||
| - | 12 | if (a_match != null) |
|
| - | 13 | { |
|
| - | 14 | descendant.prototype[a_match[1]] = parent; |
|
| - | 15 | } |
|
| - | 16 | ||
| - | 17 | for (var m in parent.prototype) |
|
| - | 18 | { |
|
| - | 19 | descendant.prototype[m] = parent.prototype[m]; |
|
| - | 20 | } |
|
| - | 21 | } |
|
| - | 22 | ||
| - | 23 | String.prototype.ltrim = function(charlist) |
|
| - | 24 | { |
|
| - | 25 | charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); |
|
| - | 26 | var re = new RegExp('^[' + charlist + ']+', 'g'); |
|
| - | 27 | return this.replace(re, ''); |
|
| - | 28 | } |
|
| - | 29 | ||
| - | 30 | String.prototype.rtrim = function(charlist) |
|
| - | 31 | { |
|
| - | 32 | charlist = !charlist ? ' \s\xA0' : charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '\$1'); |
|
| - | 33 | var re = new RegExp('[' + charlist + ']+$', 'g'); |
|
| - | 34 | return this.replace(re, ''); |
|
| - | 35 | } |
|
| - | 36 | ||
| - | 37 | String.prototype.trim = function(charlist) |
|
| - | 38 | { |
|
| - | 39 | var str = this.ltrim(charlist); |
|
| - | 40 | return str.rtrim(charlist); |
|
| - | 41 | } |
|
| - | 42 | ||
| - | 43 | function EventBase() |
|
| - | 44 | { |
|
| - | 45 | this.callbacks_ = new Array(); |
|
| - | 46 | } |
|
| - | 47 | ||
| - | 48 | EventBase.prototype.callbacks_ = null; |
|
| - | 49 | ||
| - | 50 | EventBase.prototype.Bind = function(event_name, callback) |
|
| - | 51 | { |
|
| - | 52 | if (typeof this.callbacks_[event_name] == 'undefined') |
|
| - | 53 | { |
|
| - | 54 | this.callbacks_[event_name] = new Array(); |
|
| - | 55 | } |
|
| - | 56 | ||
| - | 57 | this.callbacks_[event_name].push(callback); |
|
| - | 58 | } |
|
| - | 59 | ||
| - | 60 | EventBase.prototype.Trigger = function(event_name) |
|
| - | 61 | { |
|
| - | 62 | if (typeof this.callbacks_[event_name] != 'undefined') |
|
| - | 63 | { |
|
| - | 64 | for (var n = 0; n < this.callbacks_[event_name].length; n++) |
|
| - | 65 | { |
|
| - | 66 | this.callbacks_[event_name][n].apply(null, Array.prototype.slice.call(arguments, 0)); |
|
| - | 67 | } |
|
| - | 68 | } |
|
| 5 | } |
69 | } |