mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-28 03:47:03 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
+33
-20
@@ -4,32 +4,45 @@ import { getRandomInt } from "./helpers/getRandomInt";
|
||||
import React from "react";
|
||||
|
||||
interface IProps {
|
||||
content: JSX.Element;
|
||||
content: JSX.Element;
|
||||
}
|
||||
|
||||
export function MessagePopup(props: IProps): React.ReactElement {
|
||||
return (<>{props.content}</>);
|
||||
return <>{props.content}</>;
|
||||
}
|
||||
|
||||
function dialogBoxCreate(txt: string | JSX.Element, preformatted = false): void {
|
||||
const popupId = `popup-`+(Array.from(Array(16))).map(() => `${getRandomInt(0, 9)}`).join('');
|
||||
if (typeof txt === 'string') {
|
||||
if (preformatted) {
|
||||
// For text files as they are often computed data that
|
||||
// shouldn't be wrapped and should retain tabstops.
|
||||
createPopup(popupId, MessagePopup, {
|
||||
content: (<pre dangerouslySetInnerHTML={{ __html: txt }} />),
|
||||
});
|
||||
} else {
|
||||
createPopup(popupId, MessagePopup, {
|
||||
content: (<p dangerouslySetInnerHTML={{ __html: txt.replace(/(?:\r\n|\r|\n)/g, '<br />') }} />),
|
||||
});
|
||||
}
|
||||
function dialogBoxCreate(
|
||||
txt: string | JSX.Element,
|
||||
preformatted = false,
|
||||
): void {
|
||||
const popupId =
|
||||
`popup-` +
|
||||
Array.from(Array(16))
|
||||
.map(() => `${getRandomInt(0, 9)}`)
|
||||
.join("");
|
||||
if (typeof txt === "string") {
|
||||
if (preformatted) {
|
||||
// For text files as they are often computed data that
|
||||
// shouldn't be wrapped and should retain tabstops.
|
||||
createPopup(popupId, MessagePopup, {
|
||||
content: <pre dangerouslySetInnerHTML={{ __html: txt }} />,
|
||||
});
|
||||
} else {
|
||||
createPopup(popupId, MessagePopup, {
|
||||
content: txt,
|
||||
});
|
||||
createPopup(popupId, MessagePopup, {
|
||||
content: (
|
||||
<p
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: txt.replace(/(?:\r\n|\r|\n)/g, "<br />"),
|
||||
}}
|
||||
/>
|
||||
),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
createPopup(popupId, MessagePopup, {
|
||||
content: txt,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export {dialogBoxCreate};
|
||||
export { dialogBoxCreate };
|
||||
|
||||
Reference in New Issue
Block a user