diff --git a/src/helpers/Popup.jsx b/src/helpers/Popup.jsx index 62828abd..7ea8ee49 100644 --- a/src/helpers/Popup.jsx +++ b/src/helpers/Popup.jsx @@ -75,11 +75,11 @@ export default class Popup extends Overlay { } if (this.contentIndex + 1 >= this.contentArray.length) { - this.contentNextButtonContainer.className = "sc-popup-content-next-button disabled"; + this.contentNextButtonContainer.className = "sc-popup-content-next-button sc-disabled"; this.contentPrevButtonContainer.className = "sc-popup-content-prev-button"; } else if (this.contentIndex - 1 < 0) { this.contentNextButtonContainer.className = "sc-popup-content-next-button"; - this.contentPrevButtonContainer.className = "sc-popup-content-prev-button disabled"; + this.contentPrevButtonContainer.className = "sc-popup-content-prev-button sc-disabled"; } else { this.contentNextButtonContainer.className = "sc-popup-content-next-button"; this.contentPrevButtonContainer.className = "sc-popup-content-prev-button"; @@ -103,9 +103,9 @@ export default class Popup extends Overlay { } if (this.contentIndex - 1 < 0) { this.contentNextButtonContainer.className = "sc-popup-content-next-button"; - this.contentPrevButtonContainer.className = "sc-popup-content-prev-button disabled"; + this.contentPrevButtonContainer.className = "sc-popup-content-prev-button sc-disabled"; } else if (this.contentIndex + 1 >= this.contentArray.length) { - this.contentNextButtonContainer.className = "sc-popup-content-next-button disabled"; + this.contentNextButtonContainer.className = "sc-popup-content-next-button sc-disabled"; this.contentPrevButtonContainer.className = "sc-popup-content-prev-button"; } else { this.contentNextButtonContainer.className = "sc-popup-content-next-button"; @@ -209,7 +209,7 @@ export default class Popup extends Overlay { if (this.contentIndex <= 0) { // this.contentPrevButton.style.display = "none"; this.contentNextButtonContainer.className = "sc-popup-content-next-button"; - this.contentPrevButtonContainer.className = "sc-popup-content-prev-button disabled"; + this.contentPrevButtonContainer.className = "sc-popup-content-prev-button sc-disabled"; } if (callback) callback(); return; @@ -249,8 +249,10 @@ export default class Popup extends Overlay { if (header) header.addEventListener("mousedown", (evt) => { // IGNORE CLOSE BUTTON OR MOBILE - var isCloser = evt.target.classList.contains("ol-popup-closer"); - if (isClosing || isCloser || helpers.isMobile()) { + console.log(evt.target.classList); + var isHeaderButton = evt.target.classList.contains("ol-popup-closer") || evt.target.classList.contains("ol-popup-previous") || evt.target.classList.contains("ol-popup-next"); + + if (isHeaderButton || isHeaderButton || helpers.isMobile()) { isMoving = false; isClosing = false; return; diff --git a/src/helpers/helpers.js b/src/helpers/helpers.js index 9abe16eb..53bd6ce5 100644 --- a/src/helpers/helpers.js +++ b/src/helpers/helpers.js @@ -705,9 +705,8 @@ export function getWFSGeoJSON(serverUrl, layerName, callback, sortField = null, export function getWFSLayerRecordCount(serverUrl, layerName, callback) { const recordCountUrlTemplate = (serverURL, layerName) => `${serverURL}wfs?REQUEST=GetFeature&VERSION=1.1&typeName=${layerName}&RESULTTYPE=hits`; const recordCountUrl = recordCountUrlTemplate(serverUrl, layerName); - console.log("getWFSLayerRecordCount - url", recordCountUrl); + getObjectFromXMLUrl(recordCountUrl, (result) => { - console.log("getWFSLayerRecordCount - result", result); callback(result["wfs:FeatureCollection"]["$"].numberOfFeatures); }); } @@ -1139,6 +1138,22 @@ export function getWKTStringFromFeature(feature) { // return feature; } +export function formatReplace(fmt, ...args) { + if (!fmt.match(/^(?:(?:(?:[^{}]|(?:\{\{)|(?:\}\}))+)|(?:\{[0-9]+\}))+$/)) { + throw new Error("invalid format string."); + } + return fmt.replace(/((?:[^{}]|(?:\{\{)|(?:\}\}))+)|(?:\{([0-9]+)\})/g, (m, str, index) => { + if (str) { + return str.replace(/(?:{{)|(?:}})/g, (m) => m[0]); + } else { + if (index >= args.length) { + throw new Error("argument index is out of range in format"); + } + return args[index]; + } + }); +} + export function toLatLongFromWebMercator(coords) { return transform(coords, "EPSG:3857", "EPSG:4326"); } diff --git a/src/sidebar/components/mymaps/MyMapsFooter.jsx b/src/sidebar/components/mymaps/MyMapsFooter.jsx index f221b11d..a503a951 100644 --- a/src/sidebar/components/mymaps/MyMapsFooter.jsx +++ b/src/sidebar/components/mymaps/MyMapsFooter.jsx @@ -40,7 +40,7 @@ const MyMapsFooter = (props) => { - + diff --git a/src/sidebar/components/tools/weather/WeatherRadar.jsx b/src/sidebar/components/tools/weather/WeatherRadar.jsx index bceaf1b1..40bc0a60 100644 --- a/src/sidebar/components/tools/weather/WeatherRadar.jsx +++ b/src/sidebar/components/tools/weather/WeatherRadar.jsx @@ -10,6 +10,7 @@ import Static from "ol/source/ImageStatic"; const WeatherRadar = (props) => { const radarImages = useRef([]); const radarInterval = useRef(null); + const [radarDateSliderValue, setRadarDateSliderValue] = useState(helpers.roundTime(new Date())); const [radarOpacitySliderValue, setRadarOpacitySliderValue] = useState(0.7); const [startDate, setStartDate] = useState(helpers.roundTime(new Date(new Date().setHours(new Date().getHours() - 3)))); @@ -93,14 +94,21 @@ const WeatherRadar = (props) => { }; const setStartAndEndDateDefault = () => { - setRadarDateSliderValue(startDate); + const firstImage = radarImages.current[0]; + const startDate = firstImage.get("radarDate"); + const lastImage = radarImages.current[radarImages.current.length - 1]; + const endDate = lastImage.get("radarDate"); + + setStartDate(startDate); + setEndDate(endDate); + setRadarDateSliderValue(endDate); window.map.once( "postrender", (event) => { setIsLoading(false); }, () => { - setRadarDateSliderValue(startDate); + setRadarDateSliderValue(endDate); } ); };