diff options
Diffstat (limited to 'viewcompetition.js')
-rw-r--r-- | viewcompetition.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/viewcompetition.js b/viewcompetition.js index ab05c3c..be44b52 100644 --- a/viewcompetition.js +++ b/viewcompetition.js @@ -51,10 +51,14 @@ function init(){ td.setAttribute("colspan","3"); td.innerHTML=" "; tr.appendChild(td); - tr.addEventListener("click",function(ev){ - if(moveidx==0)return; - while(moveidx>0)prevmove(true); - }); + (function(tr){ + tr.addEventListener("click",function(ev){ + if(moveidx==0)return; + while(moveidx>0)prevmove(true); + setselectedmovelistline(0); + }); + })(tr); + tr.classList.add("selected"); movelisttbody.appendChild(tr); MOVES.forEach(function(mv,i){ @@ -78,6 +82,7 @@ function init(){ if(moveidx==target)return; while(moveidx<target)nextmove(true); while(moveidx>target)prevmove(true); + setselectedmovelistline(i+1); };})(i+1)); movelisttbody.appendChild(tr); @@ -116,6 +121,12 @@ function init(){ canclick=true; } +function setselectedmovelistline(i){ + var movelist=document.getElementById("movelist"); + movelist.querySelectorAll("tr.selected")[0].classList.remove("selected"); + document.getElementById("movelist").getElementsByTagName("tr")[i+1].classList.add("selected"); +} + function arrowfor(dir){ return "&#x"+[2191,2197,2192,2198,2193,2199,2190,2196][dir]+";"; } @@ -166,10 +177,6 @@ function setprevenabled(en){ document.getElementById("prevmovebtn").disabled=!en; } -function displaycurrentmove(){ - -} - function nextmove(notimeout){ var newidx; if(moveidx==MOVES.length||!canclick)return false; @@ -208,6 +215,7 @@ function nextmove(notimeout){ moveidx++; setprevenabled(true); if(moveidx==MOVES.length)setnextenabled(false); + if(!notimeout)setselectedmovelistline(moveidx); return true; } function prevmove(notimeout){ @@ -249,6 +257,7 @@ function prevmove(notimeout){ setnextenabled(true); if(moveidx==0)setprevenabled(false); + if(!notimeout)setselectedmovelistline(moveidx); return true; } |