From 72d8b4e6bee0ffac79e96dd649a9da2adb86b507 Mon Sep 17 00:00:00 2001 From: name Date: Wed, 27 Sep 2023 11:34:23 +0000 Subject: 2023-09-26 --- rust/wolfree_sed_in_place/src/include_str.js | 65 ++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 rust/wolfree_sed_in_place/src/include_str.js (limited to 'rust/wolfree_sed_in_place/src/include_str.js') diff --git a/rust/wolfree_sed_in_place/src/include_str.js b/rust/wolfree_sed_in_place/src/include_str.js new file mode 100644 index 0000000..9ef3a31 --- /dev/null +++ b/rust/wolfree_sed_in_place/src/include_str.js @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ + +// @ts-check + +const wolfreeLexicalScopeName = (() => { + /** @type {string[]} */ + const possibleLetters = []; + + for (let i = 32; i < 127; i++) { + possibleLetters.push(String.fromCharCode(i)); + } + + const possibleNames = possibleLetters.flatMap((x) => + possibleLetters.map((y) => x + y) + ); + + const isValid = (name = "") => { + try { + return ( + typeof eval(name).value === "string" && + typeof eval(name).i2d === "boolean" + ); + } catch (error) { + return false; + } + }; + + const wolfreeLexicalScopeName = possibleNames.find(isValid); + + if (typeof wolfreeLexicalScopeName !== "string") { + console.warn({ wolfreeLexicalScopeName }); + return ""; + } + + return wolfreeLexicalScopeName; +})(); + +(() => { + const get = (params = "") => { + return new URLSearchParams(location.search).get(params); + }; + + eval(wolfreeLexicalScopeName).value = get("i") || "topic mathematics"; + eval(wolfreeLexicalScopeName).i2d = get("i2d") === "true"; +})(); + +/** + * Regex in regex - Rust + * https://docs.rs/regex/latest/regex/struct.Regex.html#replacement-string-syntax + */ +// @ts-ignore +$0; + +(async () => { + ( + await import( + // @ts-ignore + "/ajax/libs/wolfree/2023.8.31/js/entrypoint.js" + ) + ).default({ + input: eval(wolfreeLexicalScopeName).value, + ...(eval(wolfreeLexicalScopeName).i2d ? { i2d: true } : {}), + podstate: ["Step-by-step solution", "Step-by-step", "Show all steps"], + }); +})(); -- cgit v1.2.3