diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a7a987 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +statics/img diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf351db --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# faircoinmap-webapp +Webapp map showing places accepting FairCoin. + +Live demo: https://map.komun.org + +- Sidebar menu from: https://github.com/Turbo87/sidebar-v2/ diff --git a/index.html b/index.html new file mode 100644 index 0000000..522b801 --- /dev/null +++ b/index.html @@ -0,0 +1,205 @@ + + + + + Map Komun.org + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + +
+ Register + Login +
+
+
+
X
+
+
+ +

+ + + + + + +
+
+ + + + + + + + + + + + + + + + + + diff --git a/statics/commonroutes.js b/statics/commonroutes.js new file mode 100644 index 0000000..9a7040e --- /dev/null +++ b/statics/commonroutes.js @@ -0,0 +1,131 @@ +var urlroutes = "https://api.routes.fair.coop/api/"; + +var routes = []; +var routesMarkers = L.markerClusterGroup(); + +function getRoute(id) { + for(var i=0; i"; + }else{ + document.getElementById("rightCard-text").innerHTML = ""; + } + var html = ``; + document.getElementById("rightCard-categories").innerHTML = html; + + document.getElementById("rightCard-img").src=""; + document.getElementById("rightCard-img").className = "card-img-top hidden"; + document.getElementById("rightCard-web").href= "https://routes.fair.coop"; + document.getElementById("rightCard-web").innerHTML = "CommonRoutes website"; + document.getElementById("rightCard-mastodon").href="#"; + document.getElementById("rightCard-mastodon").innerHTML=""; + document.getElementById("rightCard-twitter").href="#"; + document.getElementById("rightCard-twitter").innerHTML=""; + document.getElementById("rightCard-facebook").href="#"; + document.getElementById("rightCard-facebook").innerHTML=""; + document.getElementById("rightCard-telegram").href="#"; + document.getElementById("rightCard-telegram").innerHTML=""; + document.getElementById("rightCard-email").href="#"; + document.getElementById("rightCard-email").innerHTML=""; + html = ` +

+ From: ` + route.from.name + ` +

+

+ To: ` + route.to.name + ` +

+
` + route.date + `
+ `; + document.getElementById("rightCard-text").innerHTML += html; + document.getElementById("rightCard").className+=" rightCard-show"; +} + +function updateRoutesMarkers() { + routesMarkers.clearLayers(); + for(var i=0; i" + }); + var marker = L.marker([lat, lon], {icon: icon}); + marker.id = routes[i]._id; + marker.bindPopup("From: "+routes[i].from.name+"
" + routes[i].date); + marker.on('mouseover', function(e) { + this.openPopup(); + }); + marker.on('mouseout', function(e) { + this.closePopup(); + }); + marker.on('click', function(e) { + var route = getRoute(this.id); + showRouteRightCard(JSON.parse(JSON.stringify(route))); + }); + routesMarkers.addLayer(marker); + + + var lat = routes[i].to.lat; + var lon = routes[i].to.long; + var icon = L.divIcon({ + className: 'markerInvisible', + iconAnchor: [20, 10], + popupAnchor: [-4, 0], // point from which the popup should open relative to the iconAnchor + html: "" + }); + var marker = L.marker([lat, lon], {icon: icon}); + marker.id = routes[i]._id; + marker.bindPopup("To: "+routes[i].to.name+"
" + routes[i].date); + marker.on('mouseover', function(e) { + this.openPopup(); + }); + marker.on('mouseout', function(e) { + this.closePopup(); + }); + marker.on('click', function(e) { + var route = getRoute(this.id); + showRouteRightCard(JSON.parse(JSON.stringify(route))); + }); + routesMarkers.addLayer(marker); + + var polyline = L.polyline([ + [routes[i].from.lat, routes[i].from.long], + [routes[i].to.lat, routes[i].to.long] + ], + { + color: '#9575CD', + weight: 5, + opacity: .7, + dashArray: '20,15', + lineJoin: 'round' + } + ).addTo(routesMarkers); + } + map.addLayer(routesMarkers); +} +function showCommonRoutes() { + $.get(urlroutes+"travels?page=", function(data){ + console.log(data); + routes = data; + console.log(routes); + updateRoutesMarkers(); + // document.getElementById("loadingbar").innerHTML=""; + }); +} diff --git a/statics/css/sidebar-loader.css b/statics/css/sidebar-loader.css new file mode 100644 index 0000000..13612df --- /dev/null +++ b/statics/css/sidebar-loader.css @@ -0,0 +1,385 @@ + + +.lorem { + font-style: italic; + color: #AAA; +} + +.sidebar { + position: absolute; + top: 0; + bottom: 0; + width: 100%; + overflow: hidden; + z-index: 2000; } + .sidebar.collapsed { + width: 40px; } + @media (min-width: 768px) { + .sidebar { + top: 10px; + bottom: 10px; + transition: width 500ms; } } + @media (min-width: 768px) and (max-width: 991px) { + .sidebar { + width: 305px; } } + @media (min-width: 992px) and (max-width: 1199px) { + .sidebar { + width: 390px; } } + @media (min-width: 1200px) { + .sidebar { + width: 460px; } } + +.sidebar-left { + left: 0; } + @media (min-width: 768px) { + .sidebar-left { + left: 10px; } } + +.sidebar-right { + right: 0; } + @media (min-width: 768px) { + .sidebar-right { + right: 10px; } } + +.sidebar-tabs { + top: 0; + bottom: 0; + height: 100%; + background-color: #fff; } + .sidebar-left .sidebar-tabs { + left: 0; } + .sidebar-right .sidebar-tabs { + right: 0; } + .sidebar-tabs, .sidebar-tabs > ul { + position: absolute; + width: 40px; + margin: 0; + padding: 0; + list-style-type: none; } + .sidebar-tabs > li, .sidebar-tabs > ul > li { + width: 100%; + height: 40px; + color: #333; + font-size: 12pt; + overflow: hidden; + transition: all 80ms; } + .sidebar-tabs > li:hover, .sidebar-tabs > ul > li:hover { + color: #000; + background-color: #eee; } + .sidebar-tabs > li.active, .sidebar-tabs > ul > li.active { + color: #fff; + background-color: #343a40; } + .sidebar-tabs > li.disabled, .sidebar-tabs > ul > li.disabled { + color: rgba(51, 51, 51, 0.4); } + .sidebar-tabs > li.disabled:hover, .sidebar-tabs > ul > li.disabled:hover { + background: transparent; } + .sidebar-tabs > li.disabled > a, .sidebar-tabs > ul > li.disabled > a { + cursor: default; } + .sidebar-tabs > li > a, .sidebar-tabs > ul > li > a { + display: block; + width: 100%; + height: 100%; + line-height: 40px; + color: inherit; + text-decoration: none; + text-align: center; } + .sidebar-tabs > ul + ul { + bottom: 0; } + +.sidebar-content { + position: absolute; + top: 0; + bottom: 0; + background-color: rgba(255, 255, 255, 0.95); + overflow-x: hidden; + overflow-y: auto; } + .sidebar-left .sidebar-content { + left: 40px; + right: 0; } + .sidebar-right .sidebar-content { + left: 0; + right: 40px; } + .sidebar.collapsed > .sidebar-content { + overflow-y: hidden; } + +.sidebar-pane { + display: none; + left: 0; + right: 0; + box-sizing: border-box; + padding: 10px 20px; } + .sidebar-pane.active { + display: block; } + @media (min-width: 768px) and (max-width: 991px) { + .sidebar-pane { + min-width: 265px; } } + @media (min-width: 992px) and (max-width: 1199px) { + .sidebar-pane { + min-width: 350px; } } + @media (min-width: 1200px) { + .sidebar-pane { + min-width: 420px; } } + +.sidebar-header { + margin: -10px -20px 0; + height: 40px; + padding: 0 20px; + line-height: 40px; + font-size: 14.4pt; + color: #fff; + background-color: #343a40; } + .sidebar-right .sidebar-header { + padding-left: 40px; } + +.sidebar-close { + position: absolute; + top: 0; + width: 40px; + height: 40px; + text-align: center; + cursor: pointer; } + .sidebar-left .sidebar-close { + right: 0; } + .sidebar-right .sidebar-close { + left: 0; } + +.sidebar-left ~ .sidebar-map { + margin-left: 40px; } + @media (min-width: 768px) { + .sidebar-left ~ .sidebar-map { + margin-left: 0; } } + +.sidebar-right ~ .sidebar-map { + margin-right: 40px; } + @media (min-width: 768px) { + .sidebar-right ~ .sidebar-map { + margin-right: 0; } } + +.sidebar { + box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65); } + .sidebar.leaflet-touch { + box-shadow: none; + border-right: 2px solid rgba(0, 0, 0, 0.2); } + @media (min-width: 768px) { + .sidebar { + border-radius: 4px; } + .sidebar.leaflet-touch { + border: 2px solid rgba(0, 0, 0, 0.2); } } + +@media (min-width: 768px) { + .sidebar-left ~ .sidebar-map .leaflet-left { + transition: left 500ms; } } + +@media (min-width: 768px) and (max-width: 991px) { + .sidebar-left ~ .sidebar-map .leaflet-left { + left: 315px; } } + +@media (min-width: 992px) and (max-width: 1199px) { + .sidebar-left ~ .sidebar-map .leaflet-left { + left: 400px; } } + +@media (min-width: 1200px) { + .sidebar-left ~ .sidebar-map .leaflet-left { + left: 470px; } } + +@media (min-width: 768px) { + .sidebar-left.collapsed ~ .sidebar-map .leaflet-left { + left: 50px; } } + +@media (min-width: 768px) { + .sidebar-right ~ .sidebar-map .leaflet-right { + transition: right 500ms; } } + +@media (min-width: 768px) and (max-width: 991px) { + .sidebar-right ~ .sidebar-map .leaflet-right { + right: 315px; } } + +@media (min-width: 992px) and (max-width: 1199px) { + .sidebar-right ~ .sidebar-map .leaflet-right { + right: 400px; } } + +@media (min-width: 1200px) { + .sidebar-right ~ .sidebar-map .leaflet-right { + right: 470px; } } + +@media (min-width: 768px) { + .sidebar-right.collapsed ~ .sidebar-map .leaflet-right { + right: 50px; } } + + + + +#loadingbar { + position:absolute; + top:40%; + left:45%; + z-index:2000; +} +.cssload-loader-inner { + bottom: 0; + height: 58px; + left: 0; + margin: auto; + position: absolute; + right: 0; + top: 0; + width: 97px; +} + +.cssload-cssload-loader-line-wrap-wrap { + animation: cssload-spin 2300ms cubic-bezier(.175, .885, .32, 1.275) infinite; + -o-animation: cssload-spin 2300ms cubic-bezier(.175, .885, .32, 1.275) infinite; + -ms-animation: cssload-spin 2300ms cubic-bezier(.175, .885, .32, 1.275) infinite; + -webkit-animation: cssload-spin 2300ms cubic-bezier(.175, .885, .32, 1.275) infinite; + -moz-animation: cssload-spin 2300ms cubic-bezier(.175, .885, .32, 1.275) infinite; + box-sizing: border-box; + -o-box-sizing: border-box; + -ms-box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + height: 49px; + left: 0; + overflow: hidden; + position: absolute; + top: 0; + transform-origin: 50% 100%; + -o-transform-origin: 50% 100%; + -ms-transform-origin: 50% 100%; + -webkit-transform-origin: 50% 100%; + -moz-transform-origin: 50% 100%; + width: 97px; +} +.cssload-loader-line-wrap { + border: 4px solid transparent; + border-radius: 100%; + -o-border-radius: 100%; + -ms-border-radius: 100%; + -webkit-border-radius: 100%; + -moz-border-radius: 100%; + box-sizing: border-box; + -o-box-sizing: border-box; + -ms-box-sizing: border-box; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + height: 97px; + left: 0; + margin: 0 auto; + position: absolute; + right: 0; + top: 0; + width: 97px; +} +.cssload-cssload-loader-line-wrap-wrap:nth-child(1) { animation-delay: -57.5ms; + -o-animation-delay: -57.5ms; + -ms-animation-delay: -57.5ms; + -webkit-animation-delay: -57.5ms; + -moz-animation-delay: -57.5ms; } +.cssload-cssload-loader-line-wrap-wrap:nth-child(2) { animation-delay: -115ms; + -o-animation-delay: -115ms; + -ms-animation-delay: -115ms; + -webkit-animation-delay: -115ms; + -moz-animation-delay: -115ms; } +.cssload-cssload-loader-line-wrap-wrap:nth-child(3) { animation-delay: -172.5ms; + -o-animation-delay: -172.5ms; + -ms-animation-delay: -172.5ms; + -webkit-animation-delay: -172.5ms; + -moz-animation-delay: -172.5ms; } +.cssload-cssload-loader-line-wrap-wrap:nth-child(4) { animation-delay: -230ms; + -o-animation-delay: -230ms; + -ms-animation-delay: -230ms; + -webkit-animation-delay: -230ms; + -moz-animation-delay: -230ms; } +.cssload-cssload-loader-line-wrap-wrap:nth-child(5) { animation-delay: -287.5ms; + -o-animation-delay: -287.5ms; + -ms-animation-delay: -287.5ms; + -webkit-animation-delay: -287.5ms; + -moz-animation-delay: -287.5ms; } + +.cssload-cssload-loader-line-wrap-wrap:nth-child(1) .cssload-loader-line-wrap { + border-color: rgb(234,71,71); + height: 88px; + width: 88px; + top: 7px; +} +.cssload-cssload-loader-line-wrap-wrap:nth-child(2) .cssload-loader-line-wrap { + border-color: rgb(234,234,71); + height: 74px; + width: 74px; + top: 14px; +} +.cssload-cssload-loader-line-wrap-wrap:nth-child(3) .cssload-loader-line-wrap { + border-color: rgb(71,234,71); + height: 60px; + width: 60px; + top: 20px; +} +.cssload-cssload-loader-line-wrap-wrap:nth-child(4) .cssload-loader-line-wrap { + border-color: rgb(71,234,234); + height: 47px; + width: 47px; + top: 27px; +} +.cssload-cssload-loader-line-wrap-wrap:nth-child(5) .cssload-loader-line-wrap { + border-color: rgb(71,71,234); + height: 33px; + width: 33px; + top: 34px; +} + + + + +@keyframes cssload-spin { + 0%, 15% { + transform: rotate(0); + transform: rotate(0); + } + 100% { + transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@-o-keyframes cssload-spin { + 0%, 15% { + -o-transform: rotate(0); + transform: rotate(0); + } + 100% { + -o-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@-ms-keyframes cssload-spin { + 0%, 15% { + -ms-transform: rotate(0); + transform: rotate(0); + } + 100% { + -ms-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@-webkit-keyframes cssload-spin { + 0%, 15% { + -webkit-transform: rotate(0); + transform: rotate(0); + } + 100% { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@-moz-keyframes cssload-spin { + 0%, 15% { + -moz-transform: rotate(0); + transform: rotate(0); + } + 100% { + -moz-transform: rotate(360deg); + transform: rotate(360deg); + } +} diff --git a/statics/index.js b/statics/index.js new file mode 100644 index 0000000..37d183b --- /dev/null +++ b/statics/index.js @@ -0,0 +1,371 @@ +var allitems = []; // array with all the items before filtering +var items = []; // the items showed in the map, after the categories +var categories = []; +var allCheckbox = {checked: true}; + +function hexToRGBA(hex,opacity){ + hex = hex.replace('#',''); + r = parseInt(hex.substring(0,2), 16); + g = parseInt(hex.substring(2,4), 16); + b = parseInt(hex.substring(4,6), 16); + + result = 'rgba('+r+','+g+','+b+','+opacity+')'; + return result; +} +function printFiltersList() { + var html = ""; + + for (var property in categories) { + if (categories.hasOwnProperty(property)) { + html += `
+ +
`; + } + } + + document.getElementById("filtersList").innerHTML = html; +} +function getItem(id) { + for(var i=0; i"; + }else{ + document.getElementById("rightCard-text").innerHTML = ""; + } + // gallery images + if(item.properties.gallery_images.length>0) { + var html = ""; + html += `
+ `; + document.getElementById("rightCard-text").innerHTML += html; + } + + + html = ""; + for (var property in item.properties.categories) { + if (item.properties.categories.hasOwnProperty(property)) { + html += ``; + } + } + document.getElementById("rightCard-categories").innerHTML = html; + if(item.properties.pictureUrl) { + document.getElementById("rightCard-img").src="https://map.komun.org/" + item.properties.pictureUrl; + document.getElementById("rightCard-img").className = "card-img-top"; + } else { + document.getElementById("rightCard-img").src=""; + document.getElementById("rightCard-img").className = "card-img-top hidden"; + } + + if(item.properties.web) { + document.getElementById("rightCard-web").href= item.properties.web; + document.getElementById("rightCard-web").innerHTML = "Web"; + } else { + document.getElementById("rightCard-web").href="#"; + document.getElementById("rightCard-web").innerHTML=""; + } + if(item.properties.mastodon) { + document.getElementById("rightCard-mastodon").href= item.properties.mastodon; + document.getElementById("rightCard-mastodon").innerHTML = ""; + } else { + document.getElementById("rightCard-mastodon").href="#"; + document.getElementById("rightCard-mastodon").innerHTML=""; + } + if(item.properties.twitter) { + document.getElementById("rightCard-twitter").href= item.properties.twitter; + document.getElementById("rightCard-twitter").innerHTML = ""; + } else { + document.getElementById("rightCard-twitter").href="#"; + document.getElementById("rightCard-twitter").innerHTML=""; + } + if(item.properties.facebook) { + document.getElementById("rightCard-facebook").href= item.properties.facebook; + document.getElementById("rightCard-facebook").innerHTML = ""; + } else { + document.getElementById("rightCard-facebook").href="#"; + document.getElementById("rightCard-facebook").innerHTML=""; + } + if(item.properties.telegram) { + document.getElementById("rightCard-telegram").href= item.properties.telegram; + document.getElementById("rightCard-telegram").innerHTML = ""; + } else { + document.getElementById("rightCard-telegram").href="#"; + document.getElementById("rightCard-telegram").innerHTML=""; + } + if(item.properties.email) { + document.getElementById("rightCard-email").href= "mailto:" + item.properties.email; + document.getElementById("rightCard-email").innerHTML = ""; + } else { + document.getElementById("rightCard-email").href="#"; + document.getElementById("rightCard-email").innerHTML=""; + } + document.getElementById("rightCard-text").innerHTML += "

"+item.properties.body+"

"; + document.getElementById("rightCard").className+=" rightCard-show"; +} +function hideRightCard() { + document.getElementById("rightCard").className ="card"; +} +function updateMarkers() { + markers.clearLayers(); + for(var i=0; i` + // html: "" + }); + var marker = L.marker([lat, lon], {icon: icon}); + marker.id = items[i].properties.slug; + if(items[i].properties.description!=null) { + marker.bindPopup(""+items[i].properties.name+"
"+items[i].properties.description+""); + } else { + marker.bindPopup(""+items[i].properties.name+""); + } + marker.on('mouseover', function(e) { + this.openPopup(); + }); + marker.on('mouseout', function(e) { + this.closePopup(); + }); + marker.on('click', function(e) { + var item = getItem(this.id); + placeid = this.id; + console.log(item.properties.gallery_images); + showRightCard(item); + window.history.pushState({},"", "?lang="+lang+"&lat=" + lat + "&lon=" + lon + "&zoom=" + zoom + "&placeid=" + placeid); + }); + markers.addLayer(marker); + } + map.addLayer(markers); + if (placeid!=="none") { + var item = getItem(placeid); + showRightCard(item); + window.history.pushState({},"", "?lang="+lang+"&lat=" + lat + "&lon=" + lon + "&zoom=" + zoom + "&placeid=" + placeid); + } +} +function updateFilter(selectedFilter) { + if(categories[selectedFilter].checked===true) { + categories[selectedFilter].checked = false; + document.getElementById('check' + selectedFilter).checked = false; + } else { + categories[selectedFilter].checked = true; + document.getElementById('check' + selectedFilter).checked = true; + } + applyFilters(); +} +function selectAllFilters() { + if(allCheckbox.checked===true) { + items = []; + allCheckbox.checked = false; + for (var property in categories) { + if (categories.hasOwnProperty(property)) { + categories[property].checked=false; + document.getElementById('check' + property).checked = false; + } + } + } else { + items = JSON.parse(JSON.stringify(allitems)); + allCheckbox.checked= true; + + for (var property in categories) { + if (categories.hasOwnProperty(property)) { + categories[property].checked=true; + document.getElementById('check' + property).checked = true; + } + } + } + updateMarkers(); +} +function itemInItems(array, el) { + for(var i=0;i +
+
` + items[i].properties.name + `
+ 3 days ago +
`; + if(items[i].properties.description!=null) { + html += `

` + items[i].properties.description + `

`; + } + html += ` + + `; + } + html += ""; + document.getElementById("searchResults").innerHTML = html; +} +function search() { + var searchResults = []; + var key = document.getElementById("searchinput").value.toUpperCase(); + if(key=="") { + document.getElementById("searchResults").innerHTML = ""; + return; + } + for(var i=0; i div.sidebar-content + for (i = this._sidebar.children.length - 1; i >= 0; i--) { + child = this._sidebar.children[i]; + if (child.tagName == 'DIV' && + L.DomUtil.hasClass(child, 'sidebar-content')) + this._container = child; + } + + // Find sidebar ul.sidebar-tabs > li, sidebar .sidebar-tabs > ul > li + this._tabitems = this._sidebar.querySelectorAll('ul.sidebar-tabs > li, .sidebar-tabs > ul > li'); + for (i = this._tabitems.length - 1; i >= 0; i--) { + this._tabitems[i]._sidebar = this; + } + + // Find sidebar > div.sidebar-content > div.sidebar-pane + this._panes = []; + this._closeButtons = []; + for (i = this._container.children.length - 1; i >= 0; i--) { + child = this._container.children[i]; + if (child.tagName == 'DIV' && + L.DomUtil.hasClass(child, 'sidebar-pane')) { + this._panes.push(child); + + var closeButtons = child.querySelectorAll('.sidebar-close'); + for (var j = 0, len = closeButtons.length; j < len; j++) + this._closeButtons.push(closeButtons[j]); + } + } + }, + + /** + * Add this sidebar to the specified map. + * + * @param {L.Map} map + * @returns {Sidebar} + */ + addTo: function (map) { + var i, child; + + this._map = map; + + for (i = this._tabitems.length - 1; i >= 0; i--) { + child = this._tabitems[i]; + var sub = child.querySelector('a'); + if (sub.hasAttribute('href') && sub.getAttribute('href').slice(0,1) == '#') { + L.DomEvent + .on(sub, 'click', L.DomEvent.preventDefault ) + .on(sub, 'click', this._onClick, child); + } + } + + for (i = this._closeButtons.length - 1; i >= 0; i--) { + child = this._closeButtons[i]; + L.DomEvent.on(child, 'click', this._onCloseClick, this); + } + + return this; + }, + + /** + * @deprecated - Please use remove() instead of removeFrom(), as of Leaflet 0.8-dev, the removeFrom() has been replaced with remove() + * Removes this sidebar from the map. + * @param {L.Map} map + * @returns {Sidebar} + */ + removeFrom: function(map) { + console.log('removeFrom() has been deprecated, please use remove() instead as support for this function will be ending soon.'); + this.remove(map); + }, + + /** + * Remove this sidebar from the map. + * + * @param {L.Map} map + * @returns {Sidebar} + */ + remove: function (map) { + var i, child; + + this._map = null; + + for (i = this._tabitems.length - 1; i >= 0; i--) { + child = this._tabitems[i]; + L.DomEvent.off(child.querySelector('a'), 'click', this._onClick); + } + + for (i = this._closeButtons.length - 1; i >= 0; i--) { + child = this._closeButtons[i]; + L.DomEvent.off(child, 'click', this._onCloseClick, this); + } + + return this; + }, + + /** + * Open sidebar (if necessary) and show the specified tab. + * + * @param {string} id - The id of the tab to show (without the # character) + */ + open: function(id) { + var i, child; + + // hide old active contents and show new content + for (i = this._panes.length - 1; i >= 0; i--) { + child = this._panes[i]; + if (child.id == id) + L.DomUtil.addClass(child, 'active'); + else if (L.DomUtil.hasClass(child, 'active')) + L.DomUtil.removeClass(child, 'active'); + } + + // remove old active highlights and set new highlight + for (i = this._tabitems.length - 1; i >= 0; i--) { + child = this._tabitems[i]; + if (child.querySelector('a').hash == '#' + id) + L.DomUtil.addClass(child, 'active'); + else if (L.DomUtil.hasClass(child, 'active')) + L.DomUtil.removeClass(child, 'active'); + } + + this.fire('content', { id: id }); + + // open sidebar (if necessary) + if (L.DomUtil.hasClass(this._sidebar, 'collapsed')) { + this.fire('opening'); + L.DomUtil.removeClass(this._sidebar, 'collapsed'); + } + + return this; + }, + + /** + * Close the sidebar (if necessary). + */ + close: function() { + // remove old active highlights + for (var i = this._tabitems.length - 1; i >= 0; i--) { + var child = this._tabitems[i]; + if (L.DomUtil.hasClass(child, 'active')) + L.DomUtil.removeClass(child, 'active'); + } + + // close sidebar + if (!L.DomUtil.hasClass(this._sidebar, 'collapsed')) { + this.fire('closing'); + L.DomUtil.addClass(this._sidebar, 'collapsed'); + } + + return this; + }, + + /** + * @private + */ + _onClick: function() { + if (L.DomUtil.hasClass(this, 'active')) + this._sidebar.close(); + else if (!L.DomUtil.hasClass(this, 'disabled')) + this._sidebar.open(this.querySelector('a').hash.slice(1)); + }, + + /** + * @private + */ + _onCloseClick: function () { + this.close(); + } +}); + +/** + * Creates a new sidebar. + * + * @example + * var sidebar = L.control.sidebar('sidebar').addTo(map); + * + * @param {string} id - The id of the sidebar element (without the # character) + * @param {Object} [options] - Optional options object + * @param {string} [options.position=left] - Position of the sidebar: 'left' or 'right' + * @returns {Sidebar} A new sidebar instance + */ +L.control.sidebar = function (id, options) { + return new L.Control.Sidebar(id, options); +}; diff --git a/statics/localnodes.js b/statics/localnodes.js new file mode 100644 index 0000000..29b9225 --- /dev/null +++ b/statics/localnodes.js @@ -0,0 +1,87 @@ +var urlln = "https://fairplayground.info/datasources/FCLN/FCLN.json"; + +var lns = []; +var lnMarkers = L.markerClusterGroup(); + + +function getLocalNode(id) { + for(var i=0; i`; + document.getElementById("rightCard-categories").innerHTML = html; + // if(ln.img!=null) { + document.getElementById("rightCard-img").src=""; + document.getElementById("rightCard-img").className = "card-img-top hidden"; + // } else { + // document.getElementById("rightCard-img").src=ln.icon; + // document.getElementById("rightCard-img").className = "card-img-top"; + // } + document.getElementById("rightCard-web").href= "#"; + document.getElementById("rightCard-web").innerHTML = ""; + document.getElementById("rightCard-mastodon").href="#"; + document.getElementById("rightCard-mastodon").innerHTML=""; + document.getElementById("rightCard-twitter").href="#"; + document.getElementById("rightCard-twitter").innerHTML=""; + document.getElementById("rightCard-facebook").href="#"; + document.getElementById("rightCard-facebook").innerHTML=""; + document.getElementById("rightCard-telegram").href="#"; + document.getElementById("rightCard-telegram").innerHTML=""; + document.getElementById("rightCard-email").href="#"; + document.getElementById("rightCard-email").innerHTML=""; + document.getElementById("rightCard").className+=" rightCard-show"; +} +function updateLocalNodesMarkers() { + lnMarkers.clearLayers(); + for(var i=0; i" + }); + var marker = L.marker([lat, lon], {icon: icon}); + marker.id = lns[i].id; + if(lns[i].description!=null) { + marker.bindPopup(""+lns[i].name+"
"+lns[i].description+""); + } else { + marker.bindPopup(""+lns[i].name+""); + } + marker.on('mouseover', function(e) { + this.openPopup(); + }); + marker.on('mouseout', function(e) { + this.closePopup(); + }); + marker.on('click', function(e) { + var ln = getLocalNode(this.id); + showLocalNodeRightCard(ln); + }); + lnMarkers.addLayer(marker); + } + map.addLayer(lnMarkers); +} +function showLocalNodes() { + $.get(urlln, function(data){ + console.log(data); + lns = data; + console.log(routes); + updateLocalNodesMarkers(); + }); +} diff --git a/statics/style.css b/statics/style.css new file mode 100644 index 0000000..8e3d194 --- /dev/null +++ b/statics/style.css @@ -0,0 +1,77 @@ +body { + padding: 0; + margin: 0; +} + +html, body, #map { + height: 100%; + width: 100%; + overflow: hidden; + font: 10pt "Helvetica Neue", Arial, Helvetica, sans-serif; +} +.registerButtonBox { + position: absolute; + right: 15px; + top: 15px; + z-index: 2000; +} +.lvl2 { + margin-left: 15px; +} +#rightCard { + position: absolute; + right: -300px; + top: 0; + max-width: 300px; + max-height: 100%; + overflow-y: scroll; + z-index: 2000; + background: #ffffff; + -webkit-transition: all 0.5s; /* Safari */ + transition: all 0.5s; +} +.rightCard-show { + right: 0px!important; +} +.hidden { + visibility: hidden; +} +.marker { + background: #ffffff; + width: 30px; + height: 30px; + border-radius: 50%; + /* box-shadow: 0 0 5px 5px rgba(66, 134, 244, 0.2); */ + -webkit-transition: all 0.2s; /* Safari */ + transition: all 0.2s; +} +/* .marker:hover { + border: 2px solid #000000; +} */ + +.routeMarker { + background: #ffffff; + width: 30px; + height: 30px; + border-radius: 50%; + border: 2px solid rgb(65, 202, 244); + box-shadow: 0 0 5px 5px rgba(65, 202, 244, 0.2); + -webkit-transition: all 0.2s; /* Safari */ + transition: all 0.2s; +} +.lnMarker { + background: #ffffff; + width: 30px; + height: 30px; + border-radius: 50%; + border: 2px solid rgb(43, 216, 129); + box-shadow: 0 0 5px 5px rgba(43, 216, 129, 0.2); + -webkit-transition: all 0.2s; /* Safari */ + transition: all 0.2s; +} +.marker-red { + box-shadow: 0 0 5px 5px rgba(244, 78, 66, 0.2)!important; +} +.marker-blue { + box-shadow: 0 0 5px 5px rgba(63, 154, 244, 0.2)!important; +}