mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-17 00:59:29 -07:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b076db25d | ||
|
|
807932fe3c | ||
|
|
7bb024eff5 | ||
|
|
f4a1a3a1d8 | ||
|
|
9a5efe9d48 | ||
|
|
14b1891efd |
1328
package-lock.json
generated
1328
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ws4kp",
|
"name": "ws4kp",
|
||||||
"version": "6.2.2",
|
"version": "6.2.4",
|
||||||
"description": "Welcome to the WeatherStar 4000+ project page!",
|
"description": "Welcome to the WeatherStar 4000+ project page!",
|
||||||
"main": "index.mjs",
|
"main": "index.mjs",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -298,4 +298,5 @@ export {
|
|||||||
hide,
|
hide,
|
||||||
screenCount,
|
screenCount,
|
||||||
atDefault,
|
atDefault,
|
||||||
|
hazards,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import Setting from './utils/setting.mjs';
|
import Setting from './utils/setting.mjs';
|
||||||
import { reset as resetScroll, addScreen as addScroll } from './currentweatherscroll.mjs';
|
import { reset as resetScroll, addScreen as addScroll, hazards } from './currentweatherscroll.mjs';
|
||||||
import { json } from './utils/fetch.mjs';
|
import { json } from './utils/fetch.mjs';
|
||||||
|
|
||||||
let firstRun = true;
|
let firstRun = true;
|
||||||
@@ -42,8 +42,9 @@ const parseFeed = (textInput) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add single text scroll
|
// add single text scroll after hazards if present
|
||||||
resetScroll();
|
resetScroll();
|
||||||
|
addScroll(hazards);
|
||||||
addScroll(
|
addScroll(
|
||||||
() => (
|
() => (
|
||||||
{
|
{
|
||||||
@@ -81,6 +82,8 @@ const getFeed = async (url) => {
|
|||||||
|
|
||||||
// reset the scroll, then add the screens
|
// reset the scroll, then add the screens
|
||||||
resetScroll();
|
resetScroll();
|
||||||
|
// add the hazards scroll first
|
||||||
|
addScroll(hazards);
|
||||||
titles.forEach((title) => {
|
titles.forEach((title) => {
|
||||||
// data is provided to the screen handler, so we return a function
|
// data is provided to the screen handler, so we return a function
|
||||||
addScroll(
|
addScroll(
|
||||||
|
|||||||
@@ -5,21 +5,22 @@ import en from '../../vendor/auto/locale/en.js';
|
|||||||
|
|
||||||
// metar-taf-parser requires regex lookbehind
|
// metar-taf-parser requires regex lookbehind
|
||||||
// this does not work in iOS < 16.4
|
// this does not work in iOS < 16.4
|
||||||
// this is a detection algorithm for iOS versions
|
// this is a detection algorithm for missing lookbehind support
|
||||||
const isIos = /iP(ad|od|hone)/i.test(window.navigator.userAgent);
|
const supportsRegexLookAheadLookBehindCheck = () => {
|
||||||
let iosVersionOk = false;
|
try {
|
||||||
if (isIos) {
|
return (
|
||||||
// regex match the version string
|
// deliberately using RegExp for broader browser support during check
|
||||||
const iosVersionRaw = /OS (\d+)_(\d+)/.exec(window.navigator.userAgent);
|
/* eslint-disable prefer-regex-literals */
|
||||||
// check for match
|
'hibyehihi'
|
||||||
if (iosVersionRaw) {
|
.replace(new RegExp('(?<=hi)hi', 'g'), 'hello')
|
||||||
// break into parts
|
.replace(new RegExp('hi(?!bye)', 'g'), 'hey') === 'hibyeheyhello'
|
||||||
const iosVersionMajor = parseInt(iosVersionRaw[1], 10);
|
/* eslint-enable prefer-regex-literals */
|
||||||
const iosVersionMinor = parseInt(iosVersionRaw[2], 10);
|
);
|
||||||
if (iosVersionMajor > 16) iosVersionOk = true;
|
} catch {
|
||||||
if (iosVersionMajor === 16 && iosVersionMinor >= 4) iosVersionOk = true;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
const supportsRegexLookAheadLookBehind = supportsRegexLookAheadLookBehindCheck();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Augment observation data by parsing METAR when API fields are missing
|
* Augment observation data by parsing METAR when API fields are missing
|
||||||
@@ -27,8 +28,8 @@ if (isIos) {
|
|||||||
* @returns {Object} - Augmented observation with parsed METAR data filled in
|
* @returns {Object} - Augmented observation with parsed METAR data filled in
|
||||||
*/
|
*/
|
||||||
const augmentObservationWithMetar = (observation) => {
|
const augmentObservationWithMetar = (observation) => {
|
||||||
// check for a metar message and for unusable ios versions
|
// check for a metar message and for regex lookbehind support
|
||||||
if (!observation?.rawMessage || (isIos && !iosVersionOk)) {
|
if (!observation?.rawMessage || (!supportsRegexLookAheadLookBehind)) {
|
||||||
return observation;
|
return observation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,10 @@
|
|||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.eslint": "explicit"
|
||||||
}
|
},
|
||||||
|
"cSpell.words": [
|
||||||
|
"hibyehihi"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"extensions": {
|
"extensions": {
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
|
|||||||
Reference in New Issue
Block a user