+
+ function makeAttribution(credit) {
+ let attribution = "";
+
+ attribution += I18n.t("javascripts.map.copyright_text", {
+ copyright_link: $("<a>", {
+ href: "/copyright",
+ text: I18n.t("javascripts.map.openstreetmap_contributors")
+ }).prop("outerHTML")
+ });
+
+ attribution += credit.donate ? " ♥ " : ". ";
+ attribution += makeCredit(credit);
+ attribution += ". ";
+
+ attribution += $("<a>", {
+ href: "https://wiki.osmfoundation.org/wiki/Terms_of_Use",
+ text: I18n.t("javascripts.map.website_and_api_terms")
+ }).prop("outerHTML");
+
+ return attribution;
+ }
+
+ function makeCredit(credit) {
+ const children = {};
+ for (const childId in credit.children) {
+ children[childId] = makeCredit(credit.children[childId]);
+ }
+ const text = I18n.t(`javascripts.map.${credit.id}`, children);
+ if (credit.href) {
+ const link = $("<a>", {
+ href: credit.href,
+ text: text
+ });
+ if (credit.donate) {
+ link.addClass("donate-attr");
+ } else {
+ link.attr("target", "_blank");
+ }
+ return link.prop("outerHTML");
+ } else {
+ return text;
+ }
+ }