feat: updates
This commit is contained in:
parent
fda13b53ad
commit
48d05fa727
5 changed files with 46 additions and 49 deletions
|
|
@ -1,25 +1,22 @@
|
|||
// Don't redeclare TERMINAL_PROMPT since it's already in common.js
|
||||
let typing = false;
|
||||
|
||||
window.typechars = function(e) {
|
||||
window.typechars = function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (e.target.classList.contains("active")) return;
|
||||
if (typing) return;
|
||||
typing = true;
|
||||
|
||||
// Clear active class from all links
|
||||
const topics = document.querySelectorAll(".topic a");
|
||||
topics.forEach((t) => {
|
||||
t.classList.remove("active");
|
||||
t.style.color = "";
|
||||
});
|
||||
|
||||
// Add active class to clicked link
|
||||
e.target.classList.add("active");
|
||||
|
||||
const repoName = e.target.textContent;
|
||||
const terminalText = ` ${repoName}`;
|
||||
const terminalText = ` /${repoName}`;
|
||||
const terminalPrompt = document.querySelector(".terminal-prompt");
|
||||
const delay = 250;
|
||||
|
||||
|
|
@ -37,42 +34,43 @@ window.typechars = function(e) {
|
|||
|
||||
typechar();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function renderRepoDescription(repoLink) {
|
||||
const postsContainer = document.getElementById("repos");
|
||||
const repoId = repoLink.getAttribute("data-repo-id");
|
||||
const repoName = repoLink.textContent;
|
||||
|
||||
// Clear the posts container
|
||||
|
||||
postsContainer.innerHTML = "";
|
||||
|
||||
// Fetch the repository data for this repo
|
||||
|
||||
fetch(`/api/repo/${repoId}`)
|
||||
.then(response => response.json())
|
||||
.then(repo => {
|
||||
// Create a post element
|
||||
.then((response) => response.json())
|
||||
.then((repo) => {
|
||||
const post = document.createElement("div");
|
||||
post.classList.add("post");
|
||||
|
||||
// Create the description text
|
||||
|
||||
const descriptionText = document.createElement("div");
|
||||
descriptionText.textContent = repo.description || "No description available";
|
||||
descriptionText.textContent =
|
||||
repo.description || "No description available";
|
||||
descriptionText.style.textDecoration = "none";
|
||||
|
||||
|
||||
post.appendChild(descriptionText);
|
||||
|
||||
// Add the clone URL to the same post
|
||||
|
||||
const cloneUrl = document.createElement("div");
|
||||
cloneUrl.style.marginTop = "15px";
|
||||
cloneUrl.innerHTML = `<code>git clone git.barrettruth.com/${repoName}.git</code>`;
|
||||
|
||||
|
||||
post.appendChild(cloneUrl);
|
||||
|
||||
// Add the post to the container
|
||||
const viewNote = document.createElement("div");
|
||||
viewNote.style.marginTop = "15px";
|
||||
viewNote.style.fontSize = "0.8em";
|
||||
viewNote.style.fontStyle = "italic";
|
||||
viewNote.textContent = "Code should not be viewed in a browser.";
|
||||
post.appendChild(viewNote);
|
||||
|
||||
postsContainer.appendChild(post);
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error("Error fetching repo data:", error);
|
||||
const errorElement = document.createElement("div");
|
||||
errorElement.classList.add("post");
|
||||
|
|
@ -80,7 +78,3 @@ function renderRepoDescription(repoLink) {
|
|||
postsContainer.appendChild(errorElement);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
// No need to add click listeners here, the onclick attribute in the HTML handles it
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue