Skip to content

Commit

Permalink
Add other Aves hosted servers
Browse files Browse the repository at this point in the history
  • Loading branch information
Simyon264 committed Aug 25, 2024
1 parent 85245a8 commit d2bd94f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
1 change: 0 additions & 1 deletion ReplayBrowser/Pages/Search.razor
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
{
ErrorMessage = "Invalid search query";
stopWatch.Stop();
NavigationManager.NavigateTo("/");
return;
}

Expand Down
34 changes: 30 additions & 4 deletions ReplayBrowser/Pages/Shared/SearchBar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@
</style>

<script>
// note: `buffer` arg can be an ArrayBuffer or a Uint8Array
async function bufferToBase64(buffer) {
// use a FileReader to generate a base64 data URI.
const base64url = await new Promise(r => {
const reader = new FileReader();
reader.onload = () => r(reader.result);
reader.readAsDataURL(new Blob([buffer]));
});
// remove the `data:...;base64,` parrt from the start
return base64url.slice(base64url.indexOf(',') + 1);
}
async function base64ToBuffer(base64) {
const binaryString = atob(base64);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes;
}
let selectedAutocompleteOption = null;
function moveUp(element) {
Expand All @@ -120,7 +142,7 @@
}
}
function search(page) {
async function search(page) {
const searchBars = document.querySelectorAll('.search-bar input');
// sanity check
Expand All @@ -147,7 +169,7 @@
);
// Encode the searches as base64
const encodedSearches = btoa(JSON.stringify(searches));
const encodedSearches = await bufferToBase64(JSON.stringify(searches));
builder.append('searches', encodedSearches);
builder.append('page', page);
Expand Down Expand Up @@ -206,12 +228,14 @@
selectedAutocompleteOption = suggestion;
});
document.addEventListener('DOMContentLoaded', e => {
document.addEventListener('DOMContentLoaded', async e => {
// Based on the current query, if we have anything loaded already in the query, create search bars based on that, otherwise if its empty, create a new one
const searchParams = new URLSearchParams(window.location.search);
const searches = searchParams.get('searches');
if (searches !== null) {
const decodedSearches = JSON.parse(atob(searches));
let decodedSearchesBuffer = await base64ToBuffer(searches);
// Extract string from buffer
const decodedSearches = JSON.parse(new TextDecoder().decode(decodedSearchesBuffer));
decodedSearches.forEach(searchObject => {
const searchBarPrefab = document.getElementsByClassName('prefab');
const newSearchBar = searchBarPrefab[0].cloneNode(true);
Expand Down Expand Up @@ -257,4 +281,6 @@
document.getElementById('addSearchBar').click();
}
}, false);
</script>
24 changes: 24 additions & 0 deletions ReplayBrowser/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@
},
"AllowedHosts": "*",
"ReplayUrls": [
{
"url": "https://cdn.networkgamez.com/replays/hullrot/",
"provider": "nginx",
"fallBackServerName": "hullrot",
"fallBackServerId": "new_frontier",
"replayRegex": "(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip",
"serverNameRegex": ""
},
{
"url": "https://cdn.networkgamez.com/replays/greystation/",
"provider": "nginx",
"fallBackServerName": "greystation",
"fallBackServerId": "greystation",
"replayRegex": "(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip",
"serverNameRegex": ""
},
{
"url": "https://cdn.networkgamez.com/replays/ebengrad/",
"provider": "nginx",
"fallBackServerName": "ebengrad",
"fallBackServerId": "S&MB",
"replayRegex": "(\\d{4}_\\d{2}_\\d{2}-\\d{2}_\\d{2})-round_\\d+\\.zip",
"serverNameRegex": ""
},
{
"url": "https://cdn.networkgamez.com/replays/goobstation/",
"provider": "nginx",
Expand Down

0 comments on commit d2bd94f

Please sign in to comment.