| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- function showMessage(text, type = 'success') {
- const messageEl = document.getElementById('message');
- messageEl.textContent = text;
- messageEl.className = `message ${type}`;
- setTimeout(() => {
- messageEl.className = 'message hidden';
- }, 5000);
- }
- async function syncLibrary() {
- showMessage('Syncing with Audiobookshelf...', 'success');
- try {
- const response = await fetch('/api/sync');
- const data = await response.json();
- if (data.status === 'success') {
- showMessage(data.message, 'success');
- setTimeout(() => window.location.reload(), 1500);
- } else {
- showMessage(data.message || 'Sync failed', 'error');
- }
- } catch (error) {
- showMessage('Error syncing with Audiobookshelf: ' + error.message, 'error');
- }
- }
- async function generateRecommendations() {
- showMessage('Generating AI recommendations...', 'success');
- try {
- const response = await fetch('/api/recommendations/generate');
- const data = await response.json();
- if (data.status === 'success') {
- showMessage(`Generated ${data.count} new recommendations!`, 'success');
- setTimeout(() => window.location.reload(), 1500);
- } else {
- showMessage(data.message || 'Failed to generate recommendations', 'error');
- }
- } catch (error) {
- showMessage('Error generating recommendations: ' + error.message, 'error');
- }
- }
|