File size: 2,908 Bytes
bfa9f17 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | <!DOCTYPE html>
<html>
<head>
<title>Test IndexedDB Data</title>
</head>
<body>
<h1>Test IndexedDB Data Setup</h1>
<button onclick="setupTestData()">Setup Test Data</button>
<button onclick="clearData()">Clear All Data</button>
<div id="status"></div>
<script type="module">
import { get, set, del } from 'https://cdn.jsdelivr.net/npm/idb-keyval@6/+esm';
window.setupTestData = async function() {
try {
// Setup test chat data
const chatData = [
{ role: 'user', content: 'Ahoj', timestamp: new Date().toISOString() },
{ role: 'assistant', content: 'Ahoj! Jak se máš?', timestamp: new Date().toISOString() }
];
await set('chat', chatData);
// Setup test journal data with activities
const journalData = [
{ text: 'Udělal jsem procházku', timestamp: new Date().toISOString(), meta: { type: 'activity' } },
{ text: 'Vyzkoušel jsem tip na relaxaci', timestamp: new Date().toISOString(), meta: { type: 'tip' } },
{ text: 'Udělal meditaci', timestamp: new Date().toISOString(), meta: { type: 'meditation' } },
{ text: 'Další aktivita', timestamp: new Date().toISOString(), meta: { type: 'activity' } },
{ text: 'Ještě jedna aktivita', timestamp: new Date().toISOString(), meta: { type: 'activity' } }
];
await set('journal', journalData);
// Setup no contact data (started 2 days ago)
const twoDaysAgo = new Date();
twoDaysAgo.setDate(twoDaysAgo.getDate() - 2);
const noContactData = {
startISO: twoDaysAgo.toISOString(),
lastPraiseISO: null
};
await set('noContact', noContactData);
// Setup profile
await set('profile', { name: 'Test User' });
document.getElementById('status').innerHTML = '✅ Test data setup complete! Refresh the main app to see medals.';
} catch (error) {
document.getElementById('status').innerHTML = '❌ Error: ' + error.message;
}
};
window.clearData = async function() {
try {
await del('chat');
await del('journal');
await del('noContact');
await del('profile');
await del('medal');
document.getElementById('status').innerHTML = '🗑️ All data cleared!';
} catch (error) {
document.getElementById('status').innerHTML = '❌ Error: ' + error.message;
}
};
</script>
</body>
</html> |