-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (33 loc) · 1.34 KB
/
Copy pathscript.js
File metadata and controls
38 lines (33 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// URL of your npoint.io endpoint
const endpoint = "https://api.npoint.io/870e5e322b3af3b50aa1"; // gouravgupta840@gmail.com
// Function to get the board name from the URL
function getBoardFromURL() {
const path = window.location.pathname; // e.g., "/testing"
return path.split("/")[1]; // Extract "testing" from "/testing"
}
function refresh() {
// Fetch data from the JSON endpoint
fetch(endpoint)
.then(response => response.json())
.then(data => {
// Get the board name from the URL
const boardName = getBoardFromURL();
// Find the matching board in the JSON data
const boardData = data.find(item => item.board === boardName);
if (boardData) {
// Update the HTML content
document.getElementById("heading").textContent = boardData.mockup.heading;
document.getElementById("task").innerHTML = marked.marked(boardData.mockup.task);
} else {
// Handle case where the board is not found
document.getElementById("heading").textContent = "Board not found";
document.getElementById("task").textContent = `No data available for board: ${boardName}`;
}
})
.catch(error => {
console.error("Error fetching data:", error);
document.getElementById("heading").textContent = "Failed to load data.";
});
}
setInterval(refresh, 1000 * 3);
refresh();