Skip to content

Commit d0fd248

Browse files
committed
Clean OSM.formatHash calls
1 parent b1aedc5 commit d0fd248

File tree

5 files changed

+11
-31
lines changed

5 files changed

+11
-31
lines changed

app/assets/javascripts/fixthemap.js

-8
This file was deleted.

app/assets/javascripts/index/history.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,7 @@ OSM.History = function (map) {
142142

143143
function setPaginationMapHashes() {
144144
$("#sidebar .pagination a").each(function () {
145-
$(this).prop("hash", OSM.formatHash({
146-
center: map.getCenter(),
147-
zoom: map.getZoom()
148-
}));
145+
$(this).prop("hash", OSM.formatHash(map));
149146
});
150147
}
151148

app/assets/javascripts/welcome.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
$(function () {
2-
const params = new URLSearchParams(location.search);
3-
4-
if (params.has("lat") && params.has("lon")) {
5-
let url = "/edit";
6-
7-
if (params.has("editor")) url += "?editor=" + params.get("editor");
8-
if (!params.has("zoom")) params.set("zoom", 17);
9-
url += OSM.formatHash(params);
10-
11-
$(".start-mapping").attr("href", url);
12-
} else {
13-
$(".start-mapping").on("click", function (e) {
2+
const mappingBtn = $(".start-mapping");
3+
if (!mappingBtn.attr("href").includes("#map=")) {
4+
mappingBtn.on("click", function (e) {
145
e.preventDefault();
15-
$(".start-mapping").addClass("loading");
6+
mappingBtn.addClass("loading");
167

178
if (navigator.geolocation) {
189
navigator.geolocation.getCurrentPosition(geoSuccess, manualEdit);

app/views/site/fixthemap.html.erb

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
<% content_for :head do %>
2-
<%= javascript_include_tag "fixthemap" %>
3-
<% end %>
4-
51
<% content_for :heading do %>
62
<h1><%= t ".title" %></h1>
73
<% end %>
@@ -22,7 +18,9 @@
2218
<div class='col-sm'>
2319
<h3 class='fs-5'><%= t "site.welcome.add_a_note.title" %></h3>
2420
<p><%= t "site.welcome.add_a_note.para_1" %></p>
25-
<p><%= t ".how_to_help.add_a_note.instructions_1_html", :note_icon => tag.a(:class => "icon note bg-dark rounded-1",
21+
<p><%= map_hash = "#map=#{params[:zoom].to_i || 17}/#{params[:lat].to_f}/#{params[:lon].to_f}" if params[:lat].present? && params[:lon].present?
22+
t ".how_to_help.add_a_note.instructions_1_html", :note_icon => tag.a(:class => "icon note bg-dark rounded-1",
23+
:href => "#{new_note_path}#{map_hash || ''}",
2624
:title => t("javascripts.site.createnote_tooltip")) %></p>
2725
</div>
2826
</div>

app/views/site/welcome.html.erb

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
<% if params[:oauth_return_url] %>
8282
<a class="btn btn-primary" href="<%= params[:oauth_return_url] %>"><%= t ".continue_authorization" %></a>
8383
<% else %>
84-
<a class="btn btn-primary start-mapping" href="<%= edit_path %>"><%= t ".start_mapping" %></a>
84+
<%= map_hash = "#map=#{params[:zoom].to_i || 17}/#{params[:lat].to_f}/#{params[:lon].to_f}" if params[:lat].present? && params[:lon].present?
85+
editor_query = "?editor=#{params[:editor].to_s.split(/\W/)[0]}" if params[:editor].present?
86+
link_to t(".start_mapping"), "#{edit_path}#{editor_query || ''}#{map_hash || ''}", :class => "btn btn-primary start-mapping" %>
8587
<% end %>
8688
</div>
8789

0 commit comments

Comments
 (0)