fix: use current filter for random

This commit is contained in:
relikd
2024-02-29 00:46:09 +01:00
parent 485c7dfdb6
commit a574556a9c
2 changed files with 12 additions and 2 deletions

View File

@@ -78,7 +78,7 @@
<div>Rating: $RATING</div> <div>Rating: $RATING</div>
<div>Advisory: $ADVISORY</div> <div>Advisory: $ADVISORY</div>
<br> <br>
<div>Current Version: $VERSION (last update: $DATE)</div> <div>Current Version: <b>$VERSION</b> (last update: $DATE)</div>
<div>Price: $PRICE</div> <div>Price: $PRICE</div>
<div>Link: <a href="$URL" rel="noopener noreferrer nofollow">iTunes</a></div> <div>Link: <a href="$URL" rel="noopener noreferrer nofollow">iTunes</a></div>
<div>$IMG</div> <div>$IMG</div>

View File

@@ -76,7 +76,9 @@ function saveConfig() {
data.push(e.id + '=' + encodeURIComponent(value)); data.push(e.id + '=' + encodeURIComponent(value));
} }
}); });
const prev = location.hash;
location.hash = '#' + data.join('&'); location.hash = '#' + data.join('&');
return prev !== location.hash;
} }
/* /*
@@ -166,7 +168,15 @@ function urlsToImgs(list) {
} }
function randomIPA() { function randomIPA() {
const idx = DB_result[Math.floor(Math.random() * DB_result.length)]; if (saveConfig()) {
applySearch();
}
var idx = 0;
if (DB_result.length > 0) {
idx = DB_result[Math.floor(Math.random() * DB_result.length)];
} else {
idx = Math.floor(Math.random() * DB.length);
}
const entry = entryToDict(DB[idx]); const entry = entryToDict(DB[idx]);
const output = document.getElementById('content'); const output = document.getElementById('content');
output.innerHTML = entriesToStr('.single', [idx]); output.innerHTML = entriesToStr('.single', [idx]);