From: Tom Hughes Date: Mon, 15 Jul 2019 19:27:42 +0000 (+0100) Subject: Stop creating a shared global querystring variable X-Git-Tag: live~3084 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6dd451c7ee48663d6b0753bfe8b4da2060c4cf60?ds=sidebyside Stop creating a shared global querystring variable --- diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 7c2e4665e..fbc76e4a8 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,16 +17,15 @@ //= require richtext //= require querystring -var qs = require("querystring-component"); - /* * Called as the user scrolls/zooms around to maniplate hrefs of the * view tab and various other links */ window.updateLinks = function (loc, zoom, layers, object) { $(".geolink").each(function (index, link) { - var href = link.href.split(/[?#]/)[0], - args = qs.parse(link.search.substring(1)), + var querystring = require("querystring-component"), + href = link.href.split(/[?#]/)[0], + args = querystring.parse(link.search.substring(1)), editlink = $(link).hasClass("editlink"); delete args.node; @@ -38,7 +37,7 @@ window.updateLinks = function (loc, zoom, layers, object) { args[object.type] = object.id; } - var query = qs.stringify(args); + var query = querystring.stringify(args); if (query) href += "?" + query; args = { diff --git a/app/assets/javascripts/edit/id.js.erb b/app/assets/javascripts/edit/id.js.erb index 933031d8c..23726519e 100644 --- a/app/assets/javascripts/edit/id.js.erb +++ b/app/assets/javascripts/edit/id.js.erb @@ -1,4 +1,7 @@ +//= require querystring + $(document).ready(function () { + var querystring = require("querystring-component"); var id = $("#id-embed"); if (id.data("key")) { @@ -36,7 +39,7 @@ $(document).ready(function () { params.gpx = hashParams.gpx; } - id.attr("src", id.data("url") + "#" + qs.stringify(params)); + id.attr("src", id.data("url") + "#" + querystring.stringify(params)); } else { alert(I18n.t("site.edit.id_not_configured")); } diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index d15ee5859..2c7d70e11 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -21,8 +21,11 @@ //= require index/query //= require router //= require bowser +//= require querystring $(document).ready(function () { + var querystring = require("querystring-component"); + var loaderTimeout; var map = new L.OSM.Map("map", { @@ -264,7 +267,7 @@ $(document).ready(function () { var iframe = $("