Dream Decoder
Add Words and Meanings
Add Save DictionaryWrite a Dream Sentence
Interpret Dream Save Decoded Dream” + Object.entries(wordMap) .map(([word, meaning]) => `${word}: ${meaning}`).join(“
“); } // Function to ask the user for interpretations of dream elements function askQuestions() { let dreamText = document.getElementById(“dreamInput”).value.trim(); if (!dreamText) { alert(“Please describe your dream first!”); return; } // Extract core words (nouns, verbs, adjectives) and ignore stop words let words = dreamText.split(/\s+/); dreamElements = []; words.forEach(word => { let cleanedWord = word.toLowerCase().replace(/[.,;:]/g, “”); if (!stopWords.includes(cleanedWord) && !dreamElements.includes(cleanedWord)) { dreamElements.push(cleanedWord); } }); if (dreamElements.length === 0) { alert(“No core words identified in your dream. Try adding more descriptive words.”); return; } let questionArea = document.getElementById(“questionArea”); questionArea.innerHTML = “
Personal Interpretations:
“; // Ask questions for each core word dreamElements.forEach((element, index) => { questionArea.innerHTML += ` What personal meaning does the word ${element} have for you?`; }); questionArea.innerHTML += `Decode Dream`; } // Function to decode the dream using the user’s provided interpretations function decodeDream() { let decodedText = dreamElements.map((word, index) => { let meaningInput = document.getElementById(`meaningInput${index}`).value.trim(); // If no interpretation provided, keep the word intact return meaningInput || word; }).join(” “); document.getElementById(“decodedOutput”).innerText = decodedText; // Using the meanings to create a narrative for the dream createDreamMeaning(decodedText); } // Function to create a narrative interpretation of the dream based on personal meanings function createDreamMeaning(decodedText) { let dreamNarrative = “Your dream could be interpreted as follows:\n\n”; dreamElements.forEach((word, index) => { let interpretation = document.getElementById(`meaningInput${index}`).value.trim(); if (interpretation) { dreamNarrative += `The word “${word}” might symbolize: ${interpretation}\n`; } else { dreamNarrative += `The word “${word}” seems to represent something unknown or open to interpretation.\n`; } }); document.getElementById(“decodedOutput”).innerText = dreamNarrative; } // Save the dream dictionary function saveDictionary() { let dictionaryContent = JSON.stringify(wordMap, null, 2); let blob = new Blob([dictionaryContent], { type: “application/json” }); let a = document.createElement(“a”); a.href = URL.createObjectURL(blob); a.download = “dream_dictionary.json”; a.click(); } // Save the decoded dream function saveDecodedDream() { let decodedText = document.getElementById(“decodedOutput”).innerText; let blob = new Blob([decodedText], { type: “text/plain” }); let a = document.createElement(“a”); a.href = URL.createObjectURL(blob); a.download = “decoded_dream.txt”; a.click(); }