mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04:58 +00:00
Clean up code
This commit is contained in:
parent
aa8f10b6a7
commit
46eb8e6609
22
app.js
22
app.js
|
@ -194,9 +194,12 @@ if (typeof CreateObject === "undefined") {
|
|||
} else {
|
||||
console.warn("(Chakra) The standalone engine does not supported. Please use the built-in engine.");
|
||||
console.warn("(Chakra) hint:", "cscript //NoLogo //E:{1b7cd997-e5ff-4932-a7a6-2a9e636da385} app.js <filename> <...arguments>");
|
||||
throw new Error("Could not find a loader");
|
||||
}
|
||||
} else if (typeof ActiveXObject !== "undefined") {
|
||||
return new ActiveXObject(p);
|
||||
} else {
|
||||
throw new Error("Could not find a loader");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -497,9 +500,9 @@ function initializeConsole() {
|
|||
var app = require(name);
|
||||
if (app) {
|
||||
if (app.main) {
|
||||
var exitStatus = app.main.call(this, args);
|
||||
if (typeof exitStatus !== "undefined") {
|
||||
exit(exitStatus);
|
||||
var status = app.main.call(this, args);
|
||||
if (typeof status !== "undefined") {
|
||||
exit(status);
|
||||
}
|
||||
} else {
|
||||
console.error("Error, missing main entry point in", name);
|
||||
|
@ -512,7 +515,7 @@ function initializeConsole() {
|
|||
|
||||
function initializeWindow(name, args, w, h) {
|
||||
if (typeof window === "undefined") {
|
||||
console.error("Error, window is not defined");
|
||||
console.error("This is not a window");
|
||||
exit(1);
|
||||
}
|
||||
var app = require(name);
|
||||
|
@ -530,11 +533,11 @@ function initializeWindow(name, args, w, h) {
|
|||
exit(exitStatus);
|
||||
}
|
||||
} else {
|
||||
console.error("Error, missing main entry point in", name + ".js");
|
||||
console.error("Missing main entry point in", name + ".js");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
console.error("Error, cannot find", name + ".js");
|
||||
console.error("Could not find", name + ".js");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -572,8 +575,11 @@ function __main__() {
|
|||
console.log(" \\ V V / __/ \\__ \\ (_) | | | | |_| |___) |");
|
||||
console.log(" \\_/\\_/ \\___|_|___/\\___/|_| |_|\\___/|____/ ");
|
||||
console.log("");
|
||||
console.log(" WelsonJS - Build a Windows app on the Windows built-in JavaScript engine");
|
||||
console.log(" https://github.com/gnh1201/welsonjs");
|
||||
console.log(" WelsonJS - Build a Windows app on the Windows built-in JavaScript engine");
|
||||
console.log(" C-2021-000237 (cros.or.kr)");
|
||||
console.log(" 10.5281/zenodo.11382385 (doi.org)");
|
||||
console.log(" This software is distributed as open source under the GPL 3.0 or MS-RL licenses.");
|
||||
console.log(" https://github.com/gnh1201/welsonjs");
|
||||
console.log("");
|
||||
|
||||
if (typeof window === "undefined") {
|
||||
|
|
|
@ -80,6 +80,11 @@
|
|||
"id": "linqjs",
|
||||
"description": "linq.js (LINQ for JavaScript) test",
|
||||
"tags": ["Library"]
|
||||
},
|
||||
{
|
||||
"id": "domparser_test",
|
||||
"description": "DOMParser compatibility test",
|
||||
"tags": ["Standards"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -54,40 +54,42 @@ CdoCharset.CdoUS_ASCII = "us-ascii";
|
|||
CdoCharset.CdoUTF_7 = "utf-7";
|
||||
CdoCharset.CdoUTF_8 = "utf-8";
|
||||
|
||||
var CRC32Table = (function() {
|
||||
var c;
|
||||
var crcTable = [];
|
||||
var randomize = Math.random;
|
||||
|
||||
function UUIDv4() {}
|
||||
UUIDv4.create = function() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = randomize() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
};
|
||||
|
||||
function CRC32() {
|
||||
this.value = 0;
|
||||
|
||||
this.fromString = function(s) {
|
||||
var crc = 0 ^ (-1);
|
||||
for (var i = 0; i < s.length; i++ ) {
|
||||
crc = (crc >>> 8) ^ CRC32.table[(crc ^ s.charCodeAt(i)) & 0xFF];
|
||||
}
|
||||
this.value = ((crc ^ (-1)) >>> 0);
|
||||
};
|
||||
|
||||
this.toString = function() {
|
||||
return this.value.toString(16).padStart(8, '0');
|
||||
};
|
||||
}
|
||||
CRC32.table = [];
|
||||
(function() {
|
||||
for (var n = 0; n < 256; n++) {
|
||||
c = n;
|
||||
for(var k =0; k < 8; k++){
|
||||
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
||||
}
|
||||
crcTable[n] = c;
|
||||
CRC32.table[n] = c;
|
||||
}
|
||||
return crcTable;
|
||||
})();
|
||||
|
||||
|
||||
var randomize = Math.random;
|
||||
|
||||
function createUUIDv4() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
var r = randomize() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
||||
function CRC32(str) {
|
||||
var crcTable = CRC32Table;
|
||||
var crc = 0 ^ (-1);
|
||||
|
||||
for (var i = 0; i < str.length; i++ ) {
|
||||
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
|
||||
}
|
||||
|
||||
return ((crc ^ (-1)) >>> 0).toString(16).padStart(8, '0');
|
||||
}
|
||||
|
||||
function makeProbabilityBit(p) {
|
||||
return !( p > 0.0 ? ( (randomize() / p) > 1.0 ) : true) ? 1 : 0;
|
||||
}
|
||||
|
@ -176,7 +178,7 @@ function PipeIPC() {
|
|||
|
||||
this.connect = function(pipename, callback) {
|
||||
if (pipename == "volatile") {
|
||||
pipename = createUUIDv4().substring(0, 8);
|
||||
pipename = UUIDv4.create().substring(0, 8);
|
||||
}
|
||||
this.path = this.path.replace(":pipename", pipename);
|
||||
//this.openWriter();
|
||||
|
@ -502,7 +504,7 @@ exports.connect = function(path, callback) {
|
|||
return pipe.connect(path, callback);
|
||||
};
|
||||
|
||||
exports.createUUIDv4 = createUUIDv4;
|
||||
exports.UUIDv4 = UUIDv4;
|
||||
exports.CRC32 = CRC32;
|
||||
|
||||
exports.ForReading = ForReading;
|
||||
|
@ -519,7 +521,7 @@ exports.adSaveCreateNotExist = adSaveCreateNotExist;
|
|||
exports.adSaveCreateOverWrite = adSaveCreateOverWrite;
|
||||
exports.adModeReadWrite = adModeReadWrite;
|
||||
|
||||
exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.21";
|
||||
exports.VERSIONINFO = "PIPE-based IPC Module (pipe-ipc.js) version 0.1.22";
|
||||
exports.AUTHOR = "abuse@catswords.net";
|
||||
exports.global = global;
|
||||
exports.require = require;
|
||||
|
|
|
@ -967,6 +967,10 @@ var test_implements = {
|
|||
}
|
||||
});
|
||||
console.log(JSON.stringify(b.toArray()));
|
||||
},
|
||||
|
||||
"domparser_test": function() {
|
||||
console.log(typeof DOMParser);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user