aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-04-27 11:59:45 +0200
committertomsmeding <hallo@tomsmeding.nl>2015-04-27 11:59:45 +0200
commit10221d269c5af4985e73cb9c6efb96debbc10562 (patch)
treeb3b64c4c413c10afb78b0ed6fc8553aec86c325b
parentf5c5445f5c8bdd80dac5896fe96c7418e366ed4c (diff)
Full visualisation now working!
-rw-r--r--viewcompetition.css3
-rw-r--r--viewcompetition.js25
2 files changed, 20 insertions, 8 deletions
diff --git a/viewcompetition.css b/viewcompetition.css
index 0fc53f5..2eb2b22 100644
--- a/viewcompetition.css
+++ b/viewcompetition.css
@@ -74,3 +74,6 @@ div#movelist tr:first-child > td{
div#movelist tr:nth-child(odd){background-color:#e4e4e4;}
div#movelist tr:nth-child(even){background-color:#fff;}
div#movelist tr:nth-child(n+2):hover{background-color:#bbf;cursor:pointer;}
+div#movelist tr.selected{
+ background-color:#afa;
+}
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="&nbsp;";
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;
}