mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-24 02:03:01 +02:00
v0.51.0 (#826)
* Hash upgrades and Bladeburner skills can now be clicked to copy to clipboard * Aug purchase confirmation popup displays money in 0.000a format * Character now displays hacknet server info properly * Character,Info now displays hacknet server info correctly. * Formulas (#825) Formulas API v0.1 * Make all money the same color, same for reputation, format all numbers consistently. * rename a lot of the formulas function to no longer contain calculate * added hacking related formulas * removed unused variable * v0.51.0
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import * as React from "react";
|
||||
|
||||
type IProps = {
|
||||
value: string;
|
||||
}
|
||||
|
||||
type IState = {
|
||||
tooltipVisible: boolean;
|
||||
}
|
||||
|
||||
export class CopyableText extends React.Component<IProps, IState> {
|
||||
constructor(props: IProps) {
|
||||
super(props);
|
||||
|
||||
this.copy = this.copy.bind(this);
|
||||
this.tooltipClasses = this.tooltipClasses.bind(this);
|
||||
this.textClasses = this.textClasses.bind(this);
|
||||
|
||||
this.state = {
|
||||
tooltipVisible: false,
|
||||
}
|
||||
}
|
||||
|
||||
copy(e: React.MouseEvent<HTMLHeadingElement>) {
|
||||
const copyText = document.createElement("textarea");
|
||||
copyText.value = this.props.value;
|
||||
document.body.appendChild(copyText);
|
||||
copyText.select();
|
||||
copyText.setSelectionRange(0, 1e10);
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(copyText);
|
||||
this.setState({tooltipVisible: true});
|
||||
setTimeout(() => this.setState({tooltipVisible: false}), 1000);
|
||||
}
|
||||
|
||||
tooltipClasses(): string {
|
||||
let classes = "copy_tooltip_text";
|
||||
if(this.state.tooltipVisible) {
|
||||
classes += " copy_tooltip_text_visible";
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
textClasses(): string {
|
||||
let classes = "copy_tooltip noselect text";
|
||||
if(this.state.tooltipVisible) {
|
||||
classes += " copy_tooltip_copied";
|
||||
}
|
||||
|
||||
return classes;
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
return (<span className={this.textClasses()} onClick={this.copy}>
|
||||
<b>{this.props.value}</b>
|
||||
<span className={this.tooltipClasses()}>Copied!</span>
|
||||
</span>);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user