Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
# WEB102 Prework - *Name of App Here*
# WEB102 Prework - Gaming102

Submitted by: **Your Name Here**
Submitted by: **Mohammad Naeem**

**Name of your app** is a website for the company Sea Monster Crowdfunding that displays information about the games they have funded.
**Gaming102** is a website for the company Sea Monster Crowdfunding that displays information about the games they have funded.

Time spent: **X** hours spent in total
Time spent: ~4 hours spent in total

## Required Features

The following **required** functionality is completed:

* [ ] The introduction section explains the background of the company and how many games remain unfunded.
* [ ] The Stats section includes information about the total contributions and dollars raised as well as the top two most funded games.
* [ ] The Our Games section initially displays all games funded by Sea Monster Crowdfunding
* [ ] The Our Games section has three buttons that allow the user to display only unfunded games, only funded games, or all games.
* [yes] The introduction section explains the background of the company and how many games remain unfunded.
* [yes] The Stats section includes information about the total contributions and dollars raised as well as the top two most funded games.
* [yes] The Our Games section initially displays all games funded by Sea Monster Crowdfunding
* [yes] The Our Games section has three buttons that allow the user to display only unfunded games, only funded games, or all games.

The following **optional** features are implemented:

* [ ] List anything else that you can get done to improve the app functionality!
* [*] Added pointer cursor to all the buttons and stats card for better visibility
* [*] Layout could be more enhanced, company name may have a link attached to it
* [ ] Company and game description on top can get an area for themselves, currently it's just written on plane area. Would add more functionalities later on

## Video Walkthrough

Here's a walkthrough of implemented features:
Here's a walkthrough of implemented features: ![A walkthrough of the web102 prework by licecap]

<img src='http://i.imgur.com/link/to/your/gif/file.gif' title='Video Walkthrough' width='' alt='Video Walkthrough' />
<img src='assets/web102_prework_walkthrough.gif' title='Video Walkthrough' width='' alt='Video Walkthrough' />

<!-- Replace this with whatever GIF tool you used! -->
GIF created with ...
GIF created with ... ![LICEcap walkthrough]
<!-- Recommended tools:
[Kap](https://getkap.co/) for macOS
[ScreenToGif](https://www.screentogif.com/) for Windows
[peek](https://github.com/phw/peek) for Linux. -->

## Notes

Describe any challenges encountered while building the app.
Describe any challenges encountered while building the app. The server stopped responding for some reason.

## License

Copyright [yyyy] [name of copyright owner]
Copyright 2025 Mohammad Naeem

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Binary file added assets/web102_prework_walkthrough.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 61 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,34 @@ const gamesContainer = document.getElementById("games-container");
function addGamesToPage(games) {

// loop over each item in the data


for (let i = 0; i < games.length; i++) {
// create a new div element, which will become the game card

const gameCard = document.createElement('div');

// add the class game-card to the list

gameCard.classList.add("game-card");

// set the inner HTML using a template literal to display some info
// about each game
// TIP: if your images are not displaying, make sure there is space
// between the end of the src attribute and the end of the tag ("/>")


gameCard.innerHTML = `
<img src="${games[i].img}" class="game-img" alt="${games[i].name}">
<h2> ${games[i].name} </h2>
<p> ${games[i].description}</p>
`;

// append the game to the games-container
gamesContainer.appendChild(gameCard);

}

}

// call the function we just defined using the correct variable
// later, we'll call this function using a different list of games
addGamesToPage(GAMES_JSON)


/*************************************************************************************
Expand All @@ -61,20 +69,29 @@ function addGamesToPage(games) {
const contributionsCard = document.getElementById("num-contributions");

// use reduce() to count the number of total contributions by summing the backers

const totalContributions = GAMES_JSON.reduce((total, game) => {
return total + game.backers;
}, 0);

// set the inner HTML using a template literal and toLocaleString to get a number with commas

contributionsCard.innerHTML = totalContributions.toLocaleString();

// grab the amount raised card, then use reduce() to find the total amount raised
const raisedCard = document.getElementById("total-raised");

// set inner HTML using template literal
const totalRaised = GAMES_JSON.reduce((total, game) => {
return total + game.pledged;
}, 0);

// set inner HTML using template literal
raisedCard.innerHTML = `$${totalRaised.toLocaleString()}`;

// grab number of games card and set its inner HTML
const gamesCard = document.getElementById("num-games");

const totalGames = GAMES_JSON.length

gamesCard.innerHTML = totalGames

/*************************************************************************************
* Challenge 5: Add functions to filter the funded and unfunded games
Expand All @@ -87,29 +104,36 @@ function filterUnfundedOnly() {
deleteChildElements(gamesContainer);

// use filter() to get a list of games that have not yet met their goal

const unfundedGames = GAMES_JSON.filter( game => {
return game.pledged < game.goal;
});

// use the function we previously created to add the unfunded games to the DOM
addGamesToPage(unfundedGames)

}
// filterUnfundedOnly()

// show only games that are fully funded
function filterFundedOnly() {
deleteChildElements(gamesContainer);

// use filter() to get a list of games that have met or exceeded their goal

const fundedGames = GAMES_JSON.filter( game => {
return game.pledged > game.goal;
});

// use the function we previously created to add unfunded games to the DOM

addGamesToPage(fundedGames)
}
// filterFundedOnly()

// show all games
function showAllGames() {
deleteChildElements(gamesContainer);

// add all games from the JSON data to the DOM

addGamesToPage(GAMES_JSON)
}

// select each button in the "Our Games" section
Expand All @@ -118,7 +142,9 @@ const fundedBtn = document.getElementById("funded-btn");
const allBtn = document.getElementById("all-btn");

// add event listeners with the correct functions to each button

unfundedBtn.addEventListener("click", filterUnfundedOnly);
fundedBtn.addEventListener("click", filterFundedOnly);
allBtn.addEventListener("click", showAllGames);

/*************************************************************************************
* Challenge 6: Add more information at the top of the page about the company.
Expand All @@ -129,12 +155,23 @@ const allBtn = document.getElementById("all-btn");
const descriptionContainer = document.getElementById("description-container");

// use filter or reduce to count the number of unfunded games

function countUnfundedGames() {
const unfundedCount = GAMES_JSON.filter( game => {
return game.pledged < game.goal;
});
return unfundedCount.length;
}
const numUnfunded = countUnfundedGames();
console.log(numUnfunded)

// create a string that explains the number of unfunded games using the ternary operator
const unfundedMsg = `Currently we have raised $${totalRaised.toLocaleString()} while ${numUnfunded} ${numUnfunded === 1 ? 'game remains' : 'games remain' } unfunded. We need your support to fund these amazing games.`


// create a new DOM element containing the template string and append it to the description container
const templateStr = document.createElement("p");
templateStr.innerHTML = unfundedMsg
descriptionContainer.append(templateStr);

/************************************************************************************
* Challenge 7: Select & display the top 2 games
Expand All @@ -149,7 +186,14 @@ const sortedGames = GAMES_JSON.sort( (item1, item2) => {
});

// use destructuring and the spread operator to grab the first and second games
const [firstGame, secondGame] = sortedGames;

// create a new element to hold the name of the top pledge game, then append it to the correct element

// do the same for the runner up item
const firstGameName = document.createElement('p');
firstGameName.innerHTML = firstGame.name;
firstGameContainer.appendChild(firstGameName);

// do the same for the runner up item
const secondGameName = document.createElement('p');
secondGameName.innerHTML = secondGame.name;
secondGameContainer.appendChild(secondGameName);
22 changes: 21 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,32 @@ body {
background-color: lightblue;
padding: 1%;
align-items: center;
margin-left: -10px;
margin-left: -10px;
margin-right: -10px;
margin-top: -10px;
}

.stats-container {
/* Code added */
display: flex;
align-items: center;
cursor: pointer;
}
/* hover stats container added */
.stats-container:hover {
box-shadow: 0 0 30px lightblue;
}

/* enhanced pointer to stats card */
.stats-card:hover {
box-shadow: 0 0 30px black;
cursor: pointer;
}
/* enhanced pointer to all the buttons */
#unfunded-btn:hover, #funded-btn:hover, #all-btn:hover {
box-shadow: 0 0 30px lightblue;
cursor: pointer;

}

.stats-card {
Expand All @@ -40,6 +59,7 @@ body {
display: flex;
flex-wrap: wrap;
justify-content: space-around;

}

.game-img {
Expand Down