Mercurial > hg > batmud > maputils
changeset 1718:781e487ecd5e
Implement "no location selected" for the html+js dropdown.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 12 Oct 2017 13:13:08 +0300 |
parents | c192d0849193 |
children | 3f38040dafce |
files | mkloc.c util.js |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mkloc.c Thu Oct 12 13:07:16 2017 +0300 +++ b/mkloc.c Thu Oct 12 13:13:08 2017 +0300 @@ -597,6 +597,8 @@ int i; assert(l != NULL); + fprintf(outFile, "<option value=\"\">-</option>\n"); + for (i = 0; i < l->n; i++) { LocMarker *tmp = l->locations[i];
--- a/util.js Thu Oct 12 13:07:16 2017 +0300 +++ b/util.js Thu Oct 12 13:13:08 2017 +0300 @@ -83,7 +83,7 @@ var n = jsSCurve(jsClamp10(scrollIndex)); var px = jsLerp(n, scrollPos0[0], scrollPos1[0]); var py = jsLerp(n, scrollPos0[1], scrollPos1[1]); - + window.scrollTo(px - (dim[0] / 2), py - (dim[1] / 2)); scrollIndex += 0.01; } @@ -105,14 +105,19 @@ nelem.className += " nactive"; var opts = document.forms[0].slocation.options; + var found = false; for (var opt, i = 0; opt = opts[i]; i++) { if (opt.value == newLoc) { document.forms[0].slocation.selectedIndex = i; + found = true; break; } } + + if (!found) + document.forms[0].slocation.selectedIndex = 0; }