Skip to content

Commit

Permalink
removing exampleBreach + nits
Browse files Browse the repository at this point in the history
Removes the --createExampleBreach and --help args from load-breaches.js and updates README. Tweaks to monitor.js for event handling.
  • Loading branch information
lesleyjanenorton committed Jun 26, 2018
1 parent 4abe793 commit 2890723
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ To populate the database with test data, use these scripts in `scripts/`:
* `node scripts/add-breached-emails.js` adds some breached email records for
`test[1-3]@test.com` users

Both scripts have `--help` arguments for usage help.
* `node scripts/add-breached-email.sjs --help` for usage help.

#### Emails

Expand Down
1 change: 0 additions & 1 deletion public/img/logos/ExampleBreach.svg

This file was deleted.

17 changes: 10 additions & 7 deletions public/js/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ function enableBtnIfInputEmpty(e) {
}
}

function hideFalseDoor() {
addClass("#false-door", "hidden");
document.body.style.overflow = "scroll";
}

function showFalseDoor() {
handleEvents("SignUp");
removeClass("#false-door", "hidden");
Expand All @@ -114,17 +119,13 @@ function showFalseDoor() {
if (e.code !== "Enter" && e.code !== "Escape") {
return;
}
addClass("#false-door", "hidden");
document.body.style.overflow = "scroll";
hideFalseDoor();
window.removeEventListener("keydown", listener);
falseDoor.removeEventListener("click", listener);
});
falseDoor.addEventListener("click", function listener (e) {
if (e.target === falseDoor || e.target === document.getElementById("close-false-door")) {
addClass("#false-door", "hidden");
document.body.style.overflow = "scroll";
hideFalseDoor();
falseDoor.removeEventListener("click", listener);
window.removeEventListener("keydown", listener);
}
});
}
Expand All @@ -147,7 +148,7 @@ async function sha1(message) {
async function hashEmailAndSend(emailFormSubmitEvent) {
emailFormSubmitEvent.preventDefault();
const emailForm = emailFormSubmitEvent.target;
if (emailForm.querySelector("input[name=email]").value === "") {
if (!emailForm.querySelector("input[name=email]").value) {
emailForm.querySelector("input[type=submit]").disabled = true;
addInvalidMessage();
return;
Expand All @@ -174,11 +175,13 @@ if (document.querySelector(".email-scan")) {
removeInvalidMessage();
});
}

window.addEventListener("pageshow", function() {
if (document.getElementById("no-breaches") || document.getElementById("found-breaches")) {
handleEvents("Pageview");
}
});

if (document.getElementById("sign-up")) {
document.getElementById("sign-up").addEventListener("click", showFalseDoor);
}
Expand Down
22 changes: 0 additions & 22 deletions scripts/load-breaches.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"use strict";

const arg = require("arg");
const got = require("got");
const createDOMPurify = require("dompurify");
const { JSDOM } = require("jsdom");
Expand All @@ -14,17 +13,6 @@ const HIBP_USER_AGENT = `${pkg.name}/${pkg.version}`;

const DOMPurify = createDOMPurify((new JSDOM("")).window);

const args = arg({
"--createExampleBreach": Boolean,
"--help": Boolean,
});

if (args["--help"]) {
console.log("Usage: node load-breaaches.js [--createExampleBreach]");
console.log("--createExampleBreach creates the 'ExampleBreach' test fixture breach.");
process.exit();
}

async function handleBreachesResponse(response) {
try {
const breachesJSON = JSON.parse(response.body);
Expand All @@ -41,16 +29,6 @@ async function handleBreachesResponse(response) {
}

(async () => {
if (args["--createExampleBreach"]) {
await DBUtils.createBreach("ExampleBreach", {
Title: "Example",
BreachDate: "2015-12-06",
DataClasses: ["Email addresses", "IP addresses", "Passwords", "Usernames", "Website activity"],
PwnCount: 1436486,
LogoType: "svg",
Description: "This is an example of the data available for each breach. Compromised Data classes are not limited to the classes listed above.",
});
}
try {
const breachesResponse = await got(
`${AppConstants.HIBP_API_ROOT}/breaches`,
Expand Down

0 comments on commit 2890723

Please sign in to comment.