From: Steinar H. Gunderson Date: Thu, 29 Dec 2022 09:07:10 +0000 (+0100) Subject: More simplification in print_pv(). X-Git-Url: https://git.sesse.net/?p=remoteglot;a=commitdiff_plain;h=ddeb2eaf98778f23b624212fa100db79a8be8560 More simplification in print_pv(). --- diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 3667f59..5314a56 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -733,16 +733,15 @@ function print_pv(line_num, splicepos, opt_limit, opt_showlast) { } let ret = document.createDocumentFragment(); - let i = 0; let in_tb = false; - let link = document.createElement('a'); - link.className = 'move'; if (opt_limit && opt_showlast && pv.length > opt_limit) { // Truncate the PV at the beginning (instead of at the end). // We assume here that toplay is 'W'. We also assume that if // opt_showlast is set, then it is the history, and thus, // the UI should be to expand the history. ret.appendChild(document.createTextNode('(')); + let link = document.createElement('a'); + link.className = 'move'; link.href = 'javascript:collapse_history(false)'; link.textContent = '…'; ret.appendChild(link); @@ -755,8 +754,8 @@ function print_pv(line_num, splicepos, opt_limit, opt_showlast) { } else if (toplay == 'B' && pv.length > 0) { ret.appendChild(document.createTextNode(move_num + '. … ')); } - for ( ; i < pv.length; ++i) { - link = document.createElement('a'); + for (let i = 0; i < pv.length; ++i) { + let link = document.createElement('a'); link.className = 'move'; link.setAttribute('id', 'automove' + line_num + '-' + i); link.textContent = pv[i]; @@ -777,10 +776,7 @@ function print_pv(line_num, splicepos, opt_limit, opt_showlast) { ret.appendChild(document.createTextNode(' (…)')); return ret; } - if (ret != '') { - ret.appendChild(document.createTextNode(' ')); - } - ret.appendChild(document.createTextNode(move_num + '. ')); + ret.appendChild(document.createTextNode(' ' + move_num + '. ')); ++move_num; toplay = 'B'; } else {