X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=scribe%2Fscribe.jsx;h=3caf03c87d313ab3e582bfc68bb0da020143c6dd;hb=91a2de0fa74185407d3dbe84e8d8efa7030ac540;hp=d81932b7b847e6bb813993fd06a20a336a90d0ec;hpb=35db0996e270ea66c7d0a94f1ddb2506005b22a3;p=lmno.games
diff --git a/scribe/scribe.jsx b/scribe/scribe.jsx
index d81932b..3caf03c 100644
--- a/scribe/scribe.jsx
+++ b/scribe/scribe.jsx
@@ -1,8 +1,8 @@
function team_symbol(team) {
if (team === "+")
- return "ð¥";
+ return "+";
else
- return "ð";
+ return "o";
}
function undisplay(element) {
@@ -26,7 +26,9 @@ const events = new EventSource("events");
events.onerror = function(event) {
if (event.target.readyState === EventSource.CLOSED) {
+ setTimeout(() => {
add_message("danger", "Connection to server lost.");
+ }, 1000);
}
};
@@ -77,14 +79,31 @@ events.addEventListener("game-state", event => {
* Game and supporting classes *
*********************************************************/
+function copy_to_clipboard(id)
+{
+ const tmp = document.createElement("input");
+ tmp.setAttribute("value", document.getElementById(id).innerHTML);
+ document.body.appendChild(tmp);
+ tmp.select();
+ document.execCommand("copy");
+ document.body.removeChild(tmp);
+}
+
function GameInfo(props) {
if (! props.id)
return null;
return (
-
{props.id}
- Invite a friend to play by sending this URL: {props.url}
+ {props.id}
+ {" "}
+ Share this link to invite a friend:{" "}
+ {props.url}
+ {" "}
+
);
}
@@ -130,7 +149,7 @@ function PlayerInfo(props) {
return (
-
Players
+
Players:
{props.player.name}
{props.player.team ? ` (${props.player.team})` : ""}
{props.first_move ? "" : " "}
@@ -146,6 +165,50 @@ function PlayerInfo(props) {
);
}
+function Glyph(props) {
+
+ const glyph_dots = [];
+
+ let last_square = 0;
+ for (let i = 0; i < 9; i++) {
+ if (props.squares[i])
+ last_square = i;
+ }
+
+ const height = Math.floor(20 * (Math.floor(last_square / 3) + 1));
+
+ const viewbox=`0 0 60 ${height}`;
+
+ for (let row = 0; row < 3; row++) {
+ for (let col = 0; col < 3; col++) {
+ if (props.squares[3 * row + col]) {
+ let cy = 10 + 20 * row;
+ let cx = 10 + 20 * col;
+ glyph_dots.push(
+
+ );
+ }
+ }
+ }
+
+ return (
+ {props.name}
+
+
+
+
+ );
+}
+
function Square(props) {
let className = "square";
@@ -249,7 +312,7 @@ class Game extends React.Component {
game_info: {},
player_info: {},
other_players: [],
- squares: Array(9).fill(null).map(() => Array(9).fill(null)),
+ squares: [...Array(9)].map(() => Array(9).fill(null)),
moves: 0,
next_to_play: "+"
};
@@ -396,6 +459,122 @@ class Game extends React.Component {
onClick={(i,j) => this.handle_click(i, j, first_move)}
/>
+ ,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
];
}