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

Allow user-defined separator and fix docker-compose process #11

Open
wants to merge 2 commits into
base: master
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
package-lock.json
node_modules/
dist/
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM node

ADD . /code
WORKDIR /code

RUN npm install -g grunt-cli
RUN npm install

CMD npm install; grunt
15 changes: 15 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ input {
text-align: center;
padding: 1%;
}
input.separator {
display: inline;
border: 1px solid #ccc;
margin: 0 auto;
font-size: 14px;
height: 30px;
width: 15px;
text-align: center;
padding: 0 10px;
}
select {
font-size: 16px;
-webkit-appearance: none;
Expand Down Expand Up @@ -103,6 +113,11 @@ li {
margin-top: 1%;
text-align: center;
}
.passphrase-separator {
display: inline;
margin-top: 1%;
text-align: center;
}
.crack-time-label {
text-align: center;
margin: 0 auto;
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ nodebuild:
build: .
volumes:
- .:/code
command: grunt
8 changes: 5 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ <h1 class="title">Use A <span>Passphrase</span></h1>
<p class="crack-time-label">Approximate Crack Time: <span class="crack-time">0 seconds</span></p>
<div class="passphrase-options">
<select id="passphrase_select">
<option value="4" selected>Four-word passphrase, with spaces</option>
<option value="5">Five-word passphrase, with spaces</option>
<option value="12">Twelve-word passphrase, with spaces</option>
<option value="4" selected>Four-word passphrase</option>
<option value="5">Five-word passphrase</option>
<option value="12">Twelve-word passphrase</option>
</select>
<p class="passphrase-separator"> with separator: </p>
<input class="separator" id="separator" type="text" value=" " onmouseover="this.select()"/>
<button class="btn-generate">Generate New Passphrase</button>
</div>
<div class="social-buttons">
Expand Down
15 changes: 12 additions & 3 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function generatePassword(numberOfWords) {
generatedPasswordArray.push(wordlist[index]);
}

return generatedPasswordArray.join(' ');
return generatedPasswordArray;
}

function setStyleFromWordNumber(passwordField, numberOfWords) {
Expand Down Expand Up @@ -68,16 +68,19 @@ function calculateAndSetCrackTime() {

var selectField = document.getElementById('passphrase_select');
var passwordField = document.getElementById('passphrase');
var separatorField = document.getElementById('separator');
var button = document.querySelector('.btn-generate');

// Initially run it upon load
passwordField.setAttribute('value', generatePassword(4));
var passArray = generatePassword(4); // Save array to easily change separator
passwordField.setAttribute('value', passArray.join(' '));
calculateAndSetCrackTime();

// Listen for a button click
button.addEventListener('click', function() {
var numberOfWords = selectField.options[selectField.selectedIndex].value;
passwordField.value = generatePassword(numberOfWords);
passArray = generatePassword(numberOfWords);
passwordField.value = passArray.join(separatorField.value);
setStyleFromWordNumber(passwordField, numberOfWords);
calculateAndSetCrackTime();
});
Expand All @@ -86,3 +89,9 @@ button.addEventListener('click', function() {
passwordField.addEventListener('input', function (evt) {
calculateAndSetCrackTime();
});

// Listen for separator value change
separatorField.addEventListener('input', function (evt) {
passwordField.value = passArray.join(separatorField.value);
calculateAndSetCrackTime();
});