Mercurial > hg > batmud > maputils
changeset 1709:5adf497ffcbf
Implement selecting the matching location in the dropdown menu of JS maps when loaded.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 12 Oct 2017 12:32:32 +0300 |
parents | 9a124fdb6dab |
children | 88c371ceebe1 |
files | util.js |
diffstat | 1 files changed, 17 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/util.js Thu Oct 12 11:43:43 2017 +0300 +++ b/util.js Thu Oct 12 12:32:32 2017 +0300 @@ -92,14 +92,27 @@ } -function jsSetActiveElem(nelem) +function jsSetActiveElem(nelem, newLoc) { - var celem = document.getElementById(currLoc); + var celem; + if (currLoc) + celem = document.getElementById(currLoc); + if (celem && currClass != "") celem.className = currClass; currClass = nelem.className; nelem.className += " nactive"; + + var opts = document.forms[0].slocation.options; + for (var opt, i = 0; opt = opts[i]; i++) + { + if (opt.value == newLoc) + { + document.forms[0].slocation.selectedIndex = i; + break; + } + } } @@ -135,7 +148,7 @@ else jsSetPosToElem(nelem); - jsSetActiveElem(nelem); + jsSetActiveElem(nelem, newLoc); currLoc = newLoc; } } @@ -153,7 +166,7 @@ if (nelem) { jsSetPosToElem(nelem); - jsSetActiveElem(nelem); + jsSetActiveElem(nelem, eid); currLoc = eid; } }