clean up html
This commit is contained in:
parent
36a3400e5d
commit
fa8ac8c9d8
68
index.html
68
index.html
|
|
@ -1,23 +1,22 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>World Map with OpenStreetMap</title>
|
<title>Mappersons</title>
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
|
||||||
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI="
|
integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin="" />
|
||||||
crossorigin=""/>
|
|
||||||
<link href="jquery-ui.css" rel="stylesheet">
|
<link href="jquery-ui.css" rel="stylesheet">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#map {
|
#map {
|
||||||
height: 90vh;
|
height: 90vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
#slider {
|
#slider {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-bottom:1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#custom-handle {
|
#custom-handle {
|
||||||
width: 8em;
|
width: 8em;
|
||||||
height: 1.6em;
|
height: 1.6em;
|
||||||
|
|
@ -26,21 +25,24 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
line-height: 1.6em;
|
line-height: 1.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<!-- Make sure you put this AFTER Leaflet's CSS -->
|
<!-- Make sure you put this AFTER Leaflet's CSS -->
|
||||||
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
|
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
|
||||||
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM="
|
integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
|
||||||
crossorigin=""></script>
|
</head>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<div id="slider"> <div id="custom-handle" class="ui-slider-handle"></div></div>
|
<div id="slider">
|
||||||
|
<div id="custom-handle" class="ui-slider-handle"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
<script>
|
<script>
|
||||||
const map = L.map('map').setView([51.14027, 10.45863], 7);
|
const map = L.map('map').setView([51.14027, 10.45863], 7);
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
|
||||||
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
'<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
|
||||||
maxZoom: 18,
|
maxZoom: 18,
|
||||||
id: 'mapbox/streets-v11',
|
id: 'mapbox/streets-v11',
|
||||||
tileSize: 512,
|
tileSize: 512,
|
||||||
|
|
@ -49,13 +51,14 @@
|
||||||
|
|
||||||
var markerLayer = L.layerGroup();
|
var markerLayer = L.layerGroup();
|
||||||
|
|
||||||
function loadWeek(locations){
|
function loadWeek(locations) {
|
||||||
locations.map(location => {
|
locations.map(location => {
|
||||||
return L.marker([location.lat, location.lng], {icon: L.icon({
|
return L.marker([location.lat, location.lng], {
|
||||||
|
icon: L.icon({
|
||||||
iconUrl: location.icon,
|
iconUrl: location.icon,
|
||||||
iconAnchor: location.anchor
|
iconAnchor: location.anchor
|
||||||
})})
|
})
|
||||||
|
})
|
||||||
.bindPopup(location.popup)
|
.bindPopup(location.popup)
|
||||||
.addTo(markerLayer);
|
.addTo(markerLayer);
|
||||||
});
|
});
|
||||||
|
|
@ -63,48 +66,49 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<script src="external/jquery/jquery.js"></script>
|
<script src="external/jquery/jquery.js"></script>
|
||||||
<script src="jquery-ui.js"></script>
|
<script src="jquery-ui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
Date.prototype.getWeek = function() {
|
Date.prototype.getWeek = function () {
|
||||||
var onejan = new Date(this.getFullYear(), 0, 1);
|
var onejan = new Date(this.getFullYear(), 0, 1);
|
||||||
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7);
|
||||||
}
|
}
|
||||||
// Set initial date to current calendar week and year
|
// Set initial date to current calendar week and year
|
||||||
// Initialize slider with current calendar week and year
|
// Initialize slider with current calendar week and year
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let year = now.getFullYear(); // get the full four-digit year
|
let year = now.getFullYear(); // get the full four-digit year
|
||||||
let week = now.getWeek(); // get the week as a number, where 0 represents the first week of the year
|
let week = now.getWeek(); // get the week as a number, where 0 represents the first week of the year
|
||||||
console.log(`The current week of ${year} is ${week}`);
|
console.log(`The current week of ${year} is ${week}`);
|
||||||
|
|
||||||
var handle = $( "#custom-handle" );
|
var handle = $("#custom-handle");
|
||||||
$("#slider").slider({
|
$("#slider").slider({
|
||||||
value: week,
|
value: week,
|
||||||
min: week - 4,
|
min: week - 4,
|
||||||
max: week + 12,
|
max: week + 12,
|
||||||
step: 1,
|
step: 1,
|
||||||
|
|
||||||
create: function() {
|
create: function () {
|
||||||
handle.text( `KW ${week}/${year}`);
|
handle.text(`KW ${week}/${year}`);
|
||||||
$.ajaxSetup({ cache: false });
|
$.ajaxSetup({ cache: false });
|
||||||
$.getJSON(`cw_${week}_${year}.json`, function( data ) {
|
$.getJSON(`cw_${week}_${year}.json`, function (data) {
|
||||||
loadWeek(data);
|
loadWeek(data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
slide: function( event, ui ) {
|
slide: function (event, ui) {
|
||||||
// ToDo: handle year change
|
// ToDo: handle year change
|
||||||
var curweek = ui.value;
|
var curweek = ui.value;
|
||||||
var curyear = year;
|
var curyear = year;
|
||||||
if (map.hasLayer(markerLayer)) {
|
if (map.hasLayer(markerLayer)) {
|
||||||
markerLayer.clearLayers();
|
markerLayer.clearLayers();
|
||||||
}
|
}
|
||||||
handle.text( `KW ${curweek}/${curyear}`);
|
handle.text(`KW ${curweek}/${curyear}`);
|
||||||
$.ajaxSetup({ cache: false });
|
$.ajaxSetup({ cache: false });
|
||||||
$.getJSON(`cw_${curweek}_${curyear}.json`, function( data ) {
|
$.getJSON(`cw_${curweek}_${curyear}.json`, function (data) {
|
||||||
loadWeek(data);
|
loadWeek(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue