Patrick Brosi 4 gadi atpakaļ
vecāks
revīzija
74820f2863
2 mainītis faili ar 34 papildinājumiem un 10 dzēšanām
  1. 10 2
      web/index.html
  2. 24 8
      web/script.js

+ 10 - 2
web/index.html

@@ -466,7 +466,7 @@ input:focus {
466 466
     display: block;
467 467
     line-height: 2;
468 468
     padding-left: 0.5rem;
469
-    padding-right: 25px;
469
+    padding-right: 55px;
470 470
     border-top-right-radius: 5px;    
471 471
     border-bottom-right-radius: 5px;
472 472
     border-left: solid 5px #78f378;
@@ -502,7 +502,7 @@ input:focus {
502 502
 .res-group, .res-stat, .res-way {
503 503
     background-size: 20px;
504 504
     background-repeat: no-repeat;
505
-    background-position: 100% center;
505
+    background-position: 100% 6px;
506 506
 }
507 507
 
508 508
 .res-group {
@@ -563,6 +563,14 @@ padding-left:20px;}
563 563
     transition: color 0.2s ease-out;
564 564
 }
565 565
 
566
+.dist {
567
+    font-size: 60%;
568
+    color: #666;
569
+    right: 30px;
570
+    position: absolute;
571
+    line-height: 3.4;
572
+}
573
+
566 574
 main, #m { width: 100%;height:100%; }
567 575
 
568 576
 #sres.res-open + #del { opacity: 1; }

+ 24 - 8
web/script.js

@@ -192,7 +192,7 @@ function rndrSt(stat) {
192 192
         .setLatLng(stat)
193 193
         .setContent(con)
194 194
         .openOn(map)
195
-        .on('remove', function() {openedSt = -1; stUnHl(stat.id);});
195
+        .on('remove', function() {if (openedSt == stat.id) {openedSt = -1; stUnHl(stat.id)}});
196 196
 }
197 197
 
198 198
 function openSt(id) {req("s", "/stat?id=" + id, function(c) {rndrSt(c)});}
@@ -318,7 +318,7 @@ function rndrGr(grp, ll) {
318 318
         .setLatLng(ll)
319 319
         .setContent(con)
320 320
         .openOn(map)
321
-        .on('remove', function() {openedGr = -1; grUnHl(grp.id)});
321
+        .on('remove', function() {if (openedGr == grp.id) {openedGr = -1; grUnHl(grp.id)}});
322 322
 }
323 323
 
324 324
 function openGr(id, ll) {
@@ -374,9 +374,11 @@ map.addControl(L.control.attribution({
374 374
 }));
375 375
 
376 376
 map.on('popupopen', function(e) {
377
-    var px = map.project(e.target._popup._latlng);
377
+    var z = Math.max(map.getZoom(), 16);
378
+    var px = map.project(e.target._popup._latlng, z);
378 379
     px.y -= e.target._popup._container.clientHeight/2;
379
-    map.panTo(map.unproject(px),{animate: true});
380
+
381
+    map.setView(map.unproject(px, z), z, {animate: true});
380 382
     s();
381 383
 });
382 384
 
@@ -504,8 +506,8 @@ function unselect(row) {
504 506
     selectedRes = undefined;
505 507
     if (!row) return;
506 508
     delCl(row, "selres");
507
-    if (row.stat) stUnHl(row.stat.i);
508
-    if (row.group) grUnHl(row.group.i);
509
+    if (row.stat && row.stat.i != openedSt) stUnHl(row.stat.i);
510
+    if (row.group && row.group.i != openedGr) grUnHl(row.group.i);
509 511
 }
510 512
 
511 513
 function isSearchOpen() {
@@ -521,6 +523,7 @@ function s(q) {
521 523
     if (!q) {
522 524
         $('#si').value = "";
523 525
         $("#sres").className = "";
526
+        $("#sres").innerHTML = "";
524 527
         return;
525 528
     }
526 529
 
@@ -550,6 +553,11 @@ function s(q) {
550 553
                     row.onmouseover = function(){select(this)};
551 554
                     row.onclick = function(){rowClick(this)};
552 555
 
556
+                    var dist = $$('span');
557
+                    addCl(dist, "dist");
558
+                    dist.innerHTML = dstr(e.s ? e.s.g : e.g.g);
559
+                    row.appendChild(dist);
560
+
553 561
                     if (e.v && e.v != e.name) {
554 562
                         var via = $$('span');
555 563
                         addCl(via, "via");
@@ -562,13 +570,21 @@ function s(q) {
562 570
         )}, delay);
563 571
 }
564 572
 
573
+function dstr(s) {
574
+    if (map.getBounds().contains(ll(s[0]))) return "";
575
+    var d = map.distance(map.getCenter(), ll(s[0]));
576
+    if (d < 500) return Math.round(d).toFixed(0) + "m";
577
+    if (d < 5000) return (d / 1000.0).toFixed(1) + "km";
578
+    return Math.round(d / 1000.0).toFixed(0) + "km";
579
+}
580
+
565 581
 function kp(e) {
566
-    if (e.keyCode == 40) {
582
+    if (e.keyCode == 40 || (!e.shiftKey && e.keyCode == 9)) {
567 583
         var sels = $('.selres')
568 584
         if (sels.length) select(sels[0].nextSibling);
569 585
         else select($('.sres')[0]);
570 586
         e.preventDefault();
571
-    } else if (e.keyCode == 38) {
587
+    } else if (e.keyCode == 38 || (e.shiftKey && e.keyCode == 9)) {
572 588
         var sels = $('.selres')
573 589
         if (sels.length) {
574 590
             if (sels[0].previousSibling) select(sels[0].previousSibling);