-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
I would like to open a feature request so that lichess lets users add timestamps to a chapter of a study.
What
Timestamps can be seen in many studies of classical tournament games (e.g. Tata Steel Chess Masters 2020 https://lichess.org/study/UN4iGUP9), but they cannot be added or edited via the lichess user interface. To this day, the only way for users to do this is to upload a pgn with timestamps in comments such as
{This is a comment [%clk 1:03:56]}
{[%clk 1:08:42]}
But this breaks the workflow of analyzing a tournament game: for a user to add timestamps, the only current solution is to
- Add the moves via a lichess study.
- Download the pgn file.
- Add the comments by editing the file using a plain text editor.
- Upload the pgn file to the corresponding chapter.
Rules of adding/editing timestamps
I would like to propose a few rules of the mechanics of editing/adding timestamps, and displaying timestamps in general, so as to ease the development process. But this is just a proposal, and I leave to lichess developers to implement whichever rules they want.
- Any user that has permissions to edit the chapters of a study should be able to add/edit timestamps.
- Timestamps can only be added to moves of the mainline.
- Equivalent to the previous item, adding a timestamp to a move that is not part of the mainline is not allowed.
- If a move, or a series of moves, have been moved into to a variation, their timestamp should be dropped.
Perhaps only the latter is controversial. The first three seem reasonable since it does not make much sense to add a timestamp to a move of a variation since it never happened. I think the latter one is controversial since a user could make a mistake by forcing the entire main line into a variation, thus losing the timestamps. Perhaps there is no need to drop the timestamp of moves that have been forced into a variation, but I think these should not be editable nonetheless.
- If a move of a variation (not the main line) has a timestamp, said timestamp should not be displayed in the right-bottom corner of the board.
Possible implementations
- (less user-friendly, but potentially easier to implement) Let the user write the string
{%clk 1:03:40}in the comment form of a chapter. The front end will parse the string and retrieve the time and send it to the back end. For example, edit the methodel.oninput = () => setTimeout(() => ctrl.submit(el.value), 50);inui/analyse/src/study/commentForm.tsso that it includes
let s: string = el.value;
const clockRegex: RegExp = /{.*%clk.*(\d+):(\d+):(\d+).*}/;
const matchClock: RegExpExecArray | null = clockRegex.exec(s);
let totalTime: number = 0;
if (matchClock) {
const hours = parseInt(matchClock[1], 10);
const minutes = parseInt(matchClock[2], 10);
const seconds = parseInt(matchClock[3]);
totalTime = hours*3600 + minutes*60 + seconds;
console.log("totalTime=", totalTime);
const startIndex: number = matchClock.index;
const endIndex: number = startIndex + matchClock[0].length - 1;
s = s.slice(0, startIndex) + s.slice(endIndex + 1, s.length)
console.log(s);
}
el.value = s;
setTimeout(() => ctrl.submit( el.value ), 50);
if (matchClock) {
// I couldn't, for the life of me, implement this submitTime function successfully
// and I'm not allowed to send messages to the development channel in lichess' discord
// so I couldn't ask for help to do so.
setTimeout(() => ctrl.submitTime( totalTime ), 50);
}
-
(more user friendly, but potentially more difficult to implement) The "box" where the clock is displayed could become visible to players if they hover the mouse over the area, which should, at that point, be clickable. After clicking on it, users can add the timestamp, as is usually done in regular text boxes, by writing, e.g. "0:45:03" to indicate "45 minutes and 3 seconds".
-
Allow both options (1) and (2).
Specifying the timestamp
I remember seeing different regexps somewhere in the scala backend to parse timestamps from an imported pgn (I can't find that code anymore), so there already exists some kind of "standard" concerning the different formats of timestamps to accept. Feel free to adapt those definitions to this request.