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

2-proj #46

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
Binary file added projects/dice-roller/dice_images/Dice-1.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 projects/dice-roller/dice_images/Dice-2.svg.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 projects/dice-roller/dice_images/Dice-3.svg.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 projects/dice-roller/dice_images/Dice-4.svg.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 projects/dice-roller/dice_images/Dice-5.svg.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 projects/dice-roller/dice_images/Dice-6.svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions projects/dice-roller/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css" >

<title>Document</title>
</head>
<body>
<div id="container" >
<h1>Dice Roller </h1>
<label># of dice:</label>
<input type="number" id="numOfDice" value="1" min="1">
<button onclick="rollDice()" >Roll Dice</button>
<div id="diceResult"></div>
<div id="diceImages"></div>
</div>
<script src="script.js" ></script>
</body>
</html>
16 changes: 16 additions & 0 deletions projects/dice-roller/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function rollDice(){
const numOfDice = document.getElementById("numOfDice").value;
const diceResult = document.getElementById("diceResult");
const diceImages = document.getElementById("diceImages");
const values = [];
const images = [];

for(let i = 0;i < numOfDice;i++){
const value = Math.floor(Math.random()*6)+1;
values.push(value);
images.push(`<img src="dice-images/${value}.png">`);
}

diceResult.textContent = `dice: ${values.join(', ')}`;
diceImages.innerHTML = images.join('');
}
30 changes: 30 additions & 0 deletions projects/dice-roller/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#container{
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
text-align: center;
font-size: 2rem;
font-weight: bold;

}
button{
font-size: 1.5rem;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
padding: 10px 15px;
border-radius: 10px;
border: none;
color: rgb(37, 37, 37);
font-weight:500;
cursor: pointer;
background: linear-gradient(to left bottom, lightgreen, lightblue);
}
button:hover{
background:linear-gradient(to left bottom, rgb(104, 246, 104), rgb(139, 223, 250));
}
button:active{
background:linear-gradient(to left bottom, rgb(158, 235, 158), rgb(179, 224, 240));
}
input{
font-size: 2rem;
width: 150px;
text-align: center;
font-weight: bold;
}
13 changes: 13 additions & 0 deletions random-password-generator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css" >
<script src="script.js" ></script>
</head>
<body>

</body>
</html>
39 changes: 39 additions & 0 deletions random-password-generator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
function generatePassword(length, includeLowercase, includeNumbers, includeSymbols, includeUppercase){
const lowercaseChars = "abscdefghijklopqrstuvwxyz";
const uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
const numberChars = "0123456789"
const symbolChars = "@._&";
let allowedChars = " ";
let password = "";
allowedChars += includeLowercase ? lowercaseChars: "";
allowedChars += includeUppercase ? uppercaseChars: "";
allowedChars += includeNumbers ? numberChars:"";
allowedChars += includeSymbols ? symbolChars:"";
console.log(allowedChars);
if(length <= 0){
return `(password length must be at least 1)`;
}
if(allowedChars.length === 0){
return `(At least 1 char needs to be selected)`
}
for(let i = 0; i<length; i++){
const randomIndex = Math.floor(Math.random() * allowedChars.length);
password += allowedChars[randomIndex];
}

return password;
}


const passwordLength = 12;
const includeLowercase = true;
const includeUppercase = true;
const includeNumbers = true;
const includeSymbols = true;

const password = generatePassword(passwordLength, includeLowercase,
includeNumbers,
includeUppercase,
includeSymbols);

console.log(`Generated Password:${password}`);
Empty file.