2022-09-06 20:44:58 +02:00
|
|
|
<!DOCTYPE html>
|
2022-09-05 16:29:51 +02:00
|
|
|
<!--
|
2022-09-06 20:44:58 +02:00
|
|
|
This is an unaffiliated fork of the Ecoji v1 webapp.
|
|
|
|
| Last modified: 2022-09-06.
|
|
|
|
|
|
|
|
Original Ecoji project info:
|
2022-09-05 16:29:51 +02:00
|
|
|
| https://github.com/keith-turner/ecoji
|
|
|
|
|
2022-09-06 20:44:58 +02:00
|
|
|
Changes in this Web build (directly edited from the gh-pages branch):
|
|
|
|
| Simplified the CSS,
|
|
|
|
| handling decode URIs with "#d=" instead of "?d=",
|
|
|
|
| added JavaScript notice,
|
|
|
|
| made the app a self-contained AHTML bundle and added notice.
|
|
|
|
|
|
|
|
License: Apache-2.0
|
|
|
|
| (https://github.com/keith-turner/ecoji/blob/main/LICENSE)
|
2022-09-05 16:29:51 +02:00
|
|
|
-->
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8"/>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<link rel="manifest" href="manifest.json">
|
|
|
|
<style>
|
|
|
|
@Media (Prefers-Color-Scheme: Light) {
|
|
|
|
Body, TextArea {
|
|
|
|
Color: #000000;
|
|
|
|
Background-Color: #F0F0F0;
|
|
|
|
}
|
|
|
|
A { Color: #CC00CC }
|
|
|
|
}
|
|
|
|
@Media (Prefers-Color-Scheme: Dark) {
|
|
|
|
Body, TextArea {
|
|
|
|
Color: #FFFFFF;
|
|
|
|
Background-Color: #0F0F0F;
|
|
|
|
}
|
|
|
|
A { Color: #FFAAFF }
|
|
|
|
}
|
|
|
|
Body {
|
|
|
|
Margin: 0px;
|
|
|
|
Padding: 16px;
|
|
|
|
Max-Height: 100vh;
|
|
|
|
Font-Family: Sans-Serif;
|
|
|
|
Font-Size: Large;
|
|
|
|
Overflow-X: Hidden;
|
|
|
|
User-Select: None;
|
|
|
|
}
|
|
|
|
Main, P {
|
|
|
|
Text-Align: Center;
|
|
|
|
}
|
|
|
|
Header {
|
|
|
|
Line-Height: 2.5;
|
|
|
|
}
|
|
|
|
TextArea {
|
|
|
|
Width: 90%;
|
|
|
|
Font-Size: Large;
|
|
|
|
}
|
|
|
|
Header > Div > * {
|
|
|
|
Display: Inline;
|
|
|
|
Margin-Left: 40px;
|
|
|
|
Margin-Right: 40px;
|
|
|
|
White-Space: NoWrap;
|
|
|
|
}
|
|
|
|
NoScript P {
|
|
|
|
Font-Size: XX-Large;
|
|
|
|
Padding: 8px;
|
|
|
|
Padding-Bottom: 48px;
|
|
|
|
}
|
|
|
|
Footer {
|
|
|
|
Font-Size: Small;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<script>
|
2022-09-06 20:44:58 +02:00
|
|
|
/*** Start golang wasm-exec code. ***/
|
|
|
|
|
2022-09-05 16:29:51 +02:00
|
|
|
// Copyright 2018 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
if (typeof global !== "undefined") {
|
|
|
|
// global already exists
|
|
|
|
} else if (typeof window !== "undefined") {
|
|
|
|
window.global = window;
|
|
|
|
} else if (typeof self !== "undefined") {
|
|
|
|
self.global = self;
|
|
|
|
} else {
|
|
|
|
throw new Error("cannot export Go (neither global, window nor self is defined)");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.require && typeof require !== "undefined") {
|
|
|
|
global.require = require;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.fs && global.require) {
|
|
|
|
global.fs = require("fs");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.fs) {
|
|
|
|
let outputBuf = "";
|
|
|
|
global.fs = {
|
|
|
|
constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused
|
|
|
|
writeSync(fd, buf) {
|
|
|
|
outputBuf += decoder.decode(buf);
|
|
|
|
const nl = outputBuf.lastIndexOf("\n");
|
|
|
|
if (nl != -1) {
|
|
|
|
console.log(outputBuf.substr(0, nl));
|
|
|
|
outputBuf = outputBuf.substr(nl + 1);
|
|
|
|
}
|
|
|
|
return buf.length;
|
|
|
|
},
|
|
|
|
write(fd, buf, offset, length, position, callback) {
|
|
|
|
if (offset !== 0 || length !== buf.length || position !== null) {
|
|
|
|
throw new Error("not implemented");
|
|
|
|
}
|
|
|
|
const n = this.writeSync(fd, buf);
|
|
|
|
callback(null, n);
|
|
|
|
},
|
|
|
|
open(path, flags, mode, callback) {
|
|
|
|
const err = new Error("not implemented");
|
|
|
|
err.code = "ENOSYS";
|
|
|
|
callback(err);
|
|
|
|
},
|
|
|
|
read(fd, buffer, offset, length, position, callback) {
|
|
|
|
const err = new Error("not implemented");
|
|
|
|
err.code = "ENOSYS";
|
|
|
|
callback(err);
|
|
|
|
},
|
|
|
|
fsync(fd, callback) {
|
|
|
|
callback(null);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.crypto) {
|
|
|
|
const nodeCrypto = require("crypto");
|
|
|
|
global.crypto = {
|
|
|
|
getRandomValues(b) {
|
|
|
|
nodeCrypto.randomFillSync(b);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.performance) {
|
|
|
|
global.performance = {
|
|
|
|
now() {
|
|
|
|
const [sec, nsec] = process.hrtime();
|
|
|
|
return sec * 1000 + nsec / 1000000;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.TextEncoder) {
|
|
|
|
global.TextEncoder = require("util").TextEncoder;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!global.TextDecoder) {
|
|
|
|
global.TextDecoder = require("util").TextDecoder;
|
|
|
|
}
|
|
|
|
|
|
|
|
const encoder = new TextEncoder("utf-8");
|
|
|
|
const decoder = new TextDecoder("utf-8");
|
|
|
|
|
|
|
|
global.Go = class {
|
|
|
|
constructor() {
|
|
|
|
this.argv = ["js"];
|
|
|
|
this.env = {};
|
|
|
|
this.exit = (code) => {
|
|
|
|
if (code !== 0) {
|
|
|
|
console.warn("exit code:", code);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
this._exitPromise = new Promise((resolve) => {
|
|
|
|
this._resolveExitPromise = resolve;
|
|
|
|
});
|
|
|
|
this._pendingEvent = null;
|
|
|
|
this._scheduledTimeouts = new Map();
|
|
|
|
this._nextCallbackTimeoutID = 1;
|
|
|
|
|
|
|
|
const mem = () => {
|
|
|
|
return new DataView(this._inst.exports.mem.buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
const setInt64 = (addr, v) => {
|
|
|
|
mem().setUint32(addr + 0, v, true);
|
|
|
|
mem().setUint32(addr + 4, Math.floor(v / 4294967296), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
const getInt64 = (addr) => {
|
|
|
|
const low = mem().getUint32(addr + 0, true);
|
|
|
|
const high = mem().getInt32(addr + 4, true);
|
|
|
|
return low + high * 4294967296;
|
|
|
|
}
|
|
|
|
|
|
|
|
const loadValue = (addr) => {
|
|
|
|
const f = mem().getFloat64(addr, true);
|
|
|
|
if (f === 0) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
if (!isNaN(f)) {
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
|
|
|
const id = mem().getUint32(addr, true);
|
|
|
|
return this._values[id];
|
|
|
|
}
|
|
|
|
|
|
|
|
const storeValue = (addr, v) => {
|
|
|
|
const nanHead = 0x7FF80000;
|
|
|
|
|
|
|
|
if (typeof v === "number") {
|
|
|
|
if (isNaN(v)) {
|
|
|
|
mem().setUint32(addr + 4, nanHead, true);
|
|
|
|
mem().setUint32(addr, 0, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (v === 0) {
|
|
|
|
mem().setUint32(addr + 4, nanHead, true);
|
|
|
|
mem().setUint32(addr, 1, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mem().setFloat64(addr, v, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (v) {
|
|
|
|
case undefined:
|
|
|
|
mem().setFloat64(addr, 0, true);
|
|
|
|
return;
|
|
|
|
case null:
|
|
|
|
mem().setUint32(addr + 4, nanHead, true);
|
|
|
|
mem().setUint32(addr, 2, true);
|
|
|
|
return;
|
|
|
|
case true:
|
|
|
|
mem().setUint32(addr + 4, nanHead, true);
|
|
|
|
mem().setUint32(addr, 3, true);
|
|
|
|
return;
|
|
|
|
case false:
|
|
|
|
mem().setUint32(addr + 4, nanHead, true);
|
|
|
|
mem().setUint32(addr, 4, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let ref = this._refs.get(v);
|
|
|
|
if (ref === undefined) {
|
|
|
|
ref = this._values.length;
|
|
|
|
this._values.push(v);
|
|
|
|
this._refs.set(v, ref);
|
|
|
|
}
|
|
|
|
let typeFlag = 0;
|
|
|
|
switch (typeof v) {
|
|
|
|
case "string":
|
|
|
|
typeFlag = 1;
|
|
|
|
break;
|
|
|
|
case "symbol":
|
|
|
|
typeFlag = 2;
|
|
|
|
break;
|
|
|
|
case "function":
|
|
|
|
typeFlag = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mem().setUint32(addr + 4, nanHead | typeFlag, true);
|
|
|
|
mem().setUint32(addr, ref, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
const loadSlice = (addr) => {
|
|
|
|
const array = getInt64(addr + 0);
|
|
|
|
const len = getInt64(addr + 8);
|
|
|
|
return new Uint8Array(this._inst.exports.mem.buffer, array, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
const loadSliceOfValues = (addr) => {
|
|
|
|
const array = getInt64(addr + 0);
|
|
|
|
const len = getInt64(addr + 8);
|
|
|
|
const a = new Array(len);
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
a[i] = loadValue(array + i * 8);
|
|
|
|
}
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
const loadString = (addr) => {
|
|
|
|
const saddr = getInt64(addr + 0);
|
|
|
|
const len = getInt64(addr + 8);
|
|
|
|
return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));
|
|
|
|
}
|
|
|
|
|
|
|
|
const timeOrigin = Date.now() - performance.now();
|
|
|
|
this.importObject = {
|
|
|
|
go: {
|
|
|
|
"runtime.wasmExit": (sp) => {
|
|
|
|
const code = mem().getInt32(sp + 8, true);
|
|
|
|
this.exited = true;
|
|
|
|
delete this._inst;
|
|
|
|
delete this._values;
|
|
|
|
delete this._refs;
|
|
|
|
this.exit(code);
|
|
|
|
},
|
|
|
|
|
|
|
|
"runtime.wasmWrite": (sp) => {
|
|
|
|
const fd = getInt64(sp + 8);
|
|
|
|
const p = getInt64(sp + 16);
|
|
|
|
const n = mem().getInt32(sp + 24, true);
|
|
|
|
fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));
|
|
|
|
},
|
|
|
|
|
|
|
|
"runtime.nanotime": (sp) => {
|
|
|
|
setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);
|
|
|
|
},
|
|
|
|
|
|
|
|
"runtime.walltime": (sp) => {
|
|
|
|
const msec = (new Date).getTime();
|
|
|
|
setInt64(sp + 8, msec / 1000);
|
|
|
|
mem().setInt32(sp + 16, (msec % 1000) * 1000000, true);
|
|
|
|
},
|
|
|
|
|
|
|
|
"runtime.scheduleTimeoutEvent": (sp) => {
|
|
|
|
const id = this._nextCallbackTimeoutID;
|
|
|
|
this._nextCallbackTimeoutID++;
|
|
|
|
this._scheduledTimeouts.set(id, setTimeout(
|
|
|
|
() => {
|
|
|
|
this._resume();
|
|
|
|
while (this._scheduledTimeouts.has(id)) {
|
|
|
|
console.warn("scheduleTimeoutEvent: missed timeout event");
|
|
|
|
this._resume();
|
|
|
|
}
|
|
|
|
},
|
2022-09-06 20:44:58 +02:00
|
|
|
getInt64(sp + 8) + 1,
|
2022-09-05 16:29:51 +02:00
|
|
|
));
|
|
|
|
mem().setInt32(sp + 16, id, true);
|
|
|
|
},
|
|
|
|
|
|
|
|
"runtime.clearTimeoutEvent": (sp) => {
|
|
|
|
const id = mem().getInt32(sp + 8, true);
|
|
|
|
clearTimeout(this._scheduledTimeouts.get(id));
|
|
|
|
this._scheduledTimeouts.delete(id);
|
|
|
|
},
|
|
|
|
|
|
|
|
"runtime.getRandomData": (sp) => {
|
|
|
|
crypto.getRandomValues(loadSlice(sp + 8));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.stringVal": (sp) => {
|
|
|
|
storeValue(sp + 24, loadString(sp + 8));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueGet": (sp) => {
|
|
|
|
const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));
|
2022-09-06 20:44:58 +02:00
|
|
|
sp = this._inst.exports.getsp();
|
2022-09-05 16:29:51 +02:00
|
|
|
storeValue(sp + 32, result);
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueSet": (sp) => {
|
|
|
|
Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueIndex": (sp) => {
|
|
|
|
storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueSetIndex": (sp) => {
|
|
|
|
Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueCall": (sp) => {
|
|
|
|
try {
|
|
|
|
const v = loadValue(sp + 8);
|
|
|
|
const m = Reflect.get(v, loadString(sp + 16));
|
|
|
|
const args = loadSliceOfValues(sp + 32);
|
|
|
|
const result = Reflect.apply(m, v, args);
|
2022-09-06 20:44:58 +02:00
|
|
|
sp = this._inst.exports.getsp();
|
2022-09-05 16:29:51 +02:00
|
|
|
storeValue(sp + 56, result);
|
|
|
|
mem().setUint8(sp + 64, 1);
|
|
|
|
} catch (err) {
|
|
|
|
storeValue(sp + 56, err);
|
|
|
|
mem().setUint8(sp + 64, 0);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueInvoke": (sp) => {
|
|
|
|
try {
|
|
|
|
const v = loadValue(sp + 8);
|
|
|
|
const args = loadSliceOfValues(sp + 16);
|
|
|
|
const result = Reflect.apply(v, undefined, args);
|
2022-09-06 20:44:58 +02:00
|
|
|
sp = this._inst.exports.getsp();
|
2022-09-05 16:29:51 +02:00
|
|
|
storeValue(sp + 40, result);
|
|
|
|
mem().setUint8(sp + 48, 1);
|
|
|
|
} catch (err) {
|
|
|
|
storeValue(sp + 40, err);
|
|
|
|
mem().setUint8(sp + 48, 0);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueNew": (sp) => {
|
|
|
|
try {
|
|
|
|
const v = loadValue(sp + 8);
|
|
|
|
const args = loadSliceOfValues(sp + 16);
|
|
|
|
const result = Reflect.construct(v, args);
|
2022-09-06 20:44:58 +02:00
|
|
|
sp = this._inst.exports.getsp();
|
2022-09-05 16:29:51 +02:00
|
|
|
storeValue(sp + 40, result);
|
|
|
|
mem().setUint8(sp + 48, 1);
|
|
|
|
} catch (err) {
|
|
|
|
storeValue(sp + 40, err);
|
|
|
|
mem().setUint8(sp + 48, 0);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueLength": (sp) => {
|
|
|
|
setInt64(sp + 16, parseInt(loadValue(sp + 8).length));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valuePrepareString": (sp) => {
|
|
|
|
const str = encoder.encode(String(loadValue(sp + 8)));
|
|
|
|
storeValue(sp + 16, str);
|
|
|
|
setInt64(sp + 24, str.length);
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueLoadString": (sp) => {
|
|
|
|
const str = loadValue(sp + 8);
|
|
|
|
loadSlice(sp + 16).set(str);
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.valueInstanceOf": (sp) => {
|
|
|
|
mem().setUint8(sp + 24, loadValue(sp + 8) instanceof loadValue(sp + 16));
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.copyBytesToGo": (sp) => {
|
|
|
|
const dst = loadSlice(sp + 8);
|
|
|
|
const src = loadValue(sp + 32);
|
|
|
|
if (!(src instanceof Uint8Array)) {
|
|
|
|
mem().setUint8(sp + 48, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const toCopy = src.subarray(0, dst.length);
|
|
|
|
dst.set(toCopy);
|
|
|
|
setInt64(sp + 40, toCopy.length);
|
|
|
|
mem().setUint8(sp + 48, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
"syscall/js.copyBytesToJS": (sp) => {
|
|
|
|
const dst = loadValue(sp + 8);
|
|
|
|
const src = loadSlice(sp + 16);
|
|
|
|
if (!(dst instanceof Uint8Array)) {
|
|
|
|
mem().setUint8(sp + 48, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const toCopy = src.subarray(0, dst.length);
|
|
|
|
dst.set(toCopy);
|
|
|
|
setInt64(sp + 40, toCopy.length);
|
|
|
|
mem().setUint8(sp + 48, 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
"debug": (value) => {
|
|
|
|
console.log(value);
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(instance) {
|
|
|
|
this._inst = instance;
|
2022-09-06 20:44:58 +02:00
|
|
|
this._values = [
|
2022-09-05 16:29:51 +02:00
|
|
|
NaN,
|
|
|
|
0,
|
|
|
|
null,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
global,
|
|
|
|
this,
|
|
|
|
];
|
|
|
|
this._refs = new Map();
|
|
|
|
this.exited = false;
|
|
|
|
|
|
|
|
const mem = new DataView(this._inst.exports.mem.buffer)
|
|
|
|
|
|
|
|
let offset = 4096;
|
|
|
|
|
|
|
|
const strPtr = (str) => {
|
|
|
|
const ptr = offset;
|
|
|
|
const bytes = encoder.encode(str + "\0");
|
|
|
|
new Uint8Array(mem.buffer, offset, bytes.length).set(bytes);
|
|
|
|
offset += bytes.length;
|
|
|
|
if (offset % 8 !== 0) {
|
|
|
|
offset += 8 - (offset % 8);
|
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
const argc = this.argv.length;
|
|
|
|
|
|
|
|
const argvPtrs = [];
|
|
|
|
this.argv.forEach((arg) => {
|
|
|
|
argvPtrs.push(strPtr(arg));
|
|
|
|
});
|
|
|
|
|
|
|
|
const keys = Object.keys(this.env).sort();
|
|
|
|
argvPtrs.push(keys.length);
|
|
|
|
keys.forEach((key) => {
|
|
|
|
argvPtrs.push(strPtr(`${key}=${this.env[key]}`));
|
|
|
|
});
|
|
|
|
|
|
|
|
const argv = offset;
|
|
|
|
argvPtrs.forEach((ptr) => {
|
|
|
|
mem.setUint32(offset, ptr, true);
|
|
|
|
mem.setUint32(offset + 4, 0, true);
|
|
|
|
offset += 8;
|
|
|
|
});
|
|
|
|
|
|
|
|
this._inst.exports.run(argc, argv);
|
|
|
|
if (this.exited) {
|
|
|
|
this._resolveExitPromise();
|
|
|
|
}
|
|
|
|
await this._exitPromise;
|
|
|
|
}
|
|
|
|
|
|
|
|
_resume() {
|
|
|
|
if (this.exited) {
|
|
|
|
throw new Error("Go program has already exited");
|
|
|
|
}
|
|
|
|
this._inst.exports.resume();
|
|
|
|
if (this.exited) {
|
|
|
|
this._resolveExitPromise();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_makeFuncWrapper(id) {
|
|
|
|
const go = this;
|
|
|
|
return function () {
|
|
|
|
const event = { id: id, this: this, args: arguments };
|
|
|
|
go._pendingEvent = event;
|
|
|
|
go._resume();
|
|
|
|
return event.result;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
global.require &&
|
|
|
|
global.require.main === module &&
|
|
|
|
global.process &&
|
|
|
|
global.process.versions &&
|
|
|
|
!global.process.versions.electron
|
|
|
|
) {
|
|
|
|
if (process.argv.length < 3) {
|
|
|
|
console.error("usage: go_js_wasm_exec [wasm binary] [arguments]");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
const go = new Go();
|
|
|
|
go.argv = process.argv.slice(2);
|
|
|
|
go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
|
|
|
|
go.exit = process.exit;
|
|
|
|
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
|
2022-09-06 20:44:58 +02:00
|
|
|
process.on("exit", (code) => {
|
2022-09-05 16:29:51 +02:00
|
|
|
if (code === 0 && !go.exited) {
|
|
|
|
go._pendingEvent = { id: 0 };
|
|
|
|
go._resume();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return go.run(result.instance);
|
|
|
|
}).catch((err) => {
|
|
|
|
console.error(err);
|
|
|
|
process.exit(1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
|
2022-09-06 20:44:58 +02:00
|
|
|
/*** End golang wasm-exec code; Start ecoji code. ***/
|
2022-09-05 16:29:51 +02:00
|
|
|
|
|
|
|
const go = new Go();
|
2022-09-06 20:44:58 +02:00
|
|
|
// Using embedded "main.wasm" from "https://ecoji.io/"
|
2022-09-05 16:29:51 +02:00
|
|
|
const ecojiPromise = WebAssembly.instantiateStreaming(fetch("data:application/wasm;base64,AGFzbQEAAAAA8oCAgAAKZ28uYnVpbGRpZP8gR28gYnVpbGQgSUQ6ICJSWkxBV05SSm1wWjZYMUxYUVZ0Si9SWmIycUQxLWk2eWZZak1Ea1ZHaS9HTE43WGdnOGFKbVZjOUkwaDVKci9td3padjJaYjVtaURYS2xMWGVZWiIKIP8Ak4CAgAAKZ28udmVyc2lvbmdvMS4xMy44AcKAgIAADGABfwF/YAF/AGA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OTA5QDlQOWA5cDmAOZA5oDmwOcA50DngOfA6ADoQOiA6MDpAOlA6YDpwOoA6kDqgOrA6wDrQOuA68DsAOxA7IDswO0A7UDtgO3A7gDuQO6A7sDvAO9A74DvwPAA8EDwgPDA8QDxQPGA8cDyAPJA8oDywPMA80DzgPPA9AD0QPSA9MD1APVA9YD1wPYA9kD2gPbA9wD3QPeA98D4APhA+ID4wPkA+UD5gPnA+gD6QPqA+sD7APtA+4D7wPwA/ED8gPzA/QD9QP2A/cD+AP5A/oD+wP8A/0D/gP/A4AEgQSCBIMEhASFBIYEhwSIBIkEigSLBIwEjQSOBI8EkASRBJIEkwSUBJUElgSXBJgEmQSaBJsEnASdBJ4EnwSgBKEEogSjBKQEpQSmBKcEqASpBKoEqwSsBK0ErgSvBLAEsQSyBLMEtAS1BLYEtwS4BLkEugS7BLwEvQS+BL8EwATBBMIEwwTEBMUExgTHBMgEyQTKBMsEzATNBM4EzwTQBNEE0gTTBNQE1QTWBNcE2ATZBNoE2wTcBN0E3gTfBOAE4QTiBOME5ATlBOYE5wToBOkE6gTrBOwE7QTuBO8E8ATxBPIE8wT0BPUE9gT3BPgE+QT6BPsE/
|
|
|
|
go.run(result.instance);
|
|
|
|
|
|
|
|
});
|
|
|
|
function doEncode(){
|
|
|
|
var data = document.getElementById('plain').value
|
|
|
|
var encoded = ecojiEncode(data)
|
|
|
|
document.getElementById('encoded').value = encoded
|
|
|
|
}
|
|
|
|
|
|
|
|
function doDecode(){
|
|
|
|
var data = document.getElementById('encoded').value
|
|
|
|
var decoded = ecojiDecode(data)
|
|
|
|
document.getElementById('plain').value = decoded
|
|
|
|
}
|
|
|
|
|
|
|
|
function doPopulate(ep) {
|
|
|
|
if(ep) {
|
|
|
|
document.getElementById('encoded').value = ep
|
|
|
|
var decoded = ecojiDecode(ep)
|
|
|
|
document.getElementById('plain').value = decoded
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript
|
|
|
|
function copyTextToClipboard(text) {
|
|
|
|
var textArea = document.createElement("textarea");
|
|
|
|
|
|
|
|
textArea.style.position = 'fixed';
|
|
|
|
textArea.style.top = 0;
|
|
|
|
textArea.style.left = 0;
|
|
|
|
textArea.style.width = '2em';
|
|
|
|
textArea.style.height = '2em';
|
|
|
|
textArea.style.padding = 0;
|
|
|
|
textArea.style.border = 'none';
|
|
|
|
textArea.style.outline = 'none';
|
|
|
|
textArea.style.boxShadow = 'none';
|
|
|
|
textArea.style.background = 'transparent';
|
|
|
|
|
|
|
|
textArea.value = text;
|
|
|
|
document.body.appendChild(textArea);
|
|
|
|
textArea.focus();
|
|
|
|
textArea.select();
|
|
|
|
|
|
|
|
try {
|
|
|
|
var successful = document.execCommand('copy');
|
|
|
|
var msg = successful ? 'successful' : 'unsuccessful';
|
|
|
|
console.log('Copying text command was ' + msg);
|
|
|
|
} catch (err) {
|
|
|
|
console.log('Oops, unable to copy');
|
|
|
|
}
|
|
|
|
|
|
|
|
document.body.removeChild(textArea);
|
|
|
|
}
|
|
|
|
|
|
|
|
function doLinkCopy(){
|
|
|
|
var data = document.getElementById('plain').value
|
|
|
|
var encoded = ecojiEncode(data)
|
|
|
|
if(encoded) {
|
2022-09-06 20:44:58 +02:00
|
|
|
encoded = "https://hub.octt.eu.org/Ecoji/#d="+encoded
|
2022-09-05 16:29:51 +02:00
|
|
|
copyTextToClipboard(encoded)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<title>Ecoji</title>
|
2022-09-06 20:44:58 +02:00
|
|
|
<meta name="description" content="Encode and Decode data as emojis!">
|
|
|
|
<meta property="og:title" content="Ecoji">
|
|
|
|
<meta property="og:description" content="Encode and Decode data as emojis!">
|
2022-09-05 16:29:51 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div>
|
|
|
|
<header>
|
|
|
|
<div>
|
|
|
|
<h5>[<a href="..">🔼 Home</a>]</h5>
|
2022-09-06 20:44:58 +02:00
|
|
|
<h3><a href="https://github.com/keith-turner/ecoji">Ecoji</a> v1 webapp fork | <a href="https://github.com/keith-turner/ecoji">🏣🔉🦐🔼</a></h3>
|
2022-09-05 16:29:51 +02:00
|
|
|
<h5><button type="button" onclick="doLinkCopy()">Copy Link</button></h5>
|
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
<br><br>
|
2022-09-06 20:44:58 +02:00
|
|
|
<noscript>
|
|
|
|
<p>
|
|
|
|
This is an actual app, not a badly-made website.
|
|
|
|
<br>
|
|
|
|
It needs JavaScript and WASM to work, so you need to enable them.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
The code is fully open, and you can review the HTML5 parts of this fork with "View Page Source".
|
|
|
|
<br>
|
|
|
|
The Go parts are not modified, and you can review them at the <a href="https://github.com/keith-turner/ecoji">official repo</a>.
|
|
|
|
</p>
|
|
|
|
</noscript>
|
2022-09-05 16:29:51 +02:00
|
|
|
<main>
|
|
|
|
<p>🔑 Decode</p>
|
|
|
|
<textarea id="encoded" class="form-control" rows="5" oninput="doDecode()" placeholder="🧾 Paste Ecoji here to 🔑 Decode..."></textarea>
|
|
|
|
<br><br><br>
|
|
|
|
<p>🔒 Encode</p>
|
|
|
|
<textarea id="plain" class="form-control" rows="5" oninput="doEncode()" placeholder="📝 Write Text here to 🔒 Encode..."></textarea>
|
|
|
|
<br><br><br>
|
|
|
|
</main>
|
|
|
|
<footer><p>
|
|
|
|
The app is self-contained - you can simply "Save Page As" to get an offline copy.
|
|
|
|
</p></footer>
|
2022-09-06 20:44:58 +02:00
|
|
|
<br>
|
2022-09-05 16:29:51 +02:00
|
|
|
</div>
|
2022-09-06 16:31:20 +02:00
|
|
|
<script>ecojiPromise.then(() => {doPopulate(new URLSearchParams(window.location.hash).get("#d"))})</script>
|
2022-09-05 16:29:51 +02:00
|
|
|
</body>
|
|
|
|
</html>
|