Menu
π±π π΄π°πΊ π±π»πΎπ²πΊπ
Search
Forum
Ping a Server
Global Stats
Heatmap
Public Profiles
Login or Register
Terms of Service
Contact Admin
⏰ Your $2 could help keep BreakBlocks alive!
Read the SOS & pledge now
🔥
π±π π΄π°πΊ π±π»πΎπ²πΊπ
π Όπ Έπ ½π ΄π ²ππ °π ΅π ππ ΄ππ π ΄π ππ ΄π °ππ ²π ·
v2.0
MOTD
Version
Organization
ASN
Country Code
Country
Region
Any
North America
Europe
Asia
South America
Africa
Oceania
Antarctica
Sort
Default
Last Updated
Players Online
Version
Min Players
Max Players
Result Limit
β οΈ
Search
\
`; $list.append(adCard); } }); $results.append($list); }).fail((xhr, derp1, derp2) => { try { msg = JSON.parse(xhr.responseText); } catch(e) { msg = xhr.responseText; } if(msg && msg.error) { $results.html(`
Error: ${msg.error}
`); return; } $results.html('
Failed to fetch results.
'); }); }); }); let nextPage = 2; let loading = false; let lastQuery = null; let moreResults = true; let prevScrollHeight = 0; function fetchNextPage() { if (!moreResults || loading || !lastQuery) return; loading = true; const url = `/api/v0.1/servers/find?${lastQuery}&page=${nextPage}`; const $results = $('#search-results'); prevScrollHeight = $(document).height(); $results.append('
Loading more...
'); $.ajax({url: url, method: 'GET', dataType: 'json', cache: false}).done((data) => { $('#loading-more').remove(); if (!data.results || !data.results.length) { moreResults = false; $results.append('
No more results.
'); return; } nextPage++; const $list = $results.find('.row.g-3'); data.results.forEach(server => { const link = `/server/${encodeURIComponent(server.address)}/${encodeURIComponent(server.port)}`; const favicon = server.favicon ? `
` : ''; const card = `
${favicon}
${server.address}:${server.port}
${server.version ? `
${server.version}
` : ''}
Players:
${server.players_online}/${server.players_limit}
MOTD:
${server.motd_stripped || ''}
Country:
${server.country || ''} (${server.country_code || ''}) ${server.city ? `
City:
${server.city}` : ''}
ASN:
${server.asn_number || ''} ${server.asn_name || ''}
Last Ping: ${server.last_ping ? new Date(server.last_ping).toLocaleString() : ''}
`; $list.append(card); if (typeof data.displayed === 'number') { // Find the "Showing X of Y results" div and update X const $showing = $results.find('> div').first(); if ($showing.length && $showing.text().startsWith('Showing')) { // Add the number of new results to displayed const match = $showing.text().match(/^Showing (\d+) of (\d+) results/); if (match) { const newDisplayed = parseInt(match[1]) + data.displayed; $showing.text(`Showing ${newDisplayed} of ${match[2]} results`); } } } }); // Restore scroll position so user stays at previous bottom //const newScrollHeight = $(document).height(); //$(window).scrollTop(newScrollHeight - prevScrollHeight + $(window).scrollTop()); loading = false; }).fail((xhr, derp1, derp2) => { try { msg = JSON.parse(xhr.responseText); } catch(e) { msg = xhr.responseText; } $('#loading-more').html('
Load more
'); if(msg && msg.error) { $results.append(`
Error: ${msg.error}
`); loading = false; moreResults = false; return; } $results.append('
Failed to fetch more results.
'); loading = false; moreResults = false; }); } /* $(window).on('scroll', function () { if (!moreResults || loading) return; if ($(window).scrollTop() + $(window).height() + 100 >= $(document).height()) { $(window).scrollTop($(window).scrollTop() - 500); console.log('Fetching next page:', nextPage); fetchNextPage(); } }); */ $('form').on('submit', function () { // After a new search, reset paging state const params = {}; $(this).serializeArray().forEach(({ name, value }) => { if (value !== '') params[name] = value; }); lastQuery = $.param(params); nextPage = 2; moreResults = true; loading = false; });