MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / addItems

Function addItems

website/source/js/loadCommunityProjects.js:8–18  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

6
7// Function to add items to the DOM
8function addItems(items) {
9 const itemList = document.getElementById('community-project-container');
10 itemList.innerText = "";
11 items.forEach(item => {
12 console.log(item)
13 const onclick_project = "window.open('https://scratch.mit.edu/projects/"+item.project_id.toString()+"/', '_blank');"
14 const onclick_author = "window.open('https://scratch.mit.edu/users/"+item.author.toString()+"/', '_blank');"
15 const new_element = '<div style="cursor: pointer" onclick="'+onclick_project+'" class="project"><img src="'+item.thumbnail_url+'" alt="Project Thumbnail" class="project-thumbnail"><h3 style="cursor: pointer; margin: 7px;" onclick="'+onclick_project+'" class="project-name">'+item.title+'</h3><p style="cursor: pointer;" class="project-author" onclick="'+onclick_author+'">by '+item.author+'</p></div>'
16 itemList.innerHTML += new_element;
17 });
18}
19
20// Fetch data when the page loads
21window.onload = fetchData;

Callers 1

fetchDataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected