// Function to open the IndexedDB database and extract data from ttSessions function exportTtSessionsToJSON() { // Open the IndexedDB database named "spaces" let request = indexedDB.open("spaces"); request.onerror = function(event) { console.error("Error opening IndexedDB:", event.target.errorCode); }; request.onsuccess = function(event) { let db = event.target.result; // Start a transaction and access the ttSessions object store let transaction = db.transaction("ttSessions", "readonly"); let objectStore = transaction.objectStore("ttSessions"); let data = []; // Open a cursor to iterate over all records in the ttSessions object store objectStore.openCursor().onsuccess = function(event) { let cursor = event.target.result; if (cursor) { data.push(cursor.value); // Add each record's value to the data array cursor.continue(); // Move to the next record } else { // All records have been processed, export data to a JSON file saveDataToFile(data, "spaces.json"); } }; transaction.oncomplete = function() { db.close(); }; }; } // Function to trigger the download of the JSON file function saveDataToFile(data, filename) { let jsonStr = JSON.stringify(data, null, 2); // Convert data array to JSON string let blob = new Blob([jsonStr], { type: "application/json" }); // Create a link element to trigger the download let url = URL.createObjectURL(blob); let a = document.createElement("a"); a.href = url; a.download = filename; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); // Clean up the object URL } // Call the function to start the process exportTtSessionsToJSON();