const rootElement = document.getElementById("root");
class App extends React.Component {
state = {
choice: "",
onlineGameRequestString: "",
domain: "https://onlinechessmc.herokuapp.com",
playerId: makeid(20),
};
render() {
return (
this.state.choice.length == 0 || this.state.choice == "Online" ? (
Online Chess
{!this.state.choice.includes("Online") ?
:
}
©2022 Mohamad Chahadeh
) :
this.state.choice.toLowerCase().includes("local") ? :
);
}
showPrompt = () => {
let gameId = prompt("Enter Game Id (Case sensitive): ");
if(gameId != null && gameId.length > 0) {
this.setState({
onlineGameRequestString: `join/${gameId}`,
choice: "joinOnline"
})
}
}
}
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() *
charactersLength));
}
return result;
}
ReactDOM.render(, rootElement);