From 6a725f9a62687f6871b54e368cddb4e4646a66cd Mon Sep 17 00:00:00 2001 From: Mahdi Qiamast <78082316+Qiamast@users.noreply.github.com> Date: Fri, 13 Jan 2023 12:23:20 +0330 Subject: [PATCH] initial Commit --- chat.js | 21 ++++++++++++++++++ index.html | 20 +++++++++++++++++ style.css | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 chat.js create mode 100644 index.html create mode 100644 style.css diff --git a/chat.js b/chat.js new file mode 100644 index 0000000..09b2356 --- /dev/null +++ b/chat.js @@ -0,0 +1,21 @@ +let input = document.querySelector('input'); +let button = document.querySelector('button'); +let conversation = document.querySelector('.conversation'); + +// Retrieve the conversation history from local storage +let history = JSON.parse(localStorage.getItem('conversation')) || []; + +// Display the conversation history +for (let i = 0; i < history.length; i++) { + conversation.innerHTML += `
${history[i]}
`; +} + +button.addEventListener('click', function() { + let message = input.value; + conversation.innerHTML += `You: ${message}
`; + input.value = ''; + + // Save the conversation to local storage + history.push(`You: ${message}`); + localStorage.setItem('conversation', JSON.stringify(history)); +}); diff --git a/index.html b/index.html new file mode 100644 index 0000000..3e32647 --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + +