mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 20:21:03 +00:00
Update std.js
This commit is contained in:
parent
77e4145f98
commit
60458ee5f3
57
lib/std.js
57
lib/std.js
|
@ -59,11 +59,11 @@ global.sleep = function(ms, callback) {
|
|||
setTimeout(callback, ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
global.CHR = function(ord) {
|
||||
return String.fromCharCode(ord);
|
||||
}
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Private APIs / Utility functions
|
||||
|
@ -104,6 +104,57 @@ exports.CreateObject = function(progId, serverName, callback) {
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
exports.VERSIONINFO = "Standard Lib (std.js) version 0.2";
|
||||
var stdEvent = function(eventName) {
|
||||
this.bubbles = false; // Not supported
|
||||
this.cancelable = false; // Not supported
|
||||
this.composed = false; // Not supported
|
||||
this.currentTarget = null; // Not supported
|
||||
this.defaultPrevented = false;
|
||||
this.eventPhase = null;
|
||||
this.isTrusted = true; // Not supported
|
||||
this.timeStamp = new Date();
|
||||
|
||||
this.eventName = eventName;
|
||||
this.target = null;
|
||||
|
||||
// Not supported
|
||||
this.composedPath = function() {
|
||||
return null;
|
||||
};
|
||||
|
||||
this.preventDefault = function() {
|
||||
this.defaultPrevented = true;
|
||||
};
|
||||
|
||||
// Not supported
|
||||
this.stopImmediatePropagation = function() {
|
||||
return null;
|
||||
};
|
||||
|
||||
// Not supported
|
||||
this.setPropagation = function() {
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
var stdEventableObject = function() {
|
||||
this.dispatchEvent = function(event) {
|
||||
event.target = this;
|
||||
if(eventName in this) this['on' + event.eventName](event);
|
||||
};
|
||||
|
||||
this.addEventListener = function(eventName, fn) {
|
||||
if (typeof(fn) == "function") {
|
||||
this['on' + eventName] = fn;
|
||||
} else {
|
||||
throw new TypeError("EventListener must be a function");
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.VERSIONINFO = "Standard Lib (std.js) version 0.3";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
||||
exports.Event = stdEvent;
|
||||
exports.EventableObject = stdEventableObject;
|
||||
|
|
Loading…
Reference in New Issue
Block a user