1 OSM.Note = function (map) {
 
   2   const content = $("#sidebar_content"),
 
   7       iconUrl: OSM.NEW_NOTE_MARKER,
 
  12       iconUrl: OSM.OPEN_NOTE_MARKER,
 
  17       iconUrl: OSM.CLOSED_NOTE_MARKER,
 
  23   page.pushstate = page.popstate = function (path, id) {
 
  24     OSM.loadSidebarContent(path, function () {
 
  25       const data = $(".details").data();
 
  27       const latLng = L.latLng(data.coordinates.split(","));
 
  28       initialize(path, id, map.getBounds().contains(latLng));
 
  32   page.load = function (path, id) {
 
  36   function initialize(path, id, skipMoveToNote) {
 
  37     content.find("button[name]").on("click", function (e) {
 
  39       const { url, method } = $(e.target).data(),
 
  40             name = $(e.target).attr("name"),
 
  41             data = new URLSearchParams();
 
  42       content.find("button[name]").prop("disabled", true);
 
  44       if (name !== "subscribe" && name !== "unsubscribe" && name !== "reopen") {
 
  45         data.set("text", content.find("textarea").val());
 
  50         headers: { ...OSM.oauth },
 
  54           if (response.ok) return response;
 
  55           return response.text().then(text => {
 
  56             throw new Error(text);
 
  60           OSM.loadSidebarContent(path, () => {
 
  61             initialize(path, id, false);
 
  65           content.find("#comment-error")
 
  67             .prop("hidden", false)
 
  68             .get(0).scrollIntoView({ block: "nearest" });
 
  73     content.find("textarea").on("input", function (e) {
 
  74       updateButtons(e.target.form);
 
  77     content.find("textarea").val("").trigger("input");
 
  79     const data = $(".details").data();
 
  82       const hashParams = OSM.parseHash();
 
  86         latLng: L.latLng(data.coordinates.split(",")),
 
  87         icon: noteIcons[data.status]
 
  89         if (!hashParams.center && !skipMoveToNote) {
 
  90           const latLng = L.latLng(data.coordinates.split(","));
 
  91           OSM.router.withoutMoveListener(function () {
 
  92             map.setView(latLng, 15, { reset: true });
 
  99   function updateButtons() {
 
 100     const resolveButton = content.find("button[name='close']");
 
 101     const commentButton = content.find("button[name='comment']");
 
 103     content.find("button[name]").prop("disabled", false);
 
 104     if (content.find("textarea").val() === "") {
 
 105       resolveButton.text(resolveButton.data("defaultActionText"));
 
 106       commentButton.prop("disabled", true);
 
 108       resolveButton.text(resolveButton.data("commentActionText"));
 
 112   page.unload = function () {