[openstreetmap/openstreetmap-website] display warning in new note form after too many anonymous notes (PR #5468)

Anton Khorev notifications at github.com
Mon Jan 6 08:08:31 UTC 2025


@AntonKhorev commented on this pull request.



> @@ -152,6 +152,16 @@ OSM.NewNote = function (map) {
       .on("input", updateControls)
       .focus();
 
+    var anonymousNotesCount = Number(localStorage.getItem("anonymousNotesCount"));
+
+    if (typeof OSM.user === "undefined" && anonymousNotesCount >= 20) {
+      var counterWarning = content.find("#new-note-counter-warning");
+      if (typeof counterWarning.html() !== "undefined") {
+        counterWarning.html(counterWarning.html().replace("(N)", anonymousNotesCount));

There is i18n library in javascript too but it's better to avoid it if possible. You'd have to declare strings in a different section of `en.yml`, then all of those strings are sent over to the client.

Example of javascript i18n with count:
https://github.com/openstreetmap/openstreetmap-website/blob/97b14ce22a0c7d17bb0b303b3795297721bc31d4/app/assets/javascripts/leaflet.locate.js#L8

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5468#discussion_r1903803530
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/5468/review/2531568488 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20250106/2a9f9f88/attachment.htm>


More information about the rails-dev mailing list