This is an editor and viewer for Portable Tak Notation (PTN). It aims to be...
- Useful for transcription of live games, even on a phone.
- Intuitive, with a minimal UI that is enjoyable to use.
- Responsive, with a fluid design that works as well on a phone as it does in full-screen on a desktop.
- Quasar: https://v1.quasar.dev/quasar-cli/installation
- Firebase: https://firebase.google.com/docs/emulator-suite/install_and_configure
yarnpushd functions && npm install && popdyarn devyarn emulateyarn lintyarn buildPTN Ninja can send and receive messages with its opening or parent window using Window.postMessage(). These messages are objects containing an action, as well as a value where applicable.
For example:
{
action: "SET_UI",
value: {
showRoads: true
}
}- Add a comment to the specified ply, or the current ply if not specified
- Add the comments to the specified plies
- Add a single move specified as a string in PTN (e.g.
Sb4) to the end of the main branch. If the current position was already the end of the main branch, it will show the new move. Otherwise, the current position will remain unchanged.
- Apply the specified board transformation
[int a, int b]whereais the number of clockwise rotations [0, 3], andbis the number of horizontal flips [0, 1].
- Abort any in-progress piece movement interaction
- Delete the specified branch
- Delete the ply specified by ID
- Replace the specified comment
- Navigate to the beginning
- Flip the board horizontally
- Flip the board vertically
- Respond with a
GET_THEMEmessage whose value is an object defining the current theme, includingid,name, and all the attributes defining the theme.
- Respond with a
GET_THEMESmessage whose value is an array of objects defining the built-in themes, includingid,name, and all the attributes defining the theme.
- Respond with a
GET_URLmessage whose value is the URL of the current game.
- Navigate to the specified ply
- Highlight the squares specified as an array of string coordinates (e.g. 'a1'). If no squares are provided, the most recent ply is highlighted.
- Insert a series of moves specified as strings in PTN (e.g.
['d5', 'e4'], ord5 e4) and go backwardprevplies. If a line number is specified in place of the first ply, following plies will be inserted at that location. If the second ply is a NOP, following plies will begin with Player 2.
- Execute a single move specified as a string in PTN (e.g.
Sb4)
- Navigate to the end
- Navigate to the last child branch of the current branch point
- Swap a branch with its main line, specified by branch name
- Navigate forward
- Navigate to the next branch (first child if on a branch point, or next sibling if at the start of a branch)
- Issue a notification, specifying either the message directly, or an object with the following structure:
message(<String>): Message to be displayedicon(<String>): Icon to be displayed (only applies toNOTIFY)caption(<String>): Optional message to be displayed in smaller text belowmessagetimeout(<Number>): Optional milliseconds before automatic dismissal (default 5000). Set to zero to disable timeout.position(<String>): Optional location in which to display the notification. Must be one of the following values (defaultbottom):top-righttop-leftbottom-rightbottom-lefttoprightbottomleftcenter
actions(<Array>): Optional list of buttons to display after the message, specified asObjects with the following structure:label(<String>): Button labelicon(<String>): Button iconcolor(<String>): Optional color name (default:primary)action(<String>):actionmessage property to send to the opening or parent window when the button is clickedvalue(<String>):valuemessage property to send with theactionto the opening or parent window when the button is clicked
group(<String>|<Number>): Optional group identifier that overrides the auto-generated group identifier with custom one. When a new notification is triggered with same group identifier, it replaces the old one and shows a badge with the number of times the notification was triggered.
- Navigate to the parent branch point
- Navigate up to the main line
- Stop stepping through plies
- Begin stepping through plies from current position
- Toggle between PLAY and PAUSE
- Navigate backward
- Navigate to the previous branch (previous sibling or parent branch point if at the start of a branch)
- Promote a branch specified by its name
- Redo
- Remove the specified comment
- Rename a branch
- Reset any board transformation
- Rotate the board 180 degrees
- Rotate the board left 90 degrees
- Rotate the board right 90 degrees
- Replace the current game with the provided PTN
- Show the specified evaluation score on the board, where -100 is a win for Player 2, and 100 is a win for Player 1.
- Show the specified analysis information below the board. Only the
pvis required. The object has the following structure:tps(<String>): Optional TPS string of the position being analyzed. If falsy, the current position is assumed.pv(<String>|<Array>): The principle variation (or a single ply) in PTN, as a string of plies separated by spaces, or an array of strings.progress(<Null>|<Number>: [0, 100]): Optional representation of the completion of the current search. If set tonull, the progress bar will be put into the 'indeterminate' state. If omitted, the progress bar will not be shown.evaluation(<Number>: [-100, 100]): Optional evaluation of the current position, where -100 is a win for Player 2, and 100 is a win for Player 1.depth(<Number>): Optional current depth of the search.nodes(<Number>): Optional number of nodes searched so far.time(<Number>): Optional milliseconds since the search began.visits(<Number>): Optional number of visits for the pv.
- Set the authoritative player clock state. Use this to drive the game clock from an external source (e.g. a live server).
time1(<Number>): Remaining time for Player 1 in millisecondstime2(<Number>): Remaining time for Player 2 in millisecondstimerTurn(1|2): Which player's clock is currently counting downlastTimeUpdateWall(<Number>): Recommended. A wall-clock timestamp (Date.now()) taken when the clock values were measured. PTN Ninja uses it to compensate forpostMessagetransit delay, keeping the iframe's countdown in sync with the sender's clock.lastTimeUpdate(<Number>): Optional reference timestamp (fromperformance.now()). Only meaningful if the sender and PTN Ninja share the sameperformancetimeline (rare across iframes). Ignored whenlastTimeUpdateWallis provided. If neither is provided, PTN Ninja uses its ownperformance.now()at message receipt.
- Does not by itself enable live countdown; send
SET_TIMER_LIVEwithtrueto start ticking.
- Switch the active player clock. PTN Ninja will automatically subtract the elapsed time since the last update from the previously active player's clock. Useful after each move, before the next authoritative
SET_GAME_TIMEarrives.
- Set the game title
- Replace all notes on the specified ply with the provided array of messages. Pass an empty array to clear notes for that ply.
- Set the user as player 1 or 2, disabling input during the opponent's turn.
- Enable or disable live countdown of the active player's clock. When
true, the clock specified bySET_GAME_TIME/SET_GAME_TIMER_TURNwill tick down in real time between authoritative updates. Sendfalsewhen the game ends, is paused, or is otherwise no longer live.
- Set one or more UI parameters
- Toggle evaluation notation on the current ply
- Toggle the specified UI parameter
- Remove non-active branches
- Remove plies, preserving the board state
- Remove all plies preceding the current ply
- Undo
These messages are sent from PTN Ninja to its parent or opening window via postMessage.
GAME_STATE(value:<Object>) — Sent whenever the game position changes. Includesmove,ply,prevPly,nextPly,flats, and other position data.INSERT_PLY(value:<String>) — Sent when a ply is inserted via user interaction on the board.SET_UI(value:<Object>) — Sent when a UI setting changes.
- Sent when a keyboard event occurs in embed mode that PTN Ninja does not handle. A key is considered unhandled when its corresponding feature is disabled via embed configuration (e.g. arrow keys when
disableNavigationistrue, since the navigation shortcut bindings are not active). The value contains the following key event properties:key(<String>): The key value (e.g."ArrowUp")code(<String>): The physical key code (e.g."ArrowUp")keyCode(<Number>): The numeric key codeshiftKey(<Boolean>): Whether Shift was heldctrlKey(<Boolean>): Whether Ctrl was heldaltKey(<Boolean>): Whether Alt was heldmetaKey(<Boolean>): Whether Meta was held
PTN Ninja uses lz-string to encode PTN and some other parameters for use in the URL. However, it will also do its best to read these parameters when passed as plaintext.
The structure of the URL is as follows:
https://ptn.ninja/<PTN>&<param1>=<value1>&<param2>=<value2>[...]
To get a shortened URL, send a POST request to https://url.ptn.ninja/short with request body { ptn, params (optional) } where ptn is a string, and params is an optional object containing any of the parameters below. If the request is valid, you'll receive the complete shortenend URL as plain text in response. If the URL is not accessed within 30 days, it will be deleted.
- Show axis labels
- Show axis labels inside the board
- Show the evaluation bar on the board behind the unplayed pieces
- Show stack counts centered on the square instead of in the corner
- Disable board interactions
- Disable game navigation, undo/redo, and ply deletion
- Remove the PTN panel
- Remove the PTN panel toolbars
- Disable selecting the last placed stone to cycle its type
- Remove the Notes panel
- Disable undo/redo
- Show evaluation text after move numbers on the board
- Show flat counts
- Show the player clocks when clock data is available. When
turnIndicatoris enabled andflatCountsis disabled, the clocks render inline inside the player bars; otherwise they render in their own row above the board. Set this tofalseto hide the clocks entirely.
- Show square highlights
- Show inline branches in the PTN panel
- Show the move number on the board
- Title of the game
- Show analysis note notifications
- Show game notifications
- Show note notifications
- Steps per minute to be used for playback
- Index of the current ply
- Ending with
!meansplyIsDone == true
- Show all branches
- Show analysis visualizations on the board
- Show the Preferences button on the board
- Show the Transform button on the board
- Show playback controls
- Show evaluation bars in the PTN panel and on the board
- Show the current move
- Show the PTN panel
- Show the "Play" button in the playback controls
- Show road connections
- Show the playback scrubber
- Show the Notes panel
- Show the toolbar analysis section below the board, displaying saved analysis suggestions
- Show stack counts
- Name of the current branch
- ID or JSON of the theme to be used
- Show turn indicator
- Show unplayed pieces
- Enable the vertical layout for the board (unplayed pieces below, move number above)
- Automatically switch between horizontal and vertical layouts
© 2022 Craig Laparo
This work is licensed under a GNU AGPLv3 License.