forked from MapComplete/MapComplete
Housekeeping: formatting
This commit is contained in:
parent
9d53a45f9a
commit
1528dfaae1
168 changed files with 3332 additions and 4560 deletions
|
|
@ -23,7 +23,7 @@
|
|||
function update() {
|
||||
const v = currentVal.data
|
||||
const l = currentLang.data
|
||||
if (<any> translations.data === "" || translations.data === undefined) {
|
||||
if (<any>translations.data === "" || translations.data === undefined) {
|
||||
translations.data = {}
|
||||
}
|
||||
if (translations.data[l] === v) {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@
|
|||
*/
|
||||
export let unvalidatedText = new UIEventSource(value.data ?? "")
|
||||
|
||||
|
||||
if(unvalidatedText == /*Compare by reference!*/ value){
|
||||
if (unvalidatedText == /*Compare by reference!*/ value) {
|
||||
throw "Value and unvalidatedText may not be the same store!"
|
||||
}
|
||||
let validator: Validator = Validators.get(type ?? "string")
|
||||
|
|
@ -55,14 +54,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function onKeyPress(e: KeyboardEvent){
|
||||
if(e.key === "Enter"){
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
dispatch("submit")
|
||||
}
|
||||
function onKeyPress(e: KeyboardEvent) {
|
||||
if (e.key === "Enter") {
|
||||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
dispatch("submit")
|
||||
}
|
||||
}
|
||||
initValueAndDenom()
|
||||
|
||||
|
|
@ -139,7 +136,7 @@
|
|||
|
||||
let htmlElem: HTMLInputElement | HTMLTextAreaElement
|
||||
|
||||
let dispatch = createEventDispatcher<{ selected, submit }>()
|
||||
let dispatch = createEventDispatcher<{ selected; submit }>()
|
||||
$: {
|
||||
if (htmlElem !== undefined) {
|
||||
htmlElem.onfocus = () => dispatch("selected")
|
||||
|
|
@ -174,7 +171,13 @@
|
|||
{/if}
|
||||
|
||||
{#if unit !== undefined}
|
||||
<UnitInput {unit} {selectedUnit} textValue={unvalidatedText} upstreamValue={value} {getCountry} />
|
||||
<UnitInput
|
||||
{unit}
|
||||
{selectedUnit}
|
||||
textValue={unvalidatedText}
|
||||
upstreamValue={value}
|
||||
{getCountry}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ export default class Validators {
|
|||
"fediverse",
|
||||
"id",
|
||||
"slope",
|
||||
"velopark"
|
||||
"velopark",
|
||||
] as const
|
||||
|
||||
public static readonly AllValidators: ReadonlyArray<Validator> = [
|
||||
|
|
@ -88,7 +88,7 @@ export default class Validators {
|
|||
new FediverseValidator(),
|
||||
new IdValidator(),
|
||||
new SlopeValidator(),
|
||||
new VeloparkValidator()
|
||||
new VeloparkValidator(),
|
||||
]
|
||||
|
||||
private static _byType = Validators._byTypeConstructor()
|
||||
|
|
|
|||
|
|
@ -12,14 +12,22 @@ export default class VeloparkValidator extends UrlValidator {
|
|||
return superF
|
||||
}
|
||||
const url = new URL(s)
|
||||
if (url.hostname !== "velopark.be" && url.hostname !== "www.velopark.be" && url.hostname !== "data.velopark.be") {
|
||||
if (
|
||||
url.hostname !== "velopark.be" &&
|
||||
url.hostname !== "www.velopark.be" &&
|
||||
url.hostname !== "data.velopark.be"
|
||||
) {
|
||||
return new Translation({ "*": "Invalid hostname, expected velopark.be" })
|
||||
}
|
||||
|
||||
if(!s.startsWith("https://data.velopark.be/data/") && !s.startsWith("https://www.velopark.be/static/data/")){
|
||||
return new Translation({"*":"A valid URL should either start with https://data.velopark.be/data/ or https://www.velopark.be/static/data/"})
|
||||
if (
|
||||
!s.startsWith("https://data.velopark.be/data/") &&
|
||||
!s.startsWith("https://www.velopark.be/static/data/")
|
||||
) {
|
||||
return new Translation({
|
||||
"*": "A valid URL should either start with https://data.velopark.be/data/ or https://www.velopark.be/static/data/",
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public isValid(str: string) {
|
||||
|
|
@ -28,9 +36,9 @@ export default class VeloparkValidator extends UrlValidator {
|
|||
|
||||
reformat(str: string): string {
|
||||
const url = new URL(super.reformat(str))
|
||||
if(url.pathname.startsWith("/static/data/")){
|
||||
const id = str.substring(str.lastIndexOf("/")+1)
|
||||
return "https://data.velopark.be/data/"+id
|
||||
if (url.pathname.startsWith("/static/data/")) {
|
||||
const id = str.substring(str.lastIndexOf("/") + 1)
|
||||
return "https://data.velopark.be/data/" + id
|
||||
}
|
||||
return super.reformat(str)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue