pruvodce / test_data.html
HonzaH's picture
Upload 105 files
bfa9f17 verified
Raw History Blame Contribute Delete
2.91 kB
<!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>