PageSourceSearch

https://qldrogaine.asn.au/wp-content/plugins/map-guessing-game/main.js

js qldrogaine.asn.au collected 2026-09-25 00:38:46 UTC 2,137 bytes, 66 lines download raw bytes

1jQuery(document).ready(function($) {
2    let map = L.map('map').setView([0, 0], 2);
3    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
4
5    let marker;
6    let endTime = mg_ajax.end_time * 1000;
7    let hasExpired = Date.now() > endTime;
8
9    function updateCountdown() {
10        let now = Date.now();
11        let remaining = endTime - now;
12        if (remaining <= 0) {
13            $('#countdown').text("Time is up! No more guesses allowed.");
14            hasExpired = true;
15            showAllGuesses();
16        } else {
17            let minutes = Math.floor(remaining / 60000);
18            let seconds = Math.floor((remaining % 60000) / 1000);
19            $('#countdown').text(`Time left: ${minutes}m ${seconds}s`);
20            setTimeout(updateCountdown, 1000);
21        }
22    }
23    updateCountdown();
24
25    function showAllGuesses() {
26        $.post(mg_ajax.ajax_url, { action: 'mg_get_guesses' }, function(response) {
27            if (response.success) {
28                response.data.forEach(guess => {
29                    L.marker([guess.lat, guess.lng])
30                        .addTo(map)
31                        .bindPopup(`${guess.name}'s Guess`);
32                });
33            }
34        });
35    }
36
37    if (!hasExpired) {
38        map.on('click', function(e) {
39            if (marker) map.removeLayer(marker);
40            marker = L.marker(e.latlng).addTo(map);
41        });
42
43        $('#submit-guess').click(function() {
44            let name = $('#name').val();
45            if (!marker || !name.trim()) {
46                alert("Please enter your name and place a marker.");
47                return;
48            }
49
50            $.post(mg_ajax.ajax_url, {
51                action: 'mg_submit_guess',
52                name: name,
53                lat: marker.getLatLng().lat,
54                lng: marker.getLatLng().lng
55            }, function(response) {
56                if (response.success) {
57                    alert("Guess submitted!");
58                } else {
59                    alert(response.data);
60                }
61            });
62        });
63    } else {
64        showAllGuesses();
65    }
66});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.