Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 38 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9bab30e
Setting up GitHub Classroom Feedback
github-classroom[bot] Aug 14, 2023
d91d8a4
add all assets
ismail-benlaredj Aug 18, 2023
edb3607
Merge pull request #5 from 202306-NEA-DZ-FEW/assets
ismail-benlaredj Aug 18, 2023
12a427c
add parseStory function
ismail-benlaredj Aug 18, 2023
bd7f823
Merge pull request #6 from 202306-NEA-DZ-FEW/parseStory
ismail-benlaredj Aug 18, 2023
45b8a01
madlibs function
ikoworld Aug 18, 2023
ebd5604
merge
ikoworld Aug 18, 2023
064c8b9
add intial pages
ismail-benlaredj Aug 18, 2023
0f6dca0
Merge pull request #7 from 202306-NEA-DZ-FEW/initPages
ismail-benlaredj Aug 18, 2023
14ad4d5
Merge pull request #8 from 202306-NEA-DZ-FEW/iko
ikoworld Aug 18, 2023
0237387
adding hotkey enter event
Ben-Tewfik Aug 18, 2023
1a9cf04
Merge pull request #9 from 202306-NEA-DZ-FEW/hotkeyevent
Ben-Tewfik Aug 18, 2023
edc3079
input bg color and reset
mounibzaidi Aug 18, 2023
90035d1
Merge pull request #10 from 202306-NEA-DZ-FEW/inputcolor
mounibzaidi Aug 18, 2023
4088505
added buttons with logic
hocine1212 Aug 18, 2023
0b92f6b
resolve problems
hocine1212 Aug 18, 2023
2892e59
Merge pull request #11 from 202306-NEA-DZ-FEW/btn_logic2
hocine1212 Aug 18, 2023
7bf94da
game page layout modifications
fketta Aug 19, 2023
fa844ef
Merge pull request #14 from 202306-NEA-DZ-FEW/game_page
fketta Aug 19, 2023
9872528
fixed scroll issue
hocine1212 Aug 19, 2023
a05fe19
Merge pull request #15 from 202306-NEA-DZ-FEW/update
hocine1212 Aug 19, 2023
bad4c58
styling span
Ben-Tewfik Aug 20, 2023
30dcd96
Merge pull request #18 from 202306-NEA-DZ-FEW/spanStyling
Ben-Tewfik Aug 20, 2023
77389c7
loading position
mounibzaidi Aug 20, 2023
8f986a0
added some styling to buttons
ikoworld Aug 20, 2023
742e38f
Merge pull request #19 from 202306-NEA-DZ-FEW/bouchra
ikoworld Aug 20, 2023
f6698f3
Reduce images size
ismail-benlaredj Aug 20, 2023
c8cdaba
update ui
ismail-benlaredj Aug 20, 2023
73f27a2
clean the code
ismail-benlaredj Aug 20, 2023
5ad8964
Merge branch 'master' into appearance
ismail-benlaredj Aug 20, 2023
9f724ed
update story
ismail-benlaredj Aug 20, 2023
84faebe
update ui
ismail-benlaredj Aug 20, 2023
102cd51
update js
ismail-benlaredj Aug 20, 2023
2e215d8
Merge pull request #20 from 202306-NEA-DZ-FEW/appearance
ismail-benlaredj Aug 20, 2023
380d1ea
fix paper hex prev and edit mobile version
ismail-benlaredj Aug 21, 2023
4814a49
Merge pull request #21 from 202306-NEA-DZ-FEW/appearance
ismail-benlaredj Aug 21, 2023
ed2ef5a
fix overflow
ikoworld Nov 24, 2023
e0438ab
Merge pull request #22 from ikoworld/master
ikoworld Nov 24, 2023
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
Binary file added assets/bab1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/bab2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons8-checkmark-96.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/jumanji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/jumanjiLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/paper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 53 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>repl.it</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class='madLibsEdit'>

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Jumanji | Madlibs</title>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great that you added a meaningful title for the web page.

<link rel="preconnect" href="https://fonts.googleapis.com" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's generally better to add Google Fonts to your CSS file rather than directly in your HTML file.

<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Merienda:wght@300;400;500;600;700;800;900&display=swap"
rel="stylesheet" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="loading" class="loading">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loading animation is a nice addition for user experience.

<img src="assets/jumanjiLogo.png" alt="logo" class="logo-load" />
<p class="progress-load-num">0 %</p>
<div class="progress-bar">
<div class="progress-fill"></div>
</div>
<div class='madLibsPreview'>
</div>
<div id="content" class="content hidden">
<div class="logoContainer">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some classes are using kebab-case and others are using camelCase. It's good to stick to one system.

<img src="assets/jumanjiLogo.png" alt="Logo" id="inLogo">
</div>
<script src="do-not-touch.js"></script>
<script src="madlibs.js"></script>
</body>
<div class="start-page">
<div class="bab1"></div>
<div class="bab2">
<div class="action-container">
<button class="start-btn" onclick="startBtn()">Start</button>
<div class="sound-btn" onclick="soundBtn()">
<div class="checkbox">
<img src="assets/icons8-checkmark-96.svg" alt="check icon" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great that all your images have alt attributes for accessibility.

</div>
<span>Sound</span>
</div>
</div>
</div>
</div>
<audio id="sound">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I loved that you added sound to your project!

<source src="sound/soundtrack.mp3" />
</audio>
<div class="container">
<div class="prev-edit">
<div class="madLibsEdit"></div>
<div class="madLibsPreview"></div>
</div>
<div class="btns-container"></div>
</div>
</div>

<script src="do-not-touch.js"></script>
<script src="madlibs.js"></script>
</body>


</html>
222 changes: 212 additions & 10 deletions madlibs.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* Complete the implementation of parseStory.
*
*
* parseStory retrieves the story as a single string from story.txt
* (I have written this part for you).
*
*
* In your code, you are required (please read this carefully):
* - to return a list of objects
* - each object should definitely have a field, `word`
* - each object should maybe have a field, `pos` (part of speech)
*
*
* So for example, the return value of this for the example story.txt
* will be an object that looks like so (note the comma! periods should
* be handled in the same way).
*
*
* Input: "Louis[n] went[v] to the store[n], and it was fun[a]."
* Output: [
* { word: "Louis", pos: "noun" },
Expand All @@ -22,21 +22,223 @@
* { word: "store", pos: "noun" }
* { word: "," }
* ....
*
*
* There are multiple ways to do this, but you may want to use regular expressions.
* Please go through this lesson: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/
*/
// document.body.style.overflow = "hidden";

const progressFill = document.querySelector(".progress-fill"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good that you added these at the top of the file!

progressLoadNum = document.querySelector(".progress-load-num");
let progressFillWidth = 10;

let id = setInterval(() => {
if (progressFillWidth >= 300) {
clearInterval(id);
} else {
progressFillWidth += 2;
progressLoadNum.innerText = parseInt((100 * progressFillWidth) / 300) + "%";
progressFill.style.width = progressFillWidth + "px";
}
}, 11);

setTimeout(() => {
const content = document.getElementById("content");
content.style.opacity = 1;
content.style.display = "block";
document.getElementById("loading").style.display = "none";
}, 4000);

///// Start btn
const startBtn = () => {
const bab1 = document.querySelector(".bab1");
const bab2 = document.querySelector(".bab2");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is bab referring to door? It would be better to stick with English in general.

const startPage = document.querySelector(".start-page");
bab1.classList.add("bab1Anim");
bab2.classList.add("bab2Anim");
container.style.display = 'flex'
setTimeout(() => {
startPage.style.display = "none";
}, 2100);
};

///// sound btn

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding comments to explain the purpose of event listeners, like the soundBtn function. It's not immediately clear what this function does without comments.

const soundBtn = () => {
const icon = document.querySelector(".checkbox img");
let opacity = icon.style.opacity;
opacity == 1 ? (icon.style.opacity = "0%") : (icon.style.opacity = "100%");
};

// Parsing the story
function parseStory(rawStory) {
// Your code here.
return {}; // This line is currently wrong :)
}
rawStory = rawStory.replace(/\./g, " .");
rawStory = rawStory.replace(/\,/g, " ,");
let arrWord = rawStory.split(" ");
let storyToObj = [];
arrWord.forEach((item) => {
if (item.match(/[[a-zA-Z]]/g)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's good to have this item.match(/[[a-zA-Z]]/g) in a separate variable with a comment explaining the purpose.

let key = item.split("[");
switch (key[1]) {
case "n]":
storyToObj.push({
word: key[0],
pos: "noun",
});
break;
case "v]":
storyToObj.push({
word: key[0],
pos: "verb",
});

break;
case "a]":
storyToObj.push({
word: key[0],
pos: "adjective",
});
default:
break;
}
} else {
storyToObj.push({
word: item,
});
}
});
return storyToObj;
}
/**
* All your other JavaScript code goes here, inside the function. Don't worry about
* the `then` and `async` syntax for now.
*
*
* You'll want to use the results of parseStory() to display the story on the page.
*
*/
getRawStory().then(parseStory).then((processedStory) => {
console.log(processedStory);
// Using querySelector to select a specific element
const body = document.querySelector("body");
const container = document.querySelector(".container");
const edit = document.querySelector(".madLibsEdit"); // Using querySelector to select a specific element
const pre = document.querySelector(".madLibsPreview"); // Using querySelector to select a specific element
const playMusic = document.createElement("button");
const resetBtn = document.createElement("button");
playMusic.id = "musicButton";
resetBtn.id = "resetButton";
playMusic.textContent = "Play";
resetBtn.textContent = "Reset";
// selecting the sound button in the start page
const soundCheckBtn = document.querySelector(".sound-btn");
const sound = document.getElementById("sound");
// adding click event to soundCheckBtn
soundCheckBtn.addEventListener("click", () => {
if (sound.paused) {
sound.play();
playMusic.textContent = "Pause";
} else {
sound.pause();
}
});
body.append(container);
playMusic.textContent = "Play";
resetBtn.textContent = "Reset";

playMusic.addEventListener("click", () => {
if (sound.paused) {
sound.play();
playMusic.textContent = "Pause";
} else {
sound.pause();
playMusic.textContent = "Play";
}
});

container.setAttribute("class", "container");


// showing the story

function madlibsEdit(processedStory) {
const editPara = document.createElement("p");
editPara.className = "editText";
const previewPara = document.createElement("p");
previewPara.className = "previewText";

const newArr = [];
//making a for loop over the processed story to check whether the item has a pos or not
for (const item of processedStory) {
if (item.pos) {
const input = document.createElement("input");
const span = document.createElement("span");
// adding style to the preview words
span.setAttribute("class", "spanText");
// adding styling to the input
input.setAttribute("class", "input");
editPara.appendChild(input);
previewPara.appendChild(span);
// Constraining user inputs;
input.setAttribute("placeholder", item.pos);
input.setAttribute("maxlength", "20");
span.innerHTML = ` ${item.pos}`;
// event listener for live update in the preview
input.addEventListener("input", (e) => {
if (e.target.value === "") {
span.innerHTML = ` ${item.pos}`;
} else {
span.innerHTML = ` ${e.target.value}`;
}
});
// Highlighting currently focused input
input.addEventListener("focus", function () {
input.style.backgroundColor = "#b9ddb8b8";
});
// input blur
input.addEventListener("blur", function () {
if (this.value != "") {
input.style.backgroundColor = "#ecd599";
} else {
input.style.backgroundColor = "#fff";

}
});
// reseting all the inputs when button is clicked
resetBtn.addEventListener("click", () => {
input.value = "";
input.setAttribute("placeholder", item.pos);
span.textContent = item.pos;
input.style.backgroundColor = "";
});
newArr.push(input);
} else {
if (item.word == ',' || item.word == '.') {
editPara.append(`${item.word} `);
previewPara.append(`${item.word} `);
} else {
editPara.append(` ${item.word} `);
previewPara.append(` ${item.word} `);
}

}
// HotKeys event
newArr.forEach((input, i) => {
input.addEventListener("keypress", (e) => {
if (e.key === "Enter") {
if (i < newArr.length - 1) {
newArr[i + 1].focus();
}
}
});
});
}
const btnsContainer = document.querySelector('.btns-container')
btnsContainer.appendChild(playMusic);
btnsContainer.appendChild(resetBtn);
edit.append(editPara);
pre.append(previewPara);
}

getRawStory()
.then(parseStory)
.then((processedStory) => {
madlibsEdit(processedStory);
});
Binary file added sound/jumanji.mp3
Binary file not shown.
Binary file added sound/soundtrack.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion story.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Louis[n] went[v] to the store[n], and it was fun[a]. He taught[v] the class[n].
In the middle of the green[a] jungle, the dangerous[a] game of Jumanji lives. The sound of drums mixes[v] with the beats[n] of hearts, making a music of excitement that echoes[v] through the colorful[a] land. People who are brave[a] enough to roll[v] its dice find[v] themselves in a world[n] of exciting adventures[n] and surprising mysteries. Beating the challenges needs strong[a] courage and clever thinking, showing secret strengths. With each exciting journey[n], Jumanji's story[n] gets bigger, a sign of the unstoppable bravery of those who choose to play[v].
Loading