Browse Source

some tweaks

Patrick Brosi 4 years ago
parent
commit
74820f2863
2 changed files with 34 additions and 10 deletions
  1. 10 2
      web/index.html
  2. 24 8
      web/script.js

+ 10 - 2
web/index.html

@@ -466,7 +466,7 @@ input:focus {
466
     display: block;
466
     display: block;
467
     line-height: 2;
467
     line-height: 2;
468
     padding-left: 0.5rem;
468
     padding-left: 0.5rem;
469
-    padding-right: 25px;
469
+    padding-right: 55px;
470
     border-top-right-radius: 5px;    
470
     border-top-right-radius: 5px;    
471
     border-bottom-right-radius: 5px;
471
     border-bottom-right-radius: 5px;
472
     border-left: solid 5px #78f378;
472
     border-left: solid 5px #78f378;
@@ -502,7 +502,7 @@ input:focus {
502
 .res-group, .res-stat, .res-way {
502
 .res-group, .res-stat, .res-way {
503
     background-size: 20px;
503
     background-size: 20px;
504
     background-repeat: no-repeat;
504
     background-repeat: no-repeat;
505
-    background-position: 100% center;
505
+    background-position: 100% 6px;
506
 }
506
 }
507
 
507
 
508
 .res-group {
508
 .res-group {
@@ -563,6 +563,14 @@ padding-left:20px;}
563
     transition: color 0.2s ease-out;
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
 main, #m { width: 100%;height:100%; }
574
 main, #m { width: 100%;height:100%; }
567
 
575
 
568
 #sres.res-open + #del { opacity: 1; }
576
 #sres.res-open + #del { opacity: 1; }

+ 24 - 8
web/script.js

@@ -192,7 +192,7 @@ function rndrSt(stat) {
192
         .setLatLng(stat)
192
         .setLatLng(stat)
193
         .setContent(con)
193
         .setContent(con)
194
         .openOn(map)
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
 function openSt(id) {req("s", "/stat?id=" + id, function(c) {rndrSt(c)});}
198
 function openSt(id) {req("s", "/stat?id=" + id, function(c) {rndrSt(c)});}
@@ -318,7 +318,7 @@ function rndrGr(grp, ll) {
318
         .setLatLng(ll)
318
         .setLatLng(ll)
319
         .setContent(con)
319
         .setContent(con)
320
         .openOn(map)
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
 function openGr(id, ll) {
324
 function openGr(id, ll) {
@@ -374,9 +374,11 @@ map.addControl(L.control.attribution({
374
 }));
374
 }));
375
 
375
 
376
 map.on('popupopen', function(e) {
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
     px.y -= e.target._popup._container.clientHeight/2;
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
     s();
382
     s();
381
 });
383
 });
382
 
384
 
@@ -504,8 +506,8 @@ function unselect(row) {
504
     selectedRes = undefined;
506
     selectedRes = undefined;
505
     if (!row) return;
507
     if (!row) return;
506
     delCl(row, "selres");
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
 function isSearchOpen() {
513
 function isSearchOpen() {
@@ -521,6 +523,7 @@ function s(q) {
521
     if (!q) {
523
     if (!q) {
522
         $('#si').value = "";
524
         $('#si').value = "";
523
         $("#sres").className = "";
525
         $("#sres").className = "";
526
+        $("#sres").innerHTML = "";
524
         return;
527
         return;
525
     }
528
     }
526
 
529
 
@@ -550,6 +553,11 @@ function s(q) {
550
                     row.onmouseover = function(){select(this)};
553
                     row.onmouseover = function(){select(this)};
551
                     row.onclick = function(){rowClick(this)};
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
                     if (e.v && e.v != e.name) {
561
                     if (e.v && e.v != e.name) {
554
                         var via = $$('span');
562
                         var via = $$('span');
555
                         addCl(via, "via");
563
                         addCl(via, "via");
@@ -562,13 +570,21 @@ function s(q) {
562
         )}, delay);
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
 function kp(e) {
581
 function kp(e) {
566
-    if (e.keyCode == 40) {
582
+    if (e.keyCode == 40 || (!e.shiftKey && e.keyCode == 9)) {
567
         var sels = $('.selres')
583
         var sels = $('.selres')
568
         if (sels.length) select(sels[0].nextSibling);
584
         if (sels.length) select(sels[0].nextSibling);
569
         else select($('.sres')[0]);
585
         else select($('.sres')[0]);
570
         e.preventDefault();
586
         e.preventDefault();
571
-    } else if (e.keyCode == 38) {
587
+    } else if (e.keyCode == 38 || (e.shiftKey && e.keyCode == 9)) {
572
         var sels = $('.selres')
588
         var sels = $('.selres')
573
         if (sels.length) {
589
         if (sels.length) {
574
             if (sels[0].previousSibling) select(sels[0].previousSibling);
590
             if (sels[0].previousSibling) select(sels[0].previousSibling);