push
This commit is contained in:
+33
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
SETTINGS — source provider toggles, API server base URL, local data.
|
||||
SETTINGS — source provider toggles, API server base URL, TMDB key, local data.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
@@ -10,6 +10,8 @@
|
||||
const providersStatus = document.getElementById('providersStatus');
|
||||
const apiBaseInput = document.getElementById('apiBaseInput');
|
||||
const connStatus = document.getElementById('connStatus');
|
||||
const tmdbKeyInput = document.getElementById('tmdbKeyInput');
|
||||
const tmdbStatus = document.getElementById('tmdbStatus');
|
||||
const dataStatus = document.getElementById('dataStatus');
|
||||
|
||||
/* ---- nav --------------------------------------------------------------------- */
|
||||
@@ -139,6 +141,36 @@
|
||||
await testConnection();
|
||||
});
|
||||
|
||||
/* ---- TMDB key ------------------------------------------------------------------- */
|
||||
|
||||
tmdbKeyInput.value = SR.config.getTmdbKey();
|
||||
|
||||
async function testTmdbKey(key) {
|
||||
setStatus(tmdbStatus, 'Testing TMDB key…');
|
||||
try {
|
||||
await SR.api.tmdb('/search/movie', { query: 'The Matrix', page: 1 }, key);
|
||||
setStatus(tmdbStatus, 'TMDB key works — search, details and images load directly from TMDB.', 'ok');
|
||||
} catch (e) {
|
||||
setStatus(tmdbStatus, e.message, 'err');
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('tmdbKeySave').addEventListener('click', async () => {
|
||||
SR.config.setTmdbKey(tmdbKeyInput.value);
|
||||
tmdbKeyInput.value = SR.config.getTmdbKey();
|
||||
await testTmdbKey(SR.config.getTmdbKey());
|
||||
});
|
||||
|
||||
document.getElementById('tmdbKeyTest').addEventListener('click', async () => {
|
||||
await testTmdbKey(tmdbKeyInput.value.trim());
|
||||
});
|
||||
|
||||
document.getElementById('tmdbKeyReset').addEventListener('click', async () => {
|
||||
SR.config.clearTmdbKey();
|
||||
tmdbKeyInput.value = SR.config.getTmdbKey();
|
||||
await testTmdbKey(SR.config.getTmdbKey());
|
||||
});
|
||||
|
||||
/* ---- data ---------------------------------------------------------------------------- */
|
||||
|
||||
document.getElementById('clearHistory').addEventListener('click', () => {
|
||||
|
||||
Reference in New Issue
Block a user