mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-15 16:19:30 -07:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e326c3464b | ||
|
|
c3e38b4077 | ||
|
|
eb11feb964 | ||
|
|
b2aca1ee8d |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ws4kp",
|
||||
"version": "5.5.0",
|
||||
"version": "5.5.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ws4kp",
|
||||
"version": "5.5.0",
|
||||
"version": "5.5.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eslint": "^8.21.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ws4kp",
|
||||
"version": "5.5.0",
|
||||
"version": "5.5.2",
|
||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -8,9 +8,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
init();
|
||||
});
|
||||
|
||||
const overrides = {};
|
||||
|
||||
let AutoSelectQuery = false;
|
||||
let FullScreenOverride = false;
|
||||
|
||||
const categories = [
|
||||
@@ -58,21 +55,12 @@ const init = () => {
|
||||
maxSuggestions: 10,
|
||||
},
|
||||
dataType: 'json',
|
||||
transformResult: (response) => {
|
||||
if (AutoSelectQuery) {
|
||||
AutoSelectQuery = false;
|
||||
window.setTimeout(() => {
|
||||
$(ac.suggestionsContainer.children[0]).click();
|
||||
}, 1);
|
||||
}
|
||||
|
||||
return {
|
||||
suggestions: $.map(response.suggestions, (i) => ({
|
||||
value: i.text,
|
||||
data: i.magicKey,
|
||||
})),
|
||||
};
|
||||
},
|
||||
transformResult: (response) => ({
|
||||
suggestions: $.map(response.suggestions, (i) => ({
|
||||
value: i.text,
|
||||
data: i.magicKey,
|
||||
})),
|
||||
}),
|
||||
minChars: 3,
|
||||
showNoSuggestionNotice: true,
|
||||
noSuggestionNotice: 'No results found. Please try a different search string.',
|
||||
@@ -88,12 +76,11 @@ const init = () => {
|
||||
|
||||
// Auto load the previous query
|
||||
const TwcQuery = localStorage.getItem('TwcQuery');
|
||||
if (TwcQuery) {
|
||||
AutoSelectQuery = true;
|
||||
const TwcLatLong = localStorage.getItem('TwcLatLon');
|
||||
if (TwcQuery && TwcLatLong) {
|
||||
const txtAddress = document.getElementById('txtAddress');
|
||||
txtAddress.value = TwcQuery;
|
||||
txtAddress.blur();
|
||||
txtAddress.focus();
|
||||
LoadTwcData(JSON.parse(TwcLatLong));
|
||||
}
|
||||
|
||||
const TwcPlay = localStorage.getItem('TwcPlay');
|
||||
@@ -118,6 +105,7 @@ const init = () => {
|
||||
postMessage('navButton', 'play');
|
||||
|
||||
localStorage.removeItem('TwcQuery');
|
||||
localStorage.removeItem('TwcLatLon');
|
||||
});
|
||||
|
||||
// swipe functionality
|
||||
@@ -129,31 +117,30 @@ const autocompleteOnSelect = async (suggestion, elem) => {
|
||||
// Do not auto get the same city twice.
|
||||
if (elem.previousSuggestionValue === suggestion.value) return;
|
||||
|
||||
if (overrides[suggestion.value]) {
|
||||
doRedirectToGeometry(overrides[suggestion.value]);
|
||||
} else {
|
||||
const data = await json('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find', {
|
||||
data: {
|
||||
text: suggestion.value,
|
||||
magicKey: suggestion.data,
|
||||
f: 'json',
|
||||
},
|
||||
});
|
||||
const data = await json('https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/find', {
|
||||
data: {
|
||||
text: suggestion.value,
|
||||
magicKey: suggestion.data,
|
||||
f: 'json',
|
||||
},
|
||||
});
|
||||
|
||||
const loc = data.locations[0];
|
||||
if (loc) {
|
||||
doRedirectToGeometry(loc.feature.geometry);
|
||||
} else {
|
||||
console.error('An unexpected error occurred. Please try a different search string.');
|
||||
}
|
||||
const loc = data.locations[0];
|
||||
if (loc) {
|
||||
doRedirectToGeometry(loc.feature.geometry);
|
||||
} else {
|
||||
console.error('An unexpected error occurred. Please try a different search string.');
|
||||
}
|
||||
};
|
||||
|
||||
const doRedirectToGeometry = (geom) => {
|
||||
const latLon = { lat: Math.round2(geom.y, 4), lon: Math.round2(geom.x, 4) };
|
||||
LoadTwcData(latLon);
|
||||
// Save the query
|
||||
localStorage.setItem('TwcQuery', document.getElementById('txtAddress').value);
|
||||
localStorage.setItem('TwcLatLon', JSON.stringify(latLon));
|
||||
|
||||
// get the data
|
||||
LoadTwcData(latLon);
|
||||
};
|
||||
|
||||
const btnFullScreenClick = () => {
|
||||
|
||||
@@ -100,8 +100,11 @@ const updateStatus = (value) => {
|
||||
if (!progress) return;
|
||||
progress.drawCanvas(displays, countLoadedDisplays());
|
||||
|
||||
// calculate first enabled display
|
||||
const firstDisplayIndex = displays.findIndex((display) => display.enabled);
|
||||
|
||||
// if this is the first display and we're playing, load it up so it starts playing
|
||||
if (isPlaying() && value.id === 0 && value.status === STATUS.loaded) {
|
||||
if (isPlaying() && value.id === firstDisplayIndex && value.status === STATUS.loaded) {
|
||||
navTo(msg.command.firstFrame);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user