From f88e70a1a3626e1bd8fb0b5cc3e93c80bb587527 Mon Sep 17 00:00:00 2001 From: RyanTG Date: Sun, 8 Dec 2024 19:37:15 -0800 Subject: [PATCH] Removed unnecessary js from redone function --- app/assets/javascripts/application.js.erb | 64 ++++++++++------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index e9c8ab3b..b7bf06cd 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -12,7 +12,6 @@ var zoomLevel; var markers = new Array(); var locationIDs = new Array(); var searchSections = new Array(); -const REDO_TIMEOUT = 200; function toggleData(name, id) { var main = id ? '_' + id : ''; @@ -196,43 +195,36 @@ function refreshButton() { function redone() { hideRefresh(); - var mapupdater; - zoomLevel = map.getZoom(); - document.getElementById("zoom_in_more").style.display = "none"; - window.clearTimeout(mapupdater); - mapupdater = window.setTimeout(function () { - - var bounds = map.getBounds(); - var sw = bounds.getSouthWest(); - var ne = bounds.getNorthEast(); - - var dfd = $.getJSON('/api/v1/locations/within_bounding_box.json?no_details=1;swlat=' + sw.lat + ';swlon=' + sw.lng + ';nelat=' + ne.lat + ';nelon=' + ne.lng + searchMachineIDString + numMachinesVal + locationTypeVal); - - dfd.done(function (response) { - if (!response.locations) { - var locationIds = []; - document.getElementById("locations").innerHTML = "

" + "No pinball found in this area." + "

"; - } else { - var locationIds = []; - for (var i = 0; i < response.locations.length; i++) { - locationIds.push(response.locations[i].id) - } - if (ismap == 1) { - var url = '/locations?map_location_data=;by_location_id=' + locationIds.join('_'); - } - else { - var url = '/locations?region=' + region + '&by_location_id=' + locationIds.join('_'); - } - - document.getElementById('search_link_wrapper').style.display = "none"; - $('#locations').html(loadingHTML()); - $.get(url, function (data) { - $('#locations').html(data); - }); - } + var bounds = map.getBounds(); + var sw = bounds.getSouthWest(); + var ne = bounds.getNorthEast(); + + var dfd = $.getJSON('/api/v1/locations/within_bounding_box.json?no_details=1;swlat=' + sw.lat + ';swlon=' + sw.lng + ';nelat=' + ne.lat + ';nelon=' + ne.lng + searchMachineIDString + numMachinesVal + locationTypeVal); + + dfd.done(function (response) { + if (!response.locations) { + var locationIds = []; + document.getElementById("locations").innerHTML = "

" + "No pinball found in this area." + "

"; + } else { + var locationIds = []; + for (var i = 0; i < response.locations.length; i++) { + locationIds.push(response.locations[i].id) + } + if (ismap == 1) { + var url = '/locations?map_location_data=;by_location_id=' + locationIds.join('_'); + } + else { + var url = '/locations?region=' + region + '&by_location_id=' + locationIds.join('_'); + } + + document.getElementById('search_link_wrapper').style.display = "none"; + $('#locations').html(loadingHTML()); + $.get(url, function (data) { + $('#locations').html(data); }); - }, REDO_TIMEOUT); + } + }); } function scrollToMiddle(id) {