Add numbered moves to each turn sequence
This commit is contained in:
parent
ca2cb19da7
commit
750c395a4f
23
takhta.html
23
takhta.html
|
@ -74,6 +74,9 @@
|
||||||
.undone {
|
.undone {
|
||||||
text-decoration: line-through;
|
text-decoration: line-through;
|
||||||
}
|
}
|
||||||
|
.numentry {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -277,6 +280,26 @@
|
||||||
|
|
||||||
// List the move
|
// List the move
|
||||||
let listElement = document.createElement('li');
|
let listElement = document.createElement('li');
|
||||||
|
|
||||||
|
if(moveHistory.length % 2 === 1) {
|
||||||
|
let padding = Math.floor(Math.log10((moveHistory.length / 2) + 1));
|
||||||
|
let moveList = document.getElementsByClassName('numentry');
|
||||||
|
|
||||||
|
for(let next = 0; next < moveList.length; next += 1) {
|
||||||
|
let digits = Math.floor(Math.log10(next + 1));
|
||||||
|
|
||||||
|
if(digits < padding) {
|
||||||
|
moveList[next].innerText = `${next + 1}. `.padStart(padding + digits + 3, " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let numEntry = document.createElement('span');
|
||||||
|
|
||||||
|
numEntry.classList.add('numentry');
|
||||||
|
numEntry.innerText = `${parseInt(moveHistory.length / 2) + 1}. `;
|
||||||
|
listElement.appendChild(numEntry);
|
||||||
|
}
|
||||||
|
|
||||||
listElement.appendChild(document.createTextNode(move));
|
listElement.appendChild(document.createTextNode(move));
|
||||||
movelist.appendChild(listElement);
|
movelist.appendChild(listElement);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue