From 6dd451c7ee48663d6b0753bfe8b4da2060c4cf60 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 15 Jul 2019 20:27:42 +0100 Subject: [PATCH] Stop creating a shared global querystring variable --- app/assets/javascripts/application.js | 9 ++++----- app/assets/javascripts/edit/id.js.erb | 5 ++++- app/assets/javascripts/index.js | 7 +++++-- app/assets/javascripts/index/contextmenu.js | 8 ++++++-- app/assets/javascripts/index/directions.js | 9 ++++++--- app/assets/javascripts/index/new_note.js | 6 +++++- app/assets/javascripts/index/query.js | 5 ++++- app/assets/javascripts/index/search.js | 5 ++++- app/assets/javascripts/leaflet.map.js | 10 +++++++--- app/assets/javascripts/login.js | 10 +++++++--- app/assets/javascripts/osm.js.erb | 6 ++++-- config/eslint.json | 1 - 12 files changed, 56 insertions(+), 25 deletions(-) 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 = $("