| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import Combine from "../Base/Combine" | 
					
						
							|  |  |  | import Translations from "../i18n/Translations" | 
					
						
							|  |  |  | import { Store, UIEventSource } from "../../Logic/UIEventSource" | 
					
						
							|  |  |  | import { FixedUiElement } from "../Base/FixedUiElement" | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  | import * as licenses from "../../assets/generated/license_info.json" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import SmallLicense from "../../Models/smallLicense" | 
					
						
							|  |  |  | import { Utils } from "../../Utils" | 
					
						
							|  |  |  | import Link from "../Base/Link" | 
					
						
							|  |  |  | import { VariableUiElement } from "../Base/VariableUIElement" | 
					
						
							| 
									
										
										
										
											2021-05-19 19:39:55 +02:00
										 |  |  | import * as contributors from "../../assets/contributors.json" | 
					
						
							| 
									
										
										
										
											2022-02-14 19:53:23 +01:00
										 |  |  | import * as translators from "../../assets/translators.json" | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | import BaseUIElement from "../BaseUIElement" | 
					
						
							|  |  |  | import LayoutConfig from "../../Models/ThemeConfig/LayoutConfig" | 
					
						
							|  |  |  | import Title from "../Base/Title" | 
					
						
							|  |  |  | import { SubtleButton } from "../Base/SubtleButton" | 
					
						
							|  |  |  | import Svg from "../../Svg" | 
					
						
							|  |  |  | import FeaturePipeline from "../../Logic/FeatureSource/FeaturePipeline" | 
					
						
							|  |  |  | import { BBox } from "../../Logic/BBox" | 
					
						
							|  |  |  | import Loc from "../../Models/Loc" | 
					
						
							|  |  |  | import Toggle from "../Input/Toggle" | 
					
						
							|  |  |  | import { OsmConnection } from "../../Logic/Osm/OsmConnection" | 
					
						
							|  |  |  | import Constants from "../../Models/Constants" | 
					
						
							|  |  |  | import ContributorCount from "../../Logic/ContributorCount" | 
					
						
							|  |  |  | import Img from "../Base/Img" | 
					
						
							|  |  |  | import { TypedTranslation } from "../i18n/Translation" | 
					
						
							|  |  |  | import TranslatorsPanel from "./TranslatorsPanel" | 
					
						
							|  |  |  | import { MapillaryLink } from "./MapillaryLink" | 
					
						
							|  |  |  | import FullWelcomePaneWithTabs from "./FullWelcomePaneWithTabs" | 
					
						
							| 
									
										
										
										
											2021-05-19 23:29:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  | export class OpenIdEditor extends VariableUiElement { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     constructor( | 
					
						
							|  |  |  |         state: { locationControl: UIEventSource<Loc> }, | 
					
						
							|  |  |  |         iconStyle?: string, | 
					
						
							|  |  |  |         objectId?: string | 
					
						
							|  |  |  |     ) { | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  |         const t = Translations.t.general.attribution | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         super( | 
					
						
							|  |  |  |             state.locationControl.map((location) => { | 
					
						
							|  |  |  |                 let elementSelect = "" | 
					
						
							|  |  |  |                 if (objectId !== undefined) { | 
					
						
							|  |  |  |                     const parts = objectId.split("/") | 
					
						
							|  |  |  |                     const tp = parts[0] | 
					
						
							|  |  |  |                     if ( | 
					
						
							|  |  |  |                         parts.length === 2 && | 
					
						
							|  |  |  |                         !isNaN(Number(parts[1])) && | 
					
						
							|  |  |  |                         (tp === "node" || tp === "way" || tp === "relation") | 
					
						
							|  |  |  |                     ) { | 
					
						
							|  |  |  |                         elementSelect = "&" + tp + "=" + parts[1] | 
					
						
							|  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 const idLink = `https://www.openstreetmap.org/edit?editor=id${elementSelect}#map=${ | 
					
						
							|  |  |  |                     location?.zoom ?? 0 | 
					
						
							|  |  |  |                 }/${location?.lat ?? 0}/${location?.lon ?? 0}`
 | 
					
						
							|  |  |  |                 return new SubtleButton(Svg.pencil_ui().SetStyle(iconStyle), t.editId, { | 
					
						
							|  |  |  |                     url: idLink, | 
					
						
							|  |  |  |                     newTab: true, | 
					
						
							|  |  |  |                 }) | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class OpenJosm extends Combine { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     constructor( | 
					
						
							|  |  |  |         state: { osmConnection: OsmConnection; currentBounds: Store<BBox> }, | 
					
						
							|  |  |  |         iconStyle?: string | 
					
						
							|  |  |  |     ) { | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  |         const t = Translations.t.general.attribution | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  |         const josmState = new UIEventSource<string>(undefined) | 
					
						
							|  |  |  |         // Reset after 15s
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         josmState.stabilized(15000).addCallbackD((_) => josmState.setData(undefined)) | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const stateIndication = new VariableUiElement( | 
					
						
							|  |  |  |             josmState.map((state) => { | 
					
						
							|  |  |  |                 if (state === undefined) { | 
					
						
							|  |  |  |                     return undefined | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 state = state.toUpperCase() | 
					
						
							|  |  |  |                 if (state === "OK") { | 
					
						
							|  |  |  |                     return t.josmOpened.SetClass("thanks") | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |                 return t.josmNotOpened.SetClass("alert") | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const toggle = new Toggle( | 
					
						
							|  |  |  |             new SubtleButton(Svg.josm_logo_ui().SetStyle(iconStyle), t.editJosm).onClick(() => { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 const bounds: any = state.currentBounds.data | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  |                 if (bounds === undefined) { | 
					
						
							|  |  |  |                     return undefined | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 const top = bounds.getNorth() | 
					
						
							|  |  |  |                 const bottom = bounds.getSouth() | 
					
						
							|  |  |  |                 const right = bounds.getEast() | 
					
						
							|  |  |  |                 const left = bounds.getWest() | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  |                 const josmLink = `http://127.0.0.1:8111/load_and_zoom?left=${left}&right=${right}&top=${top}&bottom=${bottom}` | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 Utils.download(josmLink) | 
					
						
							|  |  |  |                     .then((answer) => josmState.setData(answer.replace(/\n/g, "").trim())) | 
					
						
							|  |  |  |                     .catch((_) => josmState.setData("ERROR")) | 
					
						
							|  |  |  |             }), | 
					
						
							|  |  |  |             undefined, | 
					
						
							|  |  |  |             state.osmConnection.userDetails.map( | 
					
						
							|  |  |  |                 (ud) => ud.loggedIn && ud.csCount >= Constants.userJourney.historyLinkVisible | 
					
						
							|  |  |  |             ) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         super([stateIndication, toggle]) | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-07 01:32:39 +02:00
										 |  |  | /** | 
					
						
							|  |  |  |  * The attribution panel shown on mobile | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  | export default class CopyrightPanel extends Combine { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private static LicenseObject = CopyrightPanel.GenerateLicenses() | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     constructor(state: { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         layoutToUse: LayoutConfig | 
					
						
							|  |  |  |         featurePipeline: FeaturePipeline | 
					
						
							|  |  |  |         currentBounds: Store<BBox> | 
					
						
							|  |  |  |         locationControl: UIEventSource<Loc> | 
					
						
							|  |  |  |         osmConnection: OsmConnection | 
					
						
							| 
									
										
										
										
											2022-06-19 13:55:33 +02:00
										 |  |  |         isTranslator: Store<boolean> | 
					
						
							| 
									
										
										
										
											2021-11-21 02:44:35 +01:00
										 |  |  |     }) { | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |         const t = Translations.t.general.attribution | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |         const layoutToUse = state.layoutToUse | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |         const imgSize = "h-6 w-6" | 
					
						
							|  |  |  |         const iconStyle = "height: 1.5rem; width: 1.5rem" | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |         const actionButtons = [ | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |             new SubtleButton(Svg.liberapay_ui(), t.donate, { | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |                 url: "https://liberapay.com/pietervdvn/", | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |                 newTab: true, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 imgSize, | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |             }), | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |             new SubtleButton(Svg.bug_ui(), t.openIssueTracker, { | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |                 url: "https://github.com/pietervdvn/MapComplete/issues", | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |                 newTab: true, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 imgSize, | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |             }), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             new SubtleButton( | 
					
						
							|  |  |  |                 Svg.statistics_ui(), | 
					
						
							|  |  |  |                 t.openOsmcha.Subs({ theme: state.layoutToUse.title }), | 
					
						
							| 
									
										
										
										
											2022-06-03 19:15:59 +02:00
										 |  |  |                 { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                     url: Utils.OsmChaLinkFor(31, state.layoutToUse.id), | 
					
						
							|  |  |  |                     newTab: true, | 
					
						
							|  |  |  |                     imgSize, | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |             new SubtleButton( | 
					
						
							|  |  |  |                 Svg.mastodon_ui(), | 
					
						
							|  |  |  |                 new Combine([t.followOnMastodon.SetClass("font-bold"), t.followBridge]).SetClass( | 
					
						
							|  |  |  |                     "flex flex-col" | 
					
						
							|  |  |  |                 ), | 
					
						
							|  |  |  |                 { | 
					
						
							|  |  |  |                     url: "https://en.osm.town/web/notifications", | 
					
						
							|  |  |  |                     newTab: true, | 
					
						
							|  |  |  |                     imgSize, | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |             new SubtleButton(Svg.twitter_ui(), t.followOnTwitter, { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 url: "https://twitter.com/mapcomplete", | 
					
						
							| 
									
										
										
										
											2022-07-01 00:16:05 +02:00
										 |  |  |                 newTab: true, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 imgSize, | 
					
						
							| 
									
										
										
										
											2022-06-03 19:15:59 +02:00
										 |  |  |             }), | 
					
						
							| 
									
										
										
										
											2021-12-23 21:28:41 +01:00
										 |  |  |             new OpenIdEditor(state, iconStyle), | 
					
						
							| 
									
										
										
										
											2022-05-06 12:41:24 +02:00
										 |  |  |             new MapillaryLink(state, iconStyle), | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |             new OpenJosm(state, iconStyle), | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             new TranslatorsPanel(state, iconStyle), | 
					
						
							| 
									
										
										
										
											2021-11-08 19:49:20 +01:00
										 |  |  |         ] | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 22:37:21 +01:00
										 |  |  |         const iconAttributions = layoutToUse.usedImages.map(CopyrightPanel.IconAttribution) | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         let maintainer: BaseUIElement = undefined | 
					
						
							| 
									
										
										
										
											2022-08-22 14:46:55 +02:00
										 |  |  |         if (layoutToUse.credits !== undefined && layoutToUse.credits !== "") { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             maintainer = t.themeBy.Subs({ author: layoutToUse.credits }) | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-26 21:40:38 +01:00
										 |  |  |         const contributions = new ContributorCount(state).Contributors | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         const dataContributors = new VariableUiElement( | 
					
						
							|  |  |  |             contributions.map((contributions) => { | 
					
						
							| 
									
										
										
										
											2021-11-07 16:34:51 +01:00
										 |  |  |                 if (contributions === undefined) { | 
					
						
							| 
									
										
										
										
											2021-09-21 02:10:42 +02:00
										 |  |  |                     return "" | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2021-06-27 02:41:30 +02:00
										 |  |  |                 const sorted = Array.from(contributions, ([name, value]) => ({ | 
					
						
							|  |  |  |                     name, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                     value, | 
					
						
							|  |  |  |                 })).filter((x) => x.name !== undefined && x.name !== "undefined") | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                 if (sorted.length === 0) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                     return "" | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 sorted.sort((a, b) => b.value - a.value) | 
					
						
							|  |  |  |                 let hiddenCount = 0 | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                 if (sorted.length > 10) { | 
					
						
							|  |  |  |                     hiddenCount = sorted.length - 10 | 
					
						
							|  |  |  |                     sorted.splice(10, sorted.length - 10) | 
					
						
							|  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 const links = sorted.map( | 
					
						
							|  |  |  |                     (kv) => | 
					
						
							|  |  |  |                         `<a href="https://openstreetmap.org/user/${kv.name}" target="_blank">${kv.name}</a>` | 
					
						
							|  |  |  |                 ) | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                 const contribs = links.join(", ") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-24 14:21:41 +02:00
										 |  |  |                 if (hiddenCount <= 0) { | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |                     return t.mapContributionsBy.Subs({ | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                         contributors: contribs, | 
					
						
							| 
									
										
										
										
											2021-06-10 01:36:20 +02:00
										 |  |  |                     }) | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |                     return t.mapContributionsByAndHidden.Subs({ | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                         contributors: contribs, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                         hiddenCount: hiddenCount, | 
					
						
							|  |  |  |                     }) | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             }) | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         super( | 
					
						
							|  |  |  |             [ | 
					
						
							|  |  |  |                 new Title(t.attributionTitle), | 
					
						
							|  |  |  |                 t.attributionContent, | 
					
						
							|  |  |  |                 maintainer, | 
					
						
							|  |  |  |                 dataContributors, | 
					
						
							|  |  |  |                 CopyrightPanel.CodeContributors(contributors, t.codeContributionsBy), | 
					
						
							|  |  |  |                 CopyrightPanel.CodeContributors(translators, t.translatedBy), | 
					
						
							|  |  |  |                 new FixedUiElement("MapComplete " + Constants.vNumber).SetClass("font-bold"), | 
					
						
							|  |  |  |                 new Combine(actionButtons).SetClass("block w-full link-no-underline"), | 
					
						
							|  |  |  |                 new Title(t.iconAttribution.title, 3), | 
					
						
							|  |  |  |                 ...iconAttributions, | 
					
						
							|  |  |  |             ].map((e) => e?.SetClass("mt-4")) | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2021-07-03 21:18:19 +02:00
										 |  |  |         this.SetClass("flex flex-col link-underline overflow-hidden") | 
					
						
							| 
									
										
										
										
											2022-02-01 04:14:54 +01:00
										 |  |  |         this.SetStyle("max-width:100%; width: 40rem; margin-left: 0.75rem; margin-right: 0.5rem") | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |     private static CodeContributors( | 
					
						
							|  |  |  |         contributors, | 
					
						
							|  |  |  |         translation: TypedTranslation<{ contributors; hiddenCount }> | 
					
						
							|  |  |  |     ): BaseUIElement { | 
					
						
							|  |  |  |         const total = contributors.contributors.length | 
					
						
							| 
									
										
										
										
											2021-06-27 02:41:30 +02:00
										 |  |  |         let filtered = [...contributors.contributors] | 
					
						
							| 
									
										
										
										
											2021-05-19 23:29:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         filtered.splice(10, total - 10) | 
					
						
							| 
									
										
										
										
											2021-05-19 23:29:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         let contribsStr = filtered.map((c) => c.contributor).join(", ") | 
					
						
							| 
									
										
										
										
											2021-06-27 02:41:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (contribsStr === "") { | 
					
						
							| 
									
										
										
										
											2021-05-27 18:56:02 +02:00
										 |  |  |             // Hmm, something went wrong loading the contributors list. Lets show nothing
 | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             return undefined | 
					
						
							| 
									
										
										
										
											2021-05-27 18:56:02 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-05-19 23:29:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-14 19:53:23 +01:00
										 |  |  |         return translation.Subs({ | 
					
						
							| 
									
										
										
										
											2021-05-19 23:29:23 +02:00
										 |  |  |             contributors: contribsStr, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             hiddenCount: total - 10, | 
					
						
							|  |  |  |         }) | 
					
						
							| 
									
										
										
										
											2021-05-19 19:39:55 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-05-19 23:29:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-12 02:58:32 +02:00
										 |  |  |     private static IconAttribution(iconPath: string): BaseUIElement { | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |         if (iconPath.startsWith("http")) { | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |             try { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 iconPath = "." + new URL(iconPath).pathname | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |             } catch (e) { | 
					
						
							| 
									
										
										
										
											2022-02-22 13:43:36 +01:00
										 |  |  |                 console.warn(e) | 
					
						
							| 
									
										
										
										
											2022-02-14 15:41:14 +01:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 01:55:32 +02:00
										 |  |  |         const license: SmallLicense = CopyrightPanel.LicenseObject[iconPath] | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |         if (license == undefined) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             return undefined | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |         if (license.license.indexOf("trivial") >= 0) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             return undefined | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-10 23:48:00 +02:00
										 |  |  |         const sources = Utils.NoNull(Utils.NoEmpty(license.sources)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |         return new Combine([ | 
					
						
							| 
									
										
										
										
											2022-02-09 22:37:21 +01:00
										 |  |  |             new Img(iconPath).SetClass("w-12 min-h-12 mr-2 mb-2"), | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |             new Combine([ | 
					
						
							|  |  |  |                 new FixedUiElement(license.authors.join("; ")).SetClass("font-bold"), | 
					
						
							| 
									
										
										
										
											2022-04-01 12:51:55 +02:00
										 |  |  |                 license.license, | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |                 new Combine([ | 
					
						
							|  |  |  |                     ...sources.map((lnk) => { | 
					
						
							|  |  |  |                         let sourceLinkContent = lnk | 
					
						
							|  |  |  |                         try { | 
					
						
							|  |  |  |                             sourceLinkContent = new URL(lnk).hostname | 
					
						
							|  |  |  |                         } catch { | 
					
						
							|  |  |  |                             console.error("Not a valid URL:", lnk) | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                         return new Link(sourceLinkContent, lnk, true).SetClass("mr-2 mb-2") | 
					
						
							|  |  |  |                     }), | 
					
						
							|  |  |  |                 ]).SetClass("flex flex-wrap"), | 
					
						
							|  |  |  |             ]) | 
					
						
							|  |  |  |                 .SetClass("flex flex-col") | 
					
						
							|  |  |  |                 .SetStyle("width: calc(100% - 50px - 0.5em); min-width: 12rem;"), | 
					
						
							| 
									
										
										
										
											2021-07-03 21:18:19 +02:00
										 |  |  |         ]).SetClass("flex flex-wrap border-b border-gray-300 m-2 border-box") | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private static GenerateLicenses() { | 
					
						
							|  |  |  |         const allLicenses = {} | 
					
						
							|  |  |  |         for (const key in licenses) { | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |             const license: SmallLicense = licenses[key] | 
					
						
							| 
									
										
										
										
											2021-04-09 02:57:06 +02:00
										 |  |  |             allLicenses[license.path] = license | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  |         return allLicenses | 
					
						
							| 
									
										
										
										
											2021-04-07 01:32:39 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-09-08 21:40:48 +02:00
										 |  |  | } |