Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -696,3 +696,5 @@ a {
background-color: skyblue;
}

}
}
Comment on lines +699 to +700
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: These closing braces don't match any opening braces and will cause CSS parsing errors. Remove these lines.

14 changes: 13 additions & 1 deletion submit-challenge/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ <h2>Submit New Coding Challenge</h2>
</form>
<section id="preview"></section>
</main>
<script src="submit-challenge/script.js"></script>
<script src="script.js" defer></script>


<div class="chat-container">
<div class="chat-box" id="chat-box">
<div class="chat-message bot">Hi! I'm your chatbot. Ask me anything!</div>
</div>
<div class="input-box">
<input type="text" id="user-input" placeholder="Type your message...">
<button onclick="sendMessage()">Send</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This onclick handler will cause a runtime error because sendMessage() is defined inside the form submit event listener in script.js, making it inaccessible from the global scope.

Suggested change
<button onclick="sendMessage()">Send</button>
<button id="send-button">Send</button>

</div>
</div>


</body>
</html>
27 changes: 26 additions & 1 deletion submit-challenge/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,29 @@ form.addEventListener('submit', (e) => {
<p><strong>Test Cases:</strong><ul>${testCases.map(tc => `<li>${tc}</li>`).join('')}</ul></p>
<p><strong>Sample Solution:</strong><br><pre>${solution}</pre></p>
`;
});
});

function sendMessage() {
const input = document.getElementById("user-input");
const message = input.value.trim();
if (!message) return;

appendMessage("user", message);
input.value = "";

// Simulate AI reply (you can replace this with API call)
setTimeout(() => {
const botReply = "You said: " + message;
appendMessage("bot", botReply);
}, 500);
}

function appendMessage(sender, text) {
const chatBox = document.getElementById("chat-box");
const msg = document.createElement("div");
msg.className = "chat-message " + sender;
msg.textContent = text;
chatBox.appendChild(msg);
chatBox.scrollTop = chatBox.scrollHeight;
}
Comment on lines +37 to +59
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Functions defined inside form submit listener are not accessible globally. Move these functions outside the event listener to fix the onclick handler in HTML.

Suggested change
function sendMessage() {
const input = document.getElementById("user-input");
const message = input.value.trim();
if (!message) return;
appendMessage("user", message);
input.value = "";
// Simulate AI reply (you can replace this with API call)
setTimeout(() => {
const botReply = "You said: " + message;
appendMessage("bot", botReply);
}, 500);
}
function appendMessage(sender, text) {
const chatBox = document.getElementById("chat-box");
const msg = document.createElement("div");
msg.className = "chat-message " + sender;
msg.textContent = text;
chatBox.appendChild(msg);
chatBox.scrollTop = chatBox.scrollHeight;
}
function sendMessage() {
const input = document.getElementById("user-input");
const message = input.value.trim();
if (!message) return;
appendMessage("user", message);
input.value = "";
// Simulate AI reply (you can replace this with API call)
setTimeout(() => {
const botReply = "You said: " + message;
appendMessage("bot", botReply);
}, 500);
}
function appendMessage(sender, text) {
const chatBox = document.getElementById("chat-box");
const msg = document.createElement("div");
msg.className = "chat-message " + sender;
msg.textContent = text;
chatBox.appendChild(msg);
chatBox.scrollTop = chatBox.scrollHeight;
}


45 changes: 45 additions & 0 deletions submit-challenge/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,48 @@ input:focus, textarea:focus, select:focus, button:focus {
0% { transform: translate(-50%, -50%) rotate(0deg); }
100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.chat-container {
width: 400px;
/* margin: 50px auto; */
position: fixed;
bottom: 20px;
right: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
overflow: hidden;
}
.chat-box {
max-height: 400px;
overflow-y: auto;
padding: 20px;
border-bottom: 1px solid #ccc;
}
.chat-message {
margin-bottom: 10px;
}
.chat-message.user {
text-align: right;
color: #059669;
}
.chat-message.bot {
text-align: left;
color: #059669;
}
.input-box {
display: flex;
padding: 10px;
}
.input-box input {
flex: 1;
padding: 10px;
font-size: 16px;
}
.input-box button {
padding: 10px 20px;
background: #059669;
color: white;
border: none;
cursor: pointer;
}
Comment on lines +371 to +414
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The chatbot styles use inconsistent indentation (mix of spaces and tabs) and don't follow the existing CSS formatting patterns in the file. Consider using consistent 2-space indentation to match the rest of the stylesheet.

Suggested change
.chat-container {
width: 400px;
/* margin: 50px auto; */
position: fixed;
bottom: 20px;
right: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
overflow: hidden;
}
.chat-box {
max-height: 400px;
overflow-y: auto;
padding: 20px;
border-bottom: 1px solid #ccc;
}
.chat-message {
margin-bottom: 10px;
}
.chat-message.user {
text-align: right;
color: #059669;
}
.chat-message.bot {
text-align: left;
color: #059669;
}
.input-box {
display: flex;
padding: 10px;
}
.input-box input {
flex: 1;
padding: 10px;
font-size: 16px;
}
.input-box button {
padding: 10px 20px;
background: #059669;
color: white;
border: none;
cursor: pointer;
}
.chat-container {
width: 400px;
/* margin: 50px auto; */
position: fixed;
bottom: 20px;
right: 20px;
background: white;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
overflow: hidden;
}
.chat-box {
max-height: 400px;
overflow-y: auto;
padding: 20px;
border-bottom: 1px solid #ccc;
}
.chat-message {
margin-bottom: 10px;
}
.chat-message.user {
text-align: right;
color: #059669;
}
.chat-message.bot {
text-align: left;
color: #059669;
}
.input-box {
display: flex;
padding: 10px;
}
.input-box input {
flex: 1;
padding: 10px;
font-size: 16px;
}
.input-box button {
padding: 10px 20px;
background: #059669;
color: white;
border: none;
cursor: pointer;
}

Comment on lines +371 to +414
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The chatbot will overlap with existing page content on smaller screens due to fixed positioning. Consider adding responsive breakpoints or a toggle mechanism to hide/show the chatbot on mobile devices.

Loading