Skip to content

Commit

Permalink
Activity 5 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
li-ruihao committed Sep 20, 2024
1 parent b269541 commit 6a859d4
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ <h3 class="page-title white-text teal">Projects</h3>
<div id="recent-projects">

</div>
<button id="loadMoreButton">Load More</button>

<!-- ************* -->
</div>
Expand Down Expand Up @@ -661,10 +662,34 @@ <h3 class="page-title white-text teal">Places Travelled</h3>
const mostRecentIndex = projects.length - 1;

const parser = new DOMParser();
const projectHTML = parser.parseFromString(projects[mostRecentIndex].content, 'text/html');
const newestProjectHTML = parser.parseFromString(projects[mostRecentIndex].content, 'text/html');

const mostRecentProj = document.getElementById('recent-projects');
mostRecentProj.innerHTML = projectHTML.body.innerHTML;
mostRecentProj.innerHTML = newestProjectHTML.body.innerHTML;

const loadMoreButton = document.getElementById("loadMoreButton");
loadMoreButton.addEventListener('click', handleClick);

var clickStatus = false;

function handleClick(event) {

clickStatus = !clickStatus;

if(clickStatus) {
mostRecentProj.innerHTML = '';
let totalHTML = '';
projects.forEach(project => {
totalHTML += project.content + ' ';
});
mostRecentProj.innerHTML = parser.parseFromString(totalHTML, 'text/html').body.innerHTML;
}
else {
mostRecentProj.innerHTML = '';
mostRecentProj.innerHTML = newestProjectHTML.body.innerHTML;
}
}

</script>
</body>

Expand Down

0 comments on commit 6a859d4

Please # to comment.