diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-17 16:02:28 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-08-17 16:43:22 +0100 |
commit | 17e389222fd65b15a4004df28aacdc4c45bfd443 (patch) | |
tree | e021275955ecfd3ab4f8011c947b81df14a81a7d | |
parent | 1d9e10e980e480196ba1a5f1a3bc450a06b78dde (diff) |
Do not fetch pins server side if JS enabled.
The page currently fetches the pins again client-side (as we don't know
the extent of the map at the server point). I realise this isn't ideal,
but should speed up the normal case quite a bit.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 2 | ||||
-rw-r--r-- | web/cobrands/fixmystreet/fixmystreet.js | 7 |
2 files changed, 9 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index 4a82c67cc..b872084ff 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -249,6 +249,8 @@ sub map_features : Private { $c->stash->{all_pins} = $all_pins; my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age; + return if $c->get_param('js'); # JS will request the same (or more) data client side + my ( $on_map_all, $on_map_list, $nearby, $distance ) = FixMyStreet::Map::map_features( $c, interval => $interval, %$extra, diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js index 291455aa7..49f14f0de 100644 --- a/web/cobrands/fixmystreet/fixmystreet.js +++ b/web/cobrands/fixmystreet/fixmystreet.js @@ -256,6 +256,13 @@ $.extend(fixmystreet.set_up, { document.createElement('img').src = '/i/pin-green.png'; } + $('a[href*="around"]').each(function() { + this.href = this.href + (this.href.indexOf('?') > -1 ? '&js=1' : '?js=1'); + }); + $('form[action*="around"]').each(function() { + $('<input type="hidden" name="js" value="1">').prependTo(this); + }); + // Focus on postcode box on front page $('#pc').focus(); |