Compare commits

...

2 Commits

Author SHA1 Message Date
4b7f526902 fix trending vrcurl options 2024-05-19 12:20:09 -07:00
9f143cb84e update test.html 2024-05-19 12:19:49 -07:00
2 changed files with 15 additions and 7 deletions

View File

@ -33,7 +33,7 @@ async function VRCYoutubeSearch(pool, query, options = {}) {
for (let tab of tabs) { for (let tab of tabs) {
data.tabs.push({ data.tabs.push({
name: tab.name, name: tab.name,
vrcurl: await putVrcUrl(pool, {type: "trending", bp: tab.bp}) vrcurl: await putVrcUrl(pool, {type: "trending", bp: tab.bp, options})
}); });
} }
break; break;

View File

@ -9,24 +9,26 @@
</head><body> </head><body>
<div> <div>
<label>search: <input id="input" type="text" value="nyan cat" /></label> <label><button id="search">search:</button> <input id="input" type="text" value="nyan cat" /></label>
<button id="trending">trending</button> <br /><button id="trending">trending</button>
<br />
<label><input id="thumbnails" type="checkbox" checked>thumbnails</label> <label><input id="thumbnails" type="checkbox" checked>thumbnails</label>
<label><input id="icons" type="checkbox" checked>icons</label> <label><input id="icons" type="checkbox" checked>icons</label>
<label><input id="captions" type="checkbox" checked>captions</label> <label><input id="captions" type="checkbox" checked>captions</label>
<button id="start">start</button>
</div> </div>
<div id="output"></div> <div id="output"></div>
<button id="nextpage">next page</button>
<div id="buttons"></div>
<button id="nextpage" style="display: none">next page</button>
<script> <script>
var num = 0; var num = 0;
var lastData; var lastData;
start.onclick = () => { search.onclick = () => {
output.innerHTML = ""; output.innerHTML = "";
loadData(`/search?pool=test1000&thumbnails=${thumbnails.checked}&icons=${icons.checked}&captions=${captions.checked}&input=${encodeURIComponent(input.value)}`); loadData(`/search?pool=test1000&thumbnails=${thumbnails.checked}&icons=${icons.checked}&captions=${captions.checked}&input=${encodeURIComponent(input.value)}`);
}; };
@ -34,9 +36,9 @@ trending.onclick = () => {
output.innerHTML = ""; output.innerHTML = "";
loadData(`/trending?pool=test1000&thumbnails=${thumbnails.checked}&icons=${icons.checked}&captions=${captions.checked}`); loadData(`/trending?pool=test1000&thumbnails=${thumbnails.checked}&icons=${icons.checked}&captions=${captions.checked}`);
} }
nextpage.onclick = () => loadData(`/vrcurl/test1000/${lastData.nextpage_vrcurl}`);
async function loadData(url) { async function loadData(url) {
buttons.innerHTML = '';
var data = await fetch(url).then(res => res.json()); var data = await fetch(url).then(res => res.json());
var pre = document.createElement("pre"); var pre = document.createElement("pre");
pre.innerHTML = hljs.highlight(JSON.stringify(data, null, 4), {language: "json"}).value; pre.innerHTML = hljs.highlight(JSON.stringify(data, null, 4), {language: "json"}).value;
@ -44,6 +46,12 @@ async function loadData(url) {
var img = document.createElement("img"); var img = document.createElement("img");
img.src = `/vrcurl/test1000/${data.imagesheet_vrcurl}`; img.src = `/vrcurl/test1000/${data.imagesheet_vrcurl}`;
output.appendChild(img); output.appendChild(img);
if (data.nextpage_vrcurl) {
buttons.innerHTML = `<button onclick="loadData('/vrcurl/test1000/${data.nextpage_vrcurl}')">next page</button>`;
}
if (data.tabs) {
buttons.innerHTML = data.tabs.map(t => `<button onclick="loadData('/vrcurl/test1000/${t.vrcurl}')">${t.name}</button>`).join('');
}
lastData = data; lastData = data;
} }