feat: go back to random result
This commit is contained in:
20
index.html
20
index.html
@@ -2,8 +2,9 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title>IPA Archive</title>
|
||||
<link rel="shortcut icon" href="./favicon.ico">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="./apple-touch-icon.png">
|
||||
@@ -58,20 +59,6 @@
|
||||
<div><a onclick="searchBundle($IDX)">Show all</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="entry single">
|
||||
<div>
|
||||
<img src="$IMG">
|
||||
<button onclick="installIpa($IDX)">Install</button>
|
||||
</div>
|
||||
<div class="info">
|
||||
<h4>$TITLE</h4>
|
||||
<div>BundleId: $BUNDLEID</div>
|
||||
<div>Version: v$VERSION – $SIZE</div>
|
||||
<div>Device: $PLATFORM</div>
|
||||
<div>Minimum OS: $MINOS</div>
|
||||
<div>Link: <a href="$URL" rel="noopener noreferrer nofollow">$URLNAME</a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="itunes">
|
||||
<h4>iTunes Info:</h4>
|
||||
<div>Genre: $GENRES</div>
|
||||
@@ -85,6 +72,7 @@
|
||||
<p>$DESCRIPTION</p>
|
||||
</div>
|
||||
<a class="screenshot" href="$URL" target="_blank"><img src="$URL"></a>
|
||||
<p class="randomAllVer"> <a onclick="searchBundle($IDX, '&random=$IDX')">show all versions</a></p>
|
||||
</div>
|
||||
|
||||
<div id="overlay" hidden>
|
||||
|
||||
36
script.js
36
script.js
@@ -130,13 +130,17 @@ function applySearch() {
|
||||
|
||||
function restoreSearch() {
|
||||
location.hash = previousSearch;
|
||||
loadConfig(false);
|
||||
const conf = loadConfig(false);
|
||||
previousSearch = '';
|
||||
searchIPA(true);
|
||||
if (conf.random) {
|
||||
randomIPA(conf.random);
|
||||
} else {
|
||||
searchIPA(true);
|
||||
}
|
||||
}
|
||||
|
||||
function searchBundle(idx) {
|
||||
previousSearch = location.hash;
|
||||
function searchBundle(idx, additional) {
|
||||
previousSearch = location.hash + (additional || '');
|
||||
document.getElementById('bundleid').value = DB[idx][4];
|
||||
document.getElementById('search').value = '';
|
||||
document.getElementById('page').value = null;
|
||||
@@ -169,21 +173,27 @@ function urlsToImgs(list) {
|
||||
return rv + '</div>';
|
||||
}
|
||||
|
||||
function randomIPA() {
|
||||
if (isInitial || saveConfig()) {
|
||||
function randomIPA(specificId) {
|
||||
if (saveConfig() || isInitial || specificId) {
|
||||
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);
|
||||
var idx = specificId;
|
||||
if (!specificId) {
|
||||
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 output = document.getElementById('content');
|
||||
output.innerHTML = entriesToStr('.single', [idx]);
|
||||
output.innerHTML = entriesToStr('.full', [idx]);
|
||||
output.firstElementChild.className += ' single';
|
||||
output.firstElementChild.innerHTML += renderTemplate(getTemplate('.randomAllVer'), { $IDX: idx });
|
||||
|
||||
const iTunesUrl = 'http://itunes.apple.com/lookup?bundleId=' + entry.bundleId;
|
||||
return;
|
||||
// Append iTunes info to result
|
||||
const iTunesUrl = 'https://itunes.apple.com/lookup?bundleId=' + entry.bundleId;
|
||||
loadFile(iTunesUrl, console.error, function (data) {
|
||||
const obj = JSON.parse(data);
|
||||
if (!obj || obj.resultCount < 1) {
|
||||
|
||||
Reference in New Issue
Block a user