diff --git a/src/Logic/Osm/OsmWiki.ts b/src/Logic/Osm/OsmWiki.ts
new file mode 100644
index 0000000000..0622aa0ebe
--- /dev/null
+++ b/src/Logic/Osm/OsmWiki.ts
@@ -0,0 +1,26 @@
+/**
+ * Various tools for the OSM wiki
+ */
+export default class OsmWiki {
+
+ /**
+ * Create a link to the wiki for the given key and value (optional)
+ * @param key
+ * @param value
+ */
+ public static constructLink(key: string, value?: string) : string{
+ if (value !== undefined) {
+ return `https://wiki.openstreetmap.org/wiki/Tag:${key}%3D${value}`
+ }
+ return "https://wiki.openstreetmap.org/wiki/Key:" + key
+ }
+
+ public static constructLinkMd(key: string, value?: string) : string {
+ const link = this.constructLink(key, value)
+ let displayed = key
+ if(value){
+ displayed += "="+value
+ }
+ return `[${displayed}](${link})`
+ }
+}
diff --git a/src/Logic/Tags/Tag.ts b/src/Logic/Tags/Tag.ts
index 581ad58159..017124c433 100644
--- a/src/Logic/Tags/Tag.ts
+++ b/src/Logic/Tags/Tag.ts
@@ -6,6 +6,7 @@ import { RegexTag } from "./RegexTag"
import { OptimizedTag } from "./TagTypes"
import { Or } from "./Or"
import { And } from "./And"
+import OsmWiki from "../Osm/OsmWiki"
export class Tag extends TagsFilter {
public key: string
@@ -113,10 +114,12 @@ export class Tag extends TagsFilter {
return "" + this.key + ""
}
if (linkToWiki) {
+ const hrefK = OsmWiki.constructLink(this.key)
+ const hrefKV = OsmWiki.constructLink(this.key, this.value)
return (
- `${this.key}` +
+ `${this.key}` +
`=` +
- `${v}`
+ `${v}`
)
}
return this.key + "=" + v
diff --git a/src/Models/ThemeConfig/LayerConfig.ts b/src/Models/ThemeConfig/LayerConfig.ts
index db66b509e7..6ca6f23eb4 100644
--- a/src/Models/ThemeConfig/LayerConfig.ts
+++ b/src/Models/ThemeConfig/LayerConfig.ts
@@ -13,7 +13,6 @@ import PointRenderingConfig from "./PointRenderingConfig"
import WithContextLoader from "./WithContextLoader"
import LineRenderingConfig from "./LineRenderingConfig"
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
-import Link from "../../UI/Base/Link"
import { Utils } from "../../Utils"
import { TagsFilter } from "../../Logic/Tags/TagsFilter"
import FilterConfigJson from "./Json/FilterConfigJson"
@@ -22,6 +21,7 @@ import Constants from "../Constants"
import { QuestionableTagRenderingConfigJson } from "./Json/QuestionableTagRenderingConfigJson"
import MarkdownUtils from "../../Utils/MarkdownUtils"
import { And } from "../../Logic/Tags/And"
+import OsmWiki from "../../Logic/Osm/OsmWiki"
export default class LayerConfig extends WithContextLoader {
public static readonly syncSelectionAllowed = ["no", "local", "theme-only", "global"] as const
@@ -574,7 +574,7 @@ export default class LayerConfig extends WithContextLoader {
.filter((values) => values.key !== "id")
.map((values) => {
const embedded: string[] = values.values?.map((v) =>
- Link.OsmWiki(values.key, v, true).SetClass("mr-2").AsMarkdown()
+ OsmWiki.constructLinkMd(values.key, v)
) ?? ["_no preset options defined, or no values in them_"]
const statistics = `https://taghistory.raifer.tech/?#***/${encodeURIComponent(
values.key
@@ -584,8 +584,7 @@ export default class LayerConfig extends WithContextLoader {
[
`
`,
`
`,
-
- Link.OsmWiki(values.key).AsMarkdown(),
+ OsmWiki.constructLinkMd(values.key),
].join(" "),
values.type === undefined
? "Multiple choice"
diff --git a/src/UI/Base/Link.ts b/src/UI/Base/Link.ts
deleted file mode 100644
index 4a600fea01..0000000000
--- a/src/UI/Base/Link.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import Translations from "../i18n/Translations"
-import BaseUIElement from "../BaseUIElement"
-import { Store } from "../../Logic/UIEventSource"
-
-export default class Link extends BaseUIElement {
- private readonly _href: string | Store
- private readonly _embeddedShow: BaseUIElement
- private readonly _newTab: boolean
- private readonly _download: string
-
- constructor(
- embeddedShow: BaseUIElement | string,
- href: string | Store,
- newTab: boolean = false,
- download: string = undefined
- ) {
- super()
- this._download = download
- this._embeddedShow = Translations.W(embeddedShow)
- this._href = href
- this._newTab = newTab
- if (this._embeddedShow === undefined) {
- throw "Error: got a link where embeddedShow is undefined"
- }
- this.onClick(() => {})
- }
-
- public static OsmWiki(key: string, value?: string, hideKey = false) {
- if (value !== undefined) {
- let k = ""
- if (!hideKey) {
- k = key + "="
- }
- return new Link(
- k + value,
- `https://wiki.openstreetmap.org/wiki/Tag:${key}%3D${value}`,
- true
- )
- }
- return new Link(key, "https://wiki.openstreetmap.org/wiki/Key:" + key, true)
- }
-
- AsMarkdown(): string {
- // @ts-ignore
- return `[${this._embeddedShow.AsMarkdown()}](${this._href.data ?? this._href})`
- }
-
- protected InnerConstructElement(): HTMLElement {
- const embeddedShow = this._embeddedShow?.ConstructElement()
- if (embeddedShow === undefined) {
- return undefined
- }
- const el = document.createElement("a")
- if (typeof this._href === "string") {
- el.setAttribute("href", this._href)
- } else {
- this._href.addCallbackAndRun((href) => {
- el.setAttribute("href", href)
- })
- }
- if (this._newTab) {
- el.target = "_blank"
- }
- if (this._download) {
- el.setAttribute("download", this._download)
- }
- el.appendChild(embeddedShow)
- return el
- }
-}