Files
community_bridge/web/index.html
T

47 lines
1.3 KiB
HTML
Raw Normal View History

2025-02-21 11:02:18 -06:00
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MRC Scuba</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/main.jsx"></script>
</body>
2025-05-24 18:31:36 -05:00
<script>
2025-05-24 18:03:31 -05:00
// dont judge me
2025-05-24 18:31:36 -05:00
function isTableJSON(jsonString) {
try {
const parsed = JSON.parse(jsonString);
return parsed;
} catch (e) {
return false;
}
}
2025-05-24 18:03:31 -05:00
const copyToClipboard = (str) => {
2025-05-24 18:31:36 -05:00
const el = document.createElement("textarea");
el.value = str;
document.body.appendChild(el);
2025-05-24 18:03:31 -05:00
el.select();
document.execCommand("copy");
document.body.removeChild(el);
};
window.addEventListener("message", (event) => {
if (event?.data?.type === "copytoclipboard") {
var str = event.data.text;
2025-05-24 18:31:36 -05:00
// str = JSON.parse(str);
console.log("copying to clipboard", isTableJSON(str));
if (isTableJSON(str)) {
str = str.replace(/\[/g, '{');
str = str.replace(/\]/g, '}');
str = str.replace(/:/g, '=');
str = str.replace(/"([^"]+)"=/g, '$1=');
}
2025-05-24 18:03:31 -05:00
copyToClipboard(str);
2025-05-24 18:31:36 -05:00
}
2025-05-24 18:03:31 -05:00
});
</script>
2025-02-21 11:02:18 -06:00
</html>