mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-01 10:22:03 +00:00
- Created `torch/` directory and initialized package.json - Installed TORCH dependency from https://github.com/PR0M3TH3AN/TORCH - Initialized TORCH environment with `npx torch-lock init` - Updated .gitignore to exclude node_modules and generated files Co-authored-by: PR0M3TH3AN <[email protected]>
31 lines
870 B
JavaScript
31 lines
870 B
JavaScript
// DOM utility functions for safe rendering
|
|
|
|
/**
|
|
* Escapes unsafe HTML characters in a string.
|
|
* @param {string} unsafe The string to escape.
|
|
* @returns {string} The escaped string.
|
|
*/
|
|
export function escapeHtml(unsafe) {
|
|
if (unsafe == null) return '';
|
|
return String(unsafe)
|
|
.replace(/&/g, "&")
|
|
.replace(/</g, "<")
|
|
.replace(/>/g, ">")
|
|
.replace(/"/g, """)
|
|
.replace(/'/g, "'");
|
|
}
|
|
|
|
/**
|
|
* Creates an element with optional class and text content.
|
|
* @param {string} tag The tag name.
|
|
* @param {string} [className] The class name(s).
|
|
* @param {string} [text] The text content.
|
|
* @returns {HTMLElement} The created element.
|
|
*/
|
|
export function createElement(tag, className, text) {
|
|
const el = document.createElement(tag);
|
|
if (className) el.className = className;
|
|
if (text != null) el.textContent = text;
|
|
return el;
|
|
}
|