history: toggle-able sidebar

This commit is contained in:
Nils Schneider 2015-03-20 13:30:28 +01:00
parent ad663f60fd
commit b7fa08ef2a
2 changed files with 109 additions and 42 deletions

View File

@ -11,6 +11,25 @@
font-size: 11pt; font-size: 11pt;
} }
#sidebarhandle {
cursor: pointer;
font-family: sans;
font-size: 18pt;
position: absolute;
right: -1.4em;
top: 2em;
z-index: 10;
background: rgba(255, 255, 255, 0.6);
width: 1.5em;
padding: 0.25em 0;
text-align: center;
border-radius: 0 0.5em 0.5em 0;
}
#sidebarhandle:hover {
background: rgba(255, 255, 255, 1);
}
.hostname { .hostname {
} }
@ -26,8 +45,21 @@
flex-grow: 1; flex-grow: 1;
} }
#lists { #sidebar {
max-width: 50em; max-width: 50em;
box-sizing: border-box;
position: relative;
}
#sidebar.hidden {
width: 0px;
}
#sidebar.hidden #lists {
display: none;
}
#lists {
overflow: auto; overflow: auto;
padding: 0 1em 1em; padding: 0 1em 1em;
box-sizing: border-box; box-sizing: border-box;
@ -51,7 +83,7 @@
} }
@media screen and (max-width: 80em) { @media screen and (max-width: 80em) {
#lists { #sidebar {
max-width: 50vw; max-width: 50vw;
font-size: 0.8em; font-size: 0.8em;
} }
@ -62,14 +94,30 @@
flex-direction: column; flex-direction: column;
} }
#lists {
overflow: visible;
}
#sidebarhandle {
display: none;
}
#map { #map {
height: 60vh; height: 60vh;
} }
#lists { #sidebar {
max-width: none; max-width: none;
height: auto; height: auto;
} }
#sidebar.hidden {
width: auto;
}
#sidebar.hidden #lists {
display: block;
}
} }
</style> </style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
@ -83,6 +131,10 @@
<div id="container"> <div id="container">
<div id="map"> <div id="map">
</div> </div>
<div id="sidebar">
<div id="sidebarhandle">
</div>
<div id="lists"> <div id="lists">
<p> <p>
Zeigt Knoten an, die in den letzten 14 Tagen dazu gekommen oder verschwunden sind. Zeigt Knoten an, die in den letzten 14 Tagen dazu gekommen oder verschwunden sind.
@ -102,5 +154,6 @@
</table> </table>
</div> </div>
</div> </div>
</div>
</body> </body>
</html> </html>

View File

@ -27,7 +27,25 @@ function getJSON(url) {
} }
function main() { function main() {
getJSON('nodes.json').then(handle_data) var options = { worldCopyJump: true,
zoomControl: false
}
var map = L.map(document.getElementById("map"), options)
var sh = document.getElementById("sidebarhandle")
sh.onclick = function () {
var sb = document.getElementById("sidebar")
if (sb.classList.contains("hidden"))
sb.classList.remove("hidden")
else
sb.classList.add("hidden")
map.invalidateSize()
}
getJSON('nodes.json').then(handle_data(map))
} }
function sort(key, d) { function sort(key, d) {
@ -66,7 +84,8 @@ function subtract(a, b) {
}) })
} }
function handle_data(data) { function handle_data(map) {
return function (data) {
var nodes = Object.keys(data.nodes).map(function (key) { return data.nodes[key] }) var nodes = Object.keys(data.nodes).map(function (key) { return data.nodes[key] })
nodes = nodes.filter( function (d) { nodes = nodes.filter( function (d) {
@ -88,16 +107,11 @@ function handle_data(data) {
addToList(document.getElementById("newnodes"), "firstseen", newnodes) addToList(document.getElementById("newnodes"), "firstseen", newnodes)
addToList(document.getElementById("lostnodes"), "lastseen", lostnodes) addToList(document.getElementById("lostnodes"), "lastseen", lostnodes)
mkmap(document.getElementById("map"), newnodes, lostnodes, onlinenodes) mkmap(map, newnodes, lostnodes, onlinenodes)
}
} }
function mkmap(el, newnodes, lostnodes, onlinenodes) { function mkmap(map, newnodes, lostnodes, onlinenodes) {
var options = { worldCopyJump: true,
zoomControl: false
}
var map = L.map(el, options)
L.control.zoom({ position: "topright" }).addTo(map) L.control.zoom({ position: "topright" }).addTo(map)
L.tileLayer("http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg", { L.tileLayer("http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpg", {