Skip to content
Snippets Groups Projects
Commit 21c8e2aa authored by Nathan Meyer's avatar Nathan Meyer
Browse files

Update Labs

parent fe224f85
Branches
No related tags found
No related merge requests found
1. I see the value of Agile software development, but this
trial run was too rushed to fully represent its benefits.
2. My role as programmer was fun, I'm not very good at coming
up with ideas on short notice, but I can implement other
people's ideas and have fun doing it.
\ No newline at end of file
*{
font-family: verdana;
}
#Main{
padding-left: 20px;
padding-top: 4px;
}
.navbar-brand{
user-select: none;
cursor: default;
}
/* Begin rainbow background (https://codepen.io/nohoid/pen/kIfto?editors=1100) */
.wrapper{
z-index: -1;
height: 100%;
width: 100%;
left:0;
right: 0;
top: 0;
bottom: 0;
position: absolute;
background: linear-gradient(124deg, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
background-size: 1800% 1800%;
-webkit-animation: rainbow 120s ease infinite;
-z-animation: rainbow 120s ease infinite;
-o-animation: rainbow 120s ease infinite;
animation: rainbow 120s ease infinite;
}
@-webkit-keyframes rainbow{
0%{background-position:0% 82%}
50%{background-position:100% 19%}
100%{background-position:0% 82%}
}
@-moz-keyframes rainbow{
0%{background-position:0% 82%}
50%{background-position:100% 19%}
100%{background-position:0% 82%}
}
@-o-keyframes rainbow{
0%{background-position:0% 82%}
50%{background-position:100% 19%}
100%{background-position:0% 82%}
}
@keyframes rainbow{
0%{background-position:0% 82%}
50%{background-position:100% 19%}
100%{background-position:0% 82%}
}
/* End rainbow background */
\ No newline at end of file
<!doctype html>
<html>
<!-- Hosted on https://www.cs.drexel.edu/~nim28/CS101/Lab-4/index.html -->
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="./css/index.css"/>
<!-- Util Libraries -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="./js/index.js"></script>
<head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<div class="navbar-brand">
Password Generator
</div>
<input id="in" class="form-control mr-sm-2">
<button id="bt" class="btn btn-outline-success my-2 my-sm-0">Generate</button>
</div>
</nav>
<div class="wrapper">
<div id="Main">
<p class="output"></p>
</div>
</div>
<body>
</html>
\ No newline at end of file
var invalid = new Set(["and","not","the","it","is","or","an","a","i"]);
var passes = 10; // Change pass number (WIP)
var output;
var input;
var questions = new Array(
"Describe your dream house", // ~Nick
"Describe the term \"family\"", // ~Nick
"Describe why your role model is your role model", // ~Alec
"Describe your ideal vacation" // ~Alec
);
$(document).ready(function(){ // Upon DOM load
$("#in").attr("placeholder", questions[Math.floor(Math.random()*questions.length)] + "..."); // Ask question
});
$(function(){ // JQuery event listener
$("#bt").click(function(){ // On button click
/* Logic */
input = new String($('input.form-control').val()); // Get input
$('input.form-control').val(""); // Clear box
if(input.trim() === "")return; // Abort if no input
$('p.input').html(input); // Print input text for user
var parse = input.split(" ");
for(var i=0; i<parse.length; i++){
// Delete invalid words
if(invalid.has(parse[i].toLowerCase())){
delete parse[i];
}
}
for(var j=0; j<passes; j++){
$("p.output").append(getRandomPass() + "<br/>"); // Display passwords for user
}
/* Nested Functions */
function getRandomPass(){
return populate(
shuffle( // Fisher-Yates shuffle
parse.filter(function (el){
// Remove empty elements
return el != null;
})
).join(" ").split("") // To char array -> Spaces to numbers
);
}
// Replace spaces with single digit random numbers
function populate(input){
var output = "";
for(var j in input){
if(input[j] === " "){
input[j] = Math.round(Math.random() * 9);
}
output += input[j];
}
return output;
}
// Begin Fisher-Yates randomization algorithm (http://sedition.com/perl/javascript-fy.html)
function shuffle(array){
var currentIndex = array.length, temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex){
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
// End Fisher-Yates randomization algorithm
});
});
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment