use local

This commit is contained in:
Edgar 2023-08-17 14:37:48 +02:00
parent 7672d13b7e
commit 9ec1b6b194
No known key found for this signature in database
GPG key ID: 70ADAE8F35904387
2 changed files with 8 additions and 11 deletions

View file

@ -6,17 +6,16 @@
export let name: string;
let imageLink = `https://api.skins.tw/api/resolve/skins/${name}`;
let imageLink = `https://assets.ddstats.org/skins/${name}.png`;
let canvas: HTMLCanvasElement;
let found = false;
async function loadImage(imageLink: string) {
let blob = await fetch(imageLink, { cache: 'force-cache', credentials: 'omit' }).then((r) => r.blob());
let blob = await fetch(imageLink).then((r) => r.blob());
let bitmap = await createImageBitmap(blob, {
resizeWidth: 256,
resizeHeight: 128,
resizeQuality: 'high'
resizeHeight: 128
});
return bitmap;
}
@ -42,13 +41,11 @@
ctx.restore();
}
onMount(async () => {
found = !localStorage.getItem(imageLink);
if (!localStorage.getItem(imageLink)) {
if (name !== '' && name !== undefined) {
try {
let imgData = await loadImage(imageLink);
if (imgData) renderSkin(imgData);
} catch (e) {
localStorage.setItem(imageLink, 'not-found');
found = false;
}
}

View file

@ -50,7 +50,7 @@
});
let page = 0;
let perPage = 250;
let perPage = 50;
let inputSearch = '';
async function update() {
@ -70,7 +70,7 @@
let currentPlayers: ClientInfo[] = [];
$: {
currentPlayers = players.slice(page * perPage, page * perPage + perPage);
currentPlayers = playerSearch.slice(page * perPage, page * perPage + perPage);
}
async function onSearch() {
@ -128,7 +128,7 @@
</tr>
</thead>
<tbody class="bg-gray-800 border border-gray-800">
{#each playerSearch as client, index (page * perPage + index)}
{#each currentPlayers as client, index (page * perPage + index)}
<tr class="border border-gray-700">
<td class="px-2 py-2 font-bold text-left">{client.client.name}</td>
<td class="px-2 py-2 font-bold text-left">{client.client.clan}</td>
@ -143,7 +143,7 @@
href={`ddnet://${client.server.addresses[0].replace(address_re, '')}`}>{client.server.info.name}</a
></td
>
<td class="px-2 py-2 font-bold text-center flex justify-center" title={client.client.country}
<td class="px-2 py-2 font-bold text-center flex justify-center" title={client.client.country.toString()}
>{#if code_to_country[client.client.country] !== undefined}
<img
alt={code_to_country[client.client.country].name}