Public
Back

Version 317

1/1/2025
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import React, { createRef, useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";

function getUniqueLetters(word: string): string {
return [...new Set(word.toUpperCase().replace(/[^A-Z]/g, ""))].join("");
}

function incrementAgain(input: string): string {
// Use a regular expression to detect if the string ends with `-again<number>`
const match = input.match(/^(.*-again)(\d+)$/);

if (match) {
// match[1] will be the part up to `-again`
// match[2] will be the numeric part
const prefix = match[1]; // e.g., "myString-again"
const currentNumber = parseInt(match[2], 10);
const nextNumber = currentNumber + 1;

return `${prefix}${nextNumber}`;
}

// If no match, just append `-again1`
return `${input}-again1`;
}

function appendToLocalStorage(text: string, author: string | null): void {
const key = "known_texts";
// Get the existing data from local storage
const storedData = localStorage.getItem(key);

// If it exists, parse it; otherwise, use an empty array
let arr: string[] = storedData ? JSON.parse(storedData) : [];

// Push the new value onto the array
arr.push(`${text} - ${author ?? ""}`);
bao-cipher.web.val.run
Updated: January 29, 2025