Update std.js

This commit is contained in:
Namhyeon Go 2022-01-08 23:12:59 +09:00 committed by GitHub
parent 77e4145f98
commit 60458ee5f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;