Update std.js

This commit is contained in:
Namhyeon Go 2022-01-08 23:35:07 +09:00 committed by GitHub
parent aeb474b888
commit 8fe35ac9c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,13 +104,13 @@ exports.CreateObject = function(progId, serverName, callback) {
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
var stdEvent = function(eventName) { var StdEvent = function(eventName) {
this.bubbles = false; // Not supported this.bubbles = false; // Not supported
this.cancelable = false; // Not supported this.cancelable = false; // Not supported
this.composed = false; // Not supported this.composed = false; // Not supported
this.currentTarget = null; // Not supported this.currentTarget = null; // Not supported
this.defaultPrevented = false; this.defaultPrevented = false;
this.eventPhase = null; this.eventPhase = null; // TODO
this.isTrusted = true; // Not supported this.isTrusted = true; // Not supported
this.timeStamp = new Date(); this.timeStamp = new Date();
@ -137,7 +137,7 @@ var stdEvent = function(eventName) {
}; };
}; };
var stdEventableObject = function() { var StdEventableObject = function() {
this.dispatchEvent = function(event) { this.dispatchEvent = function(event) {
event.target = this; event.target = this;
if(eventName in this) this['on' + event.eventName](event); if(eventName in this) this['on' + event.eventName](event);
@ -152,9 +152,17 @@ var stdEventableObject = function() {
}; };
}; };
var getRandomInt = function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
exports.VERSIONINFO = "Standard Lib (std.js) version 0.3"; exports.VERSIONINFO = "Standard Lib (std.js) version 0.3";
exports.global = global; exports.global = global;
exports.require = global.require; exports.require = global.require;
exports.Event = stdEvent; exports.Event = StdEvent;
exports.EventableObject = stdEventableObject; exports.EventableObject = StdEventableObject;
exports.getRandomInt = getRandomInt;