Skip to content

Commit

Permalink
Bug_fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kashifalikhan36 committed Dec 2, 2024
1 parent e2a05f6 commit 5c3ae00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 48 deletions.
15 changes: 8 additions & 7 deletions LeakCode/public/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ setTimeout(async () => {
const response = await session.prompt(element.textContent);
console.log("1 ok");

const session_2 = await ai.languageModel.create({
systemPrompt:
"Pretend to be a LeetCode master. I will provide you with a code , and your task is to give me shortest and easiest explanation in very short and simple way and in simple and short steps of it with new lines. Do not modify or rewrite the code. Just explain how the code works and what it does.",
});
// const session_2 = await ai.languageModel.create({
// systemPrompt:
// "Pretend to be a LeetCode master. I will provide you with a code , and your task is to give me shortest and easiest explanation in very short and simple way and in simple and short steps of it with new lines. Do not modify or rewrite the code. Just explain how the code works and what it does.",
// });

const response_2 = await session_2.prompt(element.textContent);
console.log("2 ok");
// const response_2 = await session_2.prompt(element.textContent);
// console.log("2 ok");

const session_3 = await ai.languageModel.create({
systemPrompt:
Expand All @@ -43,6 +43,7 @@ setTimeout(async () => {

const response_3 = await session_3.prompt(element.textContent);
console.log("3 ok");
let explain = "This Section is in Under Development";

function openCodeViewerPage(code, explain, query) {
// Encode the code to be URL-safe
Expand All @@ -58,7 +59,7 @@ setTimeout(async () => {
}

// Call the function to open the new page with the code
openCodeViewerPage(response, response_2, response_3);
openCodeViewerPage(response, explain, response_3);
} catch (error) {
console.error("Error interacting with the language model:", error);
}
Expand Down
44 changes: 3 additions & 41 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,8 @@
padding: 15px;
overflow-x: auto;
font-family: "Courier New", Courier, monospace;
position: relative;
max-height: 400px;
margin-bottom: 10px;
}

.copy-button {
background-color: #8e44ad;
border: none;
color: #ffffff;
padding: 8px 15px;
font-size: 14px;
border-radius: 4px;
cursor: pointer;
position: absolute;
top: 10px;
right: 10px;
transition: background-color 0.3s ease;
}

.copy-button:hover {
background-color: #6c3483;
white-space: pre-wrap;
word-wrap: break-word;
}

.explanation-container {
Expand All @@ -90,14 +71,6 @@
word-wrap: break-word;
}

.video-container iframe {
width: 100%;
height: 315px;
border: none;
border-radius: 8px;
margin-top: 10px;
}

.no-content {
font-style: italic;
color: #aaa;
Expand Down Expand Up @@ -144,8 +117,7 @@
<div class="section">
<h2>Code</h2>
<div class="code-container">
<button class="copy-button" id="copy-code-button">Copy Code</button>
<div id="code-container"></div>
<pre><code id="code-container"></code></pre>
</div>
</div>

Expand Down Expand Up @@ -176,7 +148,6 @@ <h2>Recommended Video</h2>
"explanation-container"
);
const videoContainer = document.getElementById("video-container");
const copyButton = document.getElementById("copy-code-button");

// Get the parameters from the URL
const params = new URLSearchParams(window.location.search);
Expand All @@ -186,17 +157,8 @@ <h2>Recommended Video</h2>
if (code) {
const decodedCode = decodeURIComponent(code);
codeContainer.textContent = decodedCode;

// Add event listener to the Copy Code button
copyButton.addEventListener("click", () => {
navigator.clipboard
.writeText(decodedCode)
.then(() => alert("Code copied to clipboard!"))
.catch((err) => alert("Failed to copy code: " + err));
});
} else {
codeContainer.textContent = "No code provided.";
copyButton.style.display = "none"; // Hide the Copy Code button if no code
}

// Explanation
Expand Down

0 comments on commit 5c3ae00

Please sign in to comment.