| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- $(function() {
- const $testsList = $("#tests-list");
- $(document).on("click", "[data-jump-button]", event => {
- $("#tests-list > .list-group-item").removeClass("list-group-item-primary");
- event.preventDefault();
- const $button = $(event.currentTarget);
- const id = $button.data("id");
- const target = `#test-${id}`;
- const $listGroupItem = $(target);
- $listGroupItem.addClass("list-group-item-primary");
- const top = $listGroupItem.offset().top - 56 - 45;
- $("html, body").animate({
- scrollTop: top
- }, "fast")
- });
- });
- var infoWindow = false;
- function initialiseMarkers() {
- if(infoWindow === false) {
- infoWindow = new google.maps.InfoWindow();
- }
- $.get(window.location, {
- action: "get-tests"
- }, function(response) {
- if(!response.success) return;
- let tests = response.tests;
- let map = maps["map"];
- let bounds = new google.maps.LatLngBounds();
- for(let i in tests) {
- if(!tests.hasOwnProperty(i)) continue;
- let test = tests[i];
- let latLng = {
- lat: test.geolocation[0],
- lng: test.geolocation[1]
- };
- bounds.extend(latLng);
- let markerOptions = {
- position: latLng,
- map: map,
- title: test.name
- };
- if(test.icon) {
- markerOptions.icon = `/img/markers/${test.icon}.png`;
- }
- let marker = new google.maps.Marker(markerOptions);
- marker.addListener("click", function() {
- infoWindow.setContent(`<strong>${test.name}</strong> <span class="badge badge-${test.statusClass}">${test.status}</span><br />
- <small>${test.address}</small><br />
- <a data-jump-button data-id="${test.id}" class="btn btn-primary btn-block btn-sm mt-2" href="#">Find in List</a>`
- );
- infoWindow.open(map, marker);
- });
- }
- map.fitBounds(bounds);
- });
- }
|